-
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.
- Loading branch information
1 parent
ceada31
commit d61fdb0
Showing
6 changed files
with
146 additions
and
30 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 site settings e2e test |
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,81 @@ | ||
import type { Page } from "@playwright/test"; | ||
import { BasePage } from "@pages/basePage"; | ||
import { URL_LIST } from "@data/url"; | ||
|
||
export class SiteSettingsPage { | ||
readonly page: Page; | ||
|
||
export class SiteSettingsPage extends BasePage { | ||
constructor( | ||
page: Page, | ||
readonly companyInfoSection = page.locator('[data-test-id="company-info"]'), | ||
readonly stockReservationForAuthUserInput = page | ||
.getByTestId("reserve-stock-duration-for-auth-user-input") | ||
.locator("input"), | ||
readonly stockReservationForAnonUserInput = page | ||
.getByTestId("reserve-stock-duration-for-anon-user-input") | ||
.locator("input"), | ||
readonly checkoutLineLimitInput = page | ||
.getByTestId("checkout-limits-input") | ||
.locator("input"), | ||
readonly companyInput = page | ||
.getByTestId("company-name-input") | ||
.locator("input"), | ||
readonly addressLine1Input = page | ||
.getByTestId("company-address-line-1-input") | ||
.locator("input"), | ||
readonly addressLine2Input = page | ||
.getByTestId("company-address-line-2-input") | ||
.locator("input"), | ||
readonly city = page.getByTestId("company-city-input").locator("input"), | ||
readonly countryInput = page | ||
.getByTestId("address-edit-country-select-field") | ||
.locator("input"), | ||
readonly autocompleteDropdown = page.getByTestId("autocomplete-dropdown"), | ||
readonly countryAreaDropdown = page | ||
.getByTestId("address-edit-country-area-field") | ||
.locator("input"), | ||
readonly zipInput = page.getByTestId("company-zip-input").locator("input"), | ||
readonly phoneInput = page | ||
.getByTestId("company-phone-input") | ||
.locator("input"), | ||
readonly emailConfirmationCheckbox = page.getByTestId( | ||
"require-email-confirmation-checkbox", | ||
), | ||
readonly companyInfoSection = page.getByTestId("company-info"), | ||
) { | ||
super(page); | ||
} | ||
|
||
async gotoSiteSettings() { | ||
await this.page.goto(URL_LIST.siteSettings); | ||
} | ||
async fillStockReservationForAuthUser(value: string) { | ||
await this.stockReservationForAuthUserInput.fill(value); | ||
} | ||
async fillStockReservationForAnonUser(value: string) { | ||
await this.stockReservationForAnonUserInput.fill(value); | ||
} | ||
async fillCheckoutLineLimitInput(value: string) { | ||
await this.checkoutLineLimitInput.fill(value); | ||
} | ||
async completeAddressForm( | ||
companyName: string, | ||
addressLine1: string, | ||
addressLine2: string, | ||
city: string, | ||
country: string, | ||
countryArea: string, | ||
zip: string, | ||
phone: string, | ||
) { | ||
this.page = page; | ||
await this.companyInput.fill(companyName); | ||
await this.addressLine1Input.fill(addressLine1); | ||
await this.addressLine2Input.fill(addressLine2); | ||
await this.city.fill(city); | ||
await this.countryInput.click(); | ||
await this.autocompleteDropdown.getByText(country, { exact: true }).click(); | ||
await this.countryAreaDropdown.fill(countryArea); | ||
await this.autocompleteDropdown | ||
.getByText(countryArea, { exact: true }) | ||
.click(); | ||
await this.zipInput.fill(zip); | ||
await this.phoneInput.fill(phone); | ||
} | ||
} |
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,36 @@ | ||
import { SiteSettingsPage } from "@pages/siteSettingsPage"; | ||
import { test, expect } from "@playwright/test"; | ||
import faker from "faker"; | ||
|
||
test.use({ storageState: "./playwright/.auth/admin.json" }); | ||
let siteSettingsPage: SiteSettingsPage; | ||
|
||
test.beforeEach(({ page }) => { | ||
siteSettingsPage = new SiteSettingsPage(page); | ||
}); | ||
test("TC: SALEOR_132 Should be able to update site settings", async () => { | ||
const companyName = faker.company.companyName(); | ||
await siteSettingsPage.gotoSiteSettings(); | ||
await siteSettingsPage.fillStockReservationForAuthUser("200"); | ||
await siteSettingsPage.fillStockReservationForAnonUser("400"); | ||
await siteSettingsPage.fillCheckoutLineLimitInput("70"); | ||
await siteSettingsPage.completeAddressForm( | ||
companyName, | ||
"Hidden Valley Road", | ||
"1266", | ||
"Lancaster", | ||
"United States of America", | ||
"Pennsylvania", | ||
"17602", | ||
"7172893144", | ||
); | ||
await siteSettingsPage.emailConfirmationCheckbox.click(); | ||
await siteSettingsPage.saveButton.click(); | ||
await siteSettingsPage.expectSuccessBanner(); | ||
await expect(siteSettingsPage.companyInfoSection).not.toBeEmpty(); | ||
await expect(siteSettingsPage.companyInput).toHaveValue(companyName); | ||
await expect(siteSettingsPage.stockReservationForAuthUserInput).toHaveValue("200"); | ||
await expect(siteSettingsPage.stockReservationForAnonUserInput).toHaveValue("400"); | ||
await expect(siteSettingsPage.checkoutLineLimitInput).toHaveValue("70"); | ||
await expect(siteSettingsPage.emailConfirmationCheckbox).not.toBeChecked(); | ||
}); |
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