197 lines
8.3 KiB
JavaScript
197 lines
8.3 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('InvoiceIn basic data path', () => {
|
|
let browser;
|
|
let page;
|
|
let newDms;
|
|
|
|
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 = Date.vnNew();
|
|
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.clearInput(selectors.invoiceInBasicData.dms);
|
|
await page.write(selectors.invoiceInBasicData.dms, '2');
|
|
await page.pickDate(selectors.invoiceInBasicData.bookEntried, now);
|
|
await page.pickDate(selectors.invoiceInBasicData.booked, now);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.currency, 'USD');
|
|
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('USD');
|
|
});
|
|
|
|
it(`should confirm the invoiceIn company was edited`, async() => {
|
|
const result = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.company, 'value');
|
|
|
|
expect(result).toEqual('ORN');
|
|
});
|
|
|
|
it(`should confirm the invoiceIn dms was edited`, async() => {
|
|
const result = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.dms, 'value');
|
|
|
|
expect(result).toEqual('2');
|
|
});
|
|
|
|
it(`should create a new invoiceIn dms and save the changes`, async() => {
|
|
await page.clearInput(selectors.invoiceInBasicData.dms);
|
|
await page.waitToClick(selectors.invoiceInBasicData.create);
|
|
|
|
await page.clearInput(selectors.invoiceInBasicData.reference);
|
|
await page.write(selectors.invoiceInBasicData.reference, 'New Dms');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
let message = await page.waitForSnackbar();
|
|
|
|
await page.clearInput(selectors.invoiceInBasicData.companyId);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.companyId, 'VNL');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
message = await page.waitForSnackbar();
|
|
|
|
await page.clearInput(selectors.invoiceInBasicData.warehouseId);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.warehouseId, 'Warehouse One');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
message = await page.waitForSnackbar();
|
|
|
|
await page.clearInput(selectors.invoiceInBasicData.dmsTypeId);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.dmsTypeId, 'Ticket');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
message = await page.waitForSnackbar();
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.description);
|
|
await page.write(selectors.invoiceInBasicData.description, 'Dms without edition.');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('The files can\'t be empty');
|
|
|
|
let currentDir = process.cwd();
|
|
let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`;
|
|
|
|
const [fileChooser] = await Promise.all([
|
|
page.waitForFileChooser(),
|
|
page.waitToClick(selectors.invoiceInBasicData.inputFile)
|
|
]);
|
|
await fileChooser.accept([filePath]);
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
|
|
newDms = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.dms, 'value');
|
|
});
|
|
|
|
it(`should confirm the invoiceIn was edited with the new dms`, async() => {
|
|
await page.reloadSection('invoiceIn.card.basicData');
|
|
const result = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.dms, 'value');
|
|
|
|
expect(result).toEqual(newDms);
|
|
});
|
|
|
|
it(`should edit the invoiceIn`, async() => {
|
|
await page.waitToClick(selectors.invoiceInBasicData.edit);
|
|
|
|
await page.clearInput(selectors.invoiceInBasicData.reference);
|
|
await page.write(selectors.invoiceInBasicData.reference, 'Dms Edited');
|
|
await page.clearInput(selectors.invoiceInBasicData.companyId);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.companyId, 'CCs');
|
|
await page.clearInput(selectors.invoiceInBasicData.warehouseId);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.warehouseId, 'Algemesi');
|
|
await page.clearInput(selectors.invoiceInBasicData.dmsTypeId);
|
|
await page.autocompleteSearch(selectors.invoiceInBasicData.dmsTypeId, 'Basura');
|
|
await page.waitToClick(selectors.invoiceInBasicData.description);
|
|
await page.write(selectors.invoiceInBasicData.description, ' Nevermind, now is edited.');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
let message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the new dms has been edited`, async() => {
|
|
await page.reloadSection('invoiceIn.card.basicData');
|
|
await page.waitToClick(selectors.invoiceInBasicData.edit);
|
|
|
|
const reference = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.reference, 'value');
|
|
const companyId = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.companyId, 'value');
|
|
const warehouseId = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.warehouseId, 'value');
|
|
const dmsTypeId = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.dmsTypeId, 'value');
|
|
const description = await page
|
|
.waitToGetProperty(selectors.invoiceInBasicData.description, 'value');
|
|
|
|
expect(reference).toEqual('Dms Edited');
|
|
expect(companyId).toEqual('CCs');
|
|
expect(warehouseId).toEqual('Algemesi');
|
|
expect(dmsTypeId).toEqual('Basura');
|
|
expect(description).toEqual('Dms without edition. Nevermind, now is edited.');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.confirm);
|
|
});
|
|
|
|
it(`should disable edit and download if dms doesn't exists, and set back the original dms`, async() => {
|
|
await page.clearInput(selectors.invoiceInBasicData.dms);
|
|
await page.write(selectors.invoiceInBasicData.dms, '9999');
|
|
|
|
await page.waitForSelector(`${selectors.invoiceInBasicData.download}.disabled`);
|
|
await page.waitForSelector(`${selectors.invoiceInBasicData.edit}.disabled`);
|
|
|
|
await page.clearInput(selectors.invoiceInBasicData.dms);
|
|
await page.write(selectors.invoiceInBasicData.dms, '1');
|
|
|
|
await page.waitToClick(selectors.invoiceInBasicData.save);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
});
|