Merge pull request '#8219 Added InvoiceOut e2e tests' (!1001) from 8219-InvoiceOutE2E into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1001
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jon Elias 2025-01-08 06:41:32 +00:00
commit 1e8e2aff72
19 changed files with 200 additions and 16 deletions

View File

@ -11,6 +11,7 @@ module.exports = defineConfig({
screenshotsFolder: 'test/cypress/screenshots',
supportFile: 'test/cypress/support/index.js',
videosFolder: 'test/cypress/videos',
downloadsFolder: 'test/cypress/downloads',
video: false,
specPattern: 'test/cypress/integration/**/*.spec.js',
experimentalRunAllSpecs: true,

View File

@ -511,6 +511,7 @@ invoiceOut:
card:
issued: Issued
customerCard: Customer card
ticketList: Ticket List
summary:
issued: Issued
dued: Due

View File

@ -83,7 +83,11 @@ const { openConfirmationModal } = useVnConfirm();
</template>
<template #body="{ entity }">
<VnLv :label="t('department.chat')" :value="entity.chatName" />
<VnLv :label="t('globals.email')" :value="entity.notificationEmail" copy />
<VnLv
:label="t('globals.params.email')"
:value="entity.notificationEmail"
copy
/>
<VnLv
:label="t('department.selfConsumptionCustomer')"
:value="entity.client?.name"

View File

@ -58,7 +58,7 @@ onMounted(async () => {
dash
/>
<VnLv
:label="t('globals.email')"
:label="t('globals.params.email')"
:value="department.notificationEmail"
dash
/>

View File

@ -47,6 +47,7 @@ const states = ref();
:label="t('Amount')"
v-model="params.amount"
is-outlined
data-cy="InvoiceOutFilterAmountBtn"
/>
</QItemSection>
</QItem>

View File

@ -101,7 +101,18 @@ onMounted(async () => {
dense
outlined
rounded
/>
data-cy="InvoiceOutGlobalClientSelect"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
#{{ scope.opt?.id }} {{ scope.opt?.name }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
:label="t('invoiceOutSerialType')"
v-model="formData.serialType"
@ -115,6 +126,7 @@ onMounted(async () => {
dense
outlined
rounded
data-cy="InvoiceOutGlobalSerialSelect"
/>
<VnInputDate
v-model="formData.invoiceDate"
@ -125,6 +137,7 @@ onMounted(async () => {
v-model="formData.maxShipped"
:label="t('maxShipped')"
is-outlined
data-cy="InvoiceOutGlobalMaxShippedDate"
/>
<VnSelect
:label="t('company')"
@ -134,6 +147,7 @@ onMounted(async () => {
dense
outlined
rounded
data-cy="InvoiceOutGlobalCompanySelect"
/>
<VnSelect
:label="t('printer')"
@ -142,6 +156,7 @@ onMounted(async () => {
dense
outlined
rounded
data-cy="InvoiceOutGlobalPrinterSelect"
/>
</div>
<QBtn

View File

@ -197,6 +197,7 @@ watchEffect(selectedRows);
icon-right="cloud_download"
@click="downloadPdf()"
:disable="!hasSelectedCards"
data-cy="InvoiceOutDownloadPdfBtn"
>
<QTooltip>{{ t('downloadPdf') }}</QTooltip>
</QBtn>
@ -245,6 +246,7 @@ watchEffect(selectedRows);
v-model="data.ticketFk"
:label="t('globals.ticket')"
style="flex: 1"
data-cy="InvoiceOutCreateTicketinput"
/>
<div
@ -359,6 +361,7 @@ watchEffect(selectedRows);
option-value="code"
option-filter
:expr-builder="exprBuilder"
data-cy="InvoiceOutCreateSerialSelect"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">

View File

@ -684,6 +684,7 @@ function setReference(data) {
color="primary"
fab
icon="vn:invoice-in"
data-cy="ticketListMakeInvoiceBtn"
/>
<QTooltip>
{{ t('ticketList.createInvoice') }}

View File

@ -1,2 +1,3 @@
reports/*
screenshots/*
downloads/*

View File

@ -0,0 +1,46 @@
/// <reference types="cypress" />
describe('InvoiceOut list', () => {
const invoice = {
Ticket: { val: '8' },
Serial: { val: 'Española rapida', type: 'select' },
};
const invoiceError = {
Ticket: { val: '1' },
Serial: { val: 'Española rapida', type: 'select' },
};
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/invoice-out/list`);
cy.typeSearchbar('{enter}');
});
it('should search and filter an invoice and enter to the summary', () => {
cy.typeSearchbar('1{enter}');
cy.get('.q-virtual-scroll__content > :nth-child(2) > :nth-child(7)').click();
cy.get('.header > a.q-btn > .q-btn__content').click();
cy.typeSearchbar('{enter}');
cy.dataCy('InvoiceOutFilterAmountBtn').find('input').type('8.88{enter}');
});
it('should download all pdfs', () => {
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
cy.dataCy('InvoiceOutDownloadPdfBtn').click();
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
});
it('should give an error when manual invoicing a ticket that is already invoiced', () => {
cy.dataCy('vnTableCreateBtn').click();
cy.fillInForm(invoiceError);
cy.dataCy('FormModelPopup_save').click();
cy.checkNotification('This ticket is already invoiced');
});
it('should create a manual invoice and enter to its summary', () => {
cy.dataCy('vnTableCreateBtn').click();
cy.fillInForm(invoice);
cy.dataCy('FormModelPopup_save').click();
cy.checkNotification('Data created');
});
});

View File

@ -0,0 +1,21 @@
/// <reference types="cypress" />
describe('InvoiceOut manual invoice', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/ticket/list`);
cy.get('#searchbar input').type('{enter}');
});
it('should create an invoice from a ticket and go to that invoice', () => {
cy.searchByLabel('Customer ID', '1101');
cy.get(
'[data-q-vs-anchor=""] > :nth-child(1) > .q-checkbox > .q-checkbox__inner'
).click();
cy.dataCy('ticketListMakeInvoiceBtn').click();
cy.checkNotification('Data saved');
cy.get('.q-virtual-scroll__content > :nth-child(1) > :nth-child(3)').click();
cy.get(':nth-child(8) > .value > .link').click();
cy.get('.header > :nth-child(3) > .q-btn__content').click();
});
});

View File

@ -0,0 +1,16 @@
/// <reference types="cypress" />
describe('InvoiceOut negative bases', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/invoice-out/negative-bases`);
});
it('should filter and download as CSV', () => {
cy.get(
':nth-child(7) > .full-width > :nth-child(1) > .column > div.q-px-xs > .q-field > .q-field__inner > .q-field__control'
).type('23{enter}');
cy.get('#subToolbar > .q-btn').click();
cy.checkNotification('CSV downloaded successfully');
});
});

View File

@ -0,0 +1,47 @@
/// <reference types="cypress" />
describe('InvoiceOut summary', () => {
const transferInvoice = {
Client: { val: 'employee', type: 'select' },
Type: { val: 'Error in customer data', type: 'select' },
};
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/invoice-out/list`);
cy.typeSearchbar('{enter}');
});
it('should generate the invoice PDF', () => {
cy.typeSearchbar('T1111111{enter}');
cy.dataCy('descriptor-more-opts').click();
cy.get('.q-menu > .q-list > :nth-child(6)').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('The invoice PDF document has been regenerated');
});
it('should refund the invoice ', () => {
cy.typeSearchbar('T1111111{enter}');
cy.dataCy('descriptor-more-opts').click();
cy.get('.q-menu > .q-list > :nth-child(7)').click();
cy.get('#q-portal--menu--3 > .q-menu > .q-list > :nth-child(2)').click();
cy.checkNotification('The following refund ticket have been created 1000000');
});
it('should delete an invoice ', () => {
cy.typeSearchbar('T2222222{enter}');
cy.dataCy('descriptor-more-opts').click();
cy.get('.q-menu > .q-list > :nth-child(4)').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('InvoiceOut deleted');
});
it('should transfer the invoice ', () => {
cy.typeSearchbar('T1111111{enter}');
cy.dataCy('descriptor-more-opts').click();
cy.get('.q-menu > .q-list > :nth-child(1)').click();
cy.fillInForm(transferInvoice);
cy.get('.q-mt-lg > .q-btn').click();
cy.checkNotification('Transferred invoice');
});
});

View File

@ -0,0 +1,28 @@
/// <reference types="cypress" />
describe('InvoiceOut global invoicing', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('administrative');
cy.visit(`/#/invoice-out/global-invoicing`);
});
it('should invoice the client tickets', () => {
cy.get('.q-mb-sm > .q-radio__inner').click();
cy.dataCy('InvoiceOutGlobalClientSelect').type('1102');
cy.get('.q-menu .q-item').contains('1102').click();
cy.dataCy('InvoiceOutGlobalSerialSelect').click();
cy.get('.q-menu .q-item').contains('global').click();
cy.dataCy('InvoiceOutGlobalCompanySelect').type('VNL');
cy.get('.q-menu .q-item').contains('VNL').click();
cy.dataCy('InvoiceOutGlobalPrinterSelect').type('printer1');
cy.get('.q-menu .q-item').contains('printer1').click();
cy.get(
'[label="Invoice date"] > .q-field > .q-field__inner > .q-field__control'
).click();
cy.get(':nth-child(5) > div > .q-btn > .q-btn__content > .block').click();
cy.get('.q-date__years-content > :nth-child(2) > .q-btn').click();
cy.get('.q-date__calendar-days > :nth-child(6) > .q-btn').click();
cy.get('[label="Max date ticket"]').type('01-01-2001{enter}');
cy.get('.q-card').should('be.visible');
});
});

View File

@ -16,10 +16,12 @@ describe('VnSearchBar', () => {
});
it('should stay on the list page if there are several results or none', () => {
cy.typeSearchbar('salesA{enter}');
cy.typeSearchbar('salesA{enter}');
checkTableLength(2);
cy.clearSearchbar();
cy.typeSearchbar('0{enter}');
checkTableLength(0);
});
@ -27,6 +29,7 @@ describe('VnSearchBar', () => {
const searchAndCheck = (searchTerm, expectedText) => {
cy.clearSearchbar();
cy.typeSearchbar(`${searchTerm}{enter}`);
cy.typeSearchbar(`${searchTerm}{enter}`);
cy.get(idGap).should('have.text', expectedText);
};

View File

@ -1,6 +1,5 @@
describe('WorkerCreate', () => {
const externalRadio = '.q-radio:nth-child(2)';
const notification = '.q-notification__message';
const developerBossId = 120;
const payMethodCross =
'.grid-create .full-width > :nth-child(9) .q-select .q-field__append:not(.q-anchor--skip)';
@ -41,7 +40,7 @@ describe('WorkerCreate', () => {
cy.fillInForm(internal);
cy.get(payMethodCross).click();
cy.get(saveBtn).click();
cy.get(notification).should('contains.text', 'Payment method is required');
cy.checkNotification('Payment method is required');
});
it('should create an internal', () => {
@ -50,13 +49,13 @@ describe('WorkerCreate', () => {
'Pay method': { val: 'PayMethod one', type: 'select' },
});
cy.get(saveBtn).click();
cy.get(notification).should('contains.text', 'Data created');
cy.checkNotification('Data created');
});
it('should create an external', () => {
cy.get(externalRadio).click();
cy.fillInForm(external);
cy.get(saveBtn).click();
cy.get(notification).should('contains.text', 'Data created');
cy.checkNotification('Data created');
});
});

View File

@ -1,5 +1,4 @@
describe('ZoneBasicData', () => {
const notification = '.q-notification__message';
const priceBasicData = '[data-cy="Price_input"]';
beforeEach(() => {
@ -11,13 +10,13 @@ describe('ZoneBasicData', () => {
it('should throw an error if the name is empty', () => {
cy.get('[data-cy="zone-basic-data-name"] input').type('{selectall}{backspace}');
cy.get('.q-btn-group > .q-btn--standard').click();
cy.get(notification).should('contains.text', "can't be blank");
cy.checkNotification("can't be blank");
});
it('should throw an error if the price is empty', () => {
cy.get(priceBasicData).clear();
cy.get('.q-btn-group > .q-btn--standard').click();
cy.get(notification).should('contains.text', 'cannot be blank');
cy.checkNotification('cannot be blank');
});
it("should edit the basicData's zone", () => {

View File

@ -1,6 +1,4 @@
describe('ZoneCreate', () => {
const notification = '.q-notification__message';
const data = {
Name: { val: 'Zone pickup D' },
Price: { val: '3' },
@ -24,7 +22,7 @@ describe('ZoneCreate', () => {
cy.get('input[aria-label="Close"]').type('10:00');
cy.get('body').click();
cy.get('.q-mt-lg > .q-btn--standard').click();
cy.get(notification).should('contains.text', 'Agency cannot be blank');
cy.checkNotification('Agency cannot be blank');
});
it('should create a zone', () => {
@ -35,6 +33,6 @@ describe('ZoneCreate', () => {
cy.get('input[aria-label="Close"]').type('10:00');
cy.get('body').click();
cy.get('.q-mt-lg > .q-btn--standard').click();
cy.get(notification).should('contains.text', 'Data created');
cy.checkNotification('Data created');
});
});

View File

@ -124,7 +124,7 @@ Cypress.Commands.add('countSelectOptions', (selector, option) => {
});
Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
cy.waitForElement('.q-form > .q-card');
cy.waitForElement(form);
cy.get(`${form} input`).each(([el]) => {
cy.wrap(el)
.invoke('attr', 'aria-label')
@ -277,7 +277,7 @@ Cypress.Commands.add('clearSearchbar', (element) => {
cy.get('[data-cy="vn-searchbar"]').clear();
});
Cypress.Commands.add('writeSearchbar', (value) => {
Cypress.Commands.add('typeSearchbar', (value) => {
cy.get('[data-cy="vn-searchbar"]').type(value);
});