extensions refactor and item index e2e fix

This commit is contained in:
Carlos Jimenez Ruiz 2021-11-12 15:17:09 +01:00
parent aaed7c82f6
commit 906fce5ae3
7 changed files with 52 additions and 62 deletions

View File

@ -341,48 +341,32 @@ let actions = {
}, },
waitForTextInElement: async function(selector, text) { waitForTextInElement: async function(selector, text) {
const expectedText = text.toLowerCase(); await this.waitForFunction((selector, text) => {
return new Promise((resolve, reject) => { if (document.querySelector(selector)) {
let attempts = 0; const innerText = document.querySelector(selector).innerText.toLowerCase();
const interval = setInterval(async() => { const expectedText = text.toLowerCase();
const currentText = await this.evaluate(selector => { if (innerText.includes(expectedText))
return document.querySelector(selector).innerText.toLowerCase(); return innerText;
}, selector); }
}, {}, selector, text);
if (currentText === expectedText || attempts === 40) {
clearInterval(interval);
resolve(currentText);
}
attempts += 1;
}, 100);
}).then(result => {
return expect(result).toContain(expectedText);
});
}, },
waitForTextInField: async function(selector, text) { waitForTextInField: async function(selector, text) {
let builtSelector = await this.selectorFormater(selector); const builtSelector = await this.selectorFormater(selector);
await this.waitForSelector(builtSelector); const expectedValue = text.toLowerCase();
const expectedText = text.toLowerCase();
return new Promise((resolve, reject) => {
let attempts = 0;
const interval = setInterval(async() => {
const currentText = await this.evaluate(selector => {
return document.querySelector(selector).value.toLowerCase();
}, builtSelector);
if (currentText === expectedText || attempts === 40) { try {
clearInterval(interval); await this.waitForFunction((selector, text) => {
resolve(currentText); const element = document.querySelector(selector);
if (element) {
const value = element.value.toLowerCase();
if (value.includes(text))
return true;
} }
attempts += 1; }, {}, builtSelector, expectedValue);
}, 100); } catch (error) {
}).then(result => { throw new Error(`${text} wasn't the value of ${builtSelector}, ${error}`);
if (result === '') }
return expect(result).toEqual(expectedText);
return expect(result).toContain(expectedText);
});
}, },
selectorFormater: function(selector) { selectorFormater: function(selector) {

View File

@ -312,27 +312,26 @@ export default {
}, },
itemsIndex: { itemsIndex: {
createItemButton: `vn-float-button`, createItemButton: `vn-float-button`,
firstSearchResult: 'vn-item-index tr:nth-child(2)', firstSearchResult: 'vn-item-index tbody tr:nth-child(1)',
searchResult: 'vn-item-index tbody tr:not(.empty-rows)', searchResult: 'vn-item-index tbody tr:not(.empty-rows)',
firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]', firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]',
searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]', searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]',
acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]', acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]',
closeItemSummaryPreview: '.vn-popup.shown', closeItemSummaryPreview: '.vn-popup.shown',
fieldsToShowButton: 'vn-item-index vn-table > div > div > vn-icon-button[icon="more_vert"]', shownColumns: 'vn-item-index vn-button[id="shownColumns"]',
fieldsToShowForm: '.vn-popover.shown .content', shownColumnsList: '.vn-popover.shown .content',
firstItemImage: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1) > img', firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img',
firstItemImageTd: 'vn-item-index vn-table a:nth-child(1) vn-td:nth-child(1)', firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)',
firstItemId: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(2)', firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)',
idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(1) > vn-check', idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]',
stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(2) > vn-check', stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Stems"]',
sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check', sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Size"]',
typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(5) > vn-check', typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Type"]',
categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(6) > vn-check', categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Category"]',
intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(7) > vn-check', intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Intrastat"]',
originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(8) > vn-check', originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Origin"]',
buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(9) > vn-check', buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Buyer"]',
destinyCheckbox: '.vn-popover.shown vn-horizontal:nth-child(10) > vn-check', densityCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Density"]',
taxClassCheckbox: '.vn-popover.shown vn-horizontal:nth-child(11) > vn-check',
saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button' saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button'
}, },
itemFixedPrice: { itemFixedPrice: {

View File

@ -19,7 +19,9 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
const state = await page.getState(); const state = await page.getState();
expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase'); const errorMessage = 'Invalid login, remember that distinction is made between uppercase and lowercase';
expect(message.text).toContain(errorMessage);
expect(state).toBe('login'); expect(state).toBe('login');
}); });
@ -28,7 +30,9 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
const state = await page.getState(); const state = await page.getState();
expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase'); const errorMessage = 'Invalid login, remember that distinction is made between uppercase and lowercase';
expect(message.text).toContain(errorMessage);
expect(state).toBe('login'); expect(state).toBe('login');
}); });

View File

@ -112,7 +112,7 @@ describe('Client Edit fiscalData path', () => {
expect(message.text).toContain('Cannot check Equalization Tax in this NIF/CIF'); expect(message.text).toContain('Cannot check Equalization Tax in this NIF/CIF');
}); });
it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => { it('should edit the fiscal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => {
await page.clearInput(selectors.clientFiscalData.fiscalId); await page.clearInput(selectors.clientFiscalData.fiscalId);
await page.write(selectors.clientFiscalData.fiscalId, '94980061C'); await page.write(selectors.clientFiscalData.fiscalId, '94980061C');
await page.waitToClick(selectors.clientFiscalData.saveButton); await page.waitToClick(selectors.clientFiscalData.saveButton);

View File

@ -16,8 +16,8 @@ describe('Item index path', () => {
}); });
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() => {
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton); await page.waitToClick(selectors.itemsIndex.shownColumns);
const visible = await page.isVisible(selectors.itemsIndex.fieldsToShowForm); const visible = await page.isVisible(selectors.itemsIndex.shownColumnsList);
expect(visible).toBeTruthy(); expect(visible).toBeTruthy();
}); });
@ -31,7 +31,7 @@ describe('Item index path', () => {
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox); await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox); await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.destinyCheckbox); await page.waitToClick(selectors.itemsIndex.densityCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton); await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
@ -39,6 +39,7 @@ describe('Item index path', () => {
}); });
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() => {
await page.closePopup();
await page.waitToClick(selectors.itemsIndex.firstSearchResult); await page.waitToClick(selectors.itemsIndex.firstSearchResult);
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
await page.waitToClick(selectors.globalItems.searchButton); await page.waitToClick(selectors.globalItems.searchButton);
@ -54,7 +55,7 @@ describe('Item index path', () => {
}); });
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() => {
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton); await page.waitToClick(selectors.itemsIndex.shownColumns);
await page.waitToClick(selectors.itemsIndex.idCheckbox); await page.waitToClick(selectors.itemsIndex.idCheckbox);
await page.waitToClick(selectors.itemsIndex.stemsCheckbox); await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
await page.waitToClick(selectors.itemsIndex.sizeCheckbox); await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
@ -63,7 +64,7 @@ describe('Item index path', () => {
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox); await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox); await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.destinyCheckbox); await page.waitToClick(selectors.itemsIndex.densityCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton); await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
@ -71,6 +72,7 @@ describe('Item index path', () => {
}); });
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() => {
await page.closePopup();
await page.waitToClick(selectors.itemsIndex.firstSearchResult); await page.waitToClick(selectors.itemsIndex.firstSearchResult);
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
await page.waitToClick(selectors.globalItems.searchButton); await page.waitToClick(selectors.globalItems.searchButton);

View File

@ -62,7 +62,7 @@ describe('Ticket Create packages path', () => {
expect(result).toEqual('7 : Container medical box 1m'); expect(result).toEqual('7 : Container medical box 1m');
}); });
it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, async() => { it(`should confirm quantity is just a number and the string part was ignored by the imput number`, async() => {
await page.waitForTextInField(selectors.ticketPackages.firstQuantity, '-99'); await page.waitForTextInField(selectors.ticketPackages.firstQuantity, '-99');
const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value'); const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value');

View File

@ -2,6 +2,7 @@
<vn-horizontal class="actions"> <vn-horizontal class="actions">
<div class="actions-left"> <div class="actions-left">
<vn-button icon="view_column" <vn-button icon="view_column"
id="shownColumns"
ng-if="$ctrl.options.activeButtons.shownColumns" ng-if="$ctrl.options.activeButtons.shownColumns"
ng-click="smartTableColumns.show($event)" ng-click="smartTableColumns.show($event)"
vn-tooltip="Shown columns"> vn-tooltip="Shown columns">