Skip to content

Commit

Permalink
test(e2e): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed May 26, 2024
1 parent 1a28db6 commit c3655b1
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions e2e/tests/router/navigate-by-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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 }) => {
Expand All @@ -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 }) => {
Expand All @@ -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 }) => {
Expand Down

0 comments on commit c3655b1

Please sign in to comment.