2020-12-10 14:52:35 +01:00
|
|
|
import {UserFactory} from '../../factories/user'
|
|
|
|
|
|
|
|
import '../../support/authenticateUser'
|
|
|
|
import {ListFactory} from '../../factories/list'
|
|
|
|
import {NamespaceFactory} from '../../factories/namespace'
|
|
|
|
|
|
|
|
describe('Namepaces', () => {
|
|
|
|
let namespaces
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
UserFactory.create(1)
|
|
|
|
namespaces = NamespaceFactory.create(1)
|
|
|
|
ListFactory.create(1)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should be all there', () => {
|
|
|
|
cy.visit('/namespaces')
|
|
|
|
cy.get('.namespace h1 span')
|
|
|
|
.should('contain', namespaces[0].title)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should create a new Namespace', () => {
|
2021-05-27 08:51:42 +02:00
|
|
|
const newNamespaceTitle = 'New Namespace'
|
|
|
|
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.visit('/namespaces')
|
|
|
|
cy.get('a.button')
|
2021-06-24 01:24:57 +02:00
|
|
|
.contains('Create a new namespace')
|
2020-12-10 14:52:35 +01:00
|
|
|
.click()
|
2021-05-27 08:51:42 +02:00
|
|
|
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.url()
|
|
|
|
.should('contain', '/namespaces/new')
|
2021-01-21 23:33:16 +01:00
|
|
|
cy.get('.card-header-title')
|
2020-12-10 14:52:35 +01:00
|
|
|
.should('contain', 'Create a new namespace')
|
|
|
|
cy.get('input.input')
|
2021-05-27 08:51:42 +02:00
|
|
|
.type(newNamespaceTitle)
|
2021-01-17 18:57:57 +01:00
|
|
|
cy.get('.button')
|
2021-01-21 23:33:16 +01:00
|
|
|
.contains('Create')
|
2020-12-10 14:52:35 +01:00
|
|
|
.click()
|
2021-05-27 08:51:42 +02:00
|
|
|
|
|
|
|
cy.get('.global-notification')
|
|
|
|
.should('contain', 'Success')
|
|
|
|
cy.get('.namespace-container')
|
|
|
|
.should('contain', newNamespaceTitle)
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.url()
|
|
|
|
.should('contain', '/namespaces')
|
|
|
|
})
|
2021-05-27 08:51:42 +02:00
|
|
|
|
|
|
|
it('Should rename the namespace all places', () => {
|
|
|
|
const newNamespaces = NamespaceFactory.create(5)
|
|
|
|
const newNamespaceName = 'New namespace name'
|
|
|
|
|
|
|
|
cy.visit('/namespaces')
|
|
|
|
|
|
|
|
cy.get(`.namespace-container .menu.namespaces-lists .namespace-title:contains(${newNamespaces[0].title}) .dropdown .dropdown-trigger`)
|
|
|
|
.click()
|
|
|
|
cy.get('.namespace-container .menu.namespaces-lists .namespace-title .dropdown .dropdown-content')
|
|
|
|
.contains('Edit')
|
|
|
|
.click()
|
|
|
|
cy.url()
|
|
|
|
.should('contain', '/settings/edit')
|
|
|
|
cy.get('#namespacetext')
|
|
|
|
.invoke('val')
|
|
|
|
.should('equal', newNamespaces[0].title) // wait until the namespace data is loaded
|
|
|
|
cy.get('#namespacetext')
|
|
|
|
.type(`{selectall}${newNamespaceName}`)
|
|
|
|
cy.get('footer.modal-card-foot .button')
|
|
|
|
.contains('Save')
|
|
|
|
.click()
|
|
|
|
|
2021-10-02 22:47:13 +02:00
|
|
|
cy.get('.global-notification', { timeout: 1000 })
|
2021-05-27 08:51:42 +02:00
|
|
|
.should('contain', 'Success')
|
|
|
|
cy.get('.namespace-container .menu.namespaces-lists')
|
|
|
|
.should('contain', newNamespaceName)
|
|
|
|
.should('not.contain', newNamespaces[0].title)
|
|
|
|
cy.get('.content.namespaces-list')
|
|
|
|
.should('contain', newNamespaceName)
|
|
|
|
.should('not.contain', newNamespaces[0].title)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should remove a namespace when deleting it', () => {
|
|
|
|
const newNamespaces = NamespaceFactory.create(5)
|
|
|
|
|
|
|
|
cy.visit('/')
|
|
|
|
|
|
|
|
cy.get(`.namespace-container .menu.namespaces-lists .namespace-title:contains(${newNamespaces[0].title}) .dropdown .dropdown-trigger`)
|
|
|
|
.click()
|
|
|
|
cy.get('.namespace-container .menu.namespaces-lists .namespace-title .dropdown .dropdown-content')
|
|
|
|
.contains('Delete')
|
|
|
|
.click()
|
|
|
|
cy.url()
|
|
|
|
.should('contain', '/settings/delete')
|
2022-01-04 19:58:06 +01:00
|
|
|
cy.get('[data-cy="modalPrimary"]')
|
2021-05-27 08:51:42 +02:00
|
|
|
.contains('Do it')
|
|
|
|
.click()
|
|
|
|
|
|
|
|
cy.get('.global-notification')
|
|
|
|
.should('contain', 'Success')
|
|
|
|
cy.get('.namespace-container .menu.namespaces-lists')
|
|
|
|
.should('not.contain', newNamespaces[0].title)
|
|
|
|
})
|
2021-06-03 15:31:39 +02:00
|
|
|
|
|
|
|
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')
|
|
|
|
})
|
2020-12-10 14:52:35 +01:00
|
|
|
})
|