-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add changeset * add test data * add tests and update data-test-id * code review fixes * spaces
- Loading branch information
Showing
11 changed files
with
279 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": minor | ||
--- | ||
|
||
Add playwright tests for page types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Page, expect } from "@playwright/test"; | ||
|
||
export class AssignAttributeDialog { | ||
readonly page: Page; | ||
|
||
constructor( | ||
page: Page, | ||
readonly assignAttributesSearchInput = | ||
page.getByTestId("attribute-search-input").locator("input"), | ||
readonly attributesList = page.getByTestId("attributes-list"), | ||
readonly assignAndSaveButton = page.getByTestId("assign-and-save-button"), | ||
) { | ||
this.page = page; | ||
} | ||
|
||
async searchAttribute(attributeName: string) { | ||
await this.assignAttributesSearchInput.fill(attributeName); | ||
await expect(this.attributesList).toContainText(attributeName); | ||
} | ||
|
||
async clickAssignAndSaveButton() { | ||
await this.assignAndSaveButton.click(); | ||
await this.assignAndSaveButton.waitFor({ state: "hidden" }); | ||
} | ||
|
||
async assignSpecificAttributeByNameAndSave(attributeName: string) { | ||
const specificAttributeCheckbox = await this.page | ||
.getByRole("row", { name: attributeName }) | ||
.getByRole("checkbox"); | ||
await this.attributesList.waitFor({ state: "visible" }); | ||
await this.searchAttribute(attributeName); | ||
await specificAttributeCheckbox.click(); | ||
await this.clickAssignAndSaveButton(); | ||
await this.assignAndSaveButton.waitFor({ state: "hidden" }); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,74 @@ | ||
import type { Page } from "@playwright/test"; | ||
import { URL_LIST } from "@data/url"; | ||
import { BasePage } from "@pages/basePage"; | ||
import { DeleteDialog } from "@pages/dialogs/deleteDialog"; | ||
import { AssignAttributeDialog } from "@pages/dialogs/assignAttributeDialog"; | ||
|
||
export class PageTypesPage { | ||
export class PageTypesPage extends BasePage { | ||
readonly page: Page; | ||
readonly basePage: BasePage; | ||
readonly deletePageTypeDialog: DeleteDialog; | ||
readonly attributeDialog: AssignAttributeDialog; | ||
|
||
constructor( | ||
page: Page, | ||
readonly createPageTypeButton = page.getByTestId("create-page-type"), | ||
readonly nameInput = page.getByTestId("page-type-name").locator("input"), | ||
readonly saveButton = page.getByTestId("button-bar-confirm"), | ||
readonly bulkDeleteButton = page.getByTestId("bulk-delete-page-types"), | ||
readonly pageTypeList = page.getByTestId("page-types-list"), | ||
readonly rowCheckbox = page.getByTestId("checkbox"), | ||
readonly assignAttributesButton = page.getByTestId("assign-attributes"), | ||
readonly pageAttributes = page.getByTestId("page-attributes"), | ||
) { | ||
super(page); | ||
this.page = page; | ||
this.basePage = new BasePage(page); | ||
this.deletePageTypeDialog = new DeleteDialog(page); | ||
this.attributeDialog = new AssignAttributeDialog(page); | ||
} | ||
async assignAttributes(attributeName: string) { | ||
await this.assignAttributesButton.click(); | ||
await this.attributeDialog.assignSpecificAttributeByNameAndSave(attributeName) | ||
} | ||
|
||
async gotoPageTypeListPage() { | ||
await this.page.goto(URL_LIST.pageTypes); | ||
} | ||
|
||
async clickCreatePageTypeButton() { | ||
await this.createPageTypeButton.click(); | ||
} | ||
|
||
async typePageTypeName(name: string) { | ||
await this.nameInput.fill(name); | ||
} | ||
|
||
async updatePageTypeName(name: string) { | ||
await this.nameInput.clear(); | ||
await this.nameInput.fill(name); | ||
} | ||
|
||
async clickSaveButton() { | ||
await this.saveButton.click(); | ||
} | ||
|
||
async gotoExistingPageTypePage(pageTypeId: string) { | ||
const existingPageTypeUrl = URL_LIST.pageTypes + pageTypeId; | ||
await console.log( | ||
"Navigating to page type details: " + existingPageTypeUrl, | ||
); | ||
await this.page.goto(existingPageTypeUrl); | ||
} | ||
|
||
async clickBulkDeleteButton() { | ||
await this.bulkDeleteButton.click(); | ||
} | ||
|
||
async checkPageTypesOnList(listRows: string[]) { | ||
for (const row of listRows) { | ||
const rowLocator = this.page.getByTestId(`id-${row}`); | ||
await rowLocator.locator("input").click(); | ||
} | ||
} | ||
} |
Oops, something went wrong.