Skip to content

Commit

Permalink
Add Promise as a child test to Flight fixture (#28778)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Apr 8, 2024
1 parent f86afca commit e63918d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fixtures/flight/__tests__/__e2e__/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ test('smoke test', async ({page}) => {
pageErrors.push(error.stack);
});
await page.goto('/');
await expect(page.locator('h1')).toHaveText('Hello World');
await expect(page.getByTestId('promise-as-a-child-test')).toHaveText(
'Promise as a child hydrates without errors: deferred text'
);

await expect(consoleErrors).toEqual([]);
await expect(pageErrors).toEqual([]);
Expand Down
9 changes: 9 additions & 0 deletions fixtures/flight/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {like, greet, increment} from './actions.js';

import {getServerState} from './ServerState.js';

const promisedText = new Promise(resolve =>
setTimeout(() => resolve('deferred text'), 100)
);

export default async function App() {
const res = await fetch('http://localhost:3001/todos');
const todos = await res.json();
Expand All @@ -32,6 +36,11 @@ export default async function App() {
<body>
<Container>
<h1>{getServerState()}</h1>
<React.Suspense fallback={null}>
<div data-testid="promise-as-a-child-test">
Promise as a child hydrates without errors: {promisedText}
</div>
</React.Suspense>
<Counter incrementAction={increment} />
<Counter2 incrementAction={increment} />
<Counter3 incrementAction={increment} />
Expand Down

0 comments on commit e63918d

Please sign in to comment.