Skip to content
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

fix: add methods to suggest page and fix lineitems in homepage #283

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/page-objects/storefront/Home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Home implements PageObject {
this.accountMenuButton = page.getByLabel('Your account');
this.closeGuestSessionButton = page.locator('.account-aside-btn');
this.productImages = page.locator('.product-image-wrapper');
this.productListItems = page.getByRole('listitem');
this.productListItems = page.locator('.product-box');
frobel marked this conversation as resolved.
Show resolved Hide resolved
this.languagesDropdown = page.locator('.top-bar-language').filter({ has: page.getByRole('button') });
this.languagesMenuOptions = page.locator('.top-bar-language').filter({ has: page.getByRole('list') });
this.currenciesDropdown = page.locator('.top-bar-currency').filter({ has: page.getByRole('button') });
Expand Down
18 changes: 12 additions & 6 deletions src/page-objects/storefront/SearchSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,32 @@ import type { PageObject } from '../../types/PageObject';
import { Home } from './Home';

export class SearchSuggest extends Home implements PageObject {

public readonly searchSuggestLineItemImages: Locator;
public readonly searchInput: Locator;
public readonly searchIcon: Locator;
public readonly searchSuggestNoResult: Locator;
public readonly searchSuggestLineItemName: Locator;
public readonly searchSuggestLineItemPrice: Locator;
public readonly searchSuggestTotalLink: Locator;
public readonly searchResultTotal: Locator;
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');
this.searchSuggestNoResult = page.locator ('.search-suggest-no-result');
this.searchSuggestLineItemName = page.locator ('.search-suggest-product-name');
this.searchSuggestLineItemPrice = page.locator ('.col-auto.search-suggest-product-price');
this.searchSuggestTotalLink = page.locator ('.search-suggest-total-link');
this.searchHeadline = page.locator ('.search-headline');
this.searchSuggestNoResult = page.locator('.search-suggest-no-result');
this.searchSuggestLineItemName = page.locator('.search-suggest-product-name');
this.searchSuggestLineItemPrice = page.locator('.col-auto.search-suggest-product-price');
this.searchSuggestTotalLink = page.locator('.search-suggest-total-link');
this.searchResultTotal = page.locator('.search-suggest-total-count');
this.searchHeadline = page.locator('.search-headline');
}

async getTotalSearchResultCount(): Promise<number> {
const totalCountText = await this.searchResultTotal.textContent();
return parseInt(totalCountText?.trim().replace(/\D/g, '') || '0', 10);
}

url(searchTerm?: string) {
Expand Down
7 changes: 4 additions & 3 deletions src/tasks/shop-customer-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Register } from './shop-customer/Account/Register';
import { RegisterGuest } from './shop-customer/Account/RegisterGuest';
import { ChangeStorefrontCurrency } from './shop-customer/Account/ChangeStorefrontCurrency';


import { AddProductToCart } from './shop-customer/Product/AddProductToCart';
import { ProceedFromProductToCheckout } from './shop-customer/Product/ProceedFromProductToCheckout';

Expand All @@ -22,6 +21,7 @@ import { SubmitOrder } from './shop-customer/Checkout/SubmitOrder';

import { OpenSearchResultPage } from './shop-customer/Search/OpenSearchResultPage';
import { OpenSearchSuggestPage } from './shop-customer/Search/OpenSearchSuggestPage';
import { SearchForTerm } from './shop-customer/Search/SearchForTerm';

import { ValidateAccessibility } from './shop-customer/Accessibility/ValidateAccessibility';

Expand All @@ -44,5 +44,6 @@ export const test = mergeTests(
SubmitOrder,
OpenSearchResultPage,
OpenSearchSuggestPage,
ValidateAccessibility,
);
SearchForTerm,
ValidateAccessibility
);
16 changes: 16 additions & 0 deletions src/tasks/shop-customer/Search/SearchForTerm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { test as base } from '@playwright/test';
import type { Task } from '../../../types/Task';
import type { FixtureTypes } from '../../../types/FixtureTypes';

export const SearchForTerm = base.extend<{ SearchForTerm: Task }, FixtureTypes>({
SearchForTerm: async ({ StorefrontSearchSuggest }, use) => {
const task = (searchTerm: string) => {
return async function SearchForTerm() {
await StorefrontSearchSuggest.searchInput.fill(searchTerm);
await StorefrontSearchSuggest.page.waitForResponse((response) => response.url().includes(`suggest?search=${searchTerm}`) && response.ok());
};
};

await use(task);
},
});
Loading