Skip to content

Commit

Permalink
fix: NEXT-40281 - add some locators and extend search suggest from home
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavli committed Jan 21, 2025
1 parent 4e49199 commit b0f5312
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions src/page-objects/storefront/SearchSuggest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';
import { Home } from './Home';

export class SearchSuggest implements PageObject {
export class SearchSuggest extends Home implements PageObject {

public readonly searchSuggestLineItemImages: Locator;
public readonly searchInput: Locator;
Expand All @@ -13,6 +14,7 @@ export class SearchSuggest implements PageObject {
public readonly searchHeadline: Locator;

constructor(public readonly page: Page) {
super(page);
this.searchSuggestLineItemImages = page.locator('.search-suggest-product-image-container');
this.searchInput = page.locator('.header-search-input');
this.searchIcon = page.locator('.header-search-icon');
Expand All @@ -23,32 +25,7 @@ export class SearchSuggest implements PageObject {
this.searchHeadline = page.locator ('.search-headline');
}

async getListingItemByProductId(productId: string): Promise<Record<string, Locator>> {
const listingItem = this.page.getByRole('listitem').filter({ has: this.page.locator(`[value="${productId}"]`) });
const productImage = listingItem.locator('.product-image-link');
const productRating = listingItem.locator('.product-rating');
const productVariantCharacteristics = listingItem.locator('.product-variant-characteristics');
const productDescription = listingItem.locator('.product-description');
const productPriceUnit = listingItem.locator('.product-price-unit');
const productCheapestPrice = listingItem.locator('.product-cheapest-price');
const productPrice = listingItem.locator('.product-price');
const productName = listingItem.locator('.product-name');
const productAddToShoppingCart = listingItem.getByRole('button', { name: 'Add to shopping cart' });

return {
productImage: productImage,
productRating: productRating,
productVariantCharacteristics: productVariantCharacteristics,
productDescription: productDescription,
productPriceUnit: productPriceUnit,
productCheapestPrice: productCheapestPrice,
productPrice: productPrice,
productName: productName,
productAddToShoppingCart: productAddToShoppingCart,
}
}

url(searchTerm: string) {
url(searchTerm?: string) {
return `suggest?search=${searchTerm}`;
}
}

0 comments on commit b0f5312

Please sign in to comment.