Fix saving showing archived setting

This commit is contained in:
kolaente 2021-06-03 15:31:39 +02:00
parent 0f42ed3cf7
commit 4a3b4982ab
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
4 changed files with 51 additions and 8 deletions

View file

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

View file

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

View file

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

View file

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