Add more global state tests (#521)

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/521
Co-authored-by: konrad <konrad@kola-entertainments.de>
Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad 2021-05-27 06:51:42 +00:00
parent 1fa42f047c
commit 8c3dd387a3
2 changed files with 125 additions and 2 deletions

View file

@ -10,10 +10,12 @@ import {BucketFactory} from '../../factories/bucket'
import '../../support/authenticateUser' import '../../support/authenticateUser'
describe('Lists', () => { describe('Lists', () => {
let lists
beforeEach(() => { beforeEach(() => {
UserFactory.create(1) UserFactory.create(1)
NamespaceFactory.create(1) NamespaceFactory.create(1)
const lists = ListFactory.create(1, { lists = ListFactory.create(1, {
title: 'First List' title: 'First List'
}) })
TaskFactory.truncate() TaskFactory.truncate()
@ -54,6 +56,64 @@ describe('Lists', () => {
.should('contain', '/lists/1/kanban') .should('contain', '/lists/1/kanban')
}) })
it('Should rename the list in all places', () => {
const tasks = TaskFactory.create(5, {
id: '{increment}',
list_id: 1,
})
const newListName = 'New list name'
cy.visit('/lists/1')
cy.get('.list-title h1')
.should('contain', 'First List')
cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list li:first-child .dropdown .dropdown-trigger')
.click()
cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list li:first-child .dropdown .dropdown-content')
.contains('Edit')
.click()
cy.get('#listtext')
.type(`{selectall}${newListName}`)
cy.get('footer.modal-card-foot .button')
.contains('Save')
.click()
cy.get('.global-notification')
.should('contain', 'Success')
cy.get('.list-title h1')
.should('contain', newListName)
.should('not.contain', lists[0].title)
cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list li:first-child')
.should('contain', newListName)
.should('not.contain', lists[0].title)
cy.visit('/')
cy.get('.card-content .tasks')
.should('contain', newListName)
.should('not.contain', lists[0].title)
})
it('Should remove a list', () => {
cy.visit(`/lists/${lists[0].id}`)
cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list li:first-child .dropdown .dropdown-trigger')
.click()
cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list li:first-child .dropdown .dropdown-content')
.contains('Delete')
.click()
cy.url()
.should('contain', '/settings/delete')
cy.get('.modal-mask .modal-container .modal-content .actions a.button')
.contains('Do it')
.click()
cy.get('.global-notification')
.should('contain', 'Success')
cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list')
.should('not.contain', lists[0].title)
cy.location('pathname')
.should('equal', '/')
})
describe('List View', () => { describe('List View', () => {
it('Should be an empty list', () => { it('Should be an empty list', () => {
cy.visit('/lists/1') cy.visit('/lists/1')

View file

@ -3,6 +3,7 @@ import {UserFactory} from '../../factories/user'
import '../../support/authenticateUser' import '../../support/authenticateUser'
import {ListFactory} from '../../factories/list' import {ListFactory} from '../../factories/list'
import {NamespaceFactory} from '../../factories/namespace' import {NamespaceFactory} from '../../factories/namespace'
import {TaskFactory} from '../../factories/task'
describe('Namepaces', () => { describe('Namepaces', () => {
let namespaces let namespaces
@ -20,20 +21,82 @@ describe('Namepaces', () => {
}) })
it('Should create a new Namespace', () => { it('Should create a new Namespace', () => {
const newNamespaceTitle = 'New Namespace'
cy.visit('/namespaces') cy.visit('/namespaces')
cy.get('a.button') cy.get('a.button')
.contains('Create namespace') .contains('Create namespace')
.click() .click()
cy.url() cy.url()
.should('contain', '/namespaces/new') .should('contain', '/namespaces/new')
cy.get('.card-header-title') cy.get('.card-header-title')
.should('contain', 'Create a new namespace') .should('contain', 'Create a new namespace')
cy.get('input.input') cy.get('input.input')
.type('New Namespace') .type(newNamespaceTitle)
cy.get('.button') cy.get('.button')
.contains('Create') .contains('Create')
.click() .click()
cy.get('.global-notification')
.should('contain', 'Success')
cy.get('.namespace-container')
.should('contain', newNamespaceTitle)
cy.url() cy.url()
.should('contain', '/namespaces') .should('contain', '/namespaces')
}) })
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()
cy.get('.global-notification')
.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')
cy.get('.modal-mask .modal-container .modal-content .actions a.button')
.contains('Do it')
.click()
cy.get('.global-notification')
.should('contain', 'Success')
cy.get('.namespace-container .menu.namespaces-lists')
.should('not.contain', newNamespaces[0].title)
})
}) })