chore: unflake the network status test (#23551)

This commit is contained in:
Pavel Feldman 2023-06-06 16:55:53 -07:00 committed by GitHub
parent 1cd8f7543b
commit 7579572688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 34 additions and 7 deletions

View File

@ -420,6 +420,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
method: options.method,
headers: options.headers ? headersObjectToArray(options.headers) : undefined,
postData: options.postDataBuffer,
isFallback: internal,
}));
}, !!internal);
}

View File

@ -2003,6 +2003,7 @@ scheme.RouteContinueParams = tObject({
headers: tOptional(tArray(tType('NameValue'))),
postData: tOptional(tBinary),
requestUrl: tString,
isFallback: tBoolean,
});
scheme.RouteContinueResult = tOptional(tObject({}));
scheme.RouteFulfillParams = tObject({

View File

@ -132,6 +132,7 @@ export class RouteDispatcher extends Dispatcher<Route, channels.RouteChannel, Re
method: params.method,
headers: params.headers,
postData: params.postData,
isFallback: params.isFallback,
});
}

View File

@ -323,7 +323,7 @@ export class Route extends SdkObject {
}
this._request._setOverrides(overrides);
await this._delegate.continue(this._request, overrides);
if (Object.values(overrides).some(value => value !== undefined))
if (!overrides.isFallback)
this._request._context.emit(BrowserContext.Events.RequestContinued, this._request);
this._endHandling();
}

View File

@ -146,6 +146,7 @@ export type NormalizedContinueOverrides = {
method?: string,
headers?: HeadersArray,
postData?: Buffer,
isFallback?: boolean,
};
export type EmulatedSize = { viewport: Size, screen: Size };

View File

@ -228,7 +228,7 @@ export class TestInfoImpl implements TestInfo {
}
_addStep(data: Omit<TestStepInternal, 'complete' | 'stepId' | 'steps'>, parentStep?: TestStepInternal): TestStepInternal {
const stepId = `${data.category}@${data.title}@${++this._lastStepId}`;
const stepId = `${data.category}@${++this._lastStepId}`;
if (!parentStep)
parentStep = zones.zoneData<TestStepInternal>('stepZone', captureRawStack()) || undefined;

View File

@ -3562,6 +3562,7 @@ export type RouteContinueParams = {
headers?: NameValue[],
postData?: Binary,
requestUrl: string,
isFallback: boolean,
};
export type RouteContinueOptions = {
url?: string,

View File

@ -2818,6 +2818,7 @@ Route:
items: NameValue
postData: binary?
requestUrl: string
isFallback: boolean
fulfill:
parameters:

View File

@ -66,6 +66,7 @@ body.dark-mode .drop-target {
}
.progress {
flex: none;
width: 100%;
height: 3px;
margin-top: -3px;

View File

@ -31,7 +31,6 @@ test.beforeAll(async function recordTrace({ browser, browserName, browserType, s
const context = await browser.newContext();
await context.tracing.start({ name: 'test', screenshots: true, snapshots: true, sources: true });
const page = await context.newPage();
await page.route('**/style.css', route => route.abort());
await page.goto(`data:text/html,<html>Hello world</html>`);
await page.setContent('<button>Click</button>');
await expect(page.locator('button')).toHaveText('Click');
@ -102,7 +101,6 @@ test('should open simple trace viewer', async ({ showTraceViewer }) => {
const traceViewer = await showTraceViewer([traceFile]);
await expect(traceViewer.actionTitles).toHaveText([
/browserContext.newPage/,
/page.route/,
/page.gotodata:text\/html,<html>Hello world<\/html>/,
/page.setContent/,
/expect.toHaveTextlocator\('button'\)/,
@ -115,7 +113,6 @@ test('should open simple trace viewer', async ({ showTraceViewer }) => {
/page.waitForResponse/,
/page.waitForTimeout/,
/page.gotohttp:\/\/localhost:\d+\/frames\/frame.html/,
/route.abort/,
/page.setViewportSize/,
]);
});
@ -220,10 +217,32 @@ test('should have network requests', async ({ showTraceViewer }) => {
await traceViewer.selectAction('http://localhost');
await traceViewer.showNetworkTab();
await expect(traceViewer.networkRequests).toContainText([/200GETframe.htmltext\/html/]);
await expect(traceViewer.networkRequests).toContainText([/aborted.*style.cssx-unknown/]);
await expect(traceViewer.networkRequests).toContainText([/200GETstyle.csstext\/css/]);
await expect(traceViewer.networkRequests).toContainText([/200GETscript.jsapplication\/javascript/]);
});
test('should have network request overrides', async ({ page, server, runAndTrace }) => {
const traceViewer = await runAndTrace(async () => {
await page.route('**/style.css', route => route.abort());
await page.goto(server.PREFIX + '/frames/frame.html');
});
await traceViewer.selectAction('http://localhost');
await traceViewer.showNetworkTab();
await expect(traceViewer.networkRequests).toContainText([/200GETframe.htmltext\/html/]);
await expect(traceViewer.networkRequests).toContainText([/abort.*style.cssx-unknown/]);
});
test('should have network request overrides 2', async ({ page, server, runAndTrace }) => {
const traceViewer = await runAndTrace(async () => {
await page.route('**/script.js', route => route.continue());
await page.goto(server.PREFIX + '/frames/frame.html');
});
await traceViewer.selectAction('http://localhost');
await traceViewer.showNetworkTab();
await expect(traceViewer.networkRequests).toContainText([/200GETframe.htmltext\/html/]);
await expect(traceViewer.networkRequests).toContainText([/continue.*script.jsapplication\/javascript/]);
});
test('should show snapshot URL', async ({ page, runAndTrace, server }) => {
const traceViewer = await runAndTrace(async () => {
await page.goto(server.EMPTY_PAGE);

View File

@ -637,7 +637,8 @@ test('should store postData for global request', async ({ request, server }, tes
}));
});
test('should not flush console events', async ({ context, page }, testInfo) => {
test('should not flush console events', async ({ context, page, mode }, testInfo) => {
test.skip(mode === 'service', 'Uses artifactsFolderName');
const testId = test.info().testId;
await context.tracing.start({ name: testId });
const promise = new Promise<void>(f => {