Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional tests - Fix random errors #31492

Merged
merged 2 commits into from Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 12 additions & 13 deletions tests/UI/pages/BO/catalog/stocks/index.ts
Expand Up @@ -202,7 +202,10 @@ class Stocks extends BOBasePage {
*/
async getNumberOfProductsFromList(page: Page): Promise<number> {
await this.waitForVisibleSelector(page, this.searchButton, 2000);
await this.waitForHiddenSelector(page, this.productListLoading);
if (await this.elementVisible(page, this.productListLoading, 1000)) {
await this.waitForHiddenSelector(page, this.productListLoading);
}

return (await page.$$(this.productRows)).length;
}

Expand All @@ -222,11 +225,10 @@ class Stocks extends BOBasePage {
* @return {Promise<void>}
*/
async paginateTo(page: Page, pageNumber: number = 1): Promise<void> {
await Promise.all([
page.click(this.paginationListItemLink(pageNumber)),
this.waitForVisibleSelector(page, this.productListLoading),
]);
await this.waitForHiddenSelector(page, this.productListLoading);
await page.click(this.paginationListItemLink(pageNumber));
if (await this.elementVisible(page, this.productListLoading, 1000)) {
await this.waitForHiddenSelector(page, this.productListLoading);
}
}

/**
Expand Down Expand Up @@ -254,13 +256,10 @@ class Stocks extends BOBasePage {
*/
async simpleFilter(page: Page, value: string): Promise<void> {
await page.type(this.searchInput, value);

await Promise.all([
page.click(this.searchButton),
this.waitForVisibleSelector(page, this.productListLoading, 10000),
]);

await this.waitForHiddenSelector(page, this.productListLoading);
await page.click(this.searchButton);
if (await this.elementVisible(page, this.productListLoading, 1000)) {
await this.waitForHiddenSelector(page, this.productListLoading);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/UI/pages/BO/orders/add.ts
Expand Up @@ -1023,9 +1023,9 @@ class AddOrder extends BOBasePage {
*/
async setDeliveryOption(page: Page, deliveryOptionName: string, isFreeShipping: boolean = false): Promise<string> {
await this.selectByVisibleText(page, this.deliveryOptionSelect, deliveryOptionName);
await page.$eval(this.freeShippingToggleInput(isFreeShipping ? 1 : 0), (el: HTMLElement) => el.click());
await page.waitForTimeout(1000);
await this.setFreeShipping(page, isFreeShipping);
if (isFreeShipping) {
await this.setFreeShipping(page, isFreeShipping);
await this.waitForVisibleSelector(page, this.vouchersTable);
}
await page.waitForTimeout(1000);
Expand Down