diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a561a08cf..40b2ae68a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -915,6 +915,15 @@ export default { invoiceOutIndex: { topbarSearch: 'vn-searchbar', searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr', + createInvoice: 'vn-invoice-out-index > div > vn-vertical > vn-button > button vn-icon[icon="add"]', + createManualInvoice: 'vn-item[name="manualInvoice"]', + manualInvoiceForm: '.vn-invoice-out-manual', + manualInvoiceTicket: 'vn-autocomplete[ng-model="$ctrl.invoice.ticketFk"]', + manualInvoiceClient: 'vn-autocomplete[ng-model="$ctrl.invoice.clientFk"]', + manualInvoiceSerial: 'vn-autocomplete[ng-model="$ctrl.invoice.serial"]', + manualInvoiceTaxArea: 'vn-autocomplete[ng-model="$ctrl.invoice.taxArea"]', + saveManualInvoice: 'button[response="accept"]' + }, invoiceOutDescriptor: { moreMenu: 'vn-invoice-out-descriptor vn-icon-button[icon=more_vert]', diff --git a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js new file mode 100644 index 000000000..aa8cc7454 --- /dev/null +++ b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js @@ -0,0 +1,65 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('InvoiceOut manual invoice path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'invoiceOut'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should open the manual invoice form', async() => { + await page.waitToClick(selectors.invoiceOutIndex.createInvoice); + await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice); + await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); + }); + + it('should create an invoice from a ticket', async() => { + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '7'); + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); + await page.waitToClick(selectors.invoiceOutIndex.saveManualInvoice); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should have been redirected to the created invoice summary`, async() => { + await page.waitForState('invoiceOut.card.summary'); + }); + + it(`should navigate back to the invoiceOut index`, async() => { + await page.waitToClick(selectors.globalItems.applicationsMenuButton); + await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); + await page.waitToClick(selectors.globalItems.invoiceOutButton); + await page.waitForSelector(selectors.invoiceOutIndex.topbarSearch); + await page.waitForState('invoiceOut.index'); + }); + + it('should now open the manual invoice form', async() => { + await page.waitToClick(selectors.invoiceOutIndex.createInvoice); + await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice); + await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); + }); + + it('should create an invoice from a client', async() => { + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceClient, 'Charles Xavier'); + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); + await page.waitToClick(selectors.invoiceOutIndex.saveManualInvoice); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should have been redirected to the created invoice summary`, async() => { + await page.waitForState('invoiceOut.card.summary'); + }); +}); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 1781e0975..02443a066 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -111,5 +111,7 @@ "State": "State", "regular": "regular", "reserved": "reserved", - "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients" + "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", + "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", + "This client is not invoiceable": "This client is not invoiceable" } \ No newline at end of file