#1976 Implementar Puppeteer

This commit is contained in:
Carlos Jimenez Ruiz 2020-01-09 13:07:16 +01:00
parent 6a0e4bce72
commit 505a491f59
18 changed files with 2738 additions and 2625 deletions

View File

@ -404,11 +404,11 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`,
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
VALUES VALUES
(1, 'T', 1014.24, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 101, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1), (1, 'T', 1014.24, CURDATE(), 101, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1),
(2, 'T', 121.36, CURDATE(), 102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), (2, 'T', 121.36, CURDATE(), 102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1),
(3, 'T', 8.88, CURDATE(), 103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), (3, 'T', 8.88, CURDATE(), 103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1),
(4, 'T', 8.88, CURDATE(), 103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), (4, 'T', 8.88, CURDATE(), 103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1),
(5, 'A', 8.88, CURDATE(), 103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1); (5, 'A', 8.88, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 103, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1);
UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1; UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1;
UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2; UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2;

View File

@ -129,12 +129,13 @@ let actions = {
let field = await this.evaluate(selector => { let field = await this.evaluate(selector => {
return document.querySelector(`${selector} input`).closest('.vn-field').$ctrl.field; return document.querySelector(`${selector} input`).closest('.vn-field').$ctrl.field;
}, selector); }, selector);
if ((field != null && field != '') || field == '0') { if (field && field.lenght) {
let coords = await this.evaluate(selector => { let coords = await this.evaluate(selector => {
let rect = document.querySelector(selector).getBoundingClientRect(); let rect = document.querySelector(selector).getBoundingClientRect();
return {x: rect.x + (rect.width / 2), y: rect.y + (rect.height / 2)}; return {x: rect.x + (rect.width / 2), y: rect.y + (rect.height / 2), width: rect.width};
}, selector); }, selector);
await this.mouse.move(coords.x, coords.y); await this.mouse.move(coords.x, coords.y);
await this.waitFor(1000);
await this.waitToClick(`${selector} [icon="clear"]`); await this.waitToClick(`${selector} [icon="clear"]`);
} }
}, },
@ -237,7 +238,7 @@ let actions = {
return await this.wait(selector => { return await this.wait(selector => {
const imageReady = document.querySelector(selector).complete; const imageReady = document.querySelector(selector).complete;
return imageReady; return imageReady;
}, selector); }, {}, selector);
}, },
clickIfVisible: async function(selector) { clickIfVisible: async function(selector) {
@ -341,11 +342,6 @@ let actions = {
await this.write('vn-searchbar', searchValue); await this.write('vn-searchbar', searchValue);
await this.waitToClick('vn-searchbar vn-icon[icon="search"]'); await this.waitToClick('vn-searchbar vn-icon[icon="search"]');
await this.waitForNumberOfElements('.search-result', 1); await this.waitForNumberOfElements('.search-result', 1);
let result = await this.evaluate(() => {
return document.querySelector('ui-view vn-card vn-table') != null;
});
if (result)
return await this.waitToClick('ui-view vn-card vn-td');
return await this.waitToClick('ui-view vn-card a'); return await this.waitToClick('ui-view vn-card a');
}, },
@ -445,6 +441,19 @@ let actions = {
return !angular.equals({}, orgData) && orgData != null; return !angular.equals({}, orgData) && orgData != null;
}, {}, selector); }, {}, selector);
await this.waitForSpinnerLoad(); await this.waitForSpinnerLoad();
},
waitForTransitionEnd: async function(selector) {
await this.evaluate(selector => {
return new Promise(resolve => {
const transition = document.querySelector(selector);
const onEnd = function() {
transition.removeEventListener('transitionend', onEnd);
resolve();
};
transition.addEventListener('transitionend', onEnd);
});
}, selector);
} }
}; };

View File

@ -81,7 +81,7 @@ describe('Client Edit fiscalData path', () => {
const result = await page.waitForLastSnackbar(); const result = await page.waitForLastSnackbar();
expect(result).toEqual('Invalid Tax number'); expect(result).toEqual('Invalid Tax number');
}); }, 15000);
it(`should edit the fiscal this time with a valid fiscal id`, async() => { it(`should edit the fiscal this time with a valid fiscal id`, async() => {
await page.clearInput(selectors.clientFiscalData.fiscalIdInput); await page.clearInput(selectors.clientFiscalData.fiscalIdInput);

View File

@ -1,32 +1,32 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Worker pbx path', () => { describe('Worker pbx path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('hr', 'worker');
await page.accessToSearchResult('employee');
await page.accessToSection('worker.card.pbx');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('hr', 'worker')
.accessToSearchResult('employee')
.accessToSection('worker.card.pbx');
}); });
it('should receive an error when the extension exceeds 4 characters', async() => { it('should receive an error when the extension exceeds 4 characters', async() => {
const result = await nightmare await page.write(selectors.workerPbx.extensionInput, '55555');
.write(selectors.workerPbx.extensionInput, 55555) await page.waitToClick(selectors.workerPbx.saveButton);
const result = await page.waitForLastSnackbar();
.waitToClick(selectors.workerPbx.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Extension format is invalid'); expect(result).toEqual('Extension format is invalid');
}); });
it('should sucessfully save the changes', async() => { it('should sucessfully save the changes', async() => {
const result = await nightmare await page.clearInput(selectors.workerPbx.extensionInput);
.clearInput(selectors.workerPbx.extensionInput) await page.write(selectors.workerPbx.extensionInput, '4444');
.write(selectors.workerPbx.extensionInput, 4444) await page.waitToClick(selectors.workerPbx.saveButton);
.waitToClick(selectors.workerPbx.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved! User must access web'); expect(result).toEqual('Data saved! User must access web');
}); });

View File

@ -1,202 +1,173 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item summary path', () => { describe('Item summary path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'item');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('employee', 'item');
}); });
it('should search for an item', async() => { it('should search for an item', async() => {
const result = await nightmare await page.clearInput(selectors.itemsIndex.searchItemInput);
.clearInput(selectors.itemsIndex.searchItemInput) await page.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon longbow 2m');
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon longbow 2m') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) const result = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(1);
}); });
it(`should click on the search result summary button to open the item summary popup`, async() => { it(`should click on the search result summary button to open the item summary popup`, async() => {
const isVisible = await nightmare await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon longbow 2m');
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon longbow 2m') await page.waitToClick(selectors.itemsIndex.searchResultPreviewButton);
.waitToClick(selectors.itemsIndex.searchResultPreviewButton) const isVisible = await page.isVisible(selectors.itemSummary.basicData);
.isVisible(selectors.itemSummary.basicData);
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
}); });
it(`should check the item summary preview shows fields from basic data`, async() => { it(`should check the item summary preview shows fields from basic data`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 2m');
.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 2m') const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Ranged weapon longbow 2m'); expect(result).toContain('Ranged weapon longbow 2m');
}); });
it(`should check the item summary preview shows fields from tags`, async() => { it(`should check the item summary preview shows fields from tags`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.tags, 'Brown');
.waitForTextInElement(selectors.itemSummary.tags, 'Brown') const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
expect(result).toContain('Brown'); expect(result).toContain('Brown');
}); });
it(`should check the item summary preview shows fields from niche`, async() => { it(`should check the item summary preview shows fields from niche`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.niche, 'A1');
.waitForTextInElement(selectors.itemSummary.niche, 'A1') const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText');
.waitToGetProperty(selectors.itemSummary.niche, 'innerText');
expect(result).toContain('A1'); expect(result).toContain('A1');
}); });
it(`should check the item summary preview shows fields from botanical`, async() => { it(`should check the item summary preview shows fields from botanical`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.botanical, 'Hedera helix');
.waitForTextInElement(selectors.itemSummary.botanical, 'Hedera helix') const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
expect(result).toContain('Hedera helix'); expect(result).toContain('Hedera helix');
}); });
it(`should check the item summary preview shows fields from barcode`, async() => { it(`should check the item summary preview shows fields from barcode`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.barcode, '1');
.waitForTextInElement(selectors.itemSummary.barcode, '1') const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
expect(result).toContain('1'); expect(result).toContain('1');
}); });
it(`should close the summary popup`, async() => { it(`should close the summary popup`, async() => {
const result = await nightmare await page.keyboard.press('Escape');
.mousedown(selectors.itemsIndex.closeItemSummaryPreview) await page.waitUntilNotPresent(selectors.itemSummary.basicData);
.waitUntilNotPresent(selectors.itemSummary.basicData) await page.waitFor(selectors.itemSummary.basicData, {hidden: true});
.visible(selectors.itemSummary.basicData);
expect(result).toBeFalsy();
}); });
it('should search for other item', async() => { it('should search for other item', async() => {
const result = await nightmare await page.clearInput('vn-searchbar');
.clearInput('vn-searchbar input') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.write(selectors.itemsIndex.searchItemInput, 'Melee weapon combat fist 15cm');
.write(selectors.itemsIndex.searchItemInput, 'Melee weapon combat fist 15cm') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) const result = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(1);
}); });
it(`should now click on the search result summary button to open the item summary popup`, async() => { it(`should now click on the search result summary button to open the item summary popup`, async() => {
const isVisible = await nightmare await page.waitToClick(selectors.itemsIndex.searchResultPreviewButton);
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Melee weapon combat fist 15cm') await page.waitForSelector(selectors.itemSummary.basicData, {visible: true});
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
.isVisible(selectors.itemSummary.basicData);
expect(isVisible).toBeTruthy();
}); });
it(`should now check the item summary preview shows fields from basic data`, async() => { it(`should now check the item summary preview shows fields from basic data`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm');
.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm') const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Melee weapon combat fist 15cm'); expect(result).toContain('Melee weapon combat fist 15cm');
}); });
it(`should now check the item summary preview shows fields from tags`, async() => { it(`should now check the item summary preview shows fields from tags`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.tags, 'Silver');
.waitForTextInElement(selectors.itemSummary.tags, 'Silver') const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
expect(result).toContain('Silver'); expect(result).toContain('Silver');
}); });
it(`should now check the item summary preview shows fields from niche`, async() => { it(`should now check the item summary preview shows fields from niche`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.niche, 'A4');
.waitForTextInElement(selectors.itemSummary.niche, 'A4') const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText');
.waitToGetProperty(selectors.itemSummary.niche, 'innerText');
expect(result).toContain('A4'); expect(result).toContain('A4');
}); });
it(`should now check the item summary preview shows fields from botanical`, async() => { it(`should now check the item summary preview shows fields from botanical`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.botanical, '-');
.waitForTextInElement(selectors.itemSummary.botanical, '-') const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
expect(result).toContain('-'); expect(result).toContain('-');
}); });
it(`should now check the item summary preview shows fields from barcode`, async() => { it(`should now check the item summary preview shows fields from barcode`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.barcode, '4');
.waitForTextInElement(selectors.itemSummary.barcode, '4') const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
expect(result).toContain('4'); expect(result).toContain('4');
}); });
it(`should now close the summary popup`, async() => { it(`should now close the summary popup`, async() => {
const result = await nightmare await page.keyboard.press('Escape');
.mousedown(selectors.itemsIndex.closeItemSummaryPreview) await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true});
.waitUntilNotPresent(selectors.itemSummary.basicData)
.visible(selectors.itemSummary.basicData);
expect(result).toBeFalsy();
}); });
it(`should navigate to the one of the items detailed section`, async() => { it(`should navigate to the one of the items detailed section`, async() => {
const url = await nightmare await page.waitToClick(selectors.itemsIndex.searchResult);
.waitToClick(selectors.itemsIndex.searchResult) await page.waitForURL('summary');
.waitForURL('summary') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('summary'); expect(url.hash).toContain('summary');
}); });
it(`should check the descritor edit button is not visible for employee`, async() => { it(`should check the descritor edit button is not visible for employee`, async() => {
const visibleButton = await nightmare const visibleButton = await page.isVisible(selectors.itemDescriptor.editButton);
.isVisible(selectors.itemDescriptor.editButton);
expect(visibleButton).toBeFalsy(); expect(visibleButton).toBeFalsy();
}); });
it(`should check the item summary shows fields from basic data section`, async() => { it(`should check the item summary shows fields from basic data section`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm');
.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm') const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Melee weapon combat fist 15cm'); expect(result).toContain('Melee weapon combat fist 15cm');
}); });
it(`should check the item summary shows fields from tags section`, async() => { it(`should check the item summary shows fields from tags section`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
expect(result).toContain('Silver'); expect(result).toContain('Silver');
}); });
it(`should check the item summary shows fields from niches section`, async() => { it(`should check the item summary shows fields from niches section`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText');
.waitToGetProperty(selectors.itemSummary.niche, 'innerText');
expect(result).toContain('One A4'); expect(result).toContain('One A4');
}); });
it(`should check the item summary shows fields from botanical section`, async() => { it(`should check the item summary shows fields from botanical section`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
expect(result).toContain('-'); expect(result).toContain('-');
}); });
it(`should check the item summary shows fields from barcodes section`, async() => { it(`should check the item summary shows fields from barcodes section`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
expect(result).toContain('4'); expect(result).toContain('4');
}); });

View File

@ -1,102 +1,100 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item Edit basic data path', () => { describe('Item Edit basic data path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Melee weapon combat fist 15cm');
await page.accessToSection('item.card.basicData');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('buyer', 'item')
.accessToSearchResult('Melee weapon combat fist 15cm')
.accessToSection('item.card.basicData');
}); });
it(`should check the descritor edit button is visible for buyer`, async() => { it(`should check the descritor edit button is visible for buyer`, async() => {
const visibleButton = await nightmare await page.waitFor(selectors.itemDescriptor.editButton, {visible: true});
.isVisible(selectors.itemDescriptor.editButton);
expect(visibleButton).toBeTruthy();
}); });
it(`should edit the item basic data`, async() => { it(`should edit the item basic data`, async() => {
const result = await nightmare await page.clearInput(selectors.itemBasicData.nameInput);
.clearInput(selectors.itemBasicData.nameInput) await page.write(selectors.itemBasicData.nameInput, 'Rose of Purity');
.write(selectors.itemBasicData.nameInput, 'Rose of Purity') await page.autocompleteSearch(selectors.itemBasicData.typeAutocomplete, 'Anthurium');
.autocompleteSearch(selectors.itemBasicData.typeAutocomplete, 'Anthurium') await page.autocompleteSearch(selectors.itemBasicData.intrastatAutocomplete, 'Coral y materiales similares');
.autocompleteSearch(selectors.itemBasicData.intrastatAutocomplete, 'Coral y materiales similares') await page.clearInput(selectors.itemBasicData.relevancyInput);
.clearInput(selectors.itemBasicData.relevancyInput) await page.write(selectors.itemBasicData.relevancyInput, '1');
.write(selectors.itemBasicData.relevancyInput, '1') await page.autocompleteSearch(selectors.itemBasicData.originAutocomplete, 'Spain');
.autocompleteSearch(selectors.itemBasicData.originAutocomplete, 'Spain') await page.autocompleteSearch(selectors.itemBasicData.expenseAutocomplete, 'Alquiler VNH');
.autocompleteSearch(selectors.itemBasicData.expenseAutocomplete, 'Alquiler VNH') await page.clearInput(selectors.itemBasicData.longNameInput);
.clearInput(selectors.itemBasicData.longNameInput) await page.write(selectors.itemBasicData.longNameInput, 'RS Rose of Purity');
.write(selectors.itemBasicData.longNameInput, 'RS Rose of Purity') await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
.waitToClick(selectors.itemBasicData.isActiveCheckbox) await page.waitToClick(selectors.itemBasicData.priceInKgCheckbox);
.waitToClick(selectors.itemBasicData.priceInKgCheckbox) await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
.waitToClick(selectors.itemBasicData.submitBasicDataButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}, 15000); }, 15000);
it(`should confirm the item name was edited`, async() => { it(`should confirm the item name was edited`, async() => {
const result = await nightmare await page.reloadSection('item.card.basicData');
.reloadSection('item.card.basicData') const result = await page.waitToGetProperty(`${selectors.itemBasicData.nameInput} input`, 'value');
.waitToGetProperty(selectors.itemBasicData.nameInput, 'value');
expect(result).toEqual('Rose of Purity'); expect(result).toEqual('Rose of Purity');
}); });
it(`should confirm the item type was edited`, async() => { it(`should confirm the item type was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value');
expect(result).toEqual('Anthurium'); expect(result).toEqual('Anthurium');
}); });
it(`should confirm the item intrastad was edited`, async() => { it(`should confirm the item intrastad was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, 'value');
expect(result).toEqual('5080000 Coral y materiales similares'); expect(result).toEqual('5080000 Coral y materiales similares');
}); });
it(`should confirm the item relevancy was edited`, async() => { it(`should confirm the item relevancy was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.itemBasicData.relevancyInput, 'value'); .waitToGetProperty(`${selectors.itemBasicData.relevancyInput} input`, 'value');
expect(result).toEqual('1'); expect(result).toEqual('1');
}); });
it(`should confirm the item origin was edited`, async() => { it(`should confirm the item origin was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, 'value');
expect(result).toEqual('Spain'); expect(result).toEqual('Spain');
}); });
it(`should confirm the item expence was edited`, async() => { it(`should confirm the item expence was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.itemBasicData.expenseAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.expenseAutocomplete} input`, 'value');
expect(result).toEqual('Alquiler VNH'); expect(result).toEqual('Alquiler VNH');
}); });
it(`should confirm the item long name was edited`, async() => { it(`should confirm the item long name was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.itemBasicData.longNameInput, 'value'); .waitToGetProperty(`${selectors.itemBasicData.longNameInput} input`, 'value');
expect(result).toEqual('RS Rose of Purity'); expect(result).toEqual('RS Rose of Purity');
}); });
it('should confirm isActive checkbox is unchecked', async() => { it('should confirm isActive checkbox is unchecked', async() => {
const result = await nightmare const result = await page
.checkboxState(selectors.itemBasicData.isActiveCheckbox); .checkboxState(selectors.itemBasicData.isActiveCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm the priceInKg checkbox is checked', async() => { it('should confirm the priceInKg checkbox is checked', async() => {
const result = await nightmare const result = await page
.checkboxState(selectors.itemBasicData.priceInKgCheckbox); .checkboxState(selectors.itemBasicData.priceInKgCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');

View File

@ -1,61 +1,60 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item edit tax path', () => { describe('Item edit tax path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.tax');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon longbow 2m')
.accessToSection('item.card.tax');
}); });
it(`should add the item tax to all countries`, async() => { it(`should add the item tax to all countries`, async() => {
const result = await nightmare await page.autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'General VAT');
.autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'General VAT') await page.autocompleteSearch(selectors.itemTax.secondClassAutocomplete, 'General VAT');
.autocompleteSearch(selectors.itemTax.secondClassAutocomplete, 'General VAT') await page.autocompleteSearch(selectors.itemTax.thirdClassAutocomplete, 'General VAT');
.autocompleteSearch(selectors.itemTax.thirdClassAutocomplete, 'General VAT') await page.waitToClick(selectors.itemTax.submitTaxButton);
.waitToClick(selectors.itemTax.submitTaxButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the first item tax class was edited`, async() => { it(`should confirm the first item tax class was edited`, async() => {
const firstVatType = await nightmare await page.reloadSection('item.card.tax');
.reloadSection('item.card.tax') const firstVatType = await page.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
expect(firstVatType).toEqual('General VAT'); expect(firstVatType).toEqual('General VAT');
}); });
it(`should confirm the second item tax class was edited`, async() => { it(`should confirm the second item tax class was edited`, async() => {
const secondVatType = await nightmare const secondVatType = await page
.waitToGetProperty(`${selectors.itemTax.secondClassAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemTax.secondClassAutocomplete} input`, 'value');
expect(secondVatType).toEqual('General VAT'); expect(secondVatType).toEqual('General VAT');
}); });
it(`should confirm the third item tax class was edited`, async() => { it(`should confirm the third item tax class was edited`, async() => {
const thirdVatType = await nightmare const thirdVatType = await page
.waitToGetProperty(`${selectors.itemTax.thirdClassAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemTax.thirdClassAutocomplete} input`, 'value');
expect(thirdVatType).toEqual('General VAT'); expect(thirdVatType).toEqual('General VAT');
}); });
it(`should edit the first class without saving the form`, async() => { it(`should edit the first class without saving the form`, async() => {
const firstVatType = await nightmare await page.autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'Reduced VAT');
.autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'Reduced VAT') const firstVatType = await page.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
expect(firstVatType).toEqual('Reduced VAT'); expect(firstVatType).toEqual('Reduced VAT');
}); });
it(`should now click the undo changes button and see the changes works`, async() => { it(`should now click the undo changes button and see the changes works`, async() => {
const firstVatType = await nightmare await page.waitToClick(selectors.itemTax.undoChangesButton);
.waitToClick(selectors.itemTax.undoChangesButton) const firstVatType = await page.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
expect(firstVatType).toEqual('General VAT'); expect(firstVatType).toEqual('General VAT');
}); });

View File

@ -1,58 +1,59 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item create tags path', () => { describe('Item create tags path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.tags');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon longbow 2m')
.accessToSection('item.card.tags');
}); });
it(`should create a new tag and delete a former one`, async() => { it(`should create a new tag and delete a former one`, async() => {
const result = await nightmare await page.waitToClick(selectors.itemTags.fourthRemoveTagButton);
.waitToClick(selectors.itemTags.fourthRemoveTagButton) await page.waitToClick(selectors.itemTags.addItemTagButton);
.waitToClick(selectors.itemTags.addItemTagButton) await page.autocompleteSearch(selectors.itemTags.seventhTagAutocomplete, 'Ancho de la base');
.autocompleteSearch(selectors.itemTags.seventhTagAutocomplete, 'Ancho de la base') await page.write(selectors.itemTags.seventhValueInput, '50');
.write(selectors.itemTags.seventhValueInput, '50') await page.clearInput(selectors.itemTags.seventhRelevancyInput);
.clearInput(selectors.itemTags.seventhRelevancyInput) await page.write(selectors.itemTags.seventhRelevancyInput, '4');
.write(selectors.itemTags.seventhRelevancyInput, '4') await page.waitToClick(selectors.itemTags.submitItemTagsButton);
.waitToClick(selectors.itemTags.submitItemTagsButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the fourth row data is the expected one`, async() => { it(`should confirm the fourth row data is the expected one`, async() => {
let result = await nightmare await page.reloadSection('item.card.tags');
.reloadSection('item.card.tags') await page.wait('vn-item-tags');
.wait('vn-item-tags') let result = await page.waitToGetProperty(`${selectors.itemTags.fourthTagAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.itemTags.fourthTagAutocomplete} input`, 'value');
expect(result).toEqual('Ancho de la base'); expect(result).toEqual('Ancho de la base');
result = await nightmare result = await page
.waitToGetProperty(selectors.itemTags.fourthValueInput, 'value'); .waitToGetProperty(`${selectors.itemTags.fourthValueInput} input`, 'value');
expect(result).toEqual('50'); expect(result).toEqual('50');
result = await nightmare result = await page
.waitToGetProperty(selectors.itemTags.fourthRelevancyInput, 'value'); .waitToGetProperty(`${selectors.itemTags.fourthRelevancyInput} input`, 'value');
expect(result).toEqual('4'); expect(result).toEqual('4');
}); });
it(`should confirm the fifth row data is the expected one`, async() => { it(`should confirm the fifth row data is the expected one`, async() => {
let tag = await nightmare let tag = await page
.waitToGetProperty(`${selectors.itemTags.fifthTagAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemTags.fifthTagAutocomplete} input`, 'value');
let value = await nightmare let value = await page
.waitToGetProperty(selectors.itemTags.fifthValueInput, 'value'); .waitToGetProperty(`${selectors.itemTags.fifthValueInput} input`, 'value');
let relevancy = await nightmare let relevancy = await page
.waitToGetProperty(selectors.itemTags.fifthRelevancyInput, 'value'); .waitToGetProperty(`${selectors.itemTags.fifthRelevancyInput} input`, 'value');
expect(tag).toEqual('Color'); expect(tag).toEqual('Color');
expect(value).toEqual('Brown'); expect(value).toEqual('Brown');
@ -60,14 +61,14 @@ describe('Item create tags path', () => {
}); });
it(`should confirm the sixth row data is the expected one`, async() => { it(`should confirm the sixth row data is the expected one`, async() => {
let tag = await nightmare let tag = await page
.waitToGetProperty(`${selectors.itemTags.sixthTagAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemTags.sixthTagAutocomplete} input`, 'value');
let value = await nightmare let value = await page
.waitToGetProperty(selectors.itemTags.sixthValueInput, 'value'); .waitToGetProperty(`${selectors.itemTags.sixthValueInput} input`, 'value');
let relevancy = await nightmare let relevancy = await page
.waitToGetProperty(selectors.itemTags.sixthRelevancyInput, 'value'); .waitToGetProperty(`${selectors.itemTags.sixthRelevancyInput} input`, 'value');
expect(tag).toEqual('Categoria'); expect(tag).toEqual('Categoria');
expect(value).toEqual('+1 precission'); expect(value).toEqual('+1 precission');

View File

@ -1,61 +1,63 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item create niche path', () => { describe('Item create niche path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.niche');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon longbow 2m')
.accessToSection('item.card.niche');
}); });
it(`should click create a new niche and delete a former one`, async() => { it(`should click create a new niche and delete a former one`, async() => {
const result = await nightmare await page.waitForTextInInput(selectors.itemNiches.firstWarehouseAutocomplete, 'Warehouse One');
.waitForTextInInput(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'Warehouse One') await page.waitToClick(selectors.itemNiches.addNicheButton);
.waitToClick(selectors.itemNiches.addNicheButton) await page.waitToClick(selectors.itemNiches.secondNicheRemoveButton);
.waitToClick(selectors.itemNiches.secondNicheRemoveButton) await page.autocompleteSearch(selectors.itemNiches.thirdWarehouseAutocomplete, 'Warehouse Two');
.autocompleteSearch(selectors.itemNiches.thirdWarehouseAutocomplete, 'Warehouse Two') await page.write(selectors.itemNiches.thirdCodeInput, 'A4');
.write(selectors.itemNiches.thirdCodeInput, 'A4') await page.waitToClick(selectors.itemNiches.submitNichesButton);
.waitToClick(selectors.itemNiches.submitNichesButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the first niche is the expected one`, async() => { it(`should confirm the first niche is the expected one`, async() => {
let result = await nightmare await page.reloadSection('item.card.niche');
.reloadSection('item.card.niche') await page.waitForTextInInput(selectors.itemNiches.firstWarehouseAutocomplete, 'Warehouse One');
.waitForTextInInput(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'Warehouse One') let result = await page
.waitToGetProperty(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse One'); expect(result).toEqual('Warehouse One');
result = await nightmare
.waitToGetProperty(selectors.itemNiches.firstCodeInput, 'value'); result = await page
.waitToGetProperty(`${selectors.itemNiches.firstCodeInput} input`, 'value');
expect(result).toEqual('A1'); expect(result).toEqual('A1');
}); });
it(`should confirm the second niche is the expected one`, async() => { it(`should confirm the second niche is the expected one`, async() => {
let result = await nightmare let result = await page
.waitToGetProperty(`${selectors.itemNiches.secondWarehouseAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemNiches.secondWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse Three'); expect(result).toEqual('Warehouse Three');
result = await nightmare result = await page
.waitToGetProperty(selectors.itemNiches.secondCodeInput, 'value'); .waitToGetProperty(`${selectors.itemNiches.secondCodeInput} input`, 'value');
expect(result).toEqual('A3'); expect(result).toEqual('A3');
}); });
it(`should confirm the third niche is the expected one`, async() => { it(`should confirm the third niche is the expected one`, async() => {
let result = await nightmare let result = await page
.waitToGetProperty(`${selectors.itemNiches.thirdWarehouseAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemNiches.thirdWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse Two'); expect(result).toEqual('Warehouse Two');
result = await nightmare result = await page
.waitToGetProperty(selectors.itemNiches.thirdCodeInput, 'value'); .waitToGetProperty(`${selectors.itemNiches.thirdCodeInput} input`, 'value');
expect(result).toEqual('A4'); expect(result).toEqual('A4');
}); });

View File

@ -1,82 +1,83 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item Create botanical path', () => { describe('Item Create botanical path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.accessToSection('item.card.botanical');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon pistol 9mm')
.accessToSection('item.card.botanical');
}); });
it(`should create a new botanical for the item`, async() => { it(`should create a new botanical for the item`, async() => {
const result = await nightmare await page.write(selectors.itemBotanical.botanicalInput, 'Cicuta maculata');
.write(selectors.itemBotanical.botanicalInput, 'Cicuta maculata') await page.autocompleteSearch(selectors.itemBotanical.genusAutocomplete, 'Abelia');
.autocompleteSearch(selectors.itemBotanical.genusAutocomplete, 'Abelia') await page.autocompleteSearch(selectors.itemBotanical.speciesAutocomplete, 'dealbata');
.autocompleteSearch(selectors.itemBotanical.speciesAutocomplete, 'dealbata') await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
.waitToClick(selectors.itemBotanical.submitBotanicalButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the botanical for the item was created`, async() => { it(`should confirm the botanical for the item was created`, async() => {
const result = await nightmare await page.reloadSection('item.card.botanical');
.reloadSection('item.card.botanical') await page.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata');
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata') const result = await page
.waitToGetProperty(selectors.itemBotanical.botanicalInput, 'value'); .waitToGetProperty(`${selectors.itemBotanical.botanicalInput} input`, 'value');
expect(result).toEqual('Cicuta maculata'); expect(result).toEqual('Cicuta maculata');
}); });
it(`should confirm the Genus for the item was created`, async() => { it(`should confirm the Genus for the item was created`, async() => {
const result = await nightmare await page.waitForTextInInput(selectors.itemBotanical.genusAutocomplete, 'Abelia');
.waitForTextInInput(`${selectors.itemBotanical.genusAutocomplete} input`, 'Abelia') const result = await page
.waitToGetProperty(`${selectors.itemBotanical.genusAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBotanical.genusAutocomplete} input`, 'value');
expect(result).toEqual('Abelia'); expect(result).toEqual('Abelia');
}); });
it(`should confirm the Species for the item was created`, async() => { it(`should confirm the Species for the item was created`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.itemBotanical.speciesAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBotanical.speciesAutocomplete} input`, 'value');
expect(result).toEqual('dealbata'); expect(result).toEqual('dealbata');
}); });
it(`should edit botanical for the item`, async() => { it(`should edit botanical for the item`, async() => {
const result = await nightmare await page.clearInput(selectors.itemBotanical.botanicalInput);
.clearInput(selectors.itemBotanical.botanicalInput) await page.write(selectors.itemBotanical.botanicalInput, 'Herp Derp');
.write(selectors.itemBotanical.botanicalInput, 'Herp Derp') await page.autocompleteSearch(selectors.itemBotanical.genusAutocomplete, 'Abies');
.autocompleteSearch(selectors.itemBotanical.genusAutocomplete, 'Abies') await page.autocompleteSearch(selectors.itemBotanical.speciesAutocomplete, 'decurrens');
.autocompleteSearch(selectors.itemBotanical.speciesAutocomplete, 'decurrens') await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
.waitToClick(selectors.itemBotanical.submitBotanicalButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the botanical for the item was edited`, async() => { it(`should confirm the botanical for the item was edited`, async() => {
const result = await nightmare await page.reloadSection('item.card.botanical');
.reloadSection('item.card.botanical') await page.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp');
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp') const result = await page
.waitToGetProperty(selectors.itemBotanical.botanicalInput, 'value'); .waitToGetProperty(`${selectors.itemBotanical.botanicalInput} input`, 'value');
expect(result).toEqual('Herp Derp'); expect(result).toEqual('Herp Derp');
}); });
it(`should confirm the Genus for the item was edited`, async() => { it(`should confirm the Genus for the item was edited`, async() => {
const result = await nightmare await page.waitForTextInInput(selectors.itemBotanical.genusAutocomplete, 'Abies');
.waitForTextInInput(`${selectors.itemBotanical.genusAutocomplete} input`, 'Abies') const result = await page
.waitToGetProperty(`${selectors.itemBotanical.genusAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBotanical.genusAutocomplete} input`, 'value');
expect(result).toEqual('Abies'); expect(result).toEqual('Abies');
}); });
it(`should confirm the Species for the item was edited`, async() => { it(`should confirm the Species for the item was edited`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.itemBotanical.speciesAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBotanical.speciesAutocomplete} input`, 'value');
expect(result).toEqual('decurrens'); expect(result).toEqual('decurrens');

View File

@ -1,32 +1,34 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item Create barcodes path', () => { describe('Item Create barcodes path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.itemBarcode');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon longbow 2m')
.accessToSection('item.card.itemBarcode');
}); });
it(`should click create a new code and delete a former one`, async() => { it(`should click create a new code and delete a former one`, async() => {
const result = await nightmare await page.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton);
.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton) await page.waitToClick(selectors.itemBarcodes.addBarcodeButton);
.waitToClick(selectors.itemBarcodes.addBarcodeButton) await page.write(selectors.itemBarcodes.thirdCodeInput, '5');
.write(selectors.itemBarcodes.thirdCodeInput, '5') await page.waitToClick(selectors.itemBarcodes.submitBarcodesButton);
.waitToClick(selectors.itemBarcodes.submitBarcodesButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async() => { it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async() => {
const result = await nightmare await page.reloadSection('item.card.itemBarcode');
.reloadSection('item.card.itemBarcode') await page.waitForTextInInput(selectors.itemBarcodes.thirdCodeInput, '5');
.waitForTextInInput(selectors.itemBarcodes.thirdCodeInput, '5') const result = await page
.waitToGetProperty(selectors.itemBarcodes.thirdCodeInput, 'value'); .waitToGetProperty(`${selectors.itemBarcodes.thirdCodeInput} input`, 'value');
expect(result).toEqual('5'); expect(result).toEqual('5');
}); });

View File

@ -1,82 +1,81 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item Create/Clone path', () => { describe('Item Create/Clone path', () => {
const nightmare = createNightmare(); let page;
describe('create', () => { beforeAll(async() => {
beforeAll(() => { page = await openPage();
nightmare await page.loginAndModule('buyer', 'item');
.loginAndModule('buyer', 'item'); });
});
afterAll(async() => {
page.close();
});
describe('create', () => {
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
const result = await nightmare await page.clearInput(selectors.itemsIndex.searchItemInput);
.clearInput(selectors.itemsIndex.searchItemInput) await page.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet');
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) const result = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0); expect(result).toEqual(0);
}); });
it('should access to the create item view by clicking the create floating button', async() => { it('should access to the create item view by clicking the create floating button', async() => {
const url = await nightmare await page.waitToClick(selectors.itemsIndex.createItemButton);
.waitToClick(selectors.itemsIndex.createItemButton) await page.wait(selectors.itemCreateView.createButton);
.wait(selectors.itemCreateView.createButton) const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toEqual('#!/item/create'); expect(url.hash).toEqual('#!/item/create');
}); });
it('should return to the item index by clickig the cancel button', async() => { it('should return to the item index by clickig the cancel button', async() => {
const url = await nightmare await page.waitToClick(selectors.itemCreateView.cancelButton);
.waitToClick(selectors.itemCreateView.cancelButton) await page.wait(selectors.itemsIndex.createItemButton);
.wait(selectors.itemsIndex.createItemButton) const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toEqual('#!/item/index'); expect(url.hash).toEqual('#!/item/index');
}); });
it('should now access to the create item view by clicking the create floating button', async() => { it('should now access to the create item view by clicking the create floating button', async() => {
const url = await nightmare await page.waitToClick(selectors.itemsIndex.createItemButton);
.waitToClick(selectors.itemsIndex.createItemButton) await page.wait(selectors.itemCreateView.createButton);
.wait(selectors.itemCreateView.createButton) const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toEqual('#!/item/create'); expect(url.hash).toEqual('#!/item/create');
}); });
it('should create the Infinity Gauntlet item', async() => { it('should create the Infinity Gauntlet item', async() => {
const result = await nightmare await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet') await page.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo');
.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo') await page.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares');
.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares') await page.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand');
.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand') await page.waitToClick(selectors.itemCreateView.createButton);
.waitToClick(selectors.itemCreateView.createButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm Infinity Gauntlet item was created', async() => { it('should confirm Infinity Gauntlet item was created', async() => {
let result = await nightmare let result = await page
.waitToGetProperty(selectors.itemBasicData.nameInput, 'value'); .waitToGetProperty(`${selectors.itemBasicData.nameInput} input`, 'value');
expect(result).toEqual('Infinity Gauntlet'); expect(result).toEqual('Infinity Gauntlet');
result = await nightmare result = await page
.waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value');
expect(result).toEqual('Crisantemo'); expect(result).toEqual('Crisantemo');
result = await nightmare result = await page
.waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, 'value');
expect(result).toEqual('5080000 Coral y materiales similares'); expect(result).toEqual('5080000 Coral y materiales similares');
result = await nightmare result = await page
.waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, 'value');
expect(result).toEqual('Holand'); expect(result).toEqual('Holand');
@ -85,45 +84,41 @@ describe('Item Create/Clone path', () => {
describe('clone', () => { describe('clone', () => {
it('should return to the items index by clicking the return to items button', async() => { it('should return to the items index by clicking the return to items button', async() => {
const url = await nightmare await page.waitToClick(selectors.itemBasicData.goToItemIndexButton);
.waitToClick(selectors.itemBasicData.goToItemIndexButton) await page.wait(selectors.itemsIndex.createItemButton);
.wait(selectors.itemsIndex.createItemButton) await page.waitForURL('#!/item/index');
.waitForURL('#!/item/index') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('#!/item/index'); expect(url.hash).toContain('#!/item/index');
}); });
it(`should search for the item Infinity Gauntlet`, async() => { it(`should search for the item Infinity Gauntlet`, async() => {
const result = await nightmare await page.clearInput(selectors.itemsIndex.searchItemInput);
.clearInput(selectors.itemsIndex.searchItemInput) await page.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet');
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) const result = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(1);
}); });
it(`should clone the Infinity Gauntlet`, async() => { it(`should clone the Infinity Gauntlet`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet');
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') await page.waitToClick(selectors.itemsIndex.searchResultCloneButton);
.waitToClick(selectors.itemsIndex.searchResultCloneButton) await page.waitToClick(selectors.itemsIndex.acceptClonationAlertButton);
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton) await page.waitForURL('tags');
.waitForURL('tags') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('tags'); expect(url.hash).toContain('tags');
}); });
it('should search for the item Infinity Gauntlet and find two', async() => { it('should search for the item Infinity Gauntlet and find two', async() => {
const result = await nightmare await page.waitToClick(selectors.itemTags.goToItemIndexButton);
.waitToClick(selectors.itemTags.goToItemIndexButton) await page.clearInput(selectors.itemsIndex.searchItemInput);
.clearInput(selectors.itemsIndex.searchItemInput) await page.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet');
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) const result = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2); expect(result).toEqual(2);
}); });

View File

@ -1,206 +1,201 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item regularize path', () => { describe('Item regularize path', () => {
const nightmare = createNightmare(); let page;
beforeAll(() => { beforeAll(async() => {
nightmare page = await openPage();
.loginAndModule('employee', 'item'); await page.loginAndModule('employee', 'item');
}); });
afterAll(async() => {
page.close();
});
it('should edit the user local warehouse', async() => { it('should edit the user local warehouse', async() => {
let result = await nightmare await page.waitForSpinnerLoad();
.waitForSpinnerLoad() await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton) await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four') const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should open the user config form to check the local settings', async() => { it('should open the user config form to check the local settings', async() => {
let userLocalWarehouse = await nightmare await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton) const userLocalWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
expect(userLocalWarehouse).toContain('Warehouse Four'); expect(userLocalWarehouse).toContain('Warehouse Four');
}); });
it('should search for an item', async() => { it('should search for an specific item', async() => {
const resultCount = await nightmare await page.clearInput(selectors.itemsIndex.searchItemInput);
.clearInput(selectors.itemsIndex.searchItemInput) await page.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm');
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) const resultCount = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the item tax`, async() => { it(`should click on the search result to access to the item tax`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm');
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm') await page.waitToClick(selectors.itemsIndex.searchResult);
.waitToClick(selectors.itemsIndex.searchResult) await page.waitForURL('/summary');
.waitForURL('/summary') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/summary'); expect(url.hash).toContain('/summary');
}); });
it('should open the regularize dialog and check the warehouse matches the local user settings', async() => { it('should open the regularize dialog and check the warehouse matches the local user settings', async() => {
const result = await nightmare await page.waitToClick(selectors.itemDescriptor.moreMenu);
.waitToClick(selectors.itemDescriptor.moreMenu) await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton) const result = await page.waitToGetProperty(`${selectors.itemDescriptor.regularizeWarehouseAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.itemDescriptor.regularizeWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse Four'); expect(result).toEqual('Warehouse Four');
}); });
it('should regularize the item', async() => { it('should regularize the item', async() => {
const result = await nightmare await page.write(selectors.itemDescriptor.regularizeQuantityInput, '100');
.write(selectors.itemDescriptor.regularizeQuantityInput, 100) await page.wait(1000); // time for autocomplete to load
.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One') await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One');
.waitToClick(selectors.itemDescriptor.regularizeSaveButton) await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
.waitForLastSnackbar(); const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should click on the Tickets button of the top bar menu', async() => { it('should click on the Tickets button of the top bar menu', async() => {
const url = await nightmare await page.waitToClick(selectors.globalItems.applicationsMenuButton);
.waitToClick(selectors.globalItems.applicationsMenuButton) await page.wait(selectors.globalItems.applicationsMenuVisible);
.wait(selectors.globalItems.applicationsMenuVisible) await Promise.all([
.waitToClick(selectors.globalItems.ticketsButton) page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
.wait(selectors.ticketsIndex.searchTicketInput) page.waitToClick(selectors.globalItems.ticketsButton)
.parsedUrl(); ]);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index'); expect(url.hash).toEqual('#!/ticket/index');
}); });
it('should clear the user local settings now', async() => { it('should clear the user local settings now', async() => {
let result = await nightmare await page.waitForTransitionEnd('vn-searchbar');
.waitToClick(selectors.globalItems.userMenuButton) await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userConfigFirstAutocompleteClear) await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
.waitForLastSnackbar(); const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should search for the ticket with alias missing', async() => { it('should search for the ticket with alias missing', async() => {
const result = await nightmare await page.keyboard.press('Escape');
.write(selectors.ticketsIndex.searchTicketInput, 'missing') await page.waitForTransitionEnd('.vn-popover');
.waitToClick(selectors.ticketsIndex.searchButton) await page.write(selectors.ticketsIndex.searchTicketInput, 'missing');
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) await page.waitToClick(selectors.ticketsIndex.searchButton);
.countElement(selectors.ticketsIndex.searchResult); await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(1);
}); });
it(`should click on the search result to access to the ticket summary`, async() => { it(`should click on the search result to access to the ticket summary`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Missing');
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Missing') await page.waitToClick(selectors.ticketsIndex.searchResult);
.waitToClick(selectors.ticketsIndex.searchResult) await page.waitForURL('/summary');
.waitForURL('/summary') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/summary'); expect(url.hash).toContain('/summary');
}); });
it(`should check the ticket sale quantity is showing a negative value`, async() => { it(`should check the ticket sale quantity is showing a negative value`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100') const result = await page
.waitToGetProperty(selectors.ticketSummary.firstSaleQuantity, 'innerText'); .waitToGetProperty(selectors.ticketSummary.firstSaleQuantity, 'innerText');
expect(result).toContain('-100'); expect(result).toContain('-100');
}); });
it(`should check the ticket sale discount is 100%`, async() => { it(`should check the ticket sale discount is 100%`, async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.ticketSummary.firstSaleDiscount, 'innerText'); .waitToGetProperty(selectors.ticketSummary.firstSaleDiscount, 'innerText');
expect(result).toContain('100 %'); expect(result).toContain('100 %');
}); });
it('should now click on the Items button of the top bar menu', async() => { it('should now click on the Items button of the top bar menu', async() => {
const url = await nightmare await page.waitToClick(selectors.globalItems.applicationsMenuButton);
.waitToClick(selectors.globalItems.applicationsMenuButton) await page.wait(selectors.globalItems.applicationsMenuVisible);
.wait(selectors.globalItems.applicationsMenuVisible) await page.waitToClick(selectors.globalItems.itemsButton);
.waitToClick(selectors.globalItems.itemsButton) await page.wait(selectors.itemsIndex.searchItemInput);
.wait(selectors.itemsIndex.searchItemInput) const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toEqual('#!/item/index'); expect(url.hash).toEqual('#!/item/index');
}); });
it('should search for the item once again', async() => { it('should search for the item once again', async() => {
const resultCount = await nightmare await page.clearInput(selectors.itemsIndex.searchItemInput);
.clearInput(selectors.itemsIndex.searchItemInput) await page.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm');
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) const resultCount = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the item tax`, async() => { it(`should click on the search result to access to the item tax`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm');
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm') await page.waitToClick(selectors.itemsIndex.searchResult);
.waitToClick(selectors.itemsIndex.searchResult) await page.waitForURL('/summary');
.waitForURL('/summary') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/summary'); expect(url.hash).toContain('/summary');
}); });
it('should regularize the item once more', async() => { it('should regularize the item once more', async() => {
const result = await nightmare await page.waitToClick(selectors.itemDescriptor.moreMenu);
.waitToClick(selectors.itemDescriptor.moreMenu) await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton) await page.write(selectors.itemDescriptor.regularizeQuantityInput, '100');
.write(selectors.itemDescriptor.regularizeQuantityInput, 100) await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One');
.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One') await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
.waitToClick(selectors.itemDescriptor.regularizeSaveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should again click on the Tickets button of the top bar menu', async() => { it('should again click on the Tickets button of the top bar menu', async() => {
const url = await nightmare await page.waitToClick(selectors.globalItems.applicationsMenuButton);
.waitToClick(selectors.globalItems.applicationsMenuButton) await page.wait(selectors.globalItems.applicationsMenuVisible);
.wait(selectors.globalItems.applicationsMenuVisible) await Promise.all([
.waitToClick(selectors.globalItems.ticketsButton) page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
.wait(selectors.ticketsIndex.searchTicketInput) page.waitToClick(selectors.globalItems.ticketsButton)
.parsedUrl(); ]);
await page.waitForTransitionEnd('vn-searchbar');
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index'); expect(url.hash).toEqual('#!/ticket/index');
}); });
it('should search for the ticket with id 25 once again', async() => { it('should search for the ticket with id 25 once again', async() => {
const result = await nightmare await page.write(selectors.ticketsIndex.searchTicketInput, '25');
.write(selectors.ticketsIndex.searchTicketInput, 25) await page.waitToClick(selectors.ticketsIndex.searchButton);
.waitToClick(selectors.ticketsIndex.searchButton) await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) const result = await page.countElement(selectors.ticketsIndex.searchResult);
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1); expect(result).toEqual(1);
}); });
it(`should now click on the search result to access to the ticket summary`, async() => { it(`should now click on the search result to access to the ticket summary`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.ticketsIndex.searchResult, '25');
.waitForTextInElement(selectors.ticketsIndex.searchResult, '25') await page.waitToClick(selectors.ticketsIndex.searchResult);
.waitToClick(selectors.ticketsIndex.searchResult) await page.waitForURL('/summary');
.waitForURL('/summary') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/summary'); expect(url.hash).toContain('/summary');
}); });
it(`should check the ticket contains now two sales`, async() => { it(`should check the ticket contains now two sales`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100') const result = await page.countElement(selectors.ticketSummary.sale);
.countElement(selectors.ticketSummary.sale);
expect(result).toEqual(2); expect(result).toEqual(2);
}); });

View File

@ -1,86 +1,84 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item index path', () => { describe('Item index path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('salesPerson', 'item');
await page.waitToClick(selectors.itemsIndex.searchIcon);
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('salesPerson', 'item')
.waitToClick(selectors.itemsIndex.searchIcon);
}); });
it('should click on the fields to show button to open the list of columns to show', async() => { it('should click on the fields to show button to open the list of columns to show', async() => {
const visible = await nightmare await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
.waitToClick(selectors.itemsIndex.fieldsToShowButton) const visible = await page.isVisible(selectors.itemsIndex.fieldsToShowForm);
.isVisible(selectors.itemsIndex.fieldsToShowForm);
expect(visible).toBeTruthy(); expect(visible).toBeTruthy();
}); });
it('should unmark all checkboxes except the first and the last ones', async() => { it('should unmark all checkboxes except the first and the last ones', async() => {
const result = await nightmare await page.waitToClick(selectors.itemsIndex.idCheckbox);
.waitToClick(selectors.itemsIndex.idCheckbox) await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
.waitToClick(selectors.itemsIndex.stemsCheckbox) await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
.waitToClick(selectors.itemsIndex.sizeCheckbox) await page.waitToClick(selectors.itemsIndex.nicheCheckbox);
.waitToClick(selectors.itemsIndex.nicheCheckbox) await page.waitToClick(selectors.itemsIndex.typeCheckbox);
.waitToClick(selectors.itemsIndex.typeCheckbox) await page.waitToClick(selectors.itemsIndex.categoryCheckbox);
.waitToClick(selectors.itemsIndex.categoryCheckbox) await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
.waitToClick(selectors.itemsIndex.intrastadCheckbox) await page.waitToClick(selectors.itemsIndex.originCheckbox);
.waitToClick(selectors.itemsIndex.originCheckbox) await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
.waitToClick(selectors.itemsIndex.buyerCheckbox) await page.waitToClick(selectors.itemsIndex.destinyCheckbox);
.waitToClick(selectors.itemsIndex.destinyCheckbox) await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
.waitToClick(selectors.itemsIndex.saveFieldsButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should navigate forth and back to see the images column is still visible', async() => { it('should navigate forth and back to see the images column is still visible', async() => {
const imageVisible = await nightmare await page.waitToClick(selectors.itemsIndex.searchResult);
.waitToClick(selectors.itemsIndex.searchResult) await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton) await page.waitToClick(selectors.itemsIndex.searchIcon);
.waitToClick(selectors.itemsIndex.searchIcon) await page.wait(selectors.itemsIndex.searchResult);
.wait(selectors.itemsIndex.searchResult) await page.waitImgLoad(selectors.itemsIndex.firstItemImage);
.waitImgLoad(selectors.itemsIndex.firstItemImage) const imageVisible = await page.isVisible(selectors.itemsIndex.firstItemImageTd);
.isVisible(selectors.itemsIndex.firstItemImageTd);
expect(imageVisible).toBeTruthy(); expect(imageVisible).toBeTruthy();
}); });
it('should check the ids column is not visible', async() => { it('should check the ids column is not visible', async() => {
const idVisible = await nightmare const idVisible = await page
.isVisible(selectors.itemsIndex.firstItemId); .isVisible(selectors.itemsIndex.firstItemId);
expect(idVisible).toBeFalsy(); expect(idVisible).toBeFalsy();
}); });
it('should mark all unchecked boxes to leave the index as it was', async() => { it('should mark all unchecked boxes to leave the index as it was', async() => {
const result = await nightmare await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
.waitToClick(selectors.itemsIndex.fieldsToShowButton) await page.waitToClick(selectors.itemsIndex.idCheckbox);
.waitToClick(selectors.itemsIndex.idCheckbox) await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
.waitToClick(selectors.itemsIndex.stemsCheckbox) await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
.waitToClick(selectors.itemsIndex.sizeCheckbox) await page.waitToClick(selectors.itemsIndex.nicheCheckbox);
.waitToClick(selectors.itemsIndex.nicheCheckbox) await page.waitToClick(selectors.itemsIndex.typeCheckbox);
.waitToClick(selectors.itemsIndex.typeCheckbox) await page.waitToClick(selectors.itemsIndex.categoryCheckbox);
.waitToClick(selectors.itemsIndex.categoryCheckbox) await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
.waitToClick(selectors.itemsIndex.intrastadCheckbox) await page.waitToClick(selectors.itemsIndex.originCheckbox);
.waitToClick(selectors.itemsIndex.originCheckbox) await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
.waitToClick(selectors.itemsIndex.buyerCheckbox) await page.waitToClick(selectors.itemsIndex.destinyCheckbox);
.waitToClick(selectors.itemsIndex.destinyCheckbox) await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
.waitToClick(selectors.itemsIndex.saveFieldsButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should now navigate forth and back to see the ids column is now visible', async() => { it('should now navigate forth and back to see the ids column is now visible', async() => {
const idVisible = await nightmare await page.waitToClick(selectors.itemsIndex.searchResult);
.waitToClick(selectors.itemsIndex.searchResult) await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton) await page.waitToClick(selectors.itemsIndex.searchIcon);
.waitToClick(selectors.itemsIndex.searchIcon) await page.wait(selectors.itemsIndex.searchResult);
.wait(selectors.itemsIndex.searchResult) const idVisible = await page.isVisible(selectors.itemsIndex.firstItemId);
.isVisible(selectors.itemsIndex.firstItemId);
expect(idVisible).toBeTruthy(); expect(idVisible).toBeTruthy();
}); });

View File

@ -1,74 +1,72 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item log path', () => { describe('Item log path', () => {
const nightmare = createNightmare(); let page;
beforeAll(() => { beforeAll(async() => {
nightmare page = await openPage();
.loginAndModule('developer', 'item'); await page.loginAndModule('developer', 'item');
});
afterAll(async() => {
page.close();
}); });
it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => { it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => {
const result = await nightmare await page.write(selectors.itemsIndex.searchItemInput, 'Knowledge artifact');
.write(selectors.itemsIndex.searchItemInput, 'Knowledge artifact') await page.waitToClick(selectors.itemsIndex.searchButton);
.waitToClick(selectors.itemsIndex.searchButton) await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0);
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) const result = await page.countElement(selectors.itemsIndex.searchResult);
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0); expect(result).toEqual(0);
}); });
it('should access to the create item view by clicking the create floating button', async() => { it('should access to the create item view by clicking the create floating button', async() => {
const url = await nightmare await page.waitToClick(selectors.itemsIndex.createItemButton);
.waitToClick(selectors.itemsIndex.createItemButton) await page.wait(selectors.itemCreateView.createButton);
.wait(selectors.itemCreateView.createButton) const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toEqual('#!/item/create'); expect(url.hash).toEqual('#!/item/create');
}); });
it('should create the Knowledge artifact item', async() => { it('should create the Knowledge artifact item', async() => {
const result = await nightmare await page.write(selectors.itemCreateView.temporalName, 'Knowledge artifact');
.write(selectors.itemCreateView.temporalName, 'Knowledge artifact') await page.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo');
.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo') await page.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares');
.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares') await page.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand');
.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand') await page.waitToClick(selectors.itemCreateView.createButton);
.waitToClick(selectors.itemCreateView.createButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should return to the items index by clicking the return to items button', async() => { it('should return to the items index by clicking the return to items button', async() => {
const url = await nightmare await page.waitToClick(selectors.itemBasicData.goToItemIndexButton);
.waitToClick(selectors.itemBasicData.goToItemIndexButton) await page.wait(selectors.itemsIndex.createItemButton);
.wait(selectors.itemsIndex.createItemButton) await page.waitForURL('#!/item/index');
.waitForURL('#!/item/index') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('#!/item/index'); expect(url.hash).toContain('#!/item/index');
}); });
it(`should search for the created item and navigate to it's log section`, async() => { it(`should search for the created item and navigate to it's log section`, async() => {
const url = await nightmare await page.accessToSearchResult('Knowledge artifact');
.accessToSearchResult('Knowledge artifact') await page.accessToSection('item.card.log');
.accessToSection('item.card.log') await page.waitForURL('/log');
.waitForURL('/log') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/log'); expect(url.hash).toContain('/log');
}); });
it(`should confirm the log is showing 5 entries`, async() => { it(`should confirm the log is showing 5 entries`, async() => {
const anyLineCreatedCount = await nightmare await page.wait(selectors.itemLog.anyLineCreated);
.wait(selectors.itemLog.anyLineCreated) const anyLineCreatedCount = await page.countElement(selectors.itemLog.anyLineCreated);
.countElement(selectors.itemLog.anyLineCreated);
expect(anyLineCreatedCount).toEqual(5); expect(anyLineCreatedCount).toEqual(5);
}); });
it(`should confirm the log is showing the intrastat for the created item`, async() => { it(`should confirm the log is showing the intrastat for the created item`, async() => {
const fifthLineCreatedProperty = await nightmare const fifthLineCreatedProperty = await page
.waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText'); .waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText');
expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares'); expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares');

View File

@ -1,47 +1,47 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import openPage from '../../helpers/puppeteer';
describe('Item descriptor path', () => { describe('Item descriptor path', () => {
const nightmare = createNightmare(); let page;
beforeAll(() => { beforeAll(async() => {
nightmare page = await openPage();
.loginAndModule('buyer', 'item') await page.loginAndModule('buyer', 'item');
.accessToSearchResult(1) await page.accessToSearchResult('1');
.accessToSection('item.card.basicData'); await page.accessToSection('item.card.basicData');
});
afterAll(async() => {
page.close();
}); });
it('should check the descriptor inactive icon is dark as the item is active', async() => { it('should check the descriptor inactive icon is dark as the item is active', async() => {
let darkIcon = await nightmare await page.wait(selectors.itemDescriptor.inactiveIcon);
.wait(selectors.itemDescriptor.inactiveIcon) await page.waitForClassNotPresent(selectors.itemDescriptor.inactiveIcon, 'bright');
.waitForClassNotPresent(selectors.itemDescriptor.inactiveIcon, 'bright') let darkIcon = await page.isVisible(selectors.itemDescriptor.inactiveIcon);
.isVisible(selectors.itemDescriptor.inactiveIcon);
expect(darkIcon).toBeTruthy(); expect(darkIcon).toBeTruthy();
}); });
it('should set the item to inactive', async() => { it('should set the item to inactive', async() => {
let result = await nightmare await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
.waitToClick(selectors.itemBasicData.isActiveCheckbox) await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
.waitToClick(selectors.itemBasicData.submitBasicDataButton) let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should reload the section and check the inactive icon is bright', async() => { it('should reload the section and check the inactive icon is bright', async() => {
let brightIcon = await nightmare await page.reloadSection('item.card.basicData');
.reloadSection('item.card.basicData') await page.waitForClassPresent(selectors.itemDescriptor.inactiveIcon, 'bright');
.waitForClassPresent(selectors.itemDescriptor.inactiveIcon, 'bright') let brightIcon = await page.isVisible(selectors.itemDescriptor.inactiveIcon);
.isVisible(selectors.itemDescriptor.inactiveIcon);
expect(brightIcon).toBeTruthy(); expect(brightIcon).toBeTruthy();
}); });
it('should set the item back to active', async() => { it('should set the item back to active', async() => {
let result = await nightmare await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
.waitToClick(selectors.itemBasicData.isActiveCheckbox) await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
.waitToClick(selectors.itemBasicData.submitBasicDataButton) let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });

4224
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,36 +10,35 @@
}, },
"dependencies": { "dependencies": {
"compression": "^1.7.3", "compression": "^1.7.3",
"electron": "^7.1.2",
"fs-extra": "^5.0.0", "fs-extra": "^5.0.0",
"helmet": "^3.21.1", "helmet": "^3.21.2",
"i18n": "^0.8.3", "i18n": "^0.8.4",
"loopback": "^3.26.0", "loopback": "^3.26.0",
"loopback-boot": "^2.27.1", "loopback-boot": "^2.27.1",
"loopback-component-explorer": "^6.3.1", "loopback-component-explorer": "^6.5.0",
"loopback-component-storage": "^3.6.1", "loopback-component-storage": "^3.6.3",
"loopback-connector-mysql": "^5.3.1", "loopback-connector-mysql": "^5.4.2",
"loopback-connector-remote": "^3.4.1", "loopback-connector-remote": "^3.4.1",
"loopback-context": "^3.4.0", "loopback-context": "^3.4.0",
"md5": "^2.2.1", "md5": "^2.2.1",
"object-diff": "0.0.4", "object-diff": "0.0.4",
"object.pick": "^1.3.0", "object.pick": "^1.3.0",
"request": "^2.88.0", "request": "^2.88.0",
"request-promise-native": "^1.0.7", "request-promise-native": "^1.0.8",
"require-yaml": "0.0.1", "require-yaml": "0.0.1",
"soap": "^0.26.0", "soap": "^0.26.0",
"strong-error-handler": "^2.3.2", "strong-error-handler": "^2.3.2",
"uuid": "^3.3.2", "uuid": "^3.3.3",
"vn-loopback": "file:./loopback", "vn-loopback": "file:./loopback",
"xml2js": "^0.4.19" "xml2js": "^0.4.23"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.6.0", "@babel/core": "^7.7.7",
"@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/polyfill": "^7.2.5", "@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.6.0", "@babel/preset-env": "^7.7.7",
"@babel/register": "^7.0.0", "@babel/register": "^7.7.7",
"angular-mocks": "^1.7.7", "angular-mocks": "^1.7.9",
"babel-jest": "^24.9.0", "babel-jest": "^24.9.0",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
@ -63,9 +62,9 @@
"gulp-yaml": "^1.0.1", "gulp-yaml": "^1.0.1",
"html-loader": "^0.4.5", "html-loader": "^0.4.5",
"html-loader-jest": "^0.2.1", "html-loader-jest": "^0.2.1",
"html-webpack-plugin": "^4.0.0-beta.5", "html-webpack-plugin": "^4.0.0-beta.11",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jasmine": "^3.4.0", "jasmine": "^3.5.0",
"jasmine-reporters": "^2.3.2", "jasmine-reporters": "^2.3.2",
"jasmine-spec-reporter": "^4.2.1", "jasmine-spec-reporter": "^4.2.1",
"jest": "^24.9.0", "jest": "^24.9.0",
@ -73,19 +72,18 @@
"json-loader": "^0.5.7", "json-loader": "^0.5.7",
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"minimist": "^1.2.0", "minimist": "^1.2.0",
"mysql2": "^1.6.5", "mysql2": "^1.7.0",
"nightmare": "^3.0.2", "node-sass": "^4.13.0",
"puppeteer": "^2.0.0", "nodemon": "^1.19.4",
"node-sass": "^4.9.3",
"nodemon": "^1.18.10",
"plugin-error": "^1.0.1", "plugin-error": "^1.0.1",
"puppeteer": "^2.0.0",
"raw-loader": "^1.0.0", "raw-loader": "^1.0.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.3.1",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"webpack": "^4.29.5", "webpack": "^4.41.5",
"webpack-cli": "^3.2.3", "webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.1.14", "webpack-dev-server": "^3.10.1",
"webpack-merge": "^4.2.1", "webpack-merge": "^4.2.2",
"yaml-loader": "^0.5.0" "yaml-loader": "^0.5.0"
}, },
"scripts": { "scripts": {