Skip to content

Commit

Permalink
test: add waitUntil: 'networkidle'
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Mar 26, 2024
1 parent 196902d commit 3925920
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions test/e2e/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,38 @@ describe('react e2e test', () => {
const getUrl = (path: string) => `http://localhost:${server.config.server.port}${path}`

it('/blog/today have content', async () => {
await page.goto(getUrl('/blog/today'))
await page.goto(getUrl('/blog/today'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today/index')
})

it('/blog/today/xxx - nested cache all', async () => {
await page.goto(getUrl('/blog/today/xxx'))
await page.goto(getUrl('/blog/today/xxx'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today ...all route')
})

it('/xxx/xxx - cache all route', async () => {
await page.goto(getUrl('/xxx/xxx'))
await page.goto(getUrl('/xxx/xxx'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('...all route')
})

it('/blog/1b234bk12b3 - dynamic route', async () => {
await page.goto(getUrl('/blog/1b234bk12b3'))
await page.goto(getUrl('/blog/1b234bk12b3'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div > p').textContent()
expect(text?.trim()).toBe('blog/[id].tsx: 1b234bk12b3')
})

it('hmr - dynamic add /test route', async () => {
await page.goto(getUrl('/'))
await page.goto(getUrl('/'), { waitUntil: 'networkidle' })

await copyFile(srcPath, distPath)

// wait page reload
await page.waitForLoadState('networkidle')

await page.goto(getUrl('/test'))
await page.goto(getUrl('/test'), { waitUntil: 'networkidle' })

const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('this is test file')
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/solid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,44 @@ describe('solid e2e test', () => {
const getUrl = (path: string) => `http://localhost:${server.config.server.port}${path}`

it('/blog/today have content', async () => {
await page.goto(getUrl('/blog/today'))
await page.goto(getUrl('/blog/today'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today/index.tsx')
})

it('/blog/today/xxx - nested cache all', async () => {
await page.goto(getUrl('/blog/today/xxx'))
await page.goto(getUrl('/blog/today/xxx'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today ...all route')
})

it('/xxx/xxx - cache all route', async () => {
await page.goto(getUrl('/xxx/xxx'))
await page.goto(getUrl('/xxx/xxx'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('...all route')
})

it('/about/1b234bk12b3/more deep nested dynamic route', async () => {
await page.goto(getUrl('/about/1b234bk12b3/more'))
await page.goto(getUrl('/about/1b234bk12b3/more'), { waitUntil: 'networkidle' })
const text = await page.locator('div.deep-more').textContent()
expect(text?.trim()).toBe('deep nested: about/[id]/more.tsx')
})

it('/features/dashboard custom routes folder', async () => {
await page.goto(getUrl('/features/dashboard'))
await page.goto(getUrl('/features/dashboard'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div > p >> nth=0').textContent()
expect(text?.trim()).toBe('features/dashboard/pages/dashboard.tsx')
})

it('hmr - dynamic add /test route', async () => {
await page.goto(getUrl('/'))
await page.goto(getUrl('/'), { waitUntil: 'networkidle' })

await copyFile(srcPath, distPath)

// wait page reload
await page.waitForLoadState('networkidle')

await page.goto(getUrl('/test'))
await page.goto(getUrl('/test'), { waitUntil: 'networkidle' })

const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('this is test file')
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,50 +36,50 @@ describe('vue e2e test', () => {
const getUrl = (path: string) => `http://localhost:${server.config.server.port}${path}`

it('/blog/today have content', async () => {
await page.goto(getUrl('/blog/today'))
await page.goto(getUrl('/blog/today'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today/index.vue')
})

it('/blog/today/xxx - nested cache all', async () => {
await page.goto(getUrl('/blog/today/xxx'))
await page.goto(getUrl('/blog/today/xxx'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('blog/today ...all route')
})

it('/markdown have markdown content', async () => {
await page.goto(getUrl('/markdown'))
await page.goto(getUrl('/markdown'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div > div > h1').textContent()
expect(text?.trim()).toBe('hello from markdown file')
})

it('/xxx/xxx - cache all route', async () => {
await page.goto(getUrl('/xxx/xxx'))
await page.goto(getUrl('/xxx/xxx'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('...all route')
})

it('/about/1b234bk12b3/more deep nested dynamic route', async () => {
await page.goto(getUrl('/about/1b234bk12b3/more'))
await page.goto(getUrl('/about/1b234bk12b3/more'), { waitUntil: 'networkidle' })
const text = await page.locator('div.deep-more').textContent()
expect(text?.trim()).toBe('deep nested: about/[id]/more.vue')
})

it('/features/dashboard custom routes folder', async () => {
await page.goto(getUrl('/features/dashboard'))
await page.goto(getUrl('/features/dashboard'), { waitUntil: 'networkidle' })
const text = await page.locator('body > div > p >> nth=0').textContent()
expect(text?.trim()).toBe('features/dashboard/pages/dashboard.vue')
})

it('hmr - dynamic add /test route works', async () => {
await page.goto(getUrl('/'))
await page.goto(getUrl('/'), { waitUntil: 'networkidle' })

await copyFile(srcPath, distPath)

// wait page reload
await page.waitForLoadState('networkidle')

await page.goto(getUrl('/test'))
await page.goto(getUrl('/test'), { waitUntil: 'networkidle' })

const text = await page.locator('body > div').textContent()
expect(text?.trim()).toBe('this is test file')
Expand Down

0 comments on commit 3925920

Please sign in to comment.