Browse Source

Fix saving showing archived setting

pull/538/head
kolaente 2 weeks ago
parent
commit
4a3b4982ab
Signed by: konrad GPG Key ID: F40E70337AB24C9B
  1. 45
      cypress/integration/list/namespaces.spec.js
  2. 4
      cypress/support/factory.js
  3. 6
      cypress/support/seed.js
  4. 4
      src/views/namespaces/ListNamespaces.vue

45
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')
})
})

4
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
}

6
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'),
},

4
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))
},
},
}

Loading…
Cancel
Save