test: unflake some network-tab related tests (#35574)

This commit is contained in:
Dmitry Gozman 2025-04-10 14:18:34 +00:00 committed by GitHub
parent eed11cabb4
commit 51a7b8f27f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 12 deletions

View File

@ -12,8 +12,6 @@
}
</style>
<script src='script.js'></script>
<script>fetch('/api/endpoint')</script>
<script>fetch('/call-with-query-params?param1=value1&param1=value2&param2=value2')</script>
<script>
const body = JSON.stringify({
data: {
@ -21,17 +19,25 @@
array: ['value-1', 'value-2'],
},
});
const fetches = [
fetch('/api/endpoint'),
fetch('/call-with-query-params?param1=value1&param1=value2&param2=value2'),
fetch('/post-data-1', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body,
}),
fetch('/post-data-2', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
}),
];
window.donePromise = Promise.all(fetches.map(f => f.then(r => r.body()).then(() => null).catch(e => {})));
</script>
<script></script>
<script>
fetch('/post-data-1', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body,
});
fetch('/post-data-2', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
</script>
</head>
<body>

View File

@ -367,6 +367,7 @@ test('should filter network requests by resource type', async ({ page, runAndTra
const traceViewer = await runAndTrace(async () => {
server.setRoute('/api/endpoint', (_, res) => res.setHeader('Content-Type', 'application/json').end());
await page.goto(`${server.PREFIX}/network-tab/network.html`);
await page.evaluate(() => (window as any).donePromise);
});
await traceViewer.selectAction('http://localhost');
await traceViewer.showNetworkTab();
@ -399,6 +400,7 @@ test('should filter network requests by resource type', async ({ page, runAndTra
test('should show font preview', async ({ page, runAndTrace, server }) => {
const traceViewer = await runAndTrace(async () => {
await page.goto(`${server.PREFIX}/network-tab/network.html`);
await page.evaluate(() => (window as any).donePromise);
});
await traceViewer.selectAction('http://localhost');
await traceViewer.showNetworkTab();
@ -413,6 +415,7 @@ test('should show font preview', async ({ page, runAndTrace, server }) => {
test('should filter network requests by url', async ({ page, runAndTrace, server }) => {
const traceViewer = await runAndTrace(async () => {
await page.goto(`${server.PREFIX}/network-tab/network.html`);
await page.evaluate(() => (window as any).donePromise);
});
await traceViewer.selectAction('http://localhost');
await traceViewer.showNetworkTab();

View File

@ -24,6 +24,7 @@ test('should filter network requests by resource type', async ({ runUITest, serv
import { test, expect } from '@playwright/test';
test('network tab test', async ({ page }) => {
await page.goto('${server.PREFIX}/network-tab/network.html');
await page.evaluate(() => (window as any).donePromise);
});
`,
});
@ -64,6 +65,7 @@ test('should filter network requests by url', async ({ runUITest, server }) => {
import { test, expect } from '@playwright/test';
test('network tab test', async ({ page }) => {
await page.goto('${server.PREFIX}/network-tab/network.html');
await page.evaluate(() => (window as any).donePromise);
});
`,
});
@ -100,6 +102,7 @@ test('should format JSON request body', async ({ runUITest, server }) => {
import { test, expect } from '@playwright/test';
test('network tab test', async ({ page }) => {
await page.goto('${server.PREFIX}/network-tab/network.html');
await page.evaluate(() => (window as any).donePromise);
});
`,
});
@ -142,6 +145,7 @@ test('should display list of query parameters (only if present)', async ({ runUI
import { test, expect } from '@playwright/test';
test('network tab test', async ({ page }) => {
await page.goto('${server.PREFIX}/network-tab/network.html');
await page.evaluate(() => (window as any).donePromise);
});
`,
});