-
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.
Migrate attributes critical tests to playwright (#4383)
* attributes critical test migrated to playwright * changeset added * Update playwright/tests/attributes.spec.ts Co-authored-by: Paweł Chyła <chyla1988@gmail.com> * Update playwright/tests/attributes.spec.ts Co-authored-by: Paweł Chyła <chyla1988@gmail.com> --------- Co-authored-by: Paweł Chyła <chyla1988@gmail.com>
- Loading branch information
1 parent
85770f6
commit 308e579
Showing
14 changed files
with
159 additions
and
26 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 | ||
--- | ||
|
||
Attributes critical test migrated to playwright |
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
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
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
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,57 @@ | ||
import { AddValueDialog } from "@pages/dialogs/addValueDialog"; | ||
import type { Locator, Page } from "@playwright/test"; | ||
|
||
import { BasePage } from "./basePage"; | ||
|
||
export class AttributesPage { | ||
readonly page: Page; | ||
readonly addValueDialog: AddValueDialog; | ||
readonly basePage: BasePage; | ||
readonly createAttributeButton: Locator; | ||
readonly attributeSelect: Locator; | ||
readonly attributesRows: Locator; | ||
readonly attributeDefaultLabelInput: Locator; | ||
readonly attributeCodeInput: Locator; | ||
readonly assignAttributeValueButton: Locator; | ||
readonly saveButton: Locator; | ||
readonly valueRequiredCheckbox: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.addValueDialog = new AddValueDialog(page); | ||
this.basePage = new BasePage(page); | ||
this.createAttributeButton = page.getByTestId("create-attribute-button"); | ||
this.valueRequiredCheckbox = page.getByLabel("Value Required"); | ||
this.saveButton = page.getByTestId("button-bar-confirm"); | ||
this.attributesRows = page.getByTestId("attributes-rows"); | ||
this.assignAttributeValueButton = page.getByTestId("assign-value-button"); | ||
this.attributeSelect = page.getByTestId("attribute-type-select"); | ||
this.attributeDefaultLabelInput = page | ||
.getByTestId("attribute-default-label-input") | ||
.locator("input"); | ||
this.attributeCodeInput = page | ||
.getByTestId("attribute-code-input") | ||
.locator("input"); | ||
} | ||
|
||
async clickCreateAttributeButton() { | ||
await this.createAttributeButton.click(); | ||
} | ||
async clickValueRequiredCheckbox() { | ||
await this.valueRequiredCheckbox.click(); | ||
} | ||
async clickSaveButton() { | ||
await this.saveButton.click(); | ||
} | ||
async selectAttributeType(attributeType = "DROPDOWN") { | ||
await this.attributeSelect.click(); | ||
await this.page.getByTestId(`select-field-option-${attributeType}`).click(); | ||
} | ||
async clickAssignAttributeValueButton() { | ||
await this.assignAttributeValueButton.click(); | ||
} | ||
|
||
async typeAttributeDefaultLabel(attributeDefaultLabel: string) { | ||
await this.attributeDefaultLabelInput.fill(attributeDefaultLabel); | ||
} | ||
} |
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
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,18 @@ | ||
import type { Locator, Page } from "@playwright/test"; | ||
|
||
export class AddValueDialog { | ||
readonly page: Page; | ||
readonly nameInput: Locator; | ||
readonly saveButton: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.nameInput = page.getByTestId("value-name").locator("input"); | ||
this.saveButton = page.getByTestId("submit"); | ||
} | ||
|
||
async typeAndSaveAttributeValue(value = "XXL") { | ||
await this.nameInput.fill(value); | ||
await this.saveButton.click(); | ||
} | ||
} |
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,50 @@ | ||
import { URL_LIST } from "@data/url"; | ||
import { AttributesPage } from "@pages/attributesPage"; | ||
import { ConfigurationPage } from "@pages/configurationPage"; | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.use({ storageState: "playwright/.auth/admin.json" }); | ||
|
||
test("TC: SALEOR_34 User should be able to create Dropdown attribute, required, Product attribute @basic-regression", async ({ | ||
|
||
page, | ||
}) => { | ||
const configurationPage = new ConfigurationPage(page); | ||
const attributesPage = new AttributesPage(page); | ||
const attributeDefaultLabel = `attribute default label - ${await attributesPage.basePage.getRandomInt( | ||
1000000, | ||
)}`; | ||
|
||
await page.goto(URL_LIST.configuration); | ||
|
||
await configurationPage.openAttributes(); | ||
await attributesPage.clickCreateAttributeButton(); | ||
await attributesPage.typeAttributeDefaultLabel(attributeDefaultLabel); | ||
await attributesPage.selectAttributeType("DROPDOWN"); | ||
await attributesPage.clickAssignAttributeValueButton(); | ||
await attributesPage.addValueDialog.typeAndSaveAttributeValue(); | ||
await attributesPage.clickSaveButton(); | ||
await attributesPage.basePage.expectSuccessBanner(); | ||
await expect(await attributesPage.attributesRows.count()).toEqual(1); | ||
await expect(attributesPage.valueRequiredCheckbox).toBeEnabled(); | ||
expect(await attributesPage.valueRequiredCheckbox.isChecked()).toBeTruthy(); | ||
}); | ||
test("TC: SALEOR_35 User should be able to create Plain Text attribute, not required, Product attribute @basic-regression", async ({ | ||
|
||
page, | ||
}) => { | ||
const attributesPage = new AttributesPage(page); | ||
const attributeDefaultLabel = `attribute default label - ${await attributesPage.basePage.getRandomInt( | ||
1000000, | ||
)}`; | ||
|
||
await page.goto(URL_LIST.addAttributes); | ||
|
||
await attributesPage.typeAttributeDefaultLabel(attributeDefaultLabel); | ||
await attributesPage.selectAttributeType("PLAIN_TEXT"); | ||
await attributesPage.clickValueRequiredCheckbox(); | ||
await attributesPage.clickSaveButton(); | ||
await attributesPage.basePage.expectSuccessBanner(); | ||
await expect(attributesPage.valueRequiredCheckbox).toBeEnabled(); | ||
expect(await attributesPage.valueRequiredCheckbox.isChecked()).toBeFalsy(); | ||
}); |
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