salix-front/test/cypress/integration/worker/workerNotificationsManager....

78 lines
2.6 KiB
JavaScript
Raw Normal View History

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';
2023-05-02 06:42:31 +00:00
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();
2024-10-25 08:33:59 +00:00
cy.checkNotification(
'The notification subscription of this worker cant be modified'
);
});
2023-05-02 06:42:31 +00:00
it('should active a notification that is yours', () => {
cy.login('developer');
cy.visit(`/#/worker/${developerId}/notifications`);
cy.waitForElement(activeList);
cy.waitForElement(availableList);
2023-05-15 08:57:17 +00:00
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);
2023-05-02 06:42:31 +00:00
cy.get(activeList)
.children()
.its('length')
.then((beforeSize) => {
cy.get(firstAvailableNotification).click();
cy.get(activeList)
.children()
.should('have.length', beforeSize + 1);
2023-05-15 08:57:17 +00:00
//Rollback
cy.get(firstActiveNotification).click();
});
2023-05-02 06:42:31 +00:00
});
});