diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 25f50af93..12bd6e640 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -904,6 +904,25 @@ export default { ticketOne: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(1)', ticketTwo: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(2)' }, + invoiceInSummary: { + supplierRef: 'vn-invoice-in-summary vn-label-value:nth-child(2) > section > span' + }, + invoiceInDescriptor: { + moreMenu: 'vn-invoice-in-descriptor vn-icon-button[icon=more_vert]', + moreMenuDeleteInvoiceIn: '.vn-menu [name="deleteInvoice"]', + acceptDeleteButton: '.vn-confirm.shown button[response="accept"]' + }, + invoiceInBasicData: { + issued: 'vn-invoice-in-basic-data vn-date-picker[ng-model="$ctrl.invoiceIn.issued"]', + operated: 'vn-invoice-in-basic-data vn-date-picker[ng-model="$ctrl.invoiceIn.operated"]', + supplier: 'vn-invoice-in-basic-data vn-autocomplete[ng-model="$ctrl.invoiceIn.supplierFk"]', + supplierRef: 'vn-invoice-in-basic-data vn-textfield[ng-model="$ctrl.invoiceIn.supplierRef"]', + bookEntried: 'vn-invoice-in-basic-data vn-date-picker[ng-model="$ctrl.invoiceIn.bookEntried"]', + booked: 'vn-invoice-in-basic-data vn-date-picker[ng-model="$ctrl.invoiceIn.booked"]', + currency: 'vn-invoice-in-basic-data vn-autocomplete[ng-model="$ctrl.invoiceIn.currencyFk"]', + company: 'vn-invoice-in-basic-data vn-autocomplete[ng-model="$ctrl.invoiceIn.companyFk"]', + save: 'vn-invoice-in-basic-data button[type=submit]' + }, travelIndex: { anySearchResult: 'vn-travel-index vn-tbody > a', firstSearchResult: 'vn-travel-index vn-tbody > a:nth-child(1)', diff --git a/e2e/paths/05-ticket/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js index d81c1c3ed..08534f8e4 100644 --- a/e2e/paths/05-ticket/12_descriptor.spec.js +++ b/e2e/paths/05-ticket/12_descriptor.spec.js @@ -184,7 +184,7 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.ticketDescriptor.sendSMSbutton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('SMS sent!'); + expect(message).toBeDefined(); }); it('should send the import SMS using the descriptor menu', async() => { @@ -196,7 +196,7 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.ticketDescriptor.sendSMSbutton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('SMS sent!'); + expect(message).toBeDefined(); }); }); }); diff --git a/e2e/paths/09-invoice-in/01_summary.spec.js b/e2e/paths/09-invoice-in/01_summary.spec.js new file mode 100644 index 000000000..d5932efd0 --- /dev/null +++ b/e2e/paths/09-invoice-in/01_summary.spec.js @@ -0,0 +1,28 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('InvoiceIn summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'invoiceIn'); + await page.accessToSearchResult('1'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the summary section', async() => { + await page.waitForState('invoiceIn.card.summary'); + }); + + it('should contain some basic data from the invoice', async() => { + const result = await page.waitToGetProperty(selectors.invoiceInSummary.supplierRef, 'innerText'); + + expect(result).toEqual('1234'); + }); +}); diff --git a/e2e/paths/09-invoice-in/02_descriptor.spec.js b/e2e/paths/09-invoice-in/02_descriptor.spec.js new file mode 100644 index 000000000..2386dada4 --- /dev/null +++ b/e2e/paths/09-invoice-in/02_descriptor.spec.js @@ -0,0 +1,38 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('InvoiceIn descriptor path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'invoiceIn'); + await page.accessToSearchResult('10'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should delete the invoiceIn using the descriptor more menu', async() => { + await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); + await page.waitToClick(selectors.invoiceInDescriptor.moreMenuDeleteInvoiceIn); + await page.waitToClick(selectors.invoiceInDescriptor.acceptDeleteButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('InvoiceIn deleted'); + }); + + it('should have been relocated to the invoiceOut index', async() => { + await page.waitForState('invoiceIn.index'); + }); + + it(`should search for the deleted invouceOut to find no results`, async() => { + await page.doSearch('10'); + const nResults = await page.countElement(selectors.invoiceOutIndex.searchResult); + + expect(nResults).toEqual(0); + }); +}); diff --git a/e2e/paths/09-invoice-in/03_basic_data.spec.js b/e2e/paths/09-invoice-in/03_basic_data.spec.js new file mode 100644 index 000000000..1fac4f0d9 --- /dev/null +++ b/e2e/paths/09-invoice-in/03_basic_data.spec.js @@ -0,0 +1,64 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('InvoiceIn basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'invoiceIn'); + await page.accessToSearchResult('1'); + await page.accessToSection('invoiceIn.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should edit the invoiceIn basic data`, async() => { + const now = new Date(); + await page.pickDate(selectors.invoiceInBasicData.issued, now); + await page.pickDate(selectors.invoiceInBasicData.operated, now); + await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura'); + await page.clearInput(selectors.invoiceInBasicData.supplierRef); + await page.write(selectors.invoiceInBasicData.supplierRef, '9999'); + await page.pickDate(selectors.invoiceInBasicData.bookEntried, now); + await page.pickDate(selectors.invoiceInBasicData.booked, now); + await page.autocompleteSearch(selectors.invoiceInBasicData.currency, 'Dollar USA'); + await page.autocompleteSearch(selectors.invoiceInBasicData.company, 'ORN'); + await page.waitToClick(selectors.invoiceInBasicData.save); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should confirm the invoiceIn supplier was edited`, async() => { + await page.reloadSection('invoiceIn.card.basicData'); + const result = await page.waitToGetProperty(selectors.invoiceInBasicData.supplier, 'value'); + + expect(result).toContain('Verdnatura'); + }); + + it(`should confirm the invoiceIn supplierRef was edited`, async() => { + const result = await page + .waitToGetProperty(selectors.invoiceInBasicData.supplierRef, 'value'); + + expect(result).toEqual('9999'); + }); + + it(`should confirm the invoiceIn currency was edited`, async() => { + const result = await page + .waitToGetProperty(selectors.invoiceInBasicData.currency, 'value'); + + expect(result).toEqual('Dollar USA'); + }); + + it(`should confirm the invoiceIn company was edited`, async() => { + const result = await page + .waitToGetProperty(selectors.invoiceInBasicData.company, 'value'); + + expect(result).toEqual('ORN'); + }); +}); diff --git a/modules/account/front/accounts/index.html b/modules/account/front/accounts/index.html index 195607fd1..6941bb15b 100644 --- a/modules/account/front/accounts/index.html +++ b/modules/account/front/accounts/index.html @@ -58,24 +58,21 @@ label="Save"> diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js index b299ac3c1..d27188d53 100644 --- a/modules/client/back/methods/client/specs/sendSms.spec.js +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -1,4 +1,5 @@ const app = require('vn-loopback/server/server'); +const soap = require('soap'); describe('client sendSms()', () => { let createdLog; @@ -9,7 +10,8 @@ describe('client sendSms()', () => { done(); }); - it('should send a message and log it', async() => { + it('should now send a message and log it', async() => { + spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); let ctx = {req: {accessToken: {userId: 9}}}; let id = 101; let destination = 222222222; diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js index 612a16cf1..2c65eab24 100644 --- a/modules/client/back/methods/sms/send.spec.js +++ b/modules/client/back/methods/sms/send.spec.js @@ -4,34 +4,11 @@ const soap = require('soap'); describe('sms send()', () => { it('should return the expected message and status code', async() => { const code = 200; - const smsConfig = await app.models.SmsConfig.findOne(); - const soapClient = await soap.createClientAsync(smsConfig.uri); - spyOn(soap, 'createClientAsync').and.returnValue(soapClient); - spyOn(soapClient, 'sendSMSAsync').and.returnValue([{ - result: { - $value: - ` - - - ${code} - - - Envio en procesamiento - - - 1 - - - - 444328681 - - ` - } - }]); + spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); let ctx = {req: {accessToken: {userId: 1}}}; let result = await app.models.Sms.send(ctx, 105, 'destination', 'My SMS Body'); - expect(result.statusCode).toEqual(200); + expect(result.statusCode).toEqual(code); expect(result.status).toContain('Fake response'); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js index 20066a5ba..61dc60abc 100644 --- a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js +++ b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js @@ -1,4 +1,5 @@ const app = require('vn-loopback/server/server'); +const soap = require('soap'); describe('ticket sendSms()', () => { let logId; @@ -10,6 +11,7 @@ describe('ticket sendSms()', () => { }); it('should send a message and log it', async() => { + spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); let ctx = {req: {accessToken: {userId: 9}}}; let id = 11; let destination = 222222222;