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"
|
"test:unit:ci": "vitest run"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@quasar/cli": "^2.2.1",
|
"@quasar/cli": "^2.3.0",
|
||||||
"@quasar/extras": "^1.16.4",
|
"@quasar/extras": "^1.16.4",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"chromium": "^3.0.3",
|
"chromium": "^3.0.3",
|
||||||
|
|
|
@ -23,25 +23,29 @@ const active = ref();
|
||||||
const available = ref();
|
const available = ref();
|
||||||
|
|
||||||
async function toggleNotification(notification) {
|
async function toggleNotification(notification) {
|
||||||
if (!notification.active) {
|
try {
|
||||||
await axios.delete(`NotificationSubscriptions/${notification.id}`);
|
if (!notification.active) {
|
||||||
swapEntry(active.value, available.value, notification.notificationFk);
|
await axios.delete(`NotificationSubscriptions/${notification.id}`);
|
||||||
} else {
|
swapEntry(active.value, available.value, notification.notificationFk);
|
||||||
const { data } = await axios.post(`NotificationSubscriptions`, {
|
} else {
|
||||||
notificationFk: notification.notificationFk,
|
const { data } = await axios.post(`NotificationSubscriptions`, {
|
||||||
userFk: entityId.value,
|
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;
|
} catch {
|
||||||
|
notification.active = !notification.active;
|
||||||
swapEntry(available.value, active.value, notification.notificationFk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quasar.notify({
|
|
||||||
type: 'positive',
|
|
||||||
message: t(
|
|
||||||
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
|
|
||||||
),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const swapEntry = (from, to, key) => {
|
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(() => {
|
beforeEach(() => {
|
||||||
const workerId = 1110;
|
|
||||||
cy.viewport(1280, 720);
|
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', () => {
|
it('should throw an error if you try to change a notification that is not yours', () => {
|
||||||
cy.get('.q-chip').should('have.length', 3);
|
cy.login('developer');
|
||||||
cy.get('.q-toggle__thumb').eq(0).click();
|
cy.visit(`/#/worker/${salesPersonId}/notifications`);
|
||||||
cy.get('.q-notification__message').should(
|
cy.get(firstAvailableNotification).click();
|
||||||
'have.text',
|
cy.notificationHas(
|
||||||
'Unsubscribed from the notification'
|
'.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(activeList)
|
||||||
cy.get('.q-toggle__thumb').should('have.length', 3).eq(0).click();
|
.children()
|
||||||
cy.get('.q-notification__message').should(
|
.its('length')
|
||||||
'have.text',
|
.then((beforeSize) => {
|
||||||
'Subscribed to the notification'
|
cy.get(firstAvailableNotification).click();
|
||||||
);
|
cy.get(activeList)
|
||||||
cy.get('.q-toggle__thumb').should('have.length', 3).eq(1).click();
|
.children()
|
||||||
cy.get('.q-notification__message').should(
|
.should('have.length', beforeSize + 1);
|
||||||
'have.text',
|
});
|
||||||
'Subscribed to the notification'
|
});
|
||||||
);
|
|
||||||
|
|
||||||
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();
|
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) => {
|
Cypress.Commands.add('fillRow', (rowSelector, data) => {
|
||||||
// Usar el selector proporcionado para obtener la fila deseada
|
// Usar el selector proporcionado para obtener la fila deseada
|
||||||
cy.waitForElement('tbody');
|
cy.waitForElement('tbody');
|
||||||
|
|
Loading…
Reference in New Issue