Repository navigation
Expand file tree
/
Copy pathsearch.spec.js
More file actions
84 lines (66 loc) · 2.29 KB
/
Copy pathsearch.spec.js
File metadata and controls
84 lines (66 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23<
8000
/div>
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// @ts-check
import { test, expect } from "@playwright/test";
const AxeBuilder = require("@axe-core/playwright").default;
test("Search has title", async ({ page }) => {
await page.goto("/search");
await expect(page).toHaveTitle(/Search/);
});
test("Navigate to the Search page", async ({ page }) => {
await page.goto("/");
await page.locator("a:visible", { hasText: "Search" }).click();
await expect(page.locator("h1")).toHaveText("Search");
});
test("Search works correctly", async ({ page }) => {
// 1. navigate to search page
await page.goto("/search");
// 2. show no users are listed
await expect(page.locator("li")).toHaveCount(0);
// 3. type in search and check that user with the name exist and check a name doesn't exist
const input = page.locator("[name='keyword']");
await input.type("_test-profile-user-1");
await expect(page.locator("li")).toHaveCount(1);
});
test("Search page has no results when no search term used", async ({
page,
}) => {
await page.goto("/search");
const input = page.locator("[name='keyword']");
await input.type("");
await expect(page.locator("li")).toHaveCount(0);
});
test("Search page shows no results after typing 2 characters", async ({
page,
}) => {
await page.goto("/search");
const input = page.locator("[name='keyword']");
await input.type("ed");
await expect(page.locator("li")).toHaveCount(0);
});
test("Search page shows results after typing 3 characters", async ({
page,
}) => {
await page.goto("/search");
const input = page.locator("[name='keyword']");
await input.type("aka");
await expect(page.locator("li")).toContainText(["aka"]);
});
test.fixme("After search click profile", async ({ page }) => {
// 1. perform search
// 2. click on searched profile
// 3. check profile is displayed
});
test.fixme(
"find the profile after providing concise name",
async ({ page }) => {
// 1. click on search profile
// 2. type the whole name
// 3. Display the profile if the name is correct
}
);
test("should pass axe wcag accessibility tests", async ({ page }) => {
await page.goto("/search");
const accessibilityScanResults = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});