Skip to content

Commit b5c5fd7

Browse files
committed
test: fix e2e test
1 parent c7de465 commit b5c5fd7

File tree

6 files changed

+84
-147
lines changed

6 files changed

+84
-147
lines changed

e2e/docs/components/auto-link.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AutoLink v-for="item in anchorLinksConfig" :config="item" />
99
</div>
1010

11-
<div id="aria-label">
11+
<div id="config">
1212
<AutoLink :config="{ text: 'text', link: '/', ariaLabel: 'label' }" />
1313
</div>
1414

e2e/docs/components/route-link.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
- <RouteLink to="/README.md"><span>text</span></RouteLink>
5959
- <RouteLink to="/README.md"><span>text</span><span>text2</span></RouteLink>
6060
- <RouteLink to="/"><span>text</span></RouteLink>
61-
- <RouteLink to="/"><span>text</span><span>text</span></RouteLink>
61+
- <RouteLink to="/"><span>text</span><span>text2</span></RouteLink>
6262

6363
### Hash and query
6464

e2e/tests/components/auto-link.cy.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test.beforeEach(async ({ page }) => {
4+
await page.goto('components/auto-link.html')
5+
})
6+
7+
test('should render route-link correctly', async ({ page }) => {
8+
for (const el of await page
9+
.locator('.e2e-theme-content #route-link a')
10+
.all()) {
11+
await expect(el).toHaveAttribute('class', /route-link/)
12+
}
13+
})
14+
15+
test('should render anchor-link correctly', async ({ page }) => {
16+
for (const el of await page
17+
.locator('.e2e-theme-content #anchor-link a')
18+
.all()) {
19+
await expect(el).toHaveAttribute('class', /anchor-link/)
20+
}
21+
})
22+
23+
test('should render config correctly', async ({ page }) => {
24+
const locator = page.locator('.e2e-theme-content #config a')
25+
26+
await expect(locator).toHaveText('text')
27+
await expect(locator).toHaveAttribute('href', '/')
28+
await expect(locator).toHaveAttribute('aria-label', 'label')
29+
})

e2e/tests/components/route-link.cy.ts

Lines changed: 0 additions & 126 deletions
This file was deleted.

e2e/tests/components/route-link.spec.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ test('should render active status correctly', async ({ page }) => {
3838
const CONFIGS = [
3939
'route-link route-link-active',
4040
'route-link route-link-active',
41+
'route-link route-link-active',
42+
'route-link route-link-active',
43+
'route-link',
44+
'route-link',
4145
'route-link',
4246
'route-link',
4347
]
@@ -53,6 +57,8 @@ test('should render class correctly', async ({ page }) => {
5357
const CONFIGS = [
5458
'route-link custom-class',
5559
'route-link route-link-active custom-class',
60+
'route-link custom-class',
61+
'route-link route-link-active custom-class',
5662
]
5763

5864
for (const [index, className] of CONFIGS.entries()) {
@@ -80,6 +86,22 @@ test('should render attributes correctly', async ({ page }) => {
8086
attrName: 'aria-label',
8187
attrValue: 'test',
8288
},
89+
{
90+
attrName: 'title',
91+
attrValue: 'Title',
92+
},
93+
{
94+
attrName: 'target',
95+
attrValue: '_blank',
96+
},
97+
{
98+
attrName: 'rel',
99+
attrValue: 'noopener',
100+
},
101+
{
102+
attrName: 'aria-label',
103+
attrValue: 'test',
104+
},
83105
]
84106

85107
for (const [index, { attrName, attrValue }] of CONFIGS.entries()) {
@@ -99,6 +121,14 @@ test('should render slots correctly', async ({ page }) => {
99121
spansCount: 2,
100122
spansText: ['text', 'text2'],
101123
},
124+
{
125+
spansCount: 1,
126+
spansText: ['text'],
127+
},
128+
{
129+
spansCount: 2,
130+
spansText: ['text', 'text2'],
131+
},
102132
]
103133
for (const [index, { spansCount, spansText }] of CONFIGS.entries()) {
104134
const children = await page
@@ -114,6 +144,12 @@ test('should render slots correctly', async ({ page }) => {
114144

115145
test('should render hash and query correctly', async ({ page }) => {
116146
const CONFIGS = [
147+
`${BASE}#hash`,
148+
`${BASE}?query`,
149+
`${BASE}?query#hash`,
150+
`${BASE}?query=1#hash`,
151+
`${BASE}?query=1&query=2#hash`,
152+
`${BASE}#hash?query=1&query=2`,
117153
`${BASE}#hash`,
118154
`${BASE}?query`,
119155
`${BASE}?query#hash`,
@@ -134,3 +170,20 @@ test('should render hash and query correctly', async ({ page }) => {
134170
).toHaveAttribute('href', href)
135171
}
136172
})
173+
174+
test('should render relative links correctly', async ({ page }) => {
175+
const CONFIGS = [
176+
BASE,
177+
`${BASE}404.html`,
178+
`${BASE}components/not-exist.html`,
179+
BASE,
180+
`${BASE}404.html`,
181+
`${BASE}components/not-exist.html`,
182+
]
183+
184+
for (const [index, href] of CONFIGS.entries()) {
185+
await expect(
186+
page.locator('.e2e-theme-content #relative + ul > li a').nth(index),
187+
).toHaveAttribute('href', href)
188+
}
189+
})

0 commit comments

Comments
 (0)