refs #4797 test: workerNotification e2e
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b82f5d210f
commit
31c9876fb0
|
@ -15,7 +15,7 @@
|
|||
"test:unit:ci": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@quasar/cli": "^2.2.1",
|
||||
"@quasar/cli": "^2.3.0",
|
||||
"@quasar/extras": "^1.16.4",
|
||||
"axios": "^1.4.0",
|
||||
"chromium": "^3.0.3",
|
||||
|
|
|
@ -23,25 +23,29 @@ const active = ref();
|
|||
const available = ref();
|
||||
|
||||
async function toggleNotification(notification) {
|
||||
if (!notification.active) {
|
||||
await axios.delete(`NotificationSubscriptions/${notification.id}`);
|
||||
swapEntry(active.value, available.value, notification.notificationFk);
|
||||
} else {
|
||||
const { data } = await axios.post(`NotificationSubscriptions`, {
|
||||
notificationFk: notification.notificationFk,
|
||||
userFk: entityId.value,
|
||||
try {
|
||||
if (!notification.active) {
|
||||
await axios.delete(`NotificationSubscriptions/${notification.id}`);
|
||||
swapEntry(active.value, available.value, notification.notificationFk);
|
||||
} else {
|
||||
const { data } = await axios.post(`NotificationSubscriptions`, {
|
||||
notificationFk: notification.notificationFk,
|
||||
userFk: entityId.value,
|
||||
});
|
||||
notification.id = data.id;
|
||||
|
||||
swapEntry(available.value, active.value, notification.notificationFk);
|
||||
}
|
||||
|
||||
quasar.notify({
|
||||
type: 'positive',
|
||||
message: t(
|
||||
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
||||
),
|
||||
});
|
||||
notification.id = data.id;
|
||||
|
||||
swapEntry(available.value, active.value, notification.notificationFk);
|
||||
} catch {
|
||||
notification.active = !notification.active;
|
||||
}
|
||||
|
||||
quasar.notify({
|
||||
type: 'positive',
|
||||
message: t(
|
||||
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
const swapEntry = (from, to, key) => {
|
||||
|
|
|
@ -1,36 +1,79 @@
|
|||
xdescribe('WorkerNotificationsManager', () => {
|
||||
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(() => {
|
||||
const workerId = 1110;
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('salesBoss');
|
||||
cy.visit(`/#/worker/${workerId}/notifications`);
|
||||
});
|
||||
|
||||
it('should unsubscribe 2 notifications, check the unsubscription has been saved, subscribe to other one and should check the data has been saved', () => {
|
||||
cy.get('.q-chip').should('have.length', 3);
|
||||
cy.get('.q-toggle__thumb').eq(0).click();
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Unsubscribed from the notification'
|
||||
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'
|
||||
);
|
||||
cy.get('.q-chip > .q-icon').eq(0).click();
|
||||
});
|
||||
|
||||
cy.reload();
|
||||
it('should active a notification that is yours', () => {
|
||||
cy.login('developer');
|
||||
cy.visit(`/#/worker/${developerId}/notifications`);
|
||||
cy.waitForElement(activeList);
|
||||
cy.waitForElement(availableList);
|
||||
|
||||
cy.get('.q-chip').should('have.length', 1);
|
||||
cy.get('.q-toggle__thumb').should('have.length', 3).eq(0).click();
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Subscribed to the notification'
|
||||
);
|
||||
cy.get('.q-toggle__thumb').should('have.length', 3).eq(1).click();
|
||||
cy.get('.q-notification__message').should(
|
||||
'have.text',
|
||||
'Subscribed to the notification'
|
||||
);
|
||||
cy.get(activeList)
|
||||
.children()
|
||||
.its('length')
|
||||
.then((beforeSize) => {
|
||||
cy.get(firstAvailableNotification).click();
|
||||
cy.get(activeList)
|
||||
.children()
|
||||
.should('have.length', beforeSize + 1);
|
||||
});
|
||||
});
|
||||
|
||||
cy.reload();
|
||||
it('should deactivate a notification that is yours', () => {
|
||||
cy.login('developer');
|
||||
cy.visit(`/#/worker/${developerId}/notifications`);
|
||||
cy.waitForElement(activeList);
|
||||
cy.waitForElement(availableList);
|
||||
|
||||
cy.get('.q-chip').should('have.length', 3);
|
||||
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(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);
|
||||
|
||||
//Rollback
|
||||
cy.get(firstActiveNotification).click();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -91,6 +91,10 @@ Cypress.Commands.add('clickConfirm', () => {
|
|||
cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('notificationHas', (selector, text) => {
|
||||
cy.get(selector).should('have.text', text);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('fillRow', (rowSelector, data) => {
|
||||
// Usar el selector proporcionado para obtener la fila deseada
|
||||
cy.waitForElement('tbody');
|
||||
|
|
Loading…
Reference in New Issue