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

Split select options into 2 #5301

Merged
merged 5 commits into from
Dec 27, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-peas-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Split select link option into 2 different ones to avoid flakyness in tests
37 changes: 27 additions & 10 deletions playwright/pages/dialogs/addNavigationMenuItemDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,37 @@ export class AddNavigationMenuItemDialog extends BasePage {
super(page);
}

async selectLinkOption(option: string, optionName: string) {
async selectLinkTypeOption(linkType: string) {
await this.menuLinkType.click();
await this.waitForDOMToFullyLoad();
await this.menuLinkOptions.filter({ hasText: "Categories" }).waitFor({ state: "visible" });
await this.menuLinkOptions.filter({ hasText: "Collections" }).waitFor({ state: "visible" });
await this.menuLinkOptions.filter({ hasText: "Pages" }).waitFor({ state: "visible" });
await expect(this.menuLinkOptions.filter({ hasText: option })).toBeEnabled();
await this.menuLinkOptions.filter({ hasText: option }).click({ force: true });
await this.waitForDOMToFullyLoad();

// Ensure the link type option is visible and select it
const linkTypeOption = this.menuLinkOptions.filter({ hasText: linkType });

await linkTypeOption.waitFor({ state: "visible" });
await expect(linkTypeOption).toBeEnabled();
await linkTypeOption.click({ force: true });

// Verify the correct link type is selected
const selectedLinkType = await this.menuLinkType.inputValue();

if (selectedLinkType !== linkType) {
throw new Error(`Expected link type "${linkType}" but found "${selectedLinkType}"`);
}
}

async selectLinkTypeValue(optionName: string) {
await this.menuLinkValue.click();
await this.menuLinkOptions.filter({ hasText: optionName }).waitFor({ state: "visible" });
await expect(this.menuLinkOptions.filter({ hasText: optionName })).toBeEnabled();
await this.menuLinkOptions.filter({ hasText: optionName }).click({ force: true });
await this.waitForDOMToFullyLoad();

// Ensure the option is present and select it
const option = this.menuLinkOptions.filter({ hasText: optionName });

await option.waitFor({ state: "visible" });
await expect(option).toBeEnabled();
await option.click({ force: true });

// Verify the correct option is selected
await expect(this.menuLinkValue).toHaveValue(optionName);
}

Expand Down
9 changes: 6 additions & 3 deletions playwright/tests/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ test("TC: SALEOR_194 Should create a new menu navigation with menu item @navigat
const menuItemName = faker.random.word();

await addNavigationMenuItemDialog.typeMenuItemName(menuItemName);
await addNavigationMenuItemDialog.selectLinkOption("Categories", "Polo Shirts");
await addNavigationMenuItemDialog.selectLinkTypeOption("Categories");
await addNavigationMenuItemDialog.selectLinkTypeValue("Polo Shirts");
await addNavigationMenuItemDialog.clickSaveButton();
await expect(navigationDetailsPage.addMenuItemDialog).not.toBeVisible();
await navigation.expectSuccessBanner();
Expand All @@ -59,7 +60,8 @@ test("TC: SALEOR_198 Should update existing menu @navigation @e2e", async () =>

await navigationDetailsPage.clickEditMenuItemButton(menuItemToBeUpdated.name);
await addNavigationMenuItemDialog.typeMenuItemName(newItemName);
await addNavigationMenuItemDialog.selectLinkOption("Categories", "Polo Shirts");
await addNavigationMenuItemDialog.selectLinkTypeOption("Categories");
await addNavigationMenuItemDialog.selectLinkTypeValue("Polo Shirts");
await addNavigationMenuItemDialog.clickSaveButton();
await expect(navigationDetailsPage.addMenuItemDialog).not.toBeVisible();
await navigationDetailsPage.clickDeleteMenuItemButton(menuItemToBeDeleted.name);
Expand All @@ -69,7 +71,8 @@ test("TC: SALEOR_198 Should update existing menu @navigation @e2e", async () =>
const menuItemName = faker.random.word();

await addNavigationMenuItemDialog.typeMenuItemName(menuItemName);
await addNavigationMenuItemDialog.selectLinkOption("Categories", "Polo Shirts");
await addNavigationMenuItemDialog.selectLinkTypeOption("Categories");
await addNavigationMenuItemDialog.selectLinkTypeValue("Polo Shirts");
await addNavigationMenuItemDialog.clickSaveButton();
await expect(navigationDetailsPage.menuItemList).toContainText(menuItemName);
await navigationDetailsPage.clickDeleteMenuItemButton(menuItemName);
Expand Down
Loading