Skip to content

Commit

Permalink
Remove browser.refresh in app tests (#44186)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanneslund committed Dec 20, 2022
1 parent 6640846 commit 39f30fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
19 changes: 5 additions & 14 deletions test/development/acceptance-app/ReactRefreshRegression.test.ts
Expand Up @@ -145,8 +145,7 @@ describe('ReactRefreshRegression app', () => {
})

// https://github.com/vercel/next.js/issues/13978
// TODO-APP: fix case where server component is moved to a client component
test.skip('can fast refresh a page with dynamic rendering', async () => {
test('can fast refresh a page with dynamic rendering', async () => {
const { session, cleanup } = await sandbox(next)

await session.patch(
Expand Down Expand Up @@ -216,8 +215,7 @@ describe('ReactRefreshRegression app', () => {
})

// https://github.com/vercel/next.js/issues/13978
// TODO-APP: fix case where server component is moved to a client component
test.skip('can fast refresh a page with config', async () => {
test('can fast refresh a page with config', async () => {
const { session, cleanup } = await sandbox(next)

await session.patch(
Expand Down Expand Up @@ -264,17 +262,14 @@ describe('ReactRefreshRegression app', () => {
})

// https://github.com/vercel/next.js/issues/11504
// TODO-APP: fix case where error is not resolved to source correctly.
test('shows an overlay for anonymous function server-side error', async () => {
const { session, browser, cleanup } = await sandbox(next)
const { session, cleanup } = await sandbox(next)

await session.patch(
'app/page.js',
`export default function () { throw new Error('boom'); }`
)

await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
Expand All @@ -287,15 +282,13 @@ describe('ReactRefreshRegression app', () => {
})

test('shows an overlay for server-side error in server component', async () => {
const { session, browser, cleanup } = await sandbox(next)
const { session, cleanup } = await sandbox(next)

await session.patch(
'app/page.js',
`export default function Page() { throw new Error('boom'); }`
)

await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
Expand All @@ -308,16 +301,14 @@ describe('ReactRefreshRegression app', () => {
})

test('shows an overlay for server-side error in client component', async () => {
const { session, browser, cleanup } = await sandbox(next)
const { session, cleanup } = await sandbox(next)

await session.patch(
'app/page.js',
`'use client'
export default function Page() { throw new Error('boom'); }`
)

await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
Expand Down
15 changes: 3 additions & 12 deletions test/development/acceptance-app/server-components.test.ts
Expand Up @@ -22,7 +22,7 @@ describe('Error Overlay for server components', () => {

describe('createContext called in Server Component', () => {
it('should show error when React.createContext is called', async () => {
const { session, browser, cleanup } = await sandbox(
const { session, cleanup } = await sandbox(
next,
new Map([
[
Expand All @@ -43,9 +43,6 @@ describe('Error Overlay for server components', () => {
])
)

// TODO-APP: currently requires a full reload because moving from a client component to a server component isn't causing a Fast Refresh yet.
await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)
await check(async () => {
expect(await session.getRedboxSource(true)).toContain(
Expand All @@ -61,7 +58,7 @@ describe('Error Overlay for server components', () => {
})

it('should show error when React.createContext is called in external package', async () => {
const { session, browser, cleanup } = await sandbox(
const { session, cleanup } = await sandbox(
next,
new Map([
[
Expand Down Expand Up @@ -97,9 +94,6 @@ describe('Error Overlay for server components', () => {
])
)

// TODO-APP: currently requires a full reload because moving from a client component to a server component isn't causing a Fast Refresh yet.
await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)

await check(async () => {
Expand All @@ -117,7 +111,7 @@ describe('Error Overlay for server components', () => {
})

it('should show error when createContext is called in external package', async () => {
const { session, browser, cleanup } = await sandbox(
const { session, cleanup } = await sandbox(
next,
new Map([
[
Expand Down Expand Up @@ -153,9 +147,6 @@ describe('Error Overlay for server components', () => {
])
)

// TODO-APP: currently requires a full reload because moving from a client component to a server component isn't causing a Fast Refresh yet.
await browser.refresh()

expect(await session.hasRedbox(true)).toBe(true)

await check(async () => {
Expand Down

0 comments on commit 39f30fb

Please sign in to comment.