Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Promise as a child test to Flight fixture #28778

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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