diff --git a/src/components/CreateBankEntityForm.vue b/src/components/CreateBankEntityForm.vue index c46ac7752..1117225c7 100644 --- a/src/components/CreateBankEntityForm.vue +++ b/src/components/CreateBankEntityForm.vue @@ -1,5 +1,5 @@ diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index 7929c70c6..68338a1dc 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -228,13 +228,20 @@ defineExpose({ fetch, addFilter, paginate }); v-bind="$attrs" > -
+
diff --git a/src/pages/Wagon/Type/WagonTypeEdit.vue b/src/pages/Wagon/Type/WagonTypeEdit.vue new file mode 100644 index 000000000..eb8205d72 --- /dev/null +++ b/src/pages/Wagon/Type/WagonTypeEdit.vue @@ -0,0 +1,293 @@ + + + + + + + + en: + tray: Tray + wagonColor: Wagon color + Select a tray: Select a tray + es: + tray: Bandeja + wagonColor: Color de la bandeja + Select a tray: Seleccione una bandeja + Create new Wagon type: Crear nuevo tipo de vagón + Add new tray: Añadir nueva bandeja + Height: Altura + Tray added successfully: Bandeja añadida correctamente + Tray deleted successfully: Bandeja eliminada correctamente + diff --git a/src/pages/Wagon/Type/WagonTypeList.vue b/src/pages/Wagon/Type/WagonTypeList.vue index b7bbf8c5d..7615dea02 100644 --- a/src/pages/Wagon/Type/WagonTypeList.vue +++ b/src/pages/Wagon/Type/WagonTypeList.vue @@ -1,4 +1,5 @@ @@ -43,8 +48,9 @@ async function remove(row) {
@@ -54,12 +60,19 @@ async function remove(row) { :key="row.id" :title="(row.name || '').toString()" :id="row.id" - @click="navigate(row.id)" + @click="navigate(row.id, row.name)" > + + + +en: + nameNotEmpty: The name cannot be empty +es: + Create new Wagon type: Crear nuevo tipo de vagón + Name: Nombre + nameNotEmpty: El nombre no puede estar vacío + diff --git a/src/pages/Worker/Card/WorkerDescriptor.vue b/src/pages/Worker/Card/WorkerDescriptor.vue index 8d7f4f683..be30537df 100644 --- a/src/pages/Worker/Card/WorkerDescriptor.vue +++ b/src/pages/Worker/Card/WorkerDescriptor.vue @@ -151,7 +151,7 @@ const refetch = async () => await cardDescriptorRef.value.getData();
diff --git a/src/router/modules/wagon.js b/src/router/modules/wagon.js index d3d14a888..e25e585eb 100644 --- a/src/router/modules/wagon.js +++ b/src/router/modules/wagon.js @@ -11,7 +11,7 @@ export default { component: RouterView, redirect: { name: 'WagonMain' }, menus: { - main: ['WagonList', 'WagonTypeList', 'WagonCounter'], + main: ['WagonList', 'WagonTypeList', 'WagonCounter', 'WagonTray'], card: [], }, children: [ @@ -81,7 +81,7 @@ export default { title: 'typeCreate', icon: 'create', }, - component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'), + component: () => import('src/pages/Wagon/Type/WagonTypeList.vue'), }, { path: ':id/edit', @@ -90,7 +90,7 @@ export default { title: 'typeEdit', icon: 'edit', }, - component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'), + component: () => import('src/pages/Wagon/Type/WagonTypeEdit.vue'), }, ], }, diff --git a/test/cypress/integration/claim/claimDevelopment.spec.js b/test/cypress/integration/claim/claimDevelopment.spec.js index 903f58d4b..3b73a24d9 100755 --- a/test/cypress/integration/claim/claimDevelopment.spec.js +++ b/test/cypress/integration/claim/claimDevelopment.spec.js @@ -8,6 +8,8 @@ describe('ClaimDevelopment', () => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/claim/${claimId}/development`); + cy.intercept('GET', /\/api\/Workers\/search/).as('workers'); + cy.intercept('GET', /\/api\/Workers\/search/).as('workers'); cy.waitForElement('tbody'); }); @@ -32,10 +34,19 @@ describe('ClaimDevelopment', () => { }); it('should add and remove new line', () => { + cy.wait(['@workers', '@workers']); cy.addCard(); + cy.get(thirdRow).should('exist'); - const rowData = [false, 'Novato', 'Roces', 'Compradores', 'employeeNick', 'Tour']; + const rowData = [ + false, + 'Novato', + 'Roces', + 'Compradores', + 'administrativeNick', + 'Tour', + ]; cy.fillRow(thirdRow, rowData); cy.saveCard(); diff --git a/test/cypress/integration/ticket/ticketDescriptor.spec.js b/test/cypress/integration/ticket/ticketDescriptor.spec.js index 9bd7c6053..516b0f13d 100644 --- a/test/cypress/integration/ticket/ticketDescriptor.spec.js +++ b/test/cypress/integration/ticket/ticketDescriptor.spec.js @@ -1,19 +1,18 @@ /// describe('Ticket descriptor', () => { const toCloneOpt = '[role="menu"] .q-list > :nth-child(5)'; + const setWeightOpt = '[role="menu"] .q-list > :nth-child(6)'; const warehouseValue = ':nth-child(1) > :nth-child(6) > .value > span'; const summaryHeader = '.summaryHeader > div'; - + const weight = 25; + const weightValue = ':nth-child(10) > .value > span'; beforeEach(() => { - const ticketId = 1; - cy.login('developer'); - cy.visit(`/#/ticket/${ticketId}/summary`); - cy.waitForElement('.q-page', 7000); + cy.viewport(1920, 1080); }); it('should clone the ticket without warehouse', () => { - cy.openLeftMenu(); + cy.visit('/#/ticket/1/summary'); cy.openActionsDescriptor(); cy.get(toCloneOpt).click(); cy.clickConfirm(); @@ -25,4 +24,15 @@ describe('Ticket descriptor', () => { cy.wrap(owner.trim()).should('eq', 'Bruce Wayne (1101)'); }); }); + + it('should set the weight of the ticket', () => { + cy.visit('/#/ticket/10/summary'); + cy.openActionsDescriptor(); + cy.get(setWeightOpt).click(); + cy.intercept('POST', /\/api\/Tickets\/\d+\/setWeight/).as('weight'); + cy.get('.q-dialog input').type(weight); + cy.clickConfirm(); + cy.wait('@weight'); + cy.get(weightValue).contains(weight); + }); }); diff --git a/test/cypress/integration/wagonType/wagonTypeCreate.spec.js b/test/cypress/integration/wagonType/wagonTypeCreate.spec.js index 5e8b6b888..cd7ffa58f 100644 --- a/test/cypress/integration/wagonType/wagonTypeCreate.spec.js +++ b/test/cypress/integration/wagonType/wagonTypeCreate.spec.js @@ -6,50 +6,12 @@ describe('WagonTypeCreate', () => { cy.waitForElement('.q-page', 6000); }); - function chooseColor(color) { - cy.get('div.shelving-down').eq(1).click(); - cy.get('div.q-color-picker__cube').eq(color).click(); - cy.get('div.q-card__section').find('button').click(); - } - - function addTray(position) { - cy.get('div.action-button').last().find('button').click(); - cy.focused().type(position); - cy.focused().blur(); - } - - it('should create and delete a new wagon type', () => { + it('should create a new wagon type', () => { + cy.get('.q-page-sticky > div > .q-btn').click(); cy.get('input').first().type('Example for testing'); - cy.get('div.q-checkbox__bg').click(); - chooseColor(1); - - // Insert invalid position (not minimal height) - addTray(20); - cy.get('div[role="alert"]').should('exist'); - chooseColor(2); - addTray(150); - chooseColor(3); - addTray(100); - - // Insert invalid position (max height reached) - addTray(210); - cy.get('div[role="alert"]').should('exist'); - - // Save cy.get('button[type="submit"]').click(); - - // Check data has been saved successfully - cy.get(':nth-child(1) > :nth-child(1) > .justify-between > .flex > .title') - .contains('Example for testing') - .click(); - cy.get('input').first().should('have.value', 'Example for testing'); - cy.get('div.wagon-tray').should('have.length', 4); - cy.get('div.position').eq(0).find('input').should('have.value', '150'); - cy.get('div.position').eq(1).find('input').should('have.value', '100'); - cy.get('div.position').eq(2).find('input').should('have.value', '50'); - - // Delete wagon type created - cy.go('back'); + }); + it('delete a wagon type', () => { cy.get( ':nth-child(2) > :nth-child(1) > .card-list-body > .actions > .q-btn--standard' ).click(); diff --git a/test/cypress/integration/wagonType/wagonTypeEdit.spec.js b/test/cypress/integration/wagonType/wagonTypeEdit.spec.js new file mode 100644 index 000000000..6e5816e51 --- /dev/null +++ b/test/cypress/integration/wagonType/wagonTypeEdit.spec.js @@ -0,0 +1,27 @@ +describe('WagonTypeEdit', () => { + const trayColorRow = + '.q-select > .q-field__inner > .q-field__control > .q-field__control-container'; + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit('/#/wagon/type/2/edit'); + }); + + it('should edit the name and the divisible field of the wagon type', () => { + cy.get('.q-card'); + cy.get('input').first().type(' changed'); + cy.get('div.q-checkbox__bg').first().click(); + cy.get('.q-btn--standard').click(); + }); + + it('should create a tray', () => { + cy.get('.action-button > .q-btn > .q-btn__content > .q-icon').click(); + cy.get('input').last().type('150'); + cy.get(trayColorRow).type('{downArrow}{downArrow}{enter}'); + }); + + it('should delete a tray', () => { + cy.get('.action-button > .q-btn > .q-btn__content > .q-icon').first().click(); + cy.reload(); + }); +}); diff --git a/test/vitest/__tests__/pages/Wagons/WagonTypeCreate.spec.js b/test/vitest/__tests__/pages/Wagons/WagonTypeCreate.spec.js deleted file mode 100644 index 60c199b73..000000000 --- a/test/vitest/__tests__/pages/Wagons/WagonTypeCreate.spec.js +++ /dev/null @@ -1,271 +0,0 @@ -import { axios, createWrapper } from 'app/test/vitest/helper'; -import WagonTypeCreate from 'pages/Wagon/Type/WagonTypeCreate.vue'; -import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'; - -describe('WagonTypeCreate', () => { - let vmCreate, vmEdit; - const entityId = 1; - - beforeAll(() => { - vmEdit = createWrapper(WagonTypeCreate, {propsData: { - id: entityId, - }}).vm; - vmCreate = createWrapper(WagonTypeCreate).vm; - vmEdit.wagonConfig = vmCreate.wagonConfig = {maxTrays: 2 ,minHeightBetweenTrays: 50, maxWagonHeight: 200 }; - vmEdit.wagonTypeColors = vmCreate.wagonTypeColors = [{id: 1, color:'white', rgb:'#000000'}]; - }); - - afterEach(() => { - vi.clearAllMocks(); - }); - - describe('addTray()', () => { - it('should throw message if there are uncomplete trays', async () => { - vi.spyOn(vmEdit.quasar, 'notify'); - vmEdit.wagon = [{ - id: 1, - position: null, - color: vmEdit.wagonTypeColors[0] - }]; - - await vmEdit.addTray(); - - expect(vmEdit.quasar.notify).toHaveBeenCalledWith( - expect.objectContaining({ - type: 'warning', - }) - ); - }); - - it('should create a new tray if the limit has not been reached', async () => { - vmEdit.wagon = [{ - id: 1, - position: 0, - color: vmEdit.wagonTypeColors[0] - }]; - - await vmEdit.addTray(); - expect(vmEdit.wagon.length).toEqual(2); - }); - - it('should throw message if there are uncomplete trays', async () => { - vi.spyOn(vmEdit.quasar, 'notify'); - vmEdit.wagon = [{ - id: 1, - position: 0, - color: vmEdit.wagonTypeColors[0] - },{ - id: 2, - position: 50, - color: vmEdit.wagonTypeColors[0] - }]; - - await vmEdit.addTray(); - - expect(vmEdit.quasar.notify).toHaveBeenCalledWith( - expect.objectContaining({ - type: 'warning', - }) - ); - }); - }); - - describe('deleteTray() reorderIds()', () => { - it('should delete a tray and reorder the ids', async () => { - const trayToDelete = { - id: 1, - position: 0, - color: vmEdit.wagonTypeColors[0] - }; - const trayMaintained = { - id: 2, - position: 50, - color: vmEdit.wagonTypeColors[0] - }; - vmEdit.wagon = [trayToDelete,trayMaintained]; - - await vmEdit.deleteTray(trayToDelete); - - expect(vmEdit.wagon.length).toEqual(1); - expect(vmEdit.wagon[0].id).toEqual(0); - expect(vmEdit.wagon[0].position).toEqual(50); - - }); - }); - - describe('onSubmit()', () => { - it('should make a patch to editWagonType if have id', async () => { - vi.spyOn(axios, 'patch').mockResolvedValue({ data: true }); - const wagon = { - id: entityId, - name: "Mock name", - divisible: true, - trays: [{ - id: 1, - position: 0, - color: vmEdit.wagonTypeColors[0] - }] - } - vmEdit.name = wagon.name; - vmEdit.divisible = wagon.divisible; - vmEdit.wagon = wagon.trays; - - await vmEdit.onSubmit(); - - expect(axios.patch).toHaveBeenCalledWith( - `WagonTypes/editWagonType`, wagon - ); - }); - - it('should make a patch to createtWagonType if not have id', async () => { - vi.spyOn(axios, 'patch').mockResolvedValue({ data: true }); - const wagon = { - name: "Mock name", - divisible: true, - trays: [{ - id: 1, - position: 0, - color: vmCreate.wagonTypeColors[0] - }] - } - vmCreate.name = wagon.name; - vmCreate.divisible = wagon.divisible; - vmCreate.wagon = wagon.trays; - - await vmCreate.onSubmit(); - - expect(axios.patch).toHaveBeenCalledWith( - `WagonTypes/createWagonType`, wagon - ); - }); - }); - - describe('onReset()', () => { - it('should reset if have id', async () => { - vmEdit.name = 'Changed name'; - vmEdit.divisible = false; - vmEdit.wagon = []; - vmEdit.originalData = { - name: 'Original name', - divisible: true, - trays: [{ - id: 1, - position: 0, - color: vmEdit.wagonTypeColors[0] - },{ - id: 2, - position: 50, - color: vmEdit.wagonTypeColors[0] - }] - }; - - vmEdit.onReset(); - - expect(vmEdit.name).toEqual(vmEdit.originalData.name); - expect(vmEdit.divisible).toEqual(vmEdit.originalData.divisible); - expect(vmEdit.wagon).toEqual(vmEdit.originalData.trays); - }); - - it('should reset if not have id', async () => { - vmCreate.name = 'Changed name'; - vmCreate.divisible = false; - vmCreate.wagon = []; - - vmCreate.onReset(); - - expect(vmCreate.name).toEqual(null); - expect(vmCreate.divisible).toEqual(false); - expect(vmCreate.wagon.length).toEqual(1); - }); - }); - - describe('onPositionBlur()', () => { - it('should set position null if position is negative', async () => { - const negativeTray = { - id: 1, - position: -1, - color: vmCreate.wagonTypeColors[0] - }; - - vmCreate.onPositionBlur(negativeTray); - - expect(negativeTray.position).toEqual(null); - }); - - it('should set position and reorder array', async () => { - const trays = [{ - id: 0, - position: 100, - color: vmCreate.wagonTypeColors[0] - },{ - id: 1, - position: 0, - color: vmCreate.wagonTypeColors[0] - }]; - const newTray = { - id: 2, - position: 50, - color: vmCreate.wagonTypeColors[0] - }; - trays.push(newTray); - vmCreate.wagon = trays; - - vmCreate.onPositionBlur(newTray); - - expect(vmCreate.wagon[0].position).toEqual(100); - expect(vmCreate.wagon[1].position).toEqual(50); - expect(vmCreate.wagon[2].position).toEqual(0); - }); - - it('should throw message if not have min height between trays and should set new adequate positions', async () => { - vi.spyOn(vmCreate.quasar, 'notify'); - const trays = [{ - id: 0, - position: 0, - color: vmCreate.wagonTypeColors[0] - }]; - const newTray = { - id: 1, - position: 20, - color: vmCreate.wagonTypeColors[0] - }; - trays.push(newTray); - vmCreate.wagon = trays; - - vmCreate.onPositionBlur(newTray); - - expect(vmCreate.wagon[0].position).toEqual(50); - expect(vmCreate.wagon[1].position).toEqual(0); - expect(vmCreate.quasar.notify).toHaveBeenCalledWith( - expect.objectContaining({ - type: 'warning', - }) - ); - }); - - it('should throw message if max height has been exceed', async () => { - vi.spyOn(vmCreate.quasar, 'notify'); - const trays = [{ - id: 0, - position: 0, - color: vmCreate.wagonTypeColors[0] - }]; - const newTray = { - id: 1, - position: 210, - color: vmCreate.wagonTypeColors[0] - }; - trays.push(newTray); - vmCreate.wagon = trays; - - vmCreate.onPositionBlur(newTray); - - expect(vmCreate.wagon.length).toEqual(1); - expect(vmCreate.quasar.notify).toHaveBeenCalledWith( - expect.objectContaining({ - type: 'warning', - }) - ); - }); - }); -});