-
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 channels tests to playwright (#4584)
* channels tests migration * change channels name * Update rare-singers-cover.md * type in input missing scroll into view on CI * fix channel selection * Trigger Build
- Loading branch information
1 parent
3b9f4ee
commit 28a8f1c
Showing
15 changed files
with
240 additions
and
25 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,8 @@ | ||
--- | ||
"saleor-dashboard": minor | ||
--- | ||
|
||
Tests migrated to playwright: | ||
- Create basic channel; | ||
- Edit channel settings to contain transaction flow, allow unpaid orders, authorize instead of charging, prio high stock; | ||
- Delete channel |
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,15 +1,94 @@ | ||
import type { Locator, Page } from "@playwright/test"; | ||
import { URL_LIST } from "@data/url"; | ||
import { DeleteChannelDialog } from "@dialogs/deleteChannelDialog"; | ||
import { RightSideDetailsPage } from "@pageElements/rightSideDetailsSection"; | ||
import { BasePage } from "@pages/basePage"; | ||
import { Page } from "@playwright/test"; | ||
|
||
export class ChannelPage { | ||
export class ChannelPage extends BasePage { | ||
readonly page: Page; | ||
readonly createChannelButton: Locator; | ||
readonly deleteChannelButton: Locator; | ||
readonly channelsListTable: Locator; | ||
readonly rightSideDetailsPage: RightSideDetailsPage; | ||
readonly deleteChannelDialog: DeleteChannelDialog; | ||
|
||
constructor(page: Page) { | ||
constructor( | ||
page: Page, | ||
readonly deleteChannelButton = page.getByTestId("delete-channel"), | ||
readonly channelRow = page.getByTestId("channel-row"), | ||
readonly saveButton = page.getByTestId("button-bar-confirm"), | ||
readonly createChannelButton = page.getByTestId("add-channel"), | ||
readonly channelsListTable = page.getByTestId("channel-list"), | ||
readonly channelNameInput = page.getByTestId("channel-name-input"), | ||
readonly orderExpirationInput = page.getByTestId( | ||
"delete-expired-order-input", | ||
), | ||
readonly transactionFlowCheckbox = page | ||
.getByTestId("order-settings-mark-as-paid") | ||
.locator("button") | ||
.first(), | ||
readonly allowUnpaidOrdersCheckbox = page | ||
.getByTestId("allow-unpaid-orders-checkbox") | ||
.locator("button") | ||
.first(), | ||
readonly authorizeInsteadOfChargingCheckbox = page | ||
.getByTestId("default-transaction-strategy-checkbox") | ||
.locator("button") | ||
.first(), | ||
readonly slugNameInput = page.getByTestId("slug-name-input"), | ||
readonly channelCurrencySelect = page | ||
.getByTestId("channel-currency-select-input") | ||
.locator("input"), | ||
readonly countrySelect = page | ||
.getByTestId("country-select-input") | ||
.locator("input"), | ||
) { | ||
super(page); | ||
this.page = page; | ||
this.deleteChannelButton = page.getByTestId("delete-channel"); | ||
this.createChannelButton = page.getByTestId("add-channel"); | ||
this.channelsListTable = page.getByTestId("channel-list"); | ||
this.rightSideDetailsPage = new RightSideDetailsPage(page); | ||
this.deleteChannelDialog = new DeleteChannelDialog(page); | ||
} | ||
|
||
async clickAuthorizeInsteadOfChargingCheckbox() { | ||
await this.authorizeInsteadOfChargingCheckbox.click(); | ||
} | ||
async clickDeleteButtonOnRowContainingChannelName(channelName: string) { | ||
await this.channelRow | ||
.filter({ hasText: channelName }) | ||
.locator(this.deleteChannelButton) | ||
.click(); | ||
} | ||
async clickAllowUnpaidOrdersCheckbox() { | ||
await this.allowUnpaidOrdersCheckbox.click(); | ||
} | ||
async clickTransactionFlowCheckbox() { | ||
await this.transactionFlowCheckbox.click(); | ||
} | ||
async clickCreateChannelButton() { | ||
await this.createChannelButton.click(); | ||
} | ||
async clickSaveButton() { | ||
await this.saveButton.click(); | ||
} | ||
async typeChannelName(channelName = "z - automation") { | ||
await this.channelNameInput.fill(channelName); | ||
} | ||
async typeSlugName(slugName: string) { | ||
await this.slugNameInput.fill(slugName); | ||
} | ||
async typeOrderExpiration(expirationDays = "120") { | ||
await this.orderExpirationInput.fill(expirationDays); | ||
} | ||
async selectCurrency(currencyName: string) { | ||
await this.channelCurrencySelect.click(); | ||
await this.page.getByRole("option", { name: currencyName }).click(); | ||
} | ||
async selectCountry(countryName: string) { | ||
await this.countrySelect.click(); | ||
await this.page.getByRole("option", { name: countryName }).click(); | ||
} | ||
|
||
async gotoChannelDetails(channelId: string) { | ||
await this.page.goto(URL_LIST.channels + channelId); | ||
} | ||
async gotoChannelList() { | ||
await this.page.goto(URL_LIST.channels); | ||
} | ||
} |
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 DeleteChannelDialog { | ||
readonly page: Page; | ||
|
||
readonly deleteButton: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
|
||
this.deleteButton = page.getByTestId("submit"); | ||
} | ||
|
||
async clickDeleteButton() { | ||
await this.deleteButton.first().click(); | ||
await this.deleteButton.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
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 { CHANNELS } from "@data/e2eTestData"; | ||
import { ChannelPage } from "@pages/channelsPage"; | ||
import { ConfigurationPage } from "@pages/configurationPage"; | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.use({ storageState: "playwright/.auth/admin.json" }); | ||
let configurationPage: ConfigurationPage; | ||
let channelPage: ChannelPage; | ||
|
||
test.beforeEach(({ page }) => { | ||
configurationPage = new ConfigurationPage(page); | ||
channelPage = new ChannelPage(page); | ||
}); | ||
|
||
test("TC: SALEOR_97 Create basic channel @e2e @channels", async () => { | ||
const slugName = new Date().toISOString(); | ||
|
||
await configurationPage.gotoConfigurationView(); | ||
await configurationPage.openChannels(); | ||
await channelPage.clickCreateChannelButton(); | ||
await channelPage.typeChannelName(); | ||
await channelPage.typeSlugName(slugName); | ||
await channelPage.selectCurrency("AFN - Afghanistan"); | ||
await channelPage.selectCountry("Afghanistan"); | ||
await channelPage.clickSaveButton(); | ||
await channelPage.expectSuccessBanner(); | ||
}); | ||
test("TC: SALEOR_98 Edit channel settings to contain transaction flow, allow unpaid orders, authorize instead of charging, prio high stock @e2e @channels", async () => { | ||
await channelPage.gotoChannelDetails(CHANNELS.channelToBeEditedSettings.id); | ||
await channelPage.clickTransactionFlowCheckbox(); | ||
await channelPage.clickAllowUnpaidOrdersCheckbox(); | ||
await channelPage.clickAuthorizeInsteadOfChargingCheckbox(); | ||
await expect(channelPage.transactionFlowCheckbox).toBeChecked(); | ||
await expect(channelPage.authorizeInsteadOfChargingCheckbox).toBeChecked(); | ||
await expect(channelPage.allowUnpaidOrdersCheckbox).toBeChecked(); | ||
await channelPage.rightSideDetailsPage.clickAllocationHighStockButton(); | ||
await channelPage.clickSaveButton(); | ||
await channelPage.expectSuccessBanner(); | ||
}); | ||
test("TC: SALEOR_99 Delete channel @e2e @channels", async () => { | ||
await channelPage.gotoChannelList(); | ||
await channelPage.clickDeleteButtonOnRowContainingChannelName( | ||
CHANNELS.channelToBeDeleted.name, | ||
); | ||
await channelPage.deleteChannelDialog.clickDeleteButton(); | ||
await channelPage.expectSuccessBanner(); | ||
await expect(channelPage.channelsListTable).not.toContainText( | ||
CHANNELS.channelToBeDeleted.name, | ||
); | ||
}); |
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
Oops, something went wrong.