|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | + |
| 3 | +test('getNextPath with no querypath should return "/"', async ({ page }) => { |
| 4 | + page.on('console', (msg) => { |
| 5 | + const text = msg.text() |
| 6 | + if (!text.startsWith('[vite]')) { |
| 7 | + expect(text).toBe('nextPath: /') |
| 8 | + } |
| 9 | + }) |
| 10 | + |
| 11 | + await page.goto('/vue/') |
| 12 | +}) |
| 13 | + |
| 14 | +test('getNextPath with next=foo should return "/"', async ({ page }) => { |
| 15 | + page.on('console', (msg) => { |
| 16 | + const text = msg.text() |
| 17 | + if (!text.startsWith('[vite]')) { |
| 18 | + expect(text).toBe('nextPath: /') |
| 19 | + } |
| 20 | + }) |
| 21 | + |
| 22 | + await page.goto('/vue/?next=foo') |
| 23 | +}) |
| 24 | + |
| 25 | +test('getNextPath with next=http://foo.bar should return "/"', async ({ page }) => { |
| 26 | + page.on('console', (msg) => { |
| 27 | + const text = msg.text() |
| 28 | + if (!text.startsWith('[vite]')) { |
| 29 | + expect(text).toBe('nextPath: /') |
| 30 | + } |
| 31 | + }) |
| 32 | + |
| 33 | + await page.goto('/vue/?next=http://foo.bar') |
| 34 | +}) |
| 35 | + |
| 36 | +test('getNextPath with next=/next-url/ should return "/next-url/"', async ({ page }) => { |
| 37 | + page.on('console', (msg) => { |
| 38 | + const text = msg.text() |
| 39 | + if (!text.startsWith('[vite]')) { |
| 40 | + expect(text).toBe('nextPath: /next-url/') |
| 41 | + } |
| 42 | + }) |
| 43 | + |
| 44 | + await page.goto('/vue/?next=/next-url/') |
| 45 | +}) |
0 commit comments