|
1 |
| -import { test, expect } from '@playwright/test'; |
| 1 | +import { test, expect } from "@playwright/test"; |
2 | 2 |
|
3 | 3 | async function search(page, text: string) {
|
4 |
| - const searchFieldButton = page.locator('.dsla-search-field button'); |
| 4 | + const searchFieldButton = page.locator(".dsla-search-field button"); |
5 | 5 | searchFieldButton.click();
|
6 | 6 |
|
7 |
| - await expect(page.locator('.aa-Input')).toBeFocused(); |
8 |
| - await page.fill('.aa-Input', text); |
9 |
| - await page.press('.aa-Input', 'Enter'); |
| 7 | + await expect(page.locator(".aa-Input")).toBeFocused(); |
| 8 | + await page.fill(".aa-Input", text); |
| 9 | + await page.press(".aa-Input", "Enter"); |
10 | 10 | }
|
11 | 11 |
|
12 |
| -test('basic search works', async ({ page }) => { |
13 |
| - await page.goto('http://localhost:3000/'); |
14 |
| - await search(page, '3'); |
| 12 | +test("basic search works", async ({ page }) => { |
| 13 | + await page.goto("http://localhost:3000/"); |
| 14 | + await search(page, "3"); |
15 | 15 |
|
16 |
| - await expect(page.url()).toBe('http://localhost:3000/docs/doc3'); |
17 |
| - await expect(page.locator('mark[data-markjs="true"]')).toHaveText('3'); |
| 16 | + await expect(page.url()).toBe("http://localhost:3000/docs/doc3"); |
| 17 | + await expect(page.locator('mark[data-markjs="true"]')).toHaveText("3"); |
18 | 18 | });
|
19 | 19 |
|
20 |
| -test('version matches version in version selector navbar item', async ({ page }) => { |
21 |
| - await page.goto('http://localhost:3000/'); |
22 |
| - const searchFieldButton = page.locator('.dsla-search-field button'); |
| 20 | +test("version matches version in version selector navbar item", async ({ |
| 21 | + page, |
| 22 | +}) => { |
| 23 | + await page.goto("http://localhost:3000/"); |
| 24 | + const searchFieldButton = page.locator(".dsla-search-field button"); |
23 | 25 |
|
24 |
| - await expect(searchFieldButton).toHaveText('Search... [1.0.0]'); |
| 26 | + await expect(searchFieldButton).toHaveText("Search... [1.0.0]"); |
25 | 27 |
|
26 |
| - const VERSION_SELECTOR = '.navbar__inner > div:nth-child(1) > div:nth-child(3)'; |
| 28 | + const VERSION_SELECTOR = |
| 29 | + ".navbar__inner > div:nth-child(1) > div:nth-child(3)"; |
27 | 30 | const currentVersionButton = page.locator(`${VERSION_SELECTOR} > a`);
|
28 |
| - await expect(currentVersionButton).toHaveText('1.0.0'); |
| 31 | + await expect(currentVersionButton).toHaveText("1.0.0"); |
29 | 32 |
|
30 | 33 | // Change version to 'Next'
|
31 |
| - await (currentVersionButton).hover(); |
| 34 | + await currentVersionButton.hover(); |
32 | 35 | await page.locator(`${VERSION_SELECTOR} > ul > li:nth-child(1) > a`).click();
|
33 | 36 |
|
34 |
| - await expect(currentVersionButton).toHaveText('Next'); |
35 |
| - await expect(searchFieldButton).toHaveText('Search... [Next]'); |
| 37 | + await expect(currentVersionButton).toHaveText("Next"); |
| 38 | + await expect(searchFieldButton).toHaveText("Search... [Next]"); |
36 | 39 |
|
37 | 40 | // Go back to the homepage, which does not indicate in its url which version is active
|
38 |
| - await page.goto('http://localhost:3000/'); |
39 |
| - await expect(currentVersionButton).toHaveText('Next'); |
40 |
| - await expect(searchFieldButton).toHaveText('Search... [Next]'); |
| 41 | + await page.goto("http://localhost:3000/"); |
| 42 | + await expect(currentVersionButton).toHaveText("Next"); |
| 43 | + await expect(searchFieldButton).toHaveText("Search... [Next]"); |
41 | 44 |
|
42 | 45 | // Reload the page - the active version should be persisted in localstorage
|
43 | 46 | await page.reload();
|
44 |
| - await expect(currentVersionButton).toHaveText('Next'); |
45 |
| - await expect(searchFieldButton).toHaveText('Search... [Next]'); |
| 47 | + await expect(currentVersionButton).toHaveText("Next"); |
| 48 | + await expect(searchFieldButton).toHaveText("Search... [Next]"); |
46 | 49 |
|
47 | 50 | // Go to a doc of version 1.0.0, it should change the version back to 1.0.0.
|
48 |
| - await page.goto('http://localhost:3000/docs/d-s-l-test') |
49 |
| - await expect(currentVersionButton).toHaveText('1.0.0'); |
50 |
| - await expect(searchFieldButton).toHaveText('Search... [1.0.0]'); |
| 51 | + await page.goto("http://localhost:3000/docs/d-s-l-test"); |
| 52 | + await expect(currentVersionButton).toHaveText("1.0.0"); |
| 53 | + await expect(searchFieldButton).toHaveText("Search... [1.0.0]"); |
51 | 54 | });
|
52 | 55 |
|
53 |
| -test('language-based search index is used', async ({ page }) => { |
| 56 | +test("language-based search index is used", async ({ page }) => { |
54 | 57 | // Go to a random English doc
|
55 |
| - await page.goto('http://localhost:3000/docs/next/d-s-l-test'); |
| 58 | + await page.goto("http://localhost:3000/docs/next/d-s-l-test"); |
56 | 59 |
|
57 |
| - await search(page, 'english'); |
58 |
| - await expect(page.url()).toBe('http://localhost:3000/docs/next/translated'); |
| 60 | + await search(page, "english"); |
| 61 | + await expect(page.url()).toBe("http://localhost:3000/docs/next/translated"); |
59 | 62 |
|
60 | 63 | // Go to a random German doc
|
61 |
| - await page.goto('http://localhost:3000/de/docs/next/d-s-l-test'); |
| 64 | + await page.goto("http://localhost:3000/de/docs/next/d-s-l-test"); |
62 | 65 |
|
63 |
| - await search(page, 'german'); |
64 |
| - await expect(page.url()).toBe('http://localhost:3000/de/docs/next/translated'); |
| 66 | + await search(page, "german"); |
| 67 | + await expect(page.url()).toBe( |
| 68 | + "http://localhost:3000/de/docs/next/translated" |
| 69 | + ); |
65 | 70 | });
|
0 commit comments