diff --git a/test/cypress/integration/invoiceIn/commands.js b/test/cypress/integration/invoiceIn/commands.js new file mode 100644 index 000000000..bb88a90db --- /dev/null +++ b/test/cypress/integration/invoiceIn/commands.js @@ -0,0 +1,26 @@ +Cypress.Commands.add('createInvoiceIn', () => { + cy.dataCy('vnTableCreateBtn').click(); + cy.fillInForm( + { + vnSupplierSelect: { val: 'farmer king', type: 'select' }, + 'Invoice nÂș_input': 'mockInvoice', + Company_select: { val: 'orn', type: 'select' }, + 'Expedition date_inputDate': '16-11-2001', + }, + { attr: 'data-cy' }, + ); + cy.dataCy('FormModelPopup_save').click(); +}); + +Cypress.Commands.add('deleteInvoiceIn', () => { + cy.dataCy('cardDescriptor_subtitle') + .invoke('text') + .then((text) => { + const id = text.match(/\d+/g).join(''); + cy.request({ + method: 'DELETE', + url: `/api/InvoiceIns/${id}`, + headers: { Authorization: 'DEFAULT_TOKEN' }, + }); + }); +}); diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js index 524158b48..9c119cdae 100644 --- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js @@ -1,5 +1,7 @@ /// <reference types="cypress" /> import moment from 'moment'; +import './commands'; + describe('InvoiceInBasicData', () => { const dialogInputs = '.q-dialog input'; const getDocumentBtns = (opt) => `[data-cy="dms-buttons"] > :nth-child(${opt})`; @@ -28,18 +30,35 @@ describe('InvoiceInBasicData', () => { beforeEach(() => { cy.login('administrative'); - cy.visit(`/#/invoice-in/1/basic-data`); + cy.visit('/#/invoice-in/list'); }); it('should edit every field', () => { + cy.createInvoiceIn(); + cy.dataCy('InvoiceInBasicData-menu-item').click(); + cy.fillInForm(mock, { attr: 'data-cy' }); cy.saveCard(); cy.validateForm(mock, { attr: 'data-cy' }); + cy.deleteInvoiceIn(); }); it('should edit, remove and create the dms data', () => { - const firtsInput = 'Ticket:65'; - const secondInput = "I don't know what posting here!"; + const firtsInput = 'Invoice 65'; + const secondInput = 'Swords'; + cy.createInvoiceIn(); + cy.dataCy('InvoiceInBasicData-menu-item').click(); + + //create + cy.get('[data-cy="invoiceInBasicDataDmsAdd"]').eq(0).click(); + cy.get('[data-cy="VnDms_inputFile"').selectFile( + 'test/cypress/fixtures/image.jpg', + { + force: true, + }, + ); + cy.get('[data-cy="FormModelPopup_save"]').click(); + cy.checkNotification('Data saved'); //edit cy.get(getDocumentBtns(2)).click(); @@ -56,20 +75,6 @@ describe('InvoiceInBasicData', () => { cy.get(getDocumentBtns(3)).click(); cy.get('[data-cy="VnConfirm_confirm"]').click(); cy.checkNotification('Data saved'); - - //create - cy.get('[data-cy="invoiceInBasicDataDmsAdd"]').eq(0).click(); - cy.get('[data-cy="VnDms_inputFile"').selectFile( - 'test/cypress/fixtures/image.jpg', - { - force: true, - }, - ); - cy.get('[data-cy="FormModelPopup_save"]').click(); - cy.checkNotification('Data saved'); + cy.deleteInvoiceIn(); }); }); - -function getVnNew() { - return new Date(Date.UTC(2001, 0, 1, 11)); -} diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 6840d471d..1355e3460 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -163,6 +163,7 @@ Cypress.Commands.add('countSelectOptions', (selector, option) => { }); Cypress.Commands.add('fillInForm', (obj, opts = {}) => { + cy.waitSpinner(); const { form = '.q-form > .q-card', attr = 'aria-label' } = opts; cy.waitForElement(form); cy.get(`${form} input`).each(([el]) => {