Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trace-viewer) add request urls for actions initiated via APIRequestContext #31534

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading