From cc13e3935e49ae34cc6067f610985bce99a1a9be Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 3 Nov 2023 15:24:48 +0100 Subject: [PATCH 1/9] refs #4797 feat(workerNotificationManager): use crudModel --- .../Card/WorkerNotificationsManager.vue | 17 ++++++++++++--- src/router/modules/worker.js | 21 ++++++++++--------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index 13c9b3de2..f83223749 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -15,7 +15,7 @@ const $props = defineProps({ const entityId = computed(() => $props.id || route.params.id); onMounted(() => fetch()); -onUpdated(() => fetch()); +onUpdated(() => console.log('updated')); const route = useRoute(); const { t } = useI18n(); @@ -76,7 +76,18 @@ async function toggleNotification(notification) { } diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index f79d7f06d..e5ee7c1a2 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -11,7 +11,7 @@ export default { redirect: { name: 'WorkerMain' }, menus: { main: ['WorkerList'], - // card: ['WorkerNotificationsManager'], + card: ['WorkerNotificationsManager'], }, children: [ { @@ -46,15 +46,16 @@ export default { }, component: () => import('src/pages/Worker/Card/WorkerSummary.vue'), }, - // { - // name: 'WorkerNotificationsManager', - // path: 'notifications', - // meta: { - // title: 'notifications', - // icon: 'notifications', - // }, - // component: () => import('src/pages/Worker/Card/WorkerNotificationsManager.vue'), - // }, + { + name: 'WorkerNotificationsManager', + path: 'notifications', + meta: { + title: 'notifications', + icon: 'notifications', + }, + component: () => + import('src/pages/Worker/Card/WorkerNotificationsManager.vue'), + }, ], }, ], From 4de39452ca0e49feef53075a16c879cf0ac564e4 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 6 Nov 2023 08:32:03 +0100 Subject: [PATCH 2/9] refs #4797 feat(workerNotification): add cards --- .../Card/WorkerNotificationsManager.vue | 109 +++++++++--------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index f83223749..03948318e 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -5,6 +5,8 @@ import { computed, onMounted, onUpdated, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; +import CrudModel from 'components/CrudModel.vue'; + const $props = defineProps({ id: { type: Number, @@ -14,75 +16,60 @@ const $props = defineProps({ }); const entityId = computed(() => $props.id || route.params.id); -onMounted(() => fetch()); onUpdated(() => console.log('updated')); const route = useRoute(); const { t } = useI18n(); const quasar = useQuasar(); -const notifications = ref([]); - -async function fetch() { - try { - await axios - .get(`NotificationSubscriptions/${entityId.value}/getList`) - .then(async (res) => { - if (res.data) { - notifications.value = res.data; - } - }); - } catch (e) { - // - } -} - -async function disableNotification(notification) { - await axios - .delete(`NotificationSubscriptions/${notification.id}`) - .catch(() => (notification.active = true)) - .then((res) => { - if (res.data) { - notification.id = null; - notification.active = false; - quasar.notify({ - type: 'positive', - message: t('worker.notificationsManager.unsubscribed'), - }); - } - }); -} - async function toggleNotification(notification) { - if (!notification.active) { - await disableNotification(notification); - } else { - await axios - .post(`NotificationSubscriptions`, { - notificationFk: notification.notificationFk, - userFk: entityId.value, - }) - .catch(() => (notification.active = false)) - .then((res) => { - if (res.data) { - notification.id = res.data.id; - quasar.notify({ - type: 'positive', - message: t('worker.notificationsManager.subscribed'), - }); - } - }); + if (notification.active) { + await axios.delete(`NotificationSubscriptions/${notification.id}`); + notification.id = null; + notification.active = false; + return quasar.notify({ + type: 'positive', + message: t('worker.notificationsManager.unsubscribed'), + }); } + + const { data } = await axios.post(`NotificationSubscriptions`, { + notificationFk: notification.notificationFk, + userFk: entityId.value, + }); + + notification.id = data.id; + quasar.notify({ + type: 'positive', + message: t('worker.notificationsManager.subscribed'), + }); } + + + From 535076546971e95675db490a7e828b1fabcd52f3 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 6 Nov 2023 15:33:18 +0100 Subject: [PATCH 3/9] refs #4797 style(workerNotificationManager) --- src/components/CrudModel.vue | 1 + .../Card/WorkerNotificationsManager.vue | 158 +++++++----------- 2 files changed, 60 insertions(+), 99 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 2a4982fce..96d52b98c 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -89,6 +89,7 @@ async function fetch(data) { watch(formData, () => (hasChanges.value = true), { deep: true }); emit('onFetch', data); + return data; } async function reset() { diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index 03948318e..1b3cf1704 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -14,35 +14,38 @@ const $props = defineProps({ default: null, }, }); -const entityId = computed(() => $props.id || route.params.id); - -onUpdated(() => console.log('updated')); const route = useRoute(); const { t } = useI18n(); const quasar = useQuasar(); +const entityId = computed(() => $props.id || route.params.id); +const notifications = ref(); async function toggleNotification(notification) { + let data = {}; if (notification.active) { await axios.delete(`NotificationSubscriptions/${notification.id}`); - notification.id = null; - notification.active = false; - return quasar.notify({ - type: 'positive', - message: t('worker.notificationsManager.unsubscribed'), + } else { + const res = await axios.post(`NotificationSubscriptions`, { + notificationFk: notification.notificationFk, + userFk: entityId.value, }); + data = res.data; } - const { data } = await axios.post(`NotificationSubscriptions`, { - notificationFk: notification.notificationFk, - userFk: entityId.value, - }); - notification.id = data.id; + notification.active = !notification.active; quasar.notify({ type: 'positive', - message: t('worker.notificationsManager.subscribed'), + message: t( + `worker.notificationsManager.${notification.active ? 'un' : ''}subscribed` + ), }); + orderNotification(notifications.value); +} + +function orderNotification(data) { + notifications.value = data.sort((notification) => -+notification.active); } @@ -51,98 +54,55 @@ async function toggleNotification(notification) { auto-load data-key="NotificationSubscriptions" :url="`NotificationSubscriptions/${entityId}/getList`" + :default-reset="false" :default-remove="false" + :default-save="false" + @on-fetch="orderNotification" > - - - + + + + + - From e8aef295123cdb52bb7ee82631c35a85660e800e Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 8 Nov 2023 12:19:38 +0100 Subject: [PATCH 4/9] refs #4797 feat(WorkerNotification): use Maps --- .vscode/settings.json | 3 +- src/pages/Claim/Card/ClaimDevelopment.vue | 3 - .../Card/WorkerNotificationsManager.vue | 132 ++++++++++++------ 3 files changed, 88 insertions(+), 50 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ecc1d50d7..5026b7d3b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,5 +13,6 @@ ], "[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - } + }, + "cSpell.words": ["axios"] } diff --git a/src/pages/Claim/Card/ClaimDevelopment.vue b/src/pages/Claim/Card/ClaimDevelopment.vue index c2c9b925c..09422f7a1 100644 --- a/src/pages/Claim/Card/ClaimDevelopment.vue +++ b/src/pages/Claim/Card/ClaimDevelopment.vue @@ -249,9 +249,6 @@ function goToAction() { .grid-style-transition { transition: transform 0.28s, background-color 0.28s; } -.maxwidth { - width: 100%; -} diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index 1b3cf1704..e384870dc 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -1,7 +1,7 @@ @@ -57,34 +64,53 @@ function orderNotification(data) { :default-reset="false" :default-remove="false" :default-save="false" - @on-fetch="orderNotification" + @on-fetch="setNotifications" > @@ -92,17 +118,31 @@ function orderNotification(data) { From 0b3a957944661f6e1b532b017600662130c468cc Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 8 Nov 2023 12:20:00 +0100 Subject: [PATCH 5/9] refs #4797 fix: remove clientCreate --- src/pages/Customer/CustomerCreate.vue | 56 --------------------------- src/router/modules/customer.js | 22 ++++------- 2 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 src/pages/Customer/CustomerCreate.vue diff --git a/src/pages/Customer/CustomerCreate.vue b/src/pages/Customer/CustomerCreate.vue deleted file mode 100644 index d87af6cab..000000000 --- a/src/pages/Customer/CustomerCreate.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - - diff --git a/src/router/modules/customer.js b/src/router/modules/customer.js index c7e978eec..832a1e0fd 100644 --- a/src/router/modules/customer.js +++ b/src/router/modules/customer.js @@ -10,7 +10,7 @@ export default { component: RouterView, redirect: { name: 'CustomerMain' }, menus: { - main: ['CustomerList', 'CustomerPayments', 'CustomerCreate'], + main: ['CustomerList', 'CustomerPayments'], card: ['CustomerBasicData'], }, children: [ @@ -27,7 +27,7 @@ export default { title: 'list', icon: 'view_list', }, - component: () => import('src/pages/Customer/CustomerList.vue') + component: () => import('src/pages/Customer/CustomerList.vue'), }, { path: 'payments', @@ -36,17 +36,7 @@ export default { title: 'webPayments', icon: 'vn:onlinepayment', }, - component: () => import('src/pages/Customer/CustomerPayments.vue') - }, - { - path: 'create', - name: 'CustomerCreate', - meta: { - title: 'createCustomer', - icon: 'vn:addperson', - roles: ['developer'], - }, - component: () => import('src/pages/Customer/CustomerCreate.vue'), + component: () => import('src/pages/Customer/CustomerPayments.vue'), }, ], }, @@ -63,7 +53,8 @@ export default { title: 'summary', icon: 'launch', }, - component: () => import('src/pages/Customer/Card/CustomerSummary.vue'), + component: () => + import('src/pages/Customer/Card/CustomerSummary.vue'), }, { path: 'basic-data', @@ -72,7 +63,8 @@ export default { title: 'basicData', icon: 'vn:settings', }, - component: () => import('src/pages/Customer/Card/CustomerBasicData.vue'), + component: () => + import('src/pages/Customer/Card/CustomerBasicData.vue'), }, ], }, From b82f5d210f1023f93357f1d961aa00624b9d35d3 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 9 Nov 2023 07:43:16 +0100 Subject: [PATCH 6/9] refs #4797 test: workerNotification front --- .../Card/WorkerNotificationsManager.vue | 1 - .../Worker/WorkerNotificationsManager.spec.js | 93 +++---------------- 2 files changed, 13 insertions(+), 81 deletions(-) diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index e384870dc..3e0c703fc 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -122,7 +122,6 @@ function setNotifications(data) { grid-template-columns: repeat(4, 1fr); grid-gap: 10px; - /* we will explain what these classes do next! */ .v-enter-active, .v-leave-active { transition: opacity 0.5s ease; diff --git a/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js b/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js index 744346078..35ce91e61 100644 --- a/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js +++ b/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js @@ -1,15 +1,15 @@ import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest'; -import { createWrapper, axios } from 'app/test/vitest/helper'; +import { createWrapper } from 'app/test/vitest/helper'; import WorkerNotificationsManager from 'src/pages/Worker/Card/WorkerNotificationsManager.vue'; +import { ref } from 'vue'; describe('WorkerNotificationsManager', () => { let vm; - const entityId = 1110; beforeAll(() => { vm = createWrapper(WorkerNotificationsManager, { - propsData: { - id: entityId, + global: { + stubs: ['CrudModel'], }, }).vm; }); @@ -18,83 +18,16 @@ describe('WorkerNotificationsManager', () => { vi.clearAllMocks(); }); - describe('fetch()', () => { - it('should fetch notification subscriptions and role mappings', async () => { - vi.spyOn(axios, 'get') - .mockResolvedValueOnce({ - data: [ - { - id: 1, - name: 'Name 1', - description: 'Description 1', - notificationFk: 1, - active: true - }, - ], - }); - await vm.fetch(); + describe('swapEntry()', () => { + it('should swap notification', async () => { + const from = ref(new Map()); + const to = ref(new Map()); + from.value.set(1, { notificationFk: 1 }); + to.value.set(2, { notificationFk: 2 }); - expect(axios.get).toHaveBeenCalledWith(`NotificationSubscriptions/${entityId}/getList`); - expect(vm.notifications).toEqual([ - { - id: 1, - notificationFk: 1, - name: 'Name 1', - description: 'Description 1', - active: true, - }, - ]); - }); - }); - - describe('disableNotification()', () => { - it('should disable the notification', async () => { - vi.spyOn(axios, 'delete').mockResolvedValue({ data: { count: 1 } }); - vi.spyOn(vm.quasar, 'notify'); - const subscriptionId = 1; - vm.notifications = [{ id: 1, active: true }]; - - await vm.disableNotification(vm.notifications[0]); - - expect(axios.delete).toHaveBeenCalledWith( - `NotificationSubscriptions/${subscriptionId}` - ); - expect(vm.notifications[0].id).toBeNull(); - expect(vm.notifications[0].id).toBeFalsy(); - expect(vm.quasar.notify).toHaveBeenCalledWith( - expect.objectContaining({ type: 'positive' }) - ); - }); - }); - - describe('toggleNotification()', () => { - it('should activate the notification', async () => { - vi.spyOn(axios, 'post').mockResolvedValue({ - data: { id: 1, notificationFk: 1 }, - }); - vm.notifications = [{ id: null, active: true, notificationFk: 1 }]; - - await vm.toggleNotification(vm.notifications[0]); - - expect(axios.post).toHaveBeenCalledWith('NotificationSubscriptions', { - notificationFk: 1, - userFk: entityId, - }); - expect(vm.notifications[0].id).toBe(1); - expect(vm.notifications[0].active).toBeTruthy(); - expect(vm.quasar.notify).toHaveBeenCalledWith( - expect.objectContaining({ type: 'positive' }) - ); - }); - - it('should disable the notification', async () => { - vi.spyOn(vm, 'disableNotification'); - vm.notifications = [{ id: 1, active: false, notificationFk: 1 }]; - - await vm.toggleNotification(vm.notifications[0]); - - expect(vm.notifications[0].id).toBe(null); - expect(vm.notifications[0].active).toBeFalsy(); + await vm.swapEntry(from.value, to.value, 1); + expect(to.value.size).toBe(2); + expect(from.value.size).toBe(0); }); }); }); From a32aab709a94862d67c616885779c4e8ed9eb496 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 9 Nov 2023 09:29:20 +0100 Subject: [PATCH 7/9] refs #6415 feat: package version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7ab5883b3..7a9331870 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-front", - "version": "23.42.01", + "version": "23.48.01", "description": "Salix frontend", "productName": "Salix", "author": "Verdnatura", @@ -53,4 +53,4 @@ "vite": "^4.3.5", "vitest": "^0.31.1" } -} +} \ No newline at end of file From 31c9876fb01ed9d9081cc571fcb6bd413ecc4af3 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 9 Nov 2023 10:59:08 +0100 Subject: [PATCH 8/9] refs #4797 test: workerNotification e2e --- package.json | 2 +- .../Card/WorkerNotificationsManager.vue | 38 ++++---- ...{ClaimNotes.spec.js => claimNotes.spec.js} | 0 .../workerNotificationsManager.spec.js | 93 ++++++++++++++----- test/cypress/support/commands.js | 4 + 5 files changed, 94 insertions(+), 43 deletions(-) rename test/cypress/integration/{ClaimNotes.spec.js => claimNotes.spec.js} (100%) diff --git a/package.json b/package.json index 7ab5883b3..666d731e1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index 3e0c703fc..ff07eb859 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -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) => { diff --git a/test/cypress/integration/ClaimNotes.spec.js b/test/cypress/integration/claimNotes.spec.js similarity index 100% rename from test/cypress/integration/ClaimNotes.spec.js rename to test/cypress/integration/claimNotes.spec.js diff --git a/test/cypress/integration/workerNotificationsManager.spec.js b/test/cypress/integration/workerNotificationsManager.spec.js index 4cd54629a..175933277 100644 --- a/test/cypress/integration/workerNotificationsManager.spec.js +++ b/test/cypress/integration/workerNotificationsManager.spec.js @@ -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(); + }); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index a725837a1..a67df121e 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -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'); From 54276b2460a44f599ace99b9ef3eff371c72f740 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 10 Nov 2023 08:09:17 +0100 Subject: [PATCH 9/9] refs #4797 refactor(workerNotification): const url_key --- src/pages/Worker/Card/WorkerNotificationsManager.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue index ff07eb859..44573adca 100644 --- a/src/pages/Worker/Card/WorkerNotificationsManager.vue +++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue @@ -19,16 +19,17 @@ const route = useRoute(); const { t } = useI18n(); const quasar = useQuasar(); const entityId = computed(() => $props.id || route.params.id); +const URL_KEY = 'NotificationSubscriptions'; const active = ref(); const available = ref(); async function toggleNotification(notification) { try { if (!notification.active) { - await axios.delete(`NotificationSubscriptions/${notification.id}`); + await axios.delete(`${URL_KEY}/${notification.id}`); swapEntry(active.value, available.value, notification.notificationFk); } else { - const { data } = await axios.post(`NotificationSubscriptions`, { + const { data } = await axios.post(URL_KEY, { notificationFk: notification.notificationFk, userFk: entityId.value, }); @@ -63,8 +64,8 @@ function setNotifications(data) {