Skip to content

Commit f050c3f

Browse files
authored
fix(trace): include method into "Fetch" action title (#36350)
1 parent 2973b0b commit f050c3f

File tree

8 files changed

+28
-25
lines changed

8 files changed

+28
-25
lines changed

packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// This file is generated by generate_channels.js, do not edit manually.
1818

1919
export const methodMetainfo = new Map<string, { internal?: boolean, title?: string, slowMo?: boolean, snapshot?: boolean, pausesBeforeInput?: boolean }>([
20-
['APIRequestContext.fetch', { title: 'Fetch "{url}"', }],
20+
['APIRequestContext.fetch', { title: '{method} "{url}"', }],
2121
['APIRequestContext.fetchResponseBody', { internal: true, }],
2222
['APIRequestContext.fetchLog', { internal: true, }],
2323
['APIRequestContext.storageState', { internal: true, }],

packages/protocol/src/protocol.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ APIRequestContext:
366366
commands:
367367

368368
fetch:
369-
title: Fetch "{url}"
369+
title: '{method} "{url}"'
370370
parameters:
371371
url: string
372372
encodedParams: string?

packages/trace-viewer/src/ui/actionList.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ export function renderTitleForCall(action: ActionTraceEvent): { elements: React.
164164
title.push(chunk);
165165

166166
const param = formatProtocolParam(action.params, quotedText);
167-
elements.push(<span className='action-title-param'>{param}</span>);
167+
if (match.index === 0)
168+
elements.push(param);
169+
else
170+
elements.push(<span className='action-title-param'>{param}</span>);
168171
title.push(param);
169172
currentIndex = match.index + fullMatch.length;
170173
}

tests/library/trace-viewer.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,16 +1056,16 @@ test('should open two trace files', async ({ context, page, request, server, sho
10561056

10571057
const traceViewer = await showTraceViewer([contextTrace, apiTrace]);
10581058

1059-
await traceViewer.selectAction('FETCH', 0);
1060-
await traceViewer.selectAction('FETCH', 1);
1061-
await traceViewer.selectAction('FETCH', 2);
1059+
await traceViewer.selectAction('GET');
1060+
await traceViewer.selectAction('HEAD');
1061+
await traceViewer.selectAction('POST');
10621062
await expect(traceViewer.actionTitles).toHaveText([
1063-
/Fetch "\/simple\.json"/,
1063+
/GET "\/simple\.json"/,
10641064
/Navigate to "\/input\/button\.html"/,
1065-
/Fetch "\/simplezip\.json"/,
1065+
/HEAD "\/simplezip\.json"/,
10661066
/Click.*locator\('button'\)/,
10671067
/Click.*locator\('button'\)/,
1068-
/Fetch "\/one-style\.css"/,
1068+
/POST "\/one-style\.css"/,
10691069
]);
10701070

10711071
await traceViewer.page.getByRole('tab', { name: 'Metadata' }).click();

tests/library/tracing.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ test('should include context API requests', async ({ context, page, server }, te
165165
await page.request.post(server.PREFIX + '/simple.json', { data: { foo: 'bar' } });
166166
await context.tracing.stop({ path: testInfo.outputPath('trace.zip') });
167167
const { events, actions } = await parseTraceRaw(testInfo.outputPath('trace.zip'));
168-
expect(actions).toContain('Fetch "/simple.json"');
168+
expect(actions).toContain('POST "/simple.json"');
169169
const harEntry = events.find(e => e.type === 'resource-snapshot');
170170
expect(harEntry).toBeTruthy();
171171
expect(harEntry.snapshot.request.url).toBe(server.PREFIX + '/simple.json');

tests/playwright-test/playwright.trace.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
9898
' Fixture "page"',
9999
' Create page',
100100
'Navigate to "about:blank"',
101-
'Fetch "/empty.html"',
101+
'GET "/empty.html"',
102102
'After Hooks',
103103
' Fixture "page"',
104104
' Fixture "context"',
@@ -108,7 +108,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
108108
expect(trace2.actionTree).toEqual([
109109
'Before Hooks',
110110
'Create request context',
111-
'Fetch "/empty.html"',
111+
'GET "/empty.html"',
112112
'After Hooks',
113113
]);
114114
const trace3 = await parseTrace(testInfo.outputPath('test-results', 'a-fail', 'trace.zip'));
@@ -121,7 +121,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
121121
' Fixture "page"',
122122
' Create page',
123123
'Navigate to "about:blank"',
124-
'Fetch "/empty.html"',
124+
'GET "/empty.html"',
125125
'Expect "toBe"',
126126
'After Hooks',
127127
' Fixture "page"',
@@ -328,7 +328,7 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve
328328
' afterAll hook',
329329
' Fixture "request"',
330330
' Create request context',
331-
' Fetch "/empty.html"',
331+
' GET "/empty.html"',
332332
' Fixture "request"',
333333
'Worker Cleanup',
334334
' Fixture "browser"',
@@ -488,7 +488,7 @@ test(`trace:retain-on-failure should create trace if request context is disposed
488488
}, { trace: 'retain-on-failure' });
489489
const tracePath = test.info().outputPath('test-results', 'a-passing-test', 'trace.zip');
490490
const trace = await parseTrace(tracePath);
491-
expect(trace.titles).toContain('Fetch "/empty.html"');
491+
expect(trace.titles).toContain('GET "/empty.html"');
492492
expect(result.failed).toBe(1);
493493
});
494494

@@ -1137,7 +1137,7 @@ test('trace:retain-on-first-failure should create trace if request context is di
11371137
}, { trace: 'retain-on-first-failure' });
11381138
const tracePath = test.info().outputPath('test-results', 'a-fail', 'trace.zip');
11391139
const trace = await parseTrace(tracePath);
1140-
expect(trace.titles).toContain('Fetch "/empty.html"');
1140+
expect(trace.titles).toContain('GET "/empty.html"');
11411141
expect(result.failed).toBe(1);
11421142
});
11431143

@@ -1243,7 +1243,7 @@ test('should not nest top level expect into unfinished api calls ', {
12431243
' Fixture "page"',
12441244
' Create page',
12451245
'Navigate to "/index"',
1246-
'Fetch "/hang"',
1246+
'GET "/hang"',
12471247
'Expect "toBeVisible"',
12481248
'After Hooks',
12491249
' Fixture "page"',

tests/playwright-test/reporter-html.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
637637
await page.click('text=Source');
638638
await expect(page.locator('.source-line-running')).toContainText('page.evaluate');
639639

640-
await page.click('.action-title >> text=FETCH');
640+
await page.click('.action-title >> text=GET');
641641
await page.click('text=Source');
642642
await expect(page.locator('.source-line-running')).toContainText('request.get');
643643
});
@@ -668,10 +668,10 @@ for (const useIntermediateMergeReport of [true, false] as const) {
668668
await page.getByRole('link', { name: 'View Trace' }).click();
669669

670670
// Trace viewer should not hang here when displaying parallal requests.
671-
await expect(page.getByTestId('actions-tree')).toContainText('Fetch');
672-
await page.getByText('Fetch').nth(2).click();
673-
await page.getByText('Fetch').nth(1).click();
674-
await page.getByText('Fetch').nth(0).click();
671+
await expect(page.getByTestId('actions-tree')).toContainText('GET');
672+
await page.getByText('GET').nth(2).click();
673+
await page.getByText('GET').nth(1).click();
674+
await page.getByText('GET').nth(0).click();
675675
});
676676

677677
test('should warn user when viewing via file:// protocol', async ({ runInlineTest, page, showReport }, testInfo) => {

tests/playwright-test/test-step.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,9 +1222,9 @@ pw:api |Wait for navigation @ a.test.ts:5
12221222
pw:api |Navigate to "data:" @ a.test.ts:6
12231223
pw:api |Click locator('button') @ a.test.ts:8
12241224
pw:api |Click getByRole('button') @ a.test.ts:9
1225-
pw:api |Fetch "/empty.html" @ a.test.ts:10
1225+
pw:api |GET "/empty.html" @ a.test.ts:10
12261226
pw:api |↪ error: <error message>
1227-
pw:api |Fetch "/empty.html" @ a.test.ts:11
1227+
pw:api |GET "/empty.html" @ a.test.ts:11
12281228
pw:api |↪ error: <error message>
12291229
hook |After Hooks
12301230
fixture | request
@@ -1519,7 +1519,7 @@ fixture | page
15191519
pw:api | Create page
15201520
test.step |custom step @ a.test.ts:4
15211521
pw:api | Navigate to "/empty.html" @ a.test.ts:12
1522-
pw:api | Fetch "/empty.html" @ a.test.ts:6
1522+
pw:api | GET "/empty.html" @ a.test.ts:6
15231523
expect | toBe @ a.test.ts:8
15241524
hook |After Hooks
15251525
fixture | page

0 commit comments

Comments
 (0)