diff --git a/cypress/integration/list/namespaces.spec.js b/cypress/integration/list/namespaces.spec.js index dbdba9156..9d3125b59 100644 --- a/cypress/integration/list/namespaces.spec.js +++ b/cypress/integration/list/namespaces.spec.js @@ -3,7 +3,6 @@ import {UserFactory} from '../../factories/user' import '../../support/authenticateUser' import {ListFactory} from '../../factories/list' import {NamespaceFactory} from '../../factories/namespace' -import {TaskFactory} from '../../factories/task' describe('Namepaces', () => { let namespaces @@ -99,4 +98,48 @@ describe('Namepaces', () => { cy.get('.namespace-container .menu.namespaces-lists') .should('not.contain', newNamespaces[0].title) }) + + it('Should not show archived lists & namespaces if the filter is not checked', () => { + const n = NamespaceFactory.create(1, { + id: 2, + is_archived: true, + }, false) + ListFactory.create(1, { + id: 2, + namespace_id: n[0].id, + }, false) + + ListFactory.create(1, { + id: 3, + is_archived: true, + }, false) + + // Initial + cy.visit('/namespaces') + cy.get('.namespaces-list .namespace') + .should('not.contain', 'Archived') + + // Show archived + cy.get('.namespaces-list .fancycheckbox.show-archived-check label.check span') + .should('be.visible') + .click() + cy.get('.namespaces-list .fancycheckbox.show-archived-check input') + .should('be.checked') + cy.get('.namespaces-list .namespace') + .should('contain', 'Archived') + + // Don't show archived + cy.get('.namespaces-list .fancycheckbox.show-archived-check label.check span') + .should('be.visible') + .click() + cy.get('.namespaces-list .fancycheckbox.show-archived-check input') + .should('not.be.checked') + + // Second time visiting after unchecking + cy.visit('/namespaces') + cy.get('.namespaces-list .fancycheckbox.show-archived-check input') + .should('not.be.checked') + cy.get('.namespaces-list .namespace') + .should('not.contain', 'Archived') + }) }) diff --git a/cypress/support/factory.js b/cypress/support/factory.js index 638464761..0c50bf8fc 100644 --- a/cypress/support/factory.js +++ b/cypress/support/factory.js @@ -21,7 +21,7 @@ export class Factory { * @param override * @returns {[]} */ - static create(count = 1, override = {}) { + static create(count = 1, override = {}, truncate = true) { const data = [] for (let i = 1; i <= count; i++) { @@ -38,7 +38,7 @@ export class Factory { data.push(entry) } - seed(this.table, data) + seed(this.table, data, truncate) return data } diff --git a/cypress/support/seed.js b/cypress/support/seed.js index acb1b2df4..d86152e2b 100644 --- a/cypress/support/seed.js +++ b/cypress/support/seed.js @@ -8,14 +8,14 @@ * @param table * @param data */ -export function seed(table, data = {}) { - if(data === null) { +export function seed(table, data = {}, truncate = true) { + if (data === null) { data = [] } cy.request({ method: 'PATCH', - url: `${Cypress.env('API_URL')}/test/${table}`, + url: `${Cypress.env('API_URL')}/test/${table}?truncate=${truncate ? 'true' : 'false'}`, headers: { 'Authorization': Cypress.env('TEST_SECRET'), }, diff --git a/src/views/namespaces/ListNamespaces.vue b/src/views/namespaces/ListNamespaces.vue index 85397e9f5..7edf311c6 100644 --- a/src/views/namespaces/ListNamespaces.vue +++ b/src/views/namespaces/ListNamespaces.vue @@ -108,7 +108,7 @@ export default { } }, created() { - this.showArchived = localStorage.getItem('showArchived') ?? false + this.showArchived = JSON.parse(localStorage.getItem('showArchived')) ?? false this.loadBackgroundsForLists() }, mounted() { @@ -147,7 +147,7 @@ export default { .catch(e => this.error(e, this)) }, saveShowArchivedState() { - localStorage.setItem('showArchived', this.showArchived) + localStorage.setItem('showArchived', JSON.stringify(this.showArchived)) }, }, }