Add Promise as a child test to Flight fixture (#28778)

This commit is contained in:
Sebastian Silbermann
2024-04-08 17:06:17 +02:00
committed by GitHub
parent f86afca090
commit e63918d2cd
2 changed files with 12 additions and 1 deletions
@@ -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([]);
+9
View File
@@ -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();
@@ -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} />