From 8c3dd387a341179dc8f887e164e89bd9f23b6286 Mon Sep 17 00:00:00 2001 From: konrad Date: Thu, 27 May 2021 06:51:42 +0000 Subject: [PATCH] Add more global state tests (#521) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/521 Co-authored-by: konrad Co-committed-by: konrad --- cypress/integration/list/list.spec.js | 62 +++++++++++++++++++- cypress/integration/list/namespaces.spec.js | 65 ++++++++++++++++++++- 2 files changed, 125 insertions(+), 2 deletions(-) diff --git a/cypress/integration/list/list.spec.js b/cypress/integration/list/list.spec.js index 4befee509..1def740e9 100644 --- a/cypress/integration/list/list.spec.js +++ b/cypress/integration/list/list.spec.js @@ -10,10 +10,12 @@ import {BucketFactory} from '../../factories/bucket' import '../../support/authenticateUser' describe('Lists', () => { + let lists + beforeEach(() => { UserFactory.create(1) NamespaceFactory.create(1) - const lists = ListFactory.create(1, { + lists = ListFactory.create(1, { title: 'First List' }) TaskFactory.truncate() @@ -54,6 +56,64 @@ describe('Lists', () => { .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', () => { it('Should be an empty list', () => { cy.visit('/lists/1') diff --git a/cypress/integration/list/namespaces.spec.js b/cypress/integration/list/namespaces.spec.js index 9dba7b431..dbdba9156 100644 --- a/cypress/integration/list/namespaces.spec.js +++ b/cypress/integration/list/namespaces.spec.js @@ -3,6 +3,7 @@ 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 @@ -20,20 +21,82 @@ describe('Namepaces', () => { }) it('Should create a new Namespace', () => { + const newNamespaceTitle = 'New Namespace' + cy.visit('/namespaces') cy.get('a.button') .contains('Create namespace') .click() + cy.url() .should('contain', '/namespaces/new') cy.get('.card-header-title') .should('contain', 'Create a new namespace') cy.get('input.input') - .type('New Namespace') + .type(newNamespaceTitle) cy.get('.button') .contains('Create') .click() + + cy.get('.global-notification') + .should('contain', 'Success') + cy.get('.namespace-container') + .should('contain', newNamespaceTitle) cy.url() .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) + }) })