mirror of
https://github.com/microsoft/playwright.git
synced 2024-07-14 23:40:34 +03:00
feat(trace-viewer) add request urls for actions initiated via APIRequestContext (#31534)
This commit is contained in:
parent
1c69d3e175
commit
e36ebb6ede
@ -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>}
|
||||
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user