-
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
eb96c45
commit 69a678f
Showing
13 changed files
with
296 additions
and
22 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 | ||
--- | ||
|
||
Tests: Create voucher with auto-generated codes and fixed amount discount, Create voucher with manual code and percentage discount, Edit voucher to have free shipping discount, Edit voucher Usage limit: used in total, per customer, staff only, code used once |
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,24 @@ | ||
import type { Page } from "@playwright/test"; | ||
|
||
export class AddVoucherCodeDialog { | ||
constructor( | ||
page: Page, | ||
readonly quantityInput = page.getByTestId("quantity-input"), | ||
readonly prefixInput = page.getByTestId("prefix-input"), | ||
readonly confirmButton = page.getByTestId("confirm-button"), | ||
readonly enterCodeInput = page.getByTestId("enter-code-input"), | ||
) {} | ||
|
||
async typeCodesQuantity(quantity = "10") { | ||
await this.quantityInput.fill(quantity); | ||
} | ||
async typeCodesPrefix(prefix = "automation") { | ||
await this.prefixInput.fill(prefix); | ||
} | ||
async typeCode(code = "123456789") { | ||
await this.enterCodeInput.fill(code); | ||
} | ||
async clickConfirmButton() { | ||
await this.confirmButton.click(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,11 +1,96 @@ | ||
import type { Locator, Page } from "@playwright/test"; | ||
import { URL_LIST } from "@data/url"; | ||
import { AddVoucherCodeDialog } from "@dialogs/addVoucherCodeDialog"; | ||
import type { Page } from "@playwright/test"; | ||
|
||
export class VouchersPage { | ||
import { BasePage } from "./basePage"; | ||
|
||
export class VouchersPage extends BasePage { | ||
readonly page: Page; | ||
readonly createVoucherButton: Locator; | ||
readonly addVoucherCodeDialog: AddVoucherCodeDialog; | ||
|
||
constructor(page: Page) { | ||
constructor( | ||
page: Page, | ||
readonly createVoucherButton = page.getByTestId("create-voucher"), | ||
readonly addCodeButton = page.getByTestId("add-code-button"), | ||
readonly usageLimitCheckbox = page.getByTestId("has-usage-limit"), | ||
readonly oncePerCustomerLimitCheckbox = page.getByTestId( | ||
"apply-once-per-customer", | ||
), | ||
readonly onlyForStaffLimitCheckbox = page.getByTestId("only-for-staff"), | ||
readonly singleUseLimitCheckbox = page.getByTestId("single-use"), | ||
readonly usageLimitSection = page.getByTestId("usage-limit-section"), | ||
readonly usageLimitInput = page.getByTestId("usage-limit").locator("input"), | ||
readonly saveButton = page.getByTestId("button-bar-confirm"), | ||
readonly voucherNameInput = page.getByTestId("voucher-name-input"), | ||
readonly discountValueInput = page.getByTestId("discount-value-input"), | ||
readonly autoGeneratedCodesItem = page.getByTestId("auto-generate codes"), | ||
readonly manualGeneratedCodesItem = page.getByTestId("manual"), | ||
readonly percentDiscountTypeButton = page.getByTestId("VALUE_PERCENTAGE"), | ||
readonly freeShippingDiscountTypeButton = page.getByTestId("SHIPPING"), | ||
) { | ||
super(page); | ||
this.page = page; | ||
this.createVoucherButton = page.getByTestId("create-voucher"); | ||
this.addVoucherCodeDialog = new AddVoucherCodeDialog(page); | ||
} | ||
|
||
async typeVoucherName(voucherName = "special voucher automation") { | ||
await this.voucherNameInput.fill(voucherName); | ||
} | ||
async typeUsageLimit(usageLimit = "10000") { | ||
await this.usageLimitInput.fill(usageLimit); | ||
} | ||
|
||
async clickCreateVoucherButton() { | ||
await this.createVoucherButton.click(); | ||
} | ||
async clickUsageTotalLimitCheckbox() { | ||
await this.usageLimitCheckbox.click(); | ||
} | ||
async clickSingleUseLimitCheckbox() { | ||
await this.singleUseLimitCheckbox.click(); | ||
} | ||
async clickOnlyForStaffLimitCheckbox() { | ||
await this.onlyForStaffLimitCheckbox.click(); | ||
} | ||
async clickOncePerCustomerLimitCheckbox() { | ||
await this.oncePerCustomerLimitCheckbox.click(); | ||
} | ||
async clickPercentDiscountTypeButton() { | ||
await this.percentDiscountTypeButton.click(); | ||
} | ||
async clickFreeShippingDiscountTypeButton() { | ||
await this.freeShippingDiscountTypeButton.click(); | ||
} | ||
async clickSaveButton() { | ||
await this.saveButton.click(); | ||
} | ||
async clickAutoGeneratedCodesItem() { | ||
await this.autoGeneratedCodesItem.click(); | ||
} | ||
async clickManualGeneratedCodesItem() { | ||
await this.manualGeneratedCodesItem.click(); | ||
} | ||
async clickAddCodeButton() { | ||
await this.addCodeButton.click(); | ||
} | ||
|
||
async gotoVouchersListPage() { | ||
await this.page.goto(URL_LIST.vouchers); | ||
} | ||
async gotoExistingVoucherPage(voucherId: string) { | ||
await this.page.goto(`${URL_LIST.vouchers}${voucherId}`); | ||
} | ||
async gotoVoucherAddPage() { | ||
await this.page.goto(URL_LIST.vouchersAddPage); | ||
} | ||
|
||
async typeDiscountValueInChannel( | ||
channel = "Channel-PLN", | ||
discountValue = "10", | ||
) { | ||
await this.page | ||
.getByTestId(channel) | ||
.locator(this.discountValueInput) | ||
.fill(discountValue); | ||
} | ||
} |
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,131 @@ | ||
import { VOUCHERS_AND_DISCOUNTS } from "@data/e2eTestData"; | ||
import { VouchersPage } from "@pages/vouchersPage"; | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.use({ storageState: "playwright/.auth/admin.json" }); | ||
|
||
let vouchersPage: VouchersPage; | ||
|
||
test.beforeEach(({ page }) => { | ||
vouchersPage = new VouchersPage(page); | ||
}); | ||
|
||
test("TC: SALEOR_85 Create voucher with auto-generated codes and fixed amount discount @vouchers @e2e", async () => { | ||
const codesQuantity = 5; | ||
const codesPrefix = "auto"; | ||
|
||
await vouchersPage.gotoVouchersListPage(); | ||
await vouchersPage.clickCreateVoucherButton(); | ||
await vouchersPage.typeVoucherName(); | ||
await vouchersPage.clickAddCodeButton(); | ||
await vouchersPage.clickAutoGeneratedCodesItem(); | ||
await vouchersPage.addVoucherCodeDialog.typeCodesQuantity( | ||
codesQuantity.toString(), | ||
); | ||
await vouchersPage.addVoucherCodeDialog.typeCodesPrefix(codesPrefix); | ||
await vouchersPage.addVoucherCodeDialog.clickConfirmButton(); | ||
await vouchersPage.waitForGrid(); | ||
|
||
const generatedCodesRows = await vouchersPage.getNumberOfGridRowsWithText( | ||
codesPrefix, | ||
); | ||
|
||
await expect( | ||
generatedCodesRows, | ||
`Auto-generated number of codes: ${codesQuantity} should be visible on grid`, | ||
).toEqual(codesQuantity); | ||
|
||
await vouchersPage.typeDiscountValueInChannel(); | ||
await vouchersPage.clickSaveButton(); | ||
await vouchersPage.expectSuccessBanner(); | ||
await vouchersPage.waitForGrid(); | ||
const activeCodesRows = await vouchersPage.getNumberOfGridRowsWithText( | ||
"Active", | ||
); | ||
await expect( | ||
activeCodesRows, | ||
`Given codes quantity: ${codesQuantity} should have status Active displayed on grid`, | ||
).toEqual(codesQuantity); | ||
}); | ||
|
||
test("TC: SALEOR_86 Create voucher with manual code and percentage discount @vouchers @e2e", async () => { | ||
const code = `code-TC: SALEOR_86 ${new Date().toISOString()}`; | ||
|
||
await vouchersPage.gotoVoucherAddPage(); | ||
await vouchersPage.typeVoucherName(); | ||
await vouchersPage.clickAddCodeButton(); | ||
await vouchersPage.clickManualGeneratedCodesItem(); | ||
await vouchersPage.addVoucherCodeDialog.typeCode(code); | ||
await vouchersPage.addVoucherCodeDialog.clickConfirmButton(); | ||
await vouchersPage.waitForGrid(); | ||
|
||
const manualCodesRows = await vouchersPage.getNumberOfGridRowsWithText(code); | ||
|
||
await expect( | ||
manualCodesRows, | ||
`Manually added code: ${code} should be visible on grid`, | ||
).toEqual(1); | ||
|
||
await vouchersPage.clickPercentDiscountTypeButton(); | ||
await vouchersPage.typeDiscountValueInChannel("Channel-PLN", "50"); | ||
await vouchersPage.clickSaveButton(); | ||
|
||
await vouchersPage.expectSuccessBanner(); | ||
await vouchersPage.waitForGrid(); | ||
const manualActiveCodesRows = await vouchersPage.getNumberOfGridRowsWithText( | ||
"Active", | ||
); | ||
|
||
await expect( | ||
manualActiveCodesRows, | ||
`Given codes: ${code} should have status Active displayed on grid`, | ||
).toEqual(1); | ||
}); | ||
|
||
test("TC: SALEOR_87 Edit voucher to have free shipping discount @vouchers @e2e", async () => { | ||
await vouchersPage.gotoExistingVoucherPage( | ||
VOUCHERS_AND_DISCOUNTS.vouchers.voucherToBeEditedWithFreeShipping.id, | ||
); | ||
await vouchersPage.waitForGrid(); | ||
const codesRows = await vouchersPage.getNumberOfGridRows(); | ||
|
||
await vouchersPage.clickFreeShippingDiscountTypeButton(); | ||
|
||
await expect( | ||
vouchersPage.discountValueInput, | ||
"No discount value input should be visible with free shipping type active ", | ||
).not.toBeVisible(); | ||
|
||
await vouchersPage.clickSaveButton(); | ||
await vouchersPage.waitForGrid(); | ||
|
||
await vouchersPage.expectSuccessBanner(); | ||
const codesRowsAfterSave = await vouchersPage.getNumberOfGridRows(); | ||
|
||
await expect( | ||
codesRows, | ||
`Same amount of codes should have status Active displayed on grid after switching to free shipping`, | ||
).toEqual(codesRowsAfterSave); | ||
}); | ||
test("TC: SALEOR_88 Edit voucher Usage limit: used in total, per customer, staff only, code used once @vouchers @e2e", async () => { | ||
await vouchersPage.gotoExistingVoucherPage( | ||
VOUCHERS_AND_DISCOUNTS.vouchers.voucherToBeEditedUsageLimits.id, | ||
); | ||
await vouchersPage.waitForGrid(); | ||
|
||
await vouchersPage.clickUsageTotalLimitCheckbox(); | ||
await vouchersPage.typeUsageLimit("100000"); | ||
await vouchersPage.clickOncePerCustomerLimitCheckbox(); | ||
await vouchersPage.clickOnlyForStaffLimitCheckbox(); | ||
await vouchersPage.clickSingleUseLimitCheckbox(); | ||
await vouchersPage.clickSaveButton(); | ||
await vouchersPage.waitForGrid(); | ||
|
||
await vouchersPage.expectSuccessBanner(); | ||
expect( | ||
await vouchersPage.usageLimitSection | ||
.locator('[class*="Mui-checked"]') | ||
.count(), | ||
"All usage limit checkboxes should be checked", | ||
).toEqual(4); | ||
}); |
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
Oops, something went wrong.