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

View File

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

View File

@ -19,7 +19,9 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar();
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');
});
@ -28,7 +30,9 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar();
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');
});

View File

@ -112,7 +112,7 @@ describe('Client Edit fiscalData path', () => {
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.write(selectors.clientFiscalData.fiscalId, '94980061C');
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() => {
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
const visible = await page.isVisible(selectors.itemsIndex.fieldsToShowForm);
await page.waitToClick(selectors.itemsIndex.shownColumns);
const visible = await page.isVisible(selectors.itemsIndex.shownColumnsList);
expect(visible).toBeTruthy();
});
@ -31,7 +31,7 @@ describe('Item index path', () => {
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.destinyCheckbox);
await page.waitToClick(selectors.itemsIndex.densityCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
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() => {
await page.closePopup();
await page.waitToClick(selectors.itemsIndex.firstSearchResult);
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
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() => {
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
await page.waitToClick(selectors.itemsIndex.shownColumns);
await page.waitToClick(selectors.itemsIndex.idCheckbox);
await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
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.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.destinyCheckbox);
await page.waitToClick(selectors.itemsIndex.densityCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
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() => {
await page.closePopup();
await page.waitToClick(selectors.itemsIndex.firstSearchResult);
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
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');
});
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');
const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value');

View File

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