Skip to content

Commit

Permalink
feat(trace-viewer) add request urls for actions initiated via APIRequ…
Browse files Browse the repository at this point in the history
…estContext (#31534)
  • Loading branch information
ryanrosello-og committed Jul 4, 2024
1 parent 1c69d3e commit e36ebb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/trace-viewer/src/ui/actionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const renderAction = (
<span>{action.apiName}</span>
{locator && <div className='action-selector' title={locator}>{locator}</div>}
{action.method === 'goto' && action.params.url && <div className='action-url' title={action.params.url}>{action.params.url}</div>}
{action.class === 'APIRequestContext' && action.params.url && <div className='action-url' title={action.params.url}>{excludeOrigin(action.params.url)}</div>}
</div>
{(showDuration || showBadges) && <div className='spacer'></div>}
{showDuration && <div className='action-duration'>{time || <span className='codicon codicon-loading'></span>}</div>}
Expand All @@ -111,3 +112,12 @@ export const renderAction = (
</div>}
</>;
};

function excludeOrigin(url: string): string {
try {
const urlObject = new URL(url);
return urlObject.pathname + urlObject.search;
} catch (error) {
return url;
}
}
6 changes: 3 additions & 3 deletions tests/library/trace-viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,12 @@ test('should open two trace files', async ({ context, page, request, server, sho
await traceViewer.selectAction('apiRequestContext.get');
await traceViewer.selectAction('apiRequestContext.post');
await expect(traceViewer.actionTitles).toHaveText([
`apiRequestContext.get`,
`apiRequestContext.get/simple.json`,
`page.gotohttp://localhost:${server.PORT}/input/button.html`,
`apiRequestContext.head`,
`apiRequestContext.head/simplezip.json`,
`locator.clicklocator('button')`,
`locator.clicklocator('button')`,
`apiRequestContext.post`,
`apiRequestContext.post/one-style.css`,
]);

await traceViewer.page.locator('text=Metadata').click();
Expand Down

0 comments on commit e36ebb6

Please sign in to comment.