-
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.
Merge branch 'main' into 4528-discount-filters
- Loading branch information
Showing
14 changed files
with
312 additions
and
4 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,12 @@ | ||
--- | ||
"saleor-dashboard": minor | ||
--- | ||
|
||
Migrated gift cards tests: | ||
- Issue gift card | ||
- Issue gift card with specific customer and expiry date | ||
- Resend code | ||
- Deactivate gift card | ||
- Activate gift card | ||
- Edit gift card | ||
- Bulk delete gift cards |
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,73 @@ | ||
import { Page } from "@playwright/test"; | ||
|
||
export class IssueGiftCardDialog { | ||
readonly page: Page; | ||
|
||
constructor( | ||
page: Page, | ||
readonly enterAmountInput = page.locator('[name="balanceAmount"]'), | ||
readonly expiryPeriodAmountInput = page.locator( | ||
'[name="expiryPeriodAmount"]', | ||
), | ||
readonly tagsInput = page | ||
.getByTestId("gift-card-tag-select-field") | ||
.locator("input"), | ||
readonly cardCode = page.getByTestId("cardCode"), | ||
|
||
readonly sendToCustomerCheckbox = page | ||
.getByTestId("send-to-customer-section") | ||
.locator("input"), | ||
readonly sendExpireDateCheckbox = page | ||
.getByTestId("expiry-section") | ||
.locator("input"), | ||
readonly customerInput = page | ||
.getByTestId("customer-field") | ||
.locator("input"), | ||
readonly noteTextArea = page | ||
.getByTestId("note-field") | ||
.locator('[name="note"]'), | ||
readonly requiresActivationCheckbox = page | ||
.getByTestId("requires-activation-section") | ||
.locator("input"), | ||
readonly issueButton = page.getByTestId("submit"), | ||
readonly okButton = page.getByTestId("submit"), | ||
readonly copyCodeButton = page.getByTestId("copy-code-button"), | ||
) { | ||
this.page = page; | ||
} | ||
|
||
async clickIssueButton() { | ||
await this.issueButton.click(); | ||
} | ||
async clickOkButton() { | ||
await this.okButton.click(); | ||
} | ||
async clickCopyCodeButton() { | ||
await this.copyCodeButton.click(); | ||
} | ||
async typeAmount(amount: string) { | ||
await this.enterAmountInput.fill(amount); | ||
} | ||
async typeCustomer(customer: string) { | ||
await this.customerInput.fill(customer); | ||
} | ||
async typeExpiryPeriodAmount(expiryPeriodAmount: string) { | ||
await this.expiryPeriodAmountInput.fill(expiryPeriodAmount); | ||
} | ||
async typeTag(tag: string) { | ||
await this.tagsInput.fill(tag); | ||
} | ||
async typeNote(tag: string) { | ||
await this.noteTextArea.fill(tag); | ||
} | ||
|
||
async clickSendToCustomerCheckbox() { | ||
await this.sendToCustomerCheckbox.click(); | ||
} | ||
async clickSendExpireDateCheckbox() { | ||
await this.sendExpireDateCheckbox.click(); | ||
} | ||
async clickRequiresActivationCheckbox() { | ||
await this.requiresActivationCheckbox.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,14 @@ | ||
import { Page } from "@playwright/test"; | ||
|
||
export class ResendGiftCardCodeDialog { | ||
readonly page: Page; | ||
|
||
constructor(page: Page, readonly resendButton = page.getByTestId("submit")) { | ||
this.page = page; | ||
} | ||
|
||
async clickResendButton() { | ||
await this.resendButton.click(); | ||
await this.resendButton.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { URL_LIST } from "@data/url"; | ||
import { DeleteDialog } from "@dialogs/deleteDialog"; | ||
import { IssueGiftCardDialog } from "@dialogs/issueGiftCardDialog"; | ||
import { ResendGiftCardCodeDialog } from "@dialogs/resendGiftCardCodeDialog"; | ||
import { MetadataSeoPage } from "@pageElements/metadataSeoPage"; | ||
import { BasePage } from "@pages/basePage"; | ||
import type { Page } from "@playwright/test"; | ||
|
||
export class GiftCardsPage extends BasePage { | ||
readonly page: Page; | ||
readonly issueGiftCardDialog: IssueGiftCardDialog; | ||
readonly resendGiftCardCodeDialog: ResendGiftCardCodeDialog; | ||
readonly metadataSeoPage: MetadataSeoPage; | ||
readonly deleteDialog: DeleteDialog; | ||
|
||
constructor( | ||
page: Page, | ||
readonly issueCardButton = page.getByTestId("issue-card-button"), | ||
readonly bulkDeleteButton = page.getByTestId("bulk-delete-button"), | ||
readonly resendCodeButton = page.getByTestId("resend-code"), | ||
readonly deactivateButton = page.getByTestId("enable-button"), | ||
readonly saveButton = page.getByTestId("button-bar-confirm"), | ||
readonly cardExpiresCheckbox = page.locator("[name='cardExpires']"), | ||
) { | ||
super(page); | ||
this.page = page; | ||
this.issueGiftCardDialog = new IssueGiftCardDialog(page); | ||
this.resendGiftCardCodeDialog = new ResendGiftCardCodeDialog(page); | ||
this.metadataSeoPage = new MetadataSeoPage(page); | ||
this.deleteDialog = new DeleteDialog(page); | ||
} | ||
|
||
async clickIssueCardButton() { | ||
await this.issueCardButton.click(); | ||
} | ||
async clickBulkDeleteButton() { | ||
await this.bulkDeleteButton.click(); | ||
} | ||
async clickSaveButton() { | ||
await this.saveButton.click(); | ||
} | ||
async clickCardExpiresCheckbox() { | ||
await this.cardExpiresCheckbox.click(); | ||
} | ||
async clickDeactivateButton() { | ||
await this.deactivateButton.click(); | ||
} | ||
async clickResendCodeButton() { | ||
await this.resendCodeButton.click(); | ||
} | ||
async gotoGiftCardsListView() { | ||
await this.page.goto(URL_LIST.giftCards); | ||
} | ||
async gotoExistingGiftCardView(giftCardId: string) { | ||
const existingGiftCardUrl = URL_LIST.giftCards + giftCardId; | ||
await console.log( | ||
"Navigating to existing gift card: " + existingGiftCardUrl, | ||
); | ||
|
||
await this.page.goto(existingGiftCardUrl); | ||
} | ||
} |
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,102 @@ | ||
import { GIFT_CARDS } from "@data/e2eTestData"; | ||
import { GiftCardsPage } from "@pages/giftCardsPage"; | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.use({ storageState: "playwright/.auth/admin.json" }); | ||
let giftCardsPage: GiftCardsPage; | ||
test.beforeEach(({ page }) => { | ||
giftCardsPage = new GiftCardsPage(page); | ||
}); | ||
|
||
test("TC: SALEOR_105 Issue gift card @e2e @gift", async () => { | ||
await giftCardsPage.gotoGiftCardsListView(); | ||
await giftCardsPage.waitForGrid(); | ||
const numberOfGiftCards = await giftCardsPage.getNumberOfGridRows(); | ||
await giftCardsPage.clickIssueCardButton(); | ||
await giftCardsPage.issueGiftCardDialog.typeAmount("50"); | ||
await giftCardsPage.issueGiftCardDialog.typeTag( | ||
"super ultra automation discount", | ||
); | ||
await giftCardsPage.issueGiftCardDialog.clickRequiresActivationCheckbox(); | ||
await giftCardsPage.issueGiftCardDialog.clickIssueButton(); | ||
await expect(giftCardsPage.issueGiftCardDialog.cardCode).toBeVisible(); | ||
await giftCardsPage.issueGiftCardDialog.clickCopyCodeButton(); | ||
await giftCardsPage.expectSuccessBanner(); | ||
await giftCardsPage.issueGiftCardDialog.clickOkButton(); | ||
await giftCardsPage.waitForGrid(); | ||
const numberOfGiftCardsAfterCreation = | ||
await giftCardsPage.getNumberOfGridRows(); | ||
expect(numberOfGiftCardsAfterCreation - numberOfGiftCards).toEqual(1); | ||
}); | ||
test("TC: SALEOR_106 Issue gift card with specific customer and expiry date @e2e @gift", async () => { | ||
await giftCardsPage.gotoGiftCardsListView(); | ||
await giftCardsPage.waitForGrid(); | ||
const numberOfGiftCards = await giftCardsPage.getNumberOfGridRows(); | ||
await giftCardsPage.clickIssueCardButton(); | ||
await giftCardsPage.issueGiftCardDialog.clickSendToCustomerCheckbox(); | ||
await giftCardsPage.issueGiftCardDialog.typeCustomer("Allison Freeman"); | ||
await giftCardsPage.issueGiftCardDialog.clickSendExpireDateCheckbox(); | ||
await giftCardsPage.issueGiftCardDialog.typeExpiryPeriodAmount("2"); | ||
await giftCardsPage.issueGiftCardDialog.clickIssueButton(); | ||
await expect(giftCardsPage.issueGiftCardDialog.cardCode).toBeVisible(); | ||
await giftCardsPage.issueGiftCardDialog.clickOkButton(); | ||
await giftCardsPage.waitForGrid(); | ||
const numberOfGiftCardsAfterCreation = | ||
await giftCardsPage.getNumberOfGridRows(); | ||
expect(numberOfGiftCardsAfterCreation - numberOfGiftCards).toEqual(1); | ||
}); | ||
test("TC: SALEOR_107 Resend code @e2e @gift", async () => { | ||
await giftCardsPage.gotoGiftCardsListView(); | ||
await giftCardsPage.waitForGrid(); | ||
await giftCardsPage.clickListRowBasedOnContainingText( | ||
GIFT_CARDS.giftCardToResendCode.name, | ||
); | ||
await giftCardsPage.clickResendCodeButton(); | ||
await giftCardsPage.resendGiftCardCodeDialog.clickResendButton(); | ||
|
||
await giftCardsPage.expectSuccessBanner(); | ||
}); | ||
test("TC: SALEOR_108 Deactivate gift card @e2e @gift", async () => { | ||
await giftCardsPage.gotoExistingGiftCardView( | ||
GIFT_CARDS.giftCardToBeDeactivated.id, | ||
); | ||
await giftCardsPage.clickDeactivateButton(); | ||
await giftCardsPage.expectSuccessBanner(); | ||
await expect(giftCardsPage.pageHeader).toContainText("Disabled"); | ||
}); | ||
test("TC: SALEOR_109 Activate gift card @e2e @gift", async () => { | ||
await giftCardsPage.gotoExistingGiftCardView( | ||
GIFT_CARDS.giftCardToBeActivated.id, | ||
); | ||
await giftCardsPage.clickDeactivateButton(); | ||
await giftCardsPage.expectSuccessBanner(); | ||
await expect(giftCardsPage.pageHeader).not.toContainText("Disabled"); | ||
}); | ||
test("TC: SALEOR_110 Edit gift card @e2e @gift", async () => { | ||
await giftCardsPage.gotoExistingGiftCardView( | ||
GIFT_CARDS.giftCardToBeEdited.id, | ||
); | ||
await giftCardsPage.clickCardExpiresCheckbox(); | ||
await giftCardsPage.metadataSeoPage.expandAndAddAllMetadata(); | ||
await giftCardsPage.clickSaveButton(); | ||
await giftCardsPage.expectSuccessBanner(); | ||
}); | ||
test("TC: SALEOR_111 Bulk delete gift cards @e2e @gift", async () => { | ||
await giftCardsPage.gotoGiftCardsListView(); | ||
await giftCardsPage.waitForGrid(); | ||
const numberOfGiftCards = await giftCardsPage.getNumberOfGridRows(); | ||
|
||
await giftCardsPage.checkListRowsBasedOnContainingText( | ||
GIFT_CARDS.giftCardsToBeDeleted.names, | ||
); | ||
await giftCardsPage.clickBulkDeleteButton(); | ||
await giftCardsPage.deleteDialog.clickConfirmDeletionCheckbox(); | ||
await giftCardsPage.deleteDialog.clickDeleteButton(); | ||
await giftCardsPage.waitForGrid(); | ||
|
||
expect( | ||
await giftCardsPage.findRowIndexBasedOnText( | ||
GIFT_CARDS.giftCardsToBeDeleted.names, | ||
), | ||
).toEqual([]); | ||
}); |
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