Skip to content
Snippets Groups Projects
Commit 8c8e11b9 authored by ilyaukin's avatar ilyaukin
Browse files

Issue #3389608: Add a test for a home page search

parent 41916e8b
Branches 1.0.x
No related tags found
1 merge request!12Resolve #3389608 "Search"
[
{
"keyword": "dammit",
"results": [
"Futurama"
]
}
]
\ No newline at end of file
/**
* atk_search.spec.js
*
* Search tests.
*
*/
/** ESLint directives */
/* eslint-disable import/first */
import * as atkCommands from '../support/atk_commands';
import * as atkUtilities from '../support/atk_utilities';
// Set up Playwright.
const { test, expect } = require('@playwright/test');
import playwrightConfig from '../../playwright.config';
const baseUrl = playwrightConfig.use.baseURL;
// Import ATK Configuration.
import atkConfig from '../../playwright.atk.config';
// Search keywords and expected results.
// Adjust for your site.
import searchData from '../data/search.json';
test.describe('Search tests.', () => {
test('(ATK-PW-1160) Search content by a keyword. @ATK-PW-1160 @search @content', async ({ page }) => {
await page.goto(baseUrl);
for (let item of searchData) {
await page.getByRole("button", { name: "Search Form" }).click();
const keyInput = page.locator('input:focus');
await keyInput.fill(item.keyword);
await keyInput.press("Enter");
// Wait for search result to be shown.
await expect(page.getByText('Search results')).toBeVisible();
// Check that expected items are shown.
for (let result of item.results) {
await expect(page.getByText(result)).toBeVisible();
}
// Check that the search keyword is highlighted in the text.
await expect(page.locator(`xpath=//strong[.="${item.keyword}"]`).first()).toBeVisible();
}
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment