From ee93d2ba27fda49ef2dd20aedbb3a9cc79b9e332 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 18 Nov 2024 13:00:47 +0100 Subject: [PATCH] also hide request --- .../playwright-core/src/client/network.ts | 1 + tests/library/trace-viewer.spec.ts | 5 ++- tests/playwright-test/test-step.spec.ts | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.ts index 6ef9189f55..cb18681ccf 100644 --- a/packages/playwright-core/src/client/network.ts +++ b/packages/playwright-core/src/client/network.ts @@ -97,6 +97,7 @@ export class Request extends ChannelOwner implements ap constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.RequestInitializer) { super(parent, type, guid, initializer); + this.markAsInternalType(); this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom); if (this._redirectedFrom) this._redirectedFrom._redirectedTo = this; diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts index e05db78bce..7e64c62156 100644 --- a/tests/library/trace-viewer.spec.ts +++ b/tests/library/trace-viewer.spec.ts @@ -1444,10 +1444,13 @@ test('should not record route actions', { ]); }); -test('should not record response actions', { +test('should not record network actions', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33558' }, }, async ({ page, runAndTrace, server }) => { const traceViewer = await runAndTrace(async () => { + page.on('request', async request => { + await request.allHeaders(); + }); page.on('response', async response => { await response.text(); }); diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts index 8caa9b17f5..ac6845eeae 100644 --- a/tests/playwright-test/test-step.spec.ts +++ b/tests/playwright-test/test-step.spec.ts @@ -1414,6 +1414,42 @@ fixture | fixture: context `); }); +test('reading network request / response should not be listed as step', { + annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33558' } +}, async ({ runInlineTest, server }) => { + const result = await runInlineTest({ + 'reporter.ts': stepIndentReporter, + 'playwright.config.ts': `module.exports = { reporter: './reporter' };`, + 'a.test.ts': ` + import { test, expect } from '@playwright/test'; + test('waitForResponse step nesting', async ({ page }) => { + page.on('request', async request => { + await request.allHeaders(); + }); + page.on('response', async response => { + await response.text(); + }); + await page.goto('${server.EMPTY_PAGE}'); + }); + ` + }, { reporter: '', workers: 1, timeout: 3000 }); + + expect(result.exitCode).toBe(0); + expect(stripAnsi(result.output)).toBe(` +hook |Before Hooks +fixture | fixture: browser +pw:api | browserType.launch +fixture | fixture: context +pw:api | browser.newContext +fixture | fixture: page +pw:api | browserContext.newPage +pw:api |page.goto(${server.EMPTY_PAGE}) @ a.test.ts:10 +hook |After Hooks +fixture | fixture: page +fixture | fixture: context +`); +}); + test('calls from page.route callback should be under its parent step', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33186' } }, async ({ runInlineTest, server }) => {