mirror of
https://github.com/microsoft/playwright.git
synced 2024-08-17 08:00:23 +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>
|
<span>{action.apiName}</span>
|
||||||
{locator && <div className='action-selector' title={locator}>{locator}</div>}
|
{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.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>
|
</div>
|
||||||
{(showDuration || showBadges) && <div className='spacer'></div>}
|
{(showDuration || showBadges) && <div className='spacer'></div>}
|
||||||
{showDuration && <div className='action-duration'>{time || <span className='codicon codicon-loading'></span>}</div>}
|
{showDuration && <div className='action-duration'>{time || <span className='codicon codicon-loading'></span>}</div>}
|
||||||
@ -111,3 +112,12 @@ export const renderAction = (
|
|||||||
</div>}
|
</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.get');
|
||||||
await traceViewer.selectAction('apiRequestContext.post');
|
await traceViewer.selectAction('apiRequestContext.post');
|
||||||
await expect(traceViewer.actionTitles).toHaveText([
|
await expect(traceViewer.actionTitles).toHaveText([
|
||||||
`apiRequestContext.get`,
|
`apiRequestContext.get/simple.json`,
|
||||||
`page.gotohttp://localhost:${server.PORT}/input/button.html`,
|
`page.gotohttp://localhost:${server.PORT}/input/button.html`,
|
||||||
`apiRequestContext.head`,
|
`apiRequestContext.head/simplezip.json`,
|
||||||
`locator.clicklocator('button')`,
|
`locator.clicklocator('button')`,
|
||||||
`locator.clicklocator('button')`,
|
`locator.clicklocator('button')`,
|
||||||
`apiRequestContext.post`,
|
`apiRequestContext.post/one-style.css`,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await traceViewer.page.locator('text=Metadata').click();
|
await traceViewer.page.locator('text=Metadata').click();
|
||||||
|
Loading…
Reference in New Issue
Block a user