feat: refs #8581 add custom Cypress commands for creating and deleting InvoiceIn entries
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
78b2a9ead6
commit
9d3c2323fd
|
@ -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' },
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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]) => {
|
||||
|
|
Loading…
Reference in New Issue