From e455fe4e99aeb3f84d04798a63cb2ac84bf50446 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 9 Oct 2024 00:33:13 +0200 Subject: [PATCH] test: create test for all sections --- .../integration/client/ClientList.spec.js | 75 ------------------- .../integration/client/clientAddress.spec.js | 13 ++++ .../integration/client/clientBalance.spec.js | 13 ++++ .../client/clientBasicData.spec.js | 13 ++++ .../client/clientBillingData.spec.js | 13 ++++ .../integration/client/clientCredits.spec.js | 13 ++++ .../client/clientFiscalData.spec.js | 13 ++++ .../integration/client/clientGreuges.spec.js | 13 ++++ .../integration/client/clientList.spec.js | 63 ++++++++++++++++ .../integration/client/clientNotes.spec.js | 13 ++++ .../client/clientRecoveries.spec.js | 13 ++++ .../client/clientWebAccess.spec.js | 13 ++++ .../clientCreditOpinion.spec.js | 13 ++++ .../client/others/clientConsumption.spec.js | 13 ++++ .../client/others/clientContacts.spec.js | 13 ++++ .../client/others/clientMandates.spec.js | 13 ++++ .../client/others/clientSamples.spec.js | 13 ++++ .../client/others/clientUnpaid.spec.js | 13 ++++ .../client/others/clientWebPayments.spec.js | 13 ++++ test/cypress/support/commands.js | 43 +++++++++++ 20 files changed, 327 insertions(+), 75 deletions(-) delete mode 100644 test/cypress/integration/client/ClientList.spec.js create mode 100644 test/cypress/integration/client/clientAddress.spec.js create mode 100644 test/cypress/integration/client/clientBalance.spec.js create mode 100644 test/cypress/integration/client/clientBasicData.spec.js create mode 100644 test/cypress/integration/client/clientBillingData.spec.js create mode 100644 test/cypress/integration/client/clientCredits.spec.js create mode 100644 test/cypress/integration/client/clientFiscalData.spec.js create mode 100644 test/cypress/integration/client/clientGreuges.spec.js create mode 100644 test/cypress/integration/client/clientList.spec.js create mode 100644 test/cypress/integration/client/clientNotes.spec.js create mode 100644 test/cypress/integration/client/clientRecoveries.spec.js create mode 100644 test/cypress/integration/client/clientWebAccess.spec.js create mode 100644 test/cypress/integration/client/credit-management/clientCreditOpinion.spec.js create mode 100644 test/cypress/integration/client/others/clientConsumption.spec.js create mode 100644 test/cypress/integration/client/others/clientContacts.spec.js create mode 100644 test/cypress/integration/client/others/clientMandates.spec.js create mode 100644 test/cypress/integration/client/others/clientSamples.spec.js create mode 100644 test/cypress/integration/client/others/clientUnpaid.spec.js create mode 100644 test/cypress/integration/client/others/clientWebPayments.spec.js diff --git a/test/cypress/integration/client/ClientList.spec.js b/test/cypress/integration/client/ClientList.spec.js deleted file mode 100644 index 712344837..000000000 --- a/test/cypress/integration/client/ClientList.spec.js +++ /dev/null @@ -1,75 +0,0 @@ -/// -describe('Handle Client list', () => { - const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(7)'; - const firstId = `${firstRow} > td:nth-child(1) span`; - const firstDetailBtn = `${firstRow} .q-btn:nth-child(1)`; - const summaryHeaders = '.summaryBody .header-link'; - const dialogInputs = '.q-dialog input'; - - beforeEach(() => { - cy.viewport(1280, 720); - cy.login('developer'); - cy.visit('/#/customer/list', { timeout: 5000 }); - }); - it('Client list create new client', () => { - const dialogInputs = '.q-dialog label input'; - - cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); - const data = { - Name: { val: 'Name 1' }, - 'Social name': { val: 'TEST 1' }, - 'Tax number': { val: '20852113Z' }, - 'Web user': { val: 'user_test_1' }, - Street: { val: 'C/ STREET 1' }, - Email: { val: 'user.test@1.com' }, - 'Business type': { val: 'Otros', type: 'select' }, - 'Sales person': { val: 'salesboss', type: 'select' }, - Location: { val: '46000, Valencia(Province one), España', type: 'select' }, - }; - cy.fillInForm(data); - // cy.get(dialogInputs).eq(0).type('NAME 1'); - // cy.get(dialogInputs).eq(1).type('TEST 1'); - // cy.get(dialogInputs).eq(2).type('20852113Z'); - // cy.get(dialogInputs).eq(3).type('C/ STREET 1'); - // cy.get(dialogInputs).eq(8).type('user_test_1'); - // cy.get(dialogInputs).eq(9).type('user.test@1.com'); - // cy.selectOption('.q-dialog input', 'Others'); - // cy.get( - // '.q-field--float > .q-field__inner > .q-field__control > .q-field__control-container' - // ).click(); - // cy.selectOption( - // '.q-dialog label input > :nth-child(5) > .q-select > .q-field__inner > .q-field__control ', - // 'salesBoss' - // ); - // cy.get( - // '.q-dialog > .q-card> .grid-create >input>:nth-child(5) > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container' - // ).click(); - // cy.selectOption( - // '.q-dialog > .q-field__inner > .q-field__control > .q-field__control-container >:nth-child(6)', - // 'salesBoss' - // ); - // cy.get(dialogInputs).eq(7).type('46000, Valencia(Province one), España'); - cy.get('.q-mt-lg > .q-btn--standard').click(); - - cy.get('.q-notification__message').should('have.text', 'Data created'); - cy.url().should('include', '/summary'); - }); - xit('should redirect on clicking a invoice', () => { - cy.get(firstId) - .invoke('text') - .then((content) => { - const id = content.replace(/\D/g, ''); - cy.get(firstRow).click(); - cy.url().should('include', `/invoice-in/${id}/summary`); - }); - }); - - xit('should open the details', () => { - cy.get(firstDetailBtn).click(); - cy.get(summaryHeaders).eq(1).contains('Basic data'); - cy.get(summaryHeaders).eq(4).contains('Vat'); - }); - xit('Create and go', function () { - cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); - }); -}); diff --git a/test/cypress/integration/client/clientAddress.spec.js b/test/cypress/integration/client/clientAddress.spec.js new file mode 100644 index 000000000..075b0b68c --- /dev/null +++ b/test/cypress/integration/client/clientAddress.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client consignee', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/address', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientBalance.spec.js b/test/cypress/integration/client/clientBalance.spec.js new file mode 100644 index 000000000..36ffb5084 --- /dev/null +++ b/test/cypress/integration/client/clientBalance.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client balance', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/balance', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientBasicData.spec.js b/test/cypress/integration/client/clientBasicData.spec.js new file mode 100644 index 000000000..406c6e426 --- /dev/null +++ b/test/cypress/integration/client/clientBasicData.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client basic data', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/basic-data', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientBillingData.spec.js b/test/cypress/integration/client/clientBillingData.spec.js new file mode 100644 index 000000000..00e92d2bb --- /dev/null +++ b/test/cypress/integration/client/clientBillingData.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client billing data', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/billing-data', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientCredits.spec.js b/test/cypress/integration/client/clientCredits.spec.js new file mode 100644 index 000000000..794d39684 --- /dev/null +++ b/test/cypress/integration/client/clientCredits.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client credits', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/credits', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientFiscalData.spec.js b/test/cypress/integration/client/clientFiscalData.spec.js new file mode 100644 index 000000000..37ddbfeaf --- /dev/null +++ b/test/cypress/integration/client/clientFiscalData.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client fiscal data', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/fiscal-data', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientGreuges.spec.js b/test/cypress/integration/client/clientGreuges.spec.js new file mode 100644 index 000000000..d8e8cd20e --- /dev/null +++ b/test/cypress/integration/client/clientGreuges.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client greuges', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/greuges', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js new file mode 100644 index 000000000..6cdadd101 --- /dev/null +++ b/test/cypress/integration/client/clientList.spec.js @@ -0,0 +1,63 @@ +/// +describe('Handle Client list', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('/#/customer/list', { + timeout: 5000, + onBeforeLoad(win) { + cy.stub(win, 'open'); + }, + }); + }); + + it('Client list create new client', () => { + cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); + const data = { + Name: { val: 'Name 1' }, + 'Social name': { val: 'TEST 1' }, + 'Tax number': { val: '20852113Z' }, + 'Web user': { val: 'user_test_1' }, + Street: { val: 'C/ STREET 1' }, + Email: { val: 'user.test@1.com' }, + 'Business type': { val: 'Otros', type: 'select' }, + 'Sales person': { val: 'salesboss', type: 'select' }, + Location: { val: '46000, Valencia(Province one), España', type: 'select' }, + }; + cy.fillInForm(data); + + cy.get('.q-mt-lg > .q-btn--standard').click(); + + cy.checkNotification('created'); + cy.url().should('include', '/summary'); + }); + it('Client list search client', () => { + const search = 'Jessica Jones'; + cy.searchByLabel('Name', search); + + cy.get('.title > span').should('have.text', search); + let id = null; + cy.get('.q-item > .q-item__label').then((text) => { + id = text.text().trim().split('#')[1]; + cy.get('.q-item > .q-item__label').should('have.text', ` #${id}`); + cy.url().should('include', `/customer/${id}/summary`); + }); + }); + + it('Client founded create ticket', () => { + const search = 'Jessica Jones'; + cy.searchByLabel('Name', search); + cy.clickButtonsDescriptor(2); + cy.waitForElement('#formModel'); + cy.waitForElement('.q-form'); + cy.checkValueForm(1, search); + }); + it('Client founded create order', () => { + const search = 'Jessica Jones'; + cy.searchByLabel('Name', search); + cy.clickButtonsDescriptor(4); + cy.waitForElement('#formModel'); + cy.waitForElement('.q-form'); + cy.checkValueForm(2, search); + }); +}); diff --git a/test/cypress/integration/client/clientNotes.spec.js b/test/cypress/integration/client/clientNotes.spec.js new file mode 100644 index 000000000..921112dbd --- /dev/null +++ b/test/cypress/integration/client/clientNotes.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client notes', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/notes', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientRecoveries.spec.js b/test/cypress/integration/client/clientRecoveries.spec.js new file mode 100644 index 000000000..c083e75b1 --- /dev/null +++ b/test/cypress/integration/client/clientRecoveries.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client recoveries', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/recoveries', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/clientWebAccess.spec.js b/test/cypress/integration/client/clientWebAccess.spec.js new file mode 100644 index 000000000..798861647 --- /dev/null +++ b/test/cypress/integration/client/clientWebAccess.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client web-access', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/web-access', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/credit-management/clientCreditOpinion.spec.js b/test/cypress/integration/client/credit-management/clientCreditOpinion.spec.js new file mode 100644 index 000000000..69ca9acc4 --- /dev/null +++ b/test/cypress/integration/client/credit-management/clientCreditOpinion.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client credit opinion', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/credit-management/credit-opinion', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/others/clientConsumption.spec.js b/test/cypress/integration/client/others/clientConsumption.spec.js new file mode 100644 index 000000000..494acc440 --- /dev/null +++ b/test/cypress/integration/client/others/clientConsumption.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client consumption', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/consumption', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/others/clientContacts.spec.js b/test/cypress/integration/client/others/clientContacts.spec.js new file mode 100644 index 000000000..8803e3f71 --- /dev/null +++ b/test/cypress/integration/client/others/clientContacts.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client contacts', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/contacts', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/others/clientMandates.spec.js b/test/cypress/integration/client/others/clientMandates.spec.js new file mode 100644 index 000000000..81e999623 --- /dev/null +++ b/test/cypress/integration/client/others/clientMandates.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client mandates', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/mandates', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/others/clientSamples.spec.js b/test/cypress/integration/client/others/clientSamples.spec.js new file mode 100644 index 000000000..8689267e9 --- /dev/null +++ b/test/cypress/integration/client/others/clientSamples.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client samples', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/samples', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/others/clientUnpaid.spec.js b/test/cypress/integration/client/others/clientUnpaid.spec.js new file mode 100644 index 000000000..05b268ec4 --- /dev/null +++ b/test/cypress/integration/client/others/clientUnpaid.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client unpaid', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/unpaid', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/client/others/clientWebPayments.spec.js b/test/cypress/integration/client/others/clientWebPayments.spec.js new file mode 100644 index 000000000..65859b4ce --- /dev/null +++ b/test/cypress/integration/client/others/clientWebPayments.spec.js @@ -0,0 +1,13 @@ +/// +describe('Handle Client web payments', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('#/customer/1110/others/web-payments', { + timeout: 5000, + }); + }); + it('Form loaded', () => { + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 43788f59f..2ef9e1a74 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -241,10 +241,53 @@ Cypress.Commands.add('writeSearchbar', (value) => { value ); }); + Cypress.Commands.add('validateContent', (selector, expectedValue) => { cy.get(selector).should('have.text', expectedValue); }); +Cypress.Commands.add('openActionDescriptor', (opt) => { + cy.openActionsDescriptor(); + const listItem = '[role="menu"] .q-list .q-item'; + cy.contains(listItem, opt).click(); + 1; +}); + Cypress.Commands.add('openActionsDescriptor', () => { cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click(); }); + +Cypress.Commands.add('clickButtonsDescriptor', (id) => { + cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`) + .invoke('removeAttr', 'target') + .click(); +}); + +Cypress.Commands.add('openActions', (row) => { + cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click(); +}); + +Cypress.Commands.add('checkNotification', (type) => { + const values = { + created: 'Data created', + updated: 'Data saved', + deleted: 'Data deleted', + }; + cy.get('.q-notification__message').should('have.text', values[type]); +}); + +Cypress.Commands.add('checkValueForm', (id, search) => { + cy.get( + `.grid-create > :nth-child(${id}) > .q-field__inner>.q-field__control> .q-field__control-container>.q-field__native >.q-field__input` + ).should('have.value', search); +}); + +Cypress.Commands.add('checkValueSelectForm', (id, search) => { + cy.get( + `.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container>.q-field__native>.q-field__input` + ).should('have.value', search); +}); + +Cypress.Commands.add('searchByLabel', (label, value) => { + cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`); +});