diff --git a/package.json b/package.json index 017412ef2..366e4bd36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-front", - "version": "25.14.0", + "version": "25.16.0", "description": "Salix frontend", "productName": "Salix", "author": "Verdnatura", @@ -76,4 +76,4 @@ "vite": "^6.0.11", "vitest": "^0.31.1" } -} \ No newline at end of file +} diff --git a/src/components/TicketProblems.vue b/src/components/TicketProblems.vue index 59be95035..c15e31d80 100644 --- a/src/components/TicketProblems.vue +++ b/src/components/TicketProblems.vue @@ -17,17 +17,6 @@ defineProps({ row: { type: Object, required: true } }); - - - {{ t('ticketSale.reserved') }} - - {{ label }} -
+
diff --git a/src/composables/__tests__/useRole.spec.js b/src/composables/__tests__/useRole.spec.js index d0bca5342..54d983a13 100644 --- a/src/composables/__tests__/useRole.spec.js +++ b/src/composables/__tests__/useRole.spec.js @@ -23,18 +23,19 @@ describe('useRole', () => { name: `T'Challa`, nickname: 'Black Panther', lang: 'en', + worker: { department: { departmentFk: 155 } }, }; const expectedUser = { id: 999, name: `T'Challa`, nickname: 'Black Panther', lang: 'en', + departmentFk: 155, }; const expectedRoles = ['salesPerson', 'admin']; - vi.spyOn(axios, 'get') - .mockResolvedValueOnce({ + vi.spyOn(axios, 'get').mockResolvedValueOnce({ data: { roles: rolesData, user: fetchedUser }, - }) + }); vi.spyOn(role.state, 'setUser'); vi.spyOn(role.state, 'setRoles'); diff --git a/src/composables/__tests__/useSession.spec.js b/src/composables/__tests__/useSession.spec.js index 789b149ec..cae33f893 100644 --- a/src/composables/__tests__/useSession.spec.js +++ b/src/composables/__tests__/useSession.spec.js @@ -75,6 +75,7 @@ describe('session', () => { userConfig: { darkMode: false, }, + worker: { department: { departmentFk: 155 } }, }; const rolesData = [ { @@ -143,7 +144,7 @@ describe('session', () => { await session.destroy(); // this clears token and user for any other test }); }, - {} + {}, ); describe('RenewToken', () => { @@ -175,7 +176,7 @@ describe('session', () => { await session.checkValidity(); expect(sessionStorage.getItem('token')).toEqual(expectedToken); expect(sessionStorage.getItem('tokenMultimedia')).toEqual( - expectedTokenMultimedia + expectedTokenMultimedia, ); }); it('Should renewToken', async () => { @@ -204,7 +205,7 @@ describe('session', () => { await session.checkValidity(); expect(sessionStorage.getItem('token')).not.toEqual(expectedToken); expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual( - expectedTokenMultimedia + expectedTokenMultimedia, ); }); }); diff --git a/src/composables/useAcl.js b/src/composables/useAcl.js index ede359186..52704fee9 100644 --- a/src/composables/useAcl.js +++ b/src/composables/useAcl.js @@ -30,9 +30,16 @@ export function useAcl() { return false; } + function hasAcl(model, prop, accessType) { + const modelAcl = state.getAcls().value[model]; + const propAcl = modelAcl?.[prop] || modelAcl?.['*']; + return !!(propAcl?.[accessType] || propAcl?.['*']); + } + return { fetch, hasAny, state, + hasAcl, }; } diff --git a/src/composables/useRole.js b/src/composables/useRole.js index ff54b409c..e700b1f2e 100644 --- a/src/composables/useRole.js +++ b/src/composables/useRole.js @@ -13,6 +13,7 @@ export function useRole() { name: data.user.name, nickname: data.user.nickname, lang: data.user.lang || 'es', + departmentFk: data.user.worker.department.departmentFk, }; state.setUser(userData); state.setRoles(roles); diff --git a/src/pages/Account/Card/AccountDescriptorMenu.vue b/src/pages/Account/Card/AccountDescriptorMenu.vue index eafd62df6..f3eabb531 100644 --- a/src/pages/Account/Card/AccountDescriptorMenu.vue +++ b/src/pages/Account/Card/AccountDescriptorMenu.vue @@ -100,12 +100,8 @@ const onChangePass = (oldPass) => { }; onMounted(() => { - hasitManagementAccess.value = useAcl().hasAny([ - { model: 'VnUser', props: 'higherPrivileges', accessType: 'WRITE' }, - ]); - hasSysadminAccess.value = useAcl().hasAny([ - { model: 'VnUser', props: 'adminUser', accessType: 'WRITE' }, - ]); + hasitManagementAccess.value = useAcl().hasAcl('VnUser', 'higherPrivileges', 'WRITE'); + hasSysadminAccess.value = useAcl().hasAcl('VnUser', 'adminUser', 'WRITE'); }); - - - {{ t('travel.summary.thermographs') }} - - + + - acl.hasAny([{ model: 'Worker', props: '__get__business', accessType: 'READ' }]), -); +const canSeeNotes = computed(() => acl.hasAcl('Worker', '__get__business', 'READ')); const workerIsFreelance = ref(); const WorkerFreelanceRef = ref(); const workerCalendarFilterRef = ref(null); diff --git a/src/pages/Worker/Card/WorkerLocker.vue b/src/pages/Worker/Card/WorkerLocker.vue index 015bced35..62891070d 100644 --- a/src/pages/Worker/Card/WorkerLocker.vue +++ b/src/pages/Worker/Card/WorkerLocker.vue @@ -9,7 +9,7 @@ import VnSelect from 'src/components/common/VnSelect.vue'; import { useArrayData } from 'src/composables/useArrayData'; import FetchData from 'components/FetchData.vue'; -const { hasAny } = useAcl(); +const { hasAcl } = useAcl(); const { t } = useI18n(); const fetchData = ref(); const originaLockerId = ref(); @@ -58,11 +58,7 @@ const init = async (data) => { option-label="code" option-value="id" hide-selected - :readonly=" - !hasAny([ - { model: 'Worker', props: '__get__locker', accessType: 'READ' }, - ]) - " + :readonly="!hasAcl('Worker', '__get__locker', 'READ')" /> diff --git a/src/pages/Worker/Card/WorkerTimeControl.vue b/src/pages/Worker/Card/WorkerTimeControl.vue index 9c0fa6758..b64166c7d 100644 --- a/src/pages/Worker/Card/WorkerTimeControl.vue +++ b/src/pages/Worker/Card/WorkerTimeControl.vue @@ -68,13 +68,9 @@ const arrayData = useArrayData('Worker'); const acl = useAcl(); const selectedDateYear = computed(() => moment(selectedDate.value).isoWeekYear()); const worker = computed(() => arrayData.store?.data); -const canSend = computed(() => - acl.hasAny([{ model: 'WorkerTimeControl', props: 'sendMail', accessType: 'WRITE' }]), -); +const canSend = computed(() => acl.hasAcl('WorkerTimeControl', 'sendMail', 'WRITE')); const canUpdate = computed(() => - acl.hasAny([ - { model: 'WorkerTimeControl', props: 'updateMailState', accessType: 'WRITE' }, - ]), + acl.hasAcl('WorkerTimeControl', 'updateMailState', 'WRITE'), ); const isHimself = computed(() => user.value.id === Number(route.params.id)); diff --git a/src/pages/Worker/WorkerFilter.vue b/src/pages/Worker/WorkerFilter.vue index 44dfd32b4..c40afe57e 100644 --- a/src/pages/Worker/WorkerFilter.vue +++ b/src/pages/Worker/WorkerFilter.vue @@ -102,8 +102,11 @@ en: lastName: Last name userName: User extension: Extension + departmentFk: Department es: + params: + departmentFk: Departamento search: Contiene firstName: Nombre lastName: Apellidos diff --git a/test/cypress/integration/account/accountDescriptorMenu.spec.js b/test/cypress/integration/account/accountDescriptorMenu.spec.js index 67a7d8ef6..04fc57040 100644 --- a/test/cypress/integration/account/accountDescriptorMenu.spec.js +++ b/test/cypress/integration/account/accountDescriptorMenu.spec.js @@ -1,4 +1,4 @@ -describe('ClaimNotes', () => { +describe('Account descriptor', () => { const descriptorOptions = '[data-cy="descriptor-more-opts-menu"] > .q-list'; const url = '/#/account/1/summary'; @@ -7,6 +7,9 @@ describe('ClaimNotes', () => { cy.visit(url); cy.dataCy('descriptor-more-opts').click(); cy.get(descriptorOptions) + .should('exist') + .should('be.visible') + .find('.q-item') .its('length') .then((count) => { diff --git a/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js b/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js index 7058e154c..fdaa01876 100644 --- a/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js @@ -13,7 +13,7 @@ describe('InvoiceInDescriptor', () => { cy.validateCheckbox(checkbox, false); }); - it('should delete the invoice properly', () => { + it.skip('should delete the invoice properly', () => { cy.visit('/#/invoice-in/2/summary'); cy.selectDescriptorOption(2); cy.clickConfirm(); diff --git a/test/cypress/integration/order/orderList.spec.js b/test/cypress/integration/order/orderList.spec.js index 34cd2bffc..ee011ea05 100644 --- a/test/cypress/integration/order/orderList.spec.js +++ b/test/cypress/integration/order/orderList.spec.js @@ -30,9 +30,11 @@ describe('OrderList', () => { cy.url().should('include', `/order`); }); - it.skip('filter list and create order', () => { + it('filter list and create order', () => { cy.dataCy('Customer ID_input').type('1101{enter}'); + cy.intercept('GET', /\/api\/Clients/).as('clientFilter'); cy.dataCy('vnTableCreateBtn').click(); + cy.wait('@clientFilter'); cy.dataCy('landedDate').find('input').type('06/01/2001'); cy.selectOption(agencyCreateSelect, 1); diff --git a/test/cypress/integration/vnComponent/VnAccountNumber.spec.js b/test/cypress/integration/vnComponent/VnAccountNumber.spec.js deleted file mode 100644 index 053902f35..000000000 --- a/test/cypress/integration/vnComponent/VnAccountNumber.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -describe('VnAccountNumber', () => { - const accountInput = 'input[data-cy="supplierFiscalDataAccount_input"]'; - beforeEach(() => { - cy.login('developer'); - cy.viewport(1920, 1080); - cy.visit('/#/supplier/1/fiscal-data'); - }); - - describe('VnInput handleInsertMode()', () => { - it('should replace character at cursor position in insert mode', () => { - cy.get(accountInput).type('{selectall}4100000001'); - cy.get(accountInput).type('{movetostart}'); - cy.get(accountInput).type('999'); - cy.get(accountInput).should('have.value', '9990000001'); - }); - - it('should replace character at cursor position in insert mode', () => { - cy.get(accountInput).clear(); - cy.get(accountInput).type('4100000001'); - cy.get(accountInput).type('{movetostart}'); - cy.get(accountInput).type('999'); - cy.get(accountInput).should('have.value', '9990000001'); - }); - - it('should respect maxlength prop', () => { - cy.get(accountInput).clear(); - cy.get(accountInput).type('123456789012345'); - cy.get(accountInput).should('have.value', '1234567890'); - }); - }); - - it('should convert short account number to standard format', () => { - cy.get(accountInput).clear(); - cy.get(accountInput).type('123.'); - cy.get(accountInput).should('have.value', '1230000000'); - }); -}); diff --git a/test/cypress/integration/vnComponent/VnShortcut.spec.js b/test/cypress/integration/vnComponent/VnShortcut.spec.js index e08c44635..fa05e2e3d 100644 --- a/test/cypress/integration/vnComponent/VnShortcut.spec.js +++ b/test/cypress/integration/vnComponent/VnShortcut.spec.js @@ -27,12 +27,15 @@ describe('VnShortcuts', () => { code: `Key${shortcut.toUpperCase()}`, }); + cy.waitSpinner(); cy.url().should('include', module); if (['monitor', 'claim'].includes(module)) { return; } cy.waitForElement('.q-page').should('exist'); cy.dataCy('vnTableCreateBtn').should('exist'); + cy.waitSpinner(); + cy.get('.q-page').trigger('keydown', { ctrlKey: true, altKey: true,