Skip to content

Commit c2b0500

Browse files
committed
test: add e2e tests
1 parent 26c28ed commit c2b0500

File tree

2 files changed

+98
-4
lines changed

2 files changed

+98
-4
lines changed

e2e/docs/router/navigate-by-link.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
<!-- TODO -->
1+
## Markdown Links with html
2+
3+
- [Home with query](/?home=true)
4+
- [Home with query and hash](/?home=true#home)
5+
- [404 with hash](/404.html#404)
6+
- [404 with hash and query](/404.html#404?notFound=true)
7+
8+
## Markdown Links with md
9+
10+
- [Home with query](/README.md?home=true)
11+
- [Home with query and hash](/README.md?home=true#home)
12+
- [404 with hash](/404.md#404)
13+
- [404 with hash and query](/404.md#404?notFound=true)
14+
15+
## HTML Links
16+
17+
<a href="/?home=true" class="home-with-query">Home</a>
18+
<a href="/?home=true#home" class="home-with-query-and-hash">Home</a>
19+
<a href="/404.html#404" class="not-found-with-hash">404</a>
20+
<a href="/404.html#404?notFound=true" class="not-found-with-hash-and-query">404</a>

e2e/tests/router/navigate-by-link.spec.ts

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,82 @@ test.beforeEach(async ({ page }) => {
55
await page.goto('router/navigate-by-link.html')
66
})
77

8-
test('TODO', async ({ page }) => {
9-
// TODO
10-
await expect(page).toHaveURL(`${BASE}router/navigate-by-link.html`)
8+
test.describe('should preserve query', () => {
9+
test('markdown links with html suffix', async ({ page }) => {
10+
await page.locator('#markdown-links-with-html + ul > li > a').nth(0).click()
11+
await expect(page).toHaveURL(`${BASE}?home=true`)
12+
await expect(page.locator('#home-h2')).toHaveText('Home H2')
13+
})
14+
15+
test('markdown links with md suffix', async ({ page }) => {
16+
await page.locator('#markdown-links-with-md + ul > li > a').nth(0).click()
17+
await expect(page).toHaveURL(`${BASE}?home=true`)
18+
await expect(page.locator('#home-h2')).toHaveText('Home H2')
19+
})
20+
21+
test('html links', async ({ page }) => {
22+
await page.locator('#html-links + a').nth(0).click()
23+
await expect(page).toHaveURL(`${BASE}?home=true`)
24+
await expect(page.locator('#home-h2')).toHaveText('Home H2')
25+
})
26+
})
27+
28+
test.describe('should preserve query and hash', () => {
29+
test('markdown links with html suffix', async ({ page }) => {
30+
await page.locator('#markdown-links-with-html + ul > li > a').nth(1).click()
31+
await expect(page).toHaveURL(`${BASE}?home=true#home`)
32+
await expect(page.locator('#home-h2')).toHaveText('Home H2')
33+
})
34+
35+
test('markdown links with md suffix', async ({ page }) => {
36+
await page.locator('#markdown-links-with-md + ul > li > a').nth(1).click()
37+
await expect(page).toHaveURL(`${BASE}?home=true#home`)
38+
await expect(page.locator('#home-h2')).toHaveText('Home H2')
39+
})
40+
41+
test('html links', async ({ page }) => {
42+
await page.locator('#html-links + a + a').nth(1).click()
43+
await expect(page).toHaveURL(`${BASE}?home=true#home`)
44+
await expect(page.locator('#home-h2')).toHaveText('Home H2')
45+
})
46+
})
47+
48+
test.describe('should preserve hash', () => {
49+
test('markdown links with html suffix', async ({ page }) => {
50+
await page.locator('#markdown-links-with-html + ul > li > a').nth(2).click()
51+
await expect(page).toHaveURL(`${BASE}404.html#404`)
52+
await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2')
53+
})
54+
55+
test('markdown links with md suffix', async ({ page }) => {
56+
await page.locator('#markdown-links-with-md + ul > li > a').nth(2).click()
57+
await expect(page).toHaveURL(`${BASE}404.html#404`)
58+
await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2')
59+
})
60+
61+
test('html links', async ({ page }) => {
62+
await page.locator('#html-links + a + a + a').nth(2).click()
63+
await expect(page).toHaveURL(`${BASE}404.html#404`)
64+
await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2')
65+
})
66+
})
67+
68+
test.describe('should preserve hash and query', () => {
69+
test('markdown links with html suffix', async ({ page }) => {
70+
await page.locator('#markdown-links-with-html + ul > li > a').nth(3).click()
71+
await expect(page).toHaveURL(`${BASE}404.html#404?notFound=true`)
72+
await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2')
73+
})
74+
75+
test('markdown links with md suffix', async ({ page }) => {
76+
await page.locator('#markdown-links-with-md + ul > li > a').nth(3).click()
77+
await expect(page).toHaveURL(`${BASE}404.html#404?notFound=true`)
78+
await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2')
79+
})
80+
81+
test('html links', async ({ page }) => {
82+
await page.locator('#html-links + a + a + a + a').nth(3).click()
83+
await expect(page).toHaveURL(`${BASE}404.html#404?notFound=true`)
84+
await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2')
85+
})
1186
})

0 commit comments

Comments
 (0)