-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create storefront wishlist page and wishlist tasks #295
base: trunk
Are you sure you want to change the base?
Changes from all commits
1021620
0ccc4e7
ee07190
fb67c27
e00afd2
123b09a
468d1bf
bdf0226
15799d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,6 +28,10 @@ | |||||
public readonly consentCookieBannerContainer: Locator; | ||||||
public readonly offcanvasBackdrop: Locator; | ||||||
|
||||||
//wishlist | ||||||
public readonly wishlistIcon: Locator; | ||||||
public readonly wishlistBasket: Locator; | ||||||
|
||||||
constructor(public readonly page: Page) { | ||||||
this.accountMenuButton = page.getByLabel('Your account'); | ||||||
this.closeGuestSessionButton = page.locator('.account-aside-btn'); | ||||||
|
@@ -63,6 +67,11 @@ | |||||
exact: true, | ||||||
}); | ||||||
this.offcanvasBackdrop = page.locator('.offcanvas-backdrop'); | ||||||
|
||||||
//wishlist | ||||||
this.wishlistIcon = page.locator('.header-wishlist-icon'); | ||||||
this.wishlistBasket = page.locator('.header-wishlist-badge'); | ||||||
this.contactFormLink = this.page.getByRole('listitem').getByTitle('Contact form', { exact: true }); | ||||||
} | ||||||
|
||||||
async getMenuItemByCategoryName(categoryName: string): Promise<Record<string, Locator>> { | ||||||
|
@@ -97,6 +106,9 @@ | |||||
const productAddToShoppingCart = listingItem.getByRole('button', { | ||||||
name: 'Add to shopping cart', | ||||||
}); | ||||||
const wishlistNotAddedIcon = listingItem.locator('.product-wishlist-not-added'); | ||||||
const wishlistAddedIcon = listingItem.locator('.product-wishlist-added'); | ||||||
const removeProductFromWishlist = listingItem.locator('.icon-wishlist-remove'); | ||||||
|
||||||
return { | ||||||
productImage: productImage, | ||||||
|
@@ -108,10 +120,13 @@ | |||||
productPrice: productPrice, | ||||||
productName: productName, | ||||||
productAddToShoppingCart: productAddToShoppingCart, | ||||||
wishlistNotAddedIcon: wishlistNotAddedIcon, | ||||||
wishlistAddedIcon: wishlistAddedIcon, | ||||||
removeFromWishlistXButton: removeProductFromWishlist, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
} | ||||||
|
||||||
url() { | ||||||
return './'; | ||||||
} | ||||||
} | ||||||
} |
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; | ||
Comment on lines
+10
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can extend these elements from OffCanvasCart.ts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then he has to extend the whole class... It doesn't make sense logically but technically possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it make more sense to inject the OffCanvasCart fixture in the test instead of defining the locators here in the Whitelist again. |
||
|
||
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`; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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); | ||
}, | ||
}); | ||
|
||
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); | ||
}, | ||
}); | ||
|
||
export const AddProductToWishlist = base.extend<{ AddProductToWishlist: Task }, FixtureTypes>({ | ||
AddProductToWishlist: async ({ StorefrontHome , ShopCustomer}, use) => { | ||
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); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SOemthing went wrong here during the merge or?