diff --git a/e2e/tests/router/navigate-by-link.spec.ts b/e2e/tests/router/navigate-by-link.spec.ts index a2076b0dd2..d8b68d0721 100644 --- a/e2e/tests/router/navigate-by-link.spec.ts +++ b/e2e/tests/router/navigate-by-link.spec.ts @@ -7,9 +7,16 @@ test.beforeEach(async ({ page }) => { test.describe('should preserve query', () => { test('markdown links with html suffix', async ({ page }) => { - await page.locator('#markdown-links-with-html + ul > li > a').nth(0).click() - await expect(page).toHaveURL(`${BASE}?home=true`) - await expect(page.locator('#home-h2')).toHaveText('Home H2') + const homeAnchor = page + .locator('#markdown-links-with-html + ul > li > a') + .nth(0) + if (BASE === '/') { + await homeAnchor.click() + await expect(page).toHaveURL('/?home=true') + await expect(page.locator('#home-h2')).toHaveText('Home H2') + } else { + expect(await homeAnchor.getAttribute('target')).toBe('_blank') + } }) test('markdown links with md suffix', async ({ page }) => { @@ -27,9 +34,16 @@ test.describe('should preserve query', () => { test.describe('should preserve query and hash', () => { test('markdown links with html suffix', async ({ page }) => { - await page.locator('#markdown-links-with-html + ul > li > a').nth(1).click() - await expect(page).toHaveURL(`${BASE}?home=true#home`) - await expect(page.locator('#home-h2')).toHaveText('Home H2') + const homeAnchor = page + .locator('#markdown-links-with-html + ul > li > a') + .nth(1) + if (BASE === '/') { + await homeAnchor.click() + await expect(page).toHaveURL('/?home=true#home') + await expect(page.locator('#home-h2')).toHaveText('Home H2') + } else { + expect(await homeAnchor.getAttribute('target')).toBe('_blank') + } }) test('markdown links with md suffix', async ({ page }) => { @@ -47,9 +61,16 @@ test.describe('should preserve query and hash', () => { test.describe('should preserve hash', () => { test('markdown links with html suffix', async ({ page }) => { - await page.locator('#markdown-links-with-html + ul > li > a').nth(2).click() - await expect(page).toHaveURL(`${BASE}404.html#404`) - await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2') + const notFound = page + .locator('#markdown-links-with-html + ul > li > a') + .nth(2) + if (BASE === '/') { + await notFound.click() + await expect(page).toHaveURL('/404.html#404') + await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2') + } else { + expect(await notFound.getAttribute('target')).toBe('_blank') + } }) test('markdown links with md suffix', async ({ page }) => { @@ -67,9 +88,16 @@ test.describe('should preserve hash', () => { test.describe('should preserve hash and query', () => { test('markdown links with html suffix', async ({ page }) => { - await page.locator('#markdown-links-with-html + ul > li > a').nth(3).click() - await expect(page).toHaveURL(`${BASE}404.html#404?notFound=true`) - await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2') + const notFound = page + .locator('#markdown-links-with-html + ul > li > a') + .nth(3) + if (BASE === '/') { + await notFound.click() + await expect(page).toHaveURL('/404.html#404?notFound=true') + await expect(page.locator('#notfound-h2')).toHaveText('NotFound H2') + } else { + expect(await notFound.getAttribute('target')).toBe('_blank') + } }) test('markdown links with md suffix', async ({ page }) => {