Skip to content
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
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
"description": "",
"main": "index.js",
"scripts": {
"test:a11y": "playwright test tests/accessibility --project=chromium"
"test": "playwright test",
"test:chromium": "playwright test --project=chromium",
"test:firefox": "playwright test --project=firefox",
"test:webkit": "playwright test --project=webkit",
"test:smoke": "playwright test --grep @smoke",
"test:functional": "playwright test --grep @functional",
"test:integration": "playwright test --grep @integration",
"test:negative": "playwright test --grep @negative",
"test:a11y": "playwright test --grep @a11y",
"report": "playwright show-report"
},
"keywords": [],
"author": "",
Expand Down
16 changes: 13 additions & 3 deletions pages/HomePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ export class HomePage {
}

async searchFor(query: string): Promise<void> {
await expect(this.searchInput).toBeVisible({ timeout: 10000 });

await this.searchInput.click();
await this.searchInput.fill(query);
await expect(this.searchInput).toHaveValue(query);

await Promise.all([
this.page.waitForURL(/\/search(?:\?|\/|$)/, {
waitUntil: 'domcontentloaded',
}),
this.page.waitForURL(
(url) =>
url.pathname === '/search' &&
url.searchParams.get('q') === query,
{
waitUntil: 'domcontentloaded',
timeout: 15000,
}
),
this.searchInput.press('Enter'),
]);
}
Expand Down
26 changes: 21 additions & 5 deletions pages/SearchResultsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,29 @@ export class SearchResultsPage {
this.noResultsMessage = page.getByText(
/no results|nothing found|did not match|try a different search/i
);

}

private async expectSearchUrlContainsQuery(query: string): Promise<void> {
await expect(this.page).toHaveURL(/\/search(?:\?|\/|$)/);

await expect
.poll(
() => {
const currentUrl = new URL(this.page.url());
return currentUrl.searchParams.get('q') ?? '';
},
{
message: `Expected search URL to contain query: ${query}`,
timeout: 10000,
}
)
.toBe(query);
}

async expectSearchResultsPageLoaded(query: string): Promise<void> {
await expect(this.page).toHaveURL(/\/search(\?|\/|$)/);
await expect(this.mainContent).toContainText(query, { timeout: 10000 });
}
await this.expectSearchUrlContainsQuery(query);
}

async expectResultContainingText(expectedText: string): Promise<void> {
const matchingResult = this.page
Expand Down Expand Up @@ -52,8 +69,7 @@ export class SearchResultsPage {
}

async expectGracefulNoResultState(query: string): Promise<void> {
await expect(this.page).toHaveURL(/\/search(?:\?|\/|$)/);
await expect(this.mainContent).toContainText(query, { timeout: 10000 });
await this.expectSearchUrlContainsQuery(query);

await expect(this.mainContent).not.toContainText(
/server error|something went wrong|application error|internal error/i
Expand Down
Loading