-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wishlist page and related tasks
- Loading branch information
Showing
6 changed files
with
97 additions
and
3 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
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,34 @@ | ||
import type { Page, Locator } from '@playwright/test'; | ||
import type { PageObject } from '../../types/PageObject'; | ||
import { Home } from './Home'; | ||
|
||
export class Wishlist extends Home implements PageObject { | ||
public readonly wishListHeader: Locator; | ||
public readonly removeAlert: Locator; | ||
public readonly emptyListing: Locator; | ||
|
||
public readonly offCanvas: Locator; | ||
public readonly offCanvasCartTitle: Locator; | ||
public readonly offCanvasCart: Locator; | ||
public readonly offCanvasCartGoToCheckoutButton: Locator; | ||
public readonly offCanvasLineItemImages: Locator; | ||
public readonly offCanvasSummaryTotalPrice: Locator; | ||
|
||
constructor(public readonly page: Page) { | ||
super(page); | ||
this.wishListHeader = page.locator('.wishlist-headline'); | ||
this.removeAlert = page.locator('.alert-content'); | ||
this.emptyListing = page.locator('.wishlist-listing-empty'); | ||
|
||
this.offCanvas = page.locator('offcanvas-body'); | ||
this.offCanvasCartTitle = page.getByText('Shopping cart', { exact: true }); | ||
this.offCanvasCart = page.getByRole('dialog'); | ||
this.offCanvasCartGoToCheckoutButton = page.getByRole('link', { name: 'Go to checkout' }); | ||
this.offCanvasLineItemImages = page.locator('.line-item-img-link'); | ||
this.offCanvasSummaryTotalPrice = page.locator('.offcanvas-summary').locator('dt:has-text("Subtotal") + dd'); | ||
} | ||
|
||
url() { | ||
return `wishlist`; | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/tasks/shop-customer/Wishlist/AddProductToCartFromWishlist.ts
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,20 @@ | ||
import { test as base } from '@playwright/test'; | ||
import type { Task } from '../../../types/Task'; | ||
import type { FixtureTypes } from '../../../types/FixtureTypes'; | ||
import { Product } from '../../../types/ShopwareTypes'; | ||
|
||
export const AddProductToCartFromWishlist = base.extend<{ AddProductToCartFromWishlist: Task }, FixtureTypes>({ | ||
AddProductToCartFromWishlist: async ({ ShopCustomer, StorefrontWishlist }, use) => { | ||
const task = (ProductData: Product) => { | ||
return async function AddProductToCart() { | ||
const listedItem = await StorefrontWishlist.getListingItemByProductId(ProductData.id); | ||
await listedItem.productAddToShoppingCart.click(); | ||
await StorefrontWishlist.page.waitForResponse((response) => response.url().includes(`checkout/offcanvas`) && response.ok()); | ||
await ShopCustomer.expects(StorefrontWishlist.offCanvasCartTitle).toBeVisible(); | ||
await ShopCustomer.expects(StorefrontWishlist.offCanvasCart.getByText(ProductData.name)).toBeVisible(); | ||
} | ||
}; | ||
|
||
await use(task); | ||
}, | ||
}); |
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 { test as base } from '@playwright/test'; | ||
import type { Task } from '../../../types/Task'; | ||
import type { FixtureTypes } from '../../../types/FixtureTypes'; | ||
import { Product } from '../../../types/ShopwareTypes'; | ||
|
||
export const AddProductToWishlist = base.extend<{ AddProductToWishlist: Task }, FixtureTypes>({ | ||
AddProductToWishlist: async ({ StorefrontHome , StorefrontWishlist, ShopCustomer}, use) => { | ||
Check warning on line 7 in src/tasks/shop-customer/Wishlist/AddProductToWishlist.ts GitHub Actions / eslint
|
||
const task = (ProductData: Product) => { | ||
return async function AddProductToWishlist() { | ||
const listedItem = await StorefrontHome.getListingItemByProductId(ProductData.id); | ||
await listedItem.wishlistNotAddedIcon.click(); | ||
await ShopCustomer.expects(listedItem.wishlistAddedIcon).toBeVisible(); | ||
} | ||
}; | ||
|
||
await use(task); | ||
}, | ||
}); |
18 changes: 18 additions & 0 deletions
18
src/tasks/shop-customer/Wishlist/RemoveProductFromWishlist.ts
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 { test as base } from '@playwright/test'; | ||
import type { Task } from '../../../types/Task'; | ||
import type { FixtureTypes } from '../../../types/FixtureTypes'; | ||
import { Product } from '../../../types/ShopwareTypes'; | ||
|
||
export const RemoveProductFromWishlist = base.extend<{ RemoveProductFromWishlist: Task }, FixtureTypes>({ | ||
RemoveProductFromWishlist: async ({ StorefrontHome , StorefrontWishlist}, use) => { | ||
const task = (ProductData: Product) => { | ||
return async function AddProductToWishlist() { | ||
const listedItem = await StorefrontHome.getListingItemByProductId(ProductData.id); | ||
await listedItem.wishlistAddedIcon.click(); | ||
await StorefrontWishlist.page.waitForResponse((response) => response.url().includes(`remove/${ProductData.id}`) && response.ok()); | ||
} | ||
}; | ||
|
||
await use(task); | ||
}, | ||
}); |