From b8294a13fe6e0d260391e933e59d34edef28ed4b Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Thu, 10 Oct 2024 12:27:25 +0800 Subject: [PATCH] test(e2e): improve auto-link component test case --- e2e/tests/components/auto-link.spec.ts | 35 +++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/e2e/tests/components/auto-link.spec.ts b/e2e/tests/components/auto-link.spec.ts index 27eae26287..2d85ac3a71 100644 --- a/e2e/tests/components/auto-link.spec.ts +++ b/e2e/tests/components/auto-link.spec.ts @@ -8,8 +8,41 @@ test.beforeEach(async ({ page }) => { test('should render route-link correctly', async ({ page }) => { const locator = page.locator('.e2e-theme-content #route-link a') - for (const el of await locator.all()) { + const count = await locator.count() + + const results = [ + '/', + '/', + '/', + '/not-existent.html', + '/not-existent.html', + '/not-existent.html', + '/routes/non-ascii-paths/中文目录名/中文文件名.html', + '/routes/non-ascii-paths/中文目录名/中文文件名.html', + '/routes/non-ascii-paths/中文目录名/中文文件名.html', + '/#hash', + '/?query', + '/?query#hash', + '#hash', + '?query', + '?query#hash', + 'route-link.html', + 'route-link.html', + 'route-link.html', + 'not-existent.html', + 'not-existent.html', + 'not-existent.html', + '../', + '../', + '../404.html', + '../404.html', + ] + + for (let index = 0; index < count; index++) { + const el = locator.nth(index) + await expect(el).toHaveAttribute('class', /route-link/) + await expect(el).toHaveAttribute('href', results[0].replace(/^\//, BASE)) } })