diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 5681ce11c..04ef13d45 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -247,6 +247,7 @@ async function saveAndGo() { } function reset() { + formData.value = JSON.parse(JSON.stringify(originalData.value)); updateAndEmit('onFetch', { val: originalData.value }); if ($props.observeFormChanges) { hasChanges.value = false; diff --git a/src/components/VnTable/VnColumn.vue b/src/components/VnTable/VnColumn.vue index 44364cca1..d0e245388 100644 --- a/src/components/VnTable/VnColumn.vue +++ b/src/components/VnTable/VnColumn.vue @@ -1,6 +1,6 @@ + diff --git a/src/pages/Travel/Card/TravelThermographsForm.vue b/src/pages/Travel/Card/TravelThermographsForm.vue index 7aec32972..446e5d506 100644 --- a/src/pages/Travel/Card/TravelThermographsForm.vue +++ b/src/pages/Travel/Card/TravelThermographsForm.vue @@ -209,7 +209,7 @@ const onThermographCreated = async (data) => { }" sort-by="thermographFk ASC" option-label="thermographFk" - option-filter-value="id" + option-filter-value="thermographFk" :disable="viewAction === 'edit'" :tooltip="t('New thermograph')" :roles-allowed-to-create="['logistic']" diff --git a/src/pages/Worker/Card/WorkerFormation.vue b/src/pages/Worker/Card/WorkerFormation.vue index e05eca7f8..e8680f7dd 100644 --- a/src/pages/Worker/Card/WorkerFormation.vue +++ b/src/pages/Worker/Card/WorkerFormation.vue @@ -119,7 +119,7 @@ const columns = computed(() => [ :url="`Workers/${entityId}/trainingCourse`" :url-create="`Workers/${entityId}/trainingCourse`" save-url="TrainingCourses/crud" - :filter="courseFilter" + :user-filter="courseFilter" :create="{ urlCreate: 'trainingCourses', title: t('Create training course'), diff --git a/src/pages/Worker/Card/WorkerMedical.vue b/src/pages/Worker/Card/WorkerMedical.vue index c220df76a..b3a599af7 100644 --- a/src/pages/Worker/Card/WorkerMedical.vue +++ b/src/pages/Worker/Card/WorkerMedical.vue @@ -8,6 +8,17 @@ const { t } = useI18n(); const route = useRoute(); const entityId = computed(() => route.params.id); +const centerFilter = { + include: [ + { + relation: 'center', + scope: { + fields: ['id', 'name'], + }, + }, + ], +}; + const columns = [ { align: 'left', @@ -33,7 +44,7 @@ const columns = [ create: true, component: 'select', attrs: { - url: 'medicalCenters', + url: 'centers', fields: ['id', 'name'], }, }, @@ -84,6 +95,7 @@ const columns = [ ref="tableRef" data-key="WorkerMedical" :url="`Workers/${entityId}/medicalReview`" + :user-filter="centerFilter" save-url="MedicalReviews/crud" :create="{ urlCreate: 'medicalReviews', diff --git a/src/pages/Worker/Card/WorkerPit.vue b/src/pages/Worker/Card/WorkerPit.vue index 40e814452..3de60d6a0 100644 --- a/src/pages/Worker/Card/WorkerPit.vue +++ b/src/pages/Worker/Card/WorkerPit.vue @@ -176,6 +176,7 @@ const deleteRelative = async (id) => { :label="t('isDescendant')" v-model="row.isDescendant" class="q-gutter-xs q-mb-xs" + data-cy="Descendant/Ascendant" /> describe('TicketSale', () => { - beforeEach(() => { - cy.login('developer'); - cy.viewport(1920, 1080); - cy.visit('/#/ticket/31/sale'); - }); - - const firstRow = 'tbody > :nth-child(1)'; - - const selectFirstRow = () => { - cy.waitForElement(firstRow); - cy.get(firstRow).find('.q-checkbox__inner').click(); - }; - - it('it should add item to basket', () => { - cy.window().then((win) => { - cy.stub(win, 'open').as('windowOpen'); + describe('Free ticket #31', () => { + beforeEach(() => { + cy.login('developer'); + cy.viewport(1920, 1080); + cy.visit('/#/ticket/31/sale'); }); - cy.dataCy('ticketSaleAddToBasketBtn').should('exist'); - cy.dataCy('ticketSaleAddToBasketBtn').click(); - cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/); - }); - it('should send SMS', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.waitForElement('[data-cy="sendShortageSMSItem"]'); - cy.dataCy('sendShortageSMSItem').should('exist'); - cy.dataCy('sendShortageSMSItem').click(); - cy.dataCy('vnSmsDialog').should('exist'); - cy.dataCy('sendSmsBtn').click(); - cy.checkNotification('SMS sent'); - }); + const firstRow = 'tbody > :nth-child(1)'; - it('should recalculate price when "Recalculate price" is clicked', () => { - cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice'); - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.waitForElement('[data-cy="recalculatePriceItem"]'); - cy.dataCy('recalculatePriceItem').should('exist'); - cy.dataCy('recalculatePriceItem').click(); - cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200); - cy.checkNotification('Data saved'); - }); + const selectFirstRow = () => { + cy.waitForElement(firstRow); + cy.get(firstRow).find('.q-checkbox__inner').click(); + }; - it('should update discount when "Update discount" is clicked', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.waitForElement('[data-cy="updateDiscountItem"]'); - cy.dataCy('updateDiscountItem').should('exist'); - cy.dataCy('updateDiscountItem').click(); - cy.waitForElement('[data-cy="ticketSaleDiscountInput"]'); - cy.dataCy('ticketSaleDiscountInput').find('input').focus(); - cy.dataCy('ticketSaleDiscountInput').find('input').type('10'); - cy.dataCy('saveManaBtn').click(); - cy.waitForElement('.q-notification__message'); - cy.checkNotification('Data saved'); - }); + it('it should add item to basket', () => { + cy.window().then((win) => { + cy.stub(win, 'open').as('windowOpen'); + }); + cy.dataCy('ticketSaleAddToBasketBtn').should('exist'); + cy.dataCy('ticketSaleAddToBasketBtn').click(); + cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/); + }); - it('adds claim', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.dataCy('createClaimItem').click(); - cy.dataCy('VnConfirm_confirm').click(); - cy.url().should('contain', 'claim/'); - // Delete created claim to avoid cluttering the database - cy.dataCy('descriptor-more-opts').click(); - cy.dataCy('deleteClaim').click(); - cy.dataCy('VnConfirm_confirm').click(); - cy.checkNotification('Data deleted'); - }); + it('should send SMS', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.waitForElement('[data-cy="sendShortageSMSItem"]'); + cy.dataCy('sendShortageSMSItem').should('exist'); + cy.dataCy('sendShortageSMSItem').click(); + cy.dataCy('vnSmsDialog').should('exist'); + cy.dataCy('sendSmsBtn').click(); + cy.checkNotification('SMS sent'); + }); - it('marks row as reserved', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.waitForElement('[data-cy="markAsReservedItem"]'); - cy.dataCy('markAsReservedItem').click(); - cy.dataCy('ticketSaleReservedIcon').should('exist'); - }); + it('should recalculate price when "Recalculate price" is clicked', () => { + cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice'); + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.waitForElement('[data-cy="recalculatePriceItem"]'); + cy.dataCy('recalculatePriceItem').should('exist'); + cy.dataCy('recalculatePriceItem').click(); + cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200); + cy.checkNotification('Data saved'); + }); - it('unmarks row as reserved', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.waitForElement('[data-cy="unmarkAsReservedItem"]'); - cy.dataCy('unmarkAsReservedItem').click(); - cy.dataCy('ticketSaleReservedIcon').should('not.exist'); - }); + it('should update discount when "Update discount" is clicked', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.waitForElement('[data-cy="updateDiscountItem"]'); + cy.dataCy('updateDiscountItem').should('exist'); + cy.dataCy('updateDiscountItem').click(); + cy.waitForElement('[data-cy="ticketSaleDiscountInput"]'); + cy.dataCy('ticketSaleDiscountInput').find('input').focus(); + cy.dataCy('ticketSaleDiscountInput').find('input').type('10'); + cy.dataCy('saveManaBtn').click(); + cy.waitForElement('.q-notification__message'); + cy.checkNotification('Data saved'); + }); - it('refunds row with warehouse', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.dataCy('ticketSaleRefundItem').click(); - cy.dataCy('ticketSaleRefundWithWarehouse').click(); - cy.checkNotification('The following refund ticket have been created'); - }); + it('adds claim', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.dataCy('createClaimItem').click(); + cy.dataCy('VnConfirm_confirm').click(); + cy.url().should('contain', 'claim/'); + // Delete created claim to avoid cluttering the database + cy.dataCy('descriptor-more-opts').click(); + cy.dataCy('deleteClaim').click(); + cy.dataCy('VnConfirm_confirm').click(); + cy.checkNotification('Data deleted'); + }); - it('refunds row without warehouse', () => { - selectFirstRow(); - cy.dataCy('ticketSaleMoreActionsDropdown').click(); - cy.dataCy('ticketSaleRefundItem').click(); - cy.dataCy('ticketSaleRefundWithoutWarehouse').click(); - cy.checkNotification('The following refund ticket have been created'); - }); + it('marks row as reserved', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.waitForElement('[data-cy="markAsReservedItem"]'); + cy.dataCy('markAsReservedItem').click(); + cy.dataCy('ticketSaleReservedIcon').should('exist'); + }); - it('transfer sale to a new ticket', () => { - cy.visit('/#/ticket/32/sale'); - cy.get('.q-item > .q-item__label').should('have.text', ' #32'); - selectFirstRow(); - cy.dataCy('ticketSaleTransferBtn').click(); - cy.dataCy('ticketTransferPopup').should('exist'); - cy.dataCy('ticketTransferNewTicketBtn').click(); - //check the new ticket has been created succesfully - cy.get('.q-item > .q-item__label').should('not.have.text', ' #32'); - }); + it('unmarks row as reserved', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.waitForElement('[data-cy="unmarkAsReservedItem"]'); + cy.dataCy('unmarkAsReservedItem').click(); + cy.dataCy('ticketSaleReservedIcon').should('not.exist'); + }); - it('should redirect to ticket logs', () => { - cy.get(firstRow).find('.q-btn:last').click(); - cy.url().should('match', /\/ticket\/31\/log/); + it('refunds row with warehouse', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.dataCy('ticketSaleRefundItem').click(); + cy.dataCy('ticketSaleRefundWithWarehouse').click(); + cy.checkNotification('The following refund ticket have been created'); + }); + + it('refunds row without warehouse', () => { + selectFirstRow(); + cy.dataCy('ticketSaleMoreActionsDropdown').click(); + cy.dataCy('ticketSaleRefundItem').click(); + cy.dataCy('ticketSaleRefundWithoutWarehouse').click(); + cy.checkNotification('The following refund ticket have been created'); + }); + + it('transfer sale to a new ticket', () => { + cy.visit('/#/ticket/32/sale'); + cy.get('.q-item > .q-item__label').should('have.text', ' #32'); + selectFirstRow(); + cy.dataCy('ticketSaleTransferBtn').click(); + cy.dataCy('ticketTransferPopup').should('exist'); + cy.dataCy('ticketTransferNewTicketBtn').click(); + //check the new ticket has been created succesfully + cy.get('.q-item > .q-item__label').should('not.have.text', ' #32'); + }); + + it('should redirect to ticket logs', () => { + cy.get(firstRow).find('.q-btn:last').click(); + cy.url().should('match', /\/ticket\/31\/log/); + }); + }); + describe('Ticket prepared #23', () => { + beforeEach(() => { + cy.login('developer'); + cy.viewport(1920, 1080); + cy.visit('/#/ticket/23/sale'); + }); + + const firstRow = 'tbody > :nth-child(1)'; + + const selectFirstRow = () => { + cy.waitForElement(firstRow); + cy.get(firstRow).find('.q-checkbox__inner').click(); + }; + + it('update price', () => { + const price = Number((Math.random() * 99 + 1).toFixed(2)); + cy.waitForElement(firstRow); + cy.get(':nth-child(10) > .q-btn').click(); + cy.waitForElement('[data-cy="ticketEditManaProxy"]'); + cy.dataCy('ticketEditManaProxy').should('exist'); + cy.waitForElement('[data-cy="Price_input"]'); + cy.dataCy('Price_input').clear(); + cy.dataCy('Price_input').type(price); + cy.dataCy('saveManaBtn').click(); + handleVnConfirm(); + + cy.get(':nth-child(10) > .q-btn > .q-btn__content').should( + 'have.text', + `€${price}`, + ); + }); + it('update dicount', () => { + const discount = Math.floor(Math.random() * 100) + 1; + selectFirstRow(); + cy.get(':nth-child(11) > .q-btn').click(); + cy.waitForElement('[data-cy="ticketEditManaProxy"]'); + cy.dataCy('ticketEditManaProxy').should('exist'); + cy.waitForElement('[data-cy="Disc_input"]'); + cy.dataCy('Disc_input').clear(); + cy.dataCy('Disc_input').type(discount); + cy.dataCy('saveManaBtn').click(); + handleVnConfirm(); + + cy.get(':nth-child(11) > .q-btn > .q-btn__content').should( + 'have.text', + `${discount}.00%`, + ); + }); + + it('change concept', () => { + const quantity = Math.floor(Math.random() * 100) + 1; + cy.waitForElement(firstRow); + cy.get(':nth-child(8) > .row').click(); + cy.get( + '.q-menu > [data-v-ca3f07a4=""] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="undefined_input"]', + ) + .type(quantity) + .type('{enter}'); + handleVnConfirm(); + + cy.get(':nth-child(8) >.row').should('contain.text', `${quantity}`); + }); + it('changequantity ', () => { + const quantity = Math.floor(Math.random() * 100) + 1; + cy.waitForElement(firstRow); + cy.dataCy('ticketSaleQuantityInput').clear(); + cy.dataCy('ticketSaleQuantityInput').type(quantity).trigger('tab'); + cy.get('.q-page > :nth-child(6)').click(); + + handleVnConfirm(); + + cy.get('[data-cy="ticketSaleQuantityInput"]') + .find('[data-cy="undefined_input"]') + .should('have.value', `${quantity}`); + }); }); }); + +function handleVnConfirm() { + cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click(); + cy.waitForElement('.q-notification__message'); + + cy.get('.q-notification__message').should('be.visible'); + cy.checkNotification('Data saved'); +} diff --git a/test/cypress/integration/wagon/wagonType/wagonTypeCreate.spec.js b/test/cypress/integration/wagon/wagonType/wagonTypeCreate.spec.js index 2cd43984a..49d7d9f01 100644 --- a/test/cypress/integration/wagon/wagonType/wagonTypeCreate.spec.js +++ b/test/cypress/integration/wagon/wagonType/wagonTypeCreate.spec.js @@ -8,7 +8,7 @@ describe('WagonTypeCreate', () => { it('should create a new wagon type and then delete it', () => { cy.get('.q-page-sticky > div > .q-btn').click(); - cy.get('input').first().type('Example for testing'); + cy.dataCy('Name_input').type('Example for testing'); cy.get('[data-cy="FormModelPopup_save"]').click(); cy.get('[title="Remove"] > .q-btn__content > .q-icon').first().click(); }); diff --git a/test/cypress/integration/worker/workerCreate.spec.js b/test/cypress/integration/worker/workerCreate.spec.js index 7f2810395..71fd6b347 100644 --- a/test/cypress/integration/worker/workerCreate.spec.js +++ b/test/cypress/integration/worker/workerCreate.spec.js @@ -2,9 +2,24 @@ describe('WorkerCreate', () => { const externalRadio = '.q-radio:nth-child(2)'; const developerBossId = 120; const payMethodCross = - '.grid-create .full-width > :nth-child(9) .q-select .q-field__append:not(.q-anchor--skip)'; + ':nth-child(9) > .q-select > .q-field__inner > .q-field__control > :nth-child(2)'; const saveBtn = '.q-mt-lg > .q-btn--standard'; + const internalWithOutPay = { + Fi: { val: '78457139E' }, + 'Web user': { val: 'manolo' }, + Name: { val: 'Manolo' }, + 'Last name': { val: 'Hurtado' }, + 'Personal email': { val: 'manolo@mydomain.com' }, + Company: { val: 'VNL', type: 'select' }, + Street: { val: 'S/ DEFAULTWORKERSTREET' }, + Location: { val: 1, type: 'select' }, + Phone: { val: '123456789' }, + 'Worker code': { val: 'DWW' }, + Boss: { val: developerBossId, type: 'select' }, + Birth: { val: '11-12-2022', type: 'date' }, + }; + const internal = { Fi: { val: '78457139E' }, 'Web user': { val: 'manolo' }, @@ -14,6 +29,7 @@ describe('WorkerCreate', () => { Company: { val: 'VNL', type: 'select' }, Street: { val: 'S/ DEFAULTWORKERSTREET' }, Location: { val: 1, type: 'select' }, + 'Pay method': { val: 1, type: 'select' }, Phone: { val: '123456789' }, 'Worker code': { val: 'DWW' }, Boss: { val: developerBossId, type: 'select' }, @@ -37,17 +53,14 @@ describe('WorkerCreate', () => { }); it('should throw an error if a pay method has not been selected', () => { - cy.fillInForm(internal); + cy.fillInForm(internalWithOutPay); cy.get(payMethodCross).click(); cy.get(saveBtn).click(); cy.checkNotification('Payment method is required'); }); it('should create an internal', () => { - cy.fillInForm({ - ...internal, - 'Pay method': { val: 'PayMethod one', type: 'select' }, - }); + cy.fillInForm(internal); cy.get(saveBtn).click(); cy.checkNotification('Data created'); }); diff --git a/test/cypress/integration/worker/workerNotificationsManager.spec.js b/test/cypress/integration/worker/workerNotificationsManager.spec.js index f121b3894..ad48d8a6c 100644 --- a/test/cypress/integration/worker/workerNotificationsManager.spec.js +++ b/test/cypress/integration/worker/workerNotificationsManager.spec.js @@ -18,7 +18,7 @@ describe('WorkerNotificationsManager', () => { cy.visit(`/#/worker/${salesPersonId}/notifications`); cy.get(firstAvailableNotification).click(); cy.checkNotification( - 'The notification subscription of this worker cant be modified' + 'The notification subscription of this worker cant be modified', ); }); diff --git a/test/cypress/integration/worker/workerPit.spec.js b/test/cypress/integration/worker/workerPit.spec.js index cc3a87637..19cbebc20 100644 --- a/test/cypress/integration/worker/workerPit.spec.js +++ b/test/cypress/integration/worker/workerPit.spec.js @@ -8,7 +8,8 @@ describe('WorkerPit', () => { const spousePensionInput = '[data-cy="Spouse Pension_input"]'; const spousePension = '120'; const addRelative = '[data-cy="addRelative"]'; - const isDescendantSelect = '[data-cy="Descendant/Ascendant_select"]'; + const isDescendantSelect = '[data-cy="Descendant/Ascendant"]'; + const Descendant = 'Descendiente'; const birthedInput = '[data-cy="Birth Year_input"]'; const birthed = '2002'; const adoptionYearInput = '[data-cy="Adoption Year_input"]'; @@ -28,11 +29,8 @@ describe('WorkerPit', () => { cy.get(spouseNifInput).type(spouseNif); cy.get(spousePensionInput).type(spousePension); cy.get(savePIT).click(); - }); - - it('complete relative', () => { cy.get(addRelative).click(); - cy.get(isDescendantSelect).type('{downArrow}{downArrow}{enter}'); + cy.get(isDescendantSelect).type(Descendant); cy.get(birthedInput).type(birthed); cy.get(adoptionYearInput).type(adoptionYear); cy.get(saveRelative).click();