describe('WorkerNotificationsManager', () => { const salesPersonId = 18; const developerId = 9; const activeList = ':nth-child(1) > .q-list'; const availableList = ':nth-child(2) > .q-list'; const firstActiveNotification = ':nth-child(1) > .q-list > :nth-child(1) > .q-item > .q-toggle > .q-toggle__inner'; const firstAvailableNotification = ':nth-child(2) > .q-list > :nth-child(1) > .q-item > .q-toggle > .q-toggle__inner'; beforeEach(() => { cy.viewport(1280, 720); }); it('should throw an error if you try to change a notification that is not yours', () => { cy.login('developer'); cy.visit(`/#/worker/${salesPersonId}/notifications`); cy.get(firstAvailableNotification).click(); cy.notificationHas( '.q-notification__message', 'The notification subscription of this worker cant be modified' ); }); it('should active a notification that is yours', () => { cy.login('developer'); cy.visit(`/#/worker/${developerId}/notifications`); cy.waitForElement(activeList); cy.waitForElement(availableList); cy.get(activeList) .children() .its('length') .then((beforeSize) => { cy.get(firstAvailableNotification).click(); cy.get(activeList) .children() .should('have.length', beforeSize + 1); }); }); it('should deactivate a notification that is yours', () => { cy.login('developer'); cy.visit(`/#/worker/${developerId}/notifications`); cy.waitForElement(activeList); cy.waitForElement(availableList); cy.get(availableList) .children() .its('length') .then((beforeSize) => { cy.get(firstActiveNotification).click(); cy.get(availableList) .children() .should('have.length', beforeSize + 1); }); }); it('should active a notification if you are their boss', () => { cy.login('salesBoss'); cy.visit(`/#/worker/${salesPersonId}/notifications`); cy.waitForElement(availableList); cy.get(activeList) .children() .its('length') .then((beforeSize) => { cy.get(firstAvailableNotification).click(); cy.get(activeList) .children() .should('have.length', beforeSize + 1); //Rollback cy.get(firstActiveNotification).click(); }); }); });