fix(trace viewer): reveal stack for highlighted action (#32919)
Closes https://github.com/microsoft/playwright/issues/32915.
In the `Call` and `Logs` tabs, we update the contents based on the
hovered action. We document that this is also the case for the `Source`
tab:
78054a7652/docs/src/test-ui-mode-js.md?plain=1#L61-L65
But it isn't. Not sure if it's a regression or not, but this PR fixes
it.
This commit is contained in:
parent
6373fe703d
commit
3a5bf1cc1d
|
|
@ -114,16 +114,16 @@ export const Workbench: React.FunctionComponent<{
|
||||||
}
|
}
|
||||||
}, [model, selectedCallId]);
|
}, [model, selectedCallId]);
|
||||||
|
|
||||||
const revealedStack = React.useMemo(() => {
|
|
||||||
if (revealedError)
|
|
||||||
return revealedError.stack;
|
|
||||||
return selectedAction?.stack;
|
|
||||||
}, [selectedAction, revealedError]);
|
|
||||||
|
|
||||||
const activeAction = React.useMemo(() => {
|
const activeAction = React.useMemo(() => {
|
||||||
return highlightedAction || selectedAction;
|
return highlightedAction || selectedAction;
|
||||||
}, [selectedAction, highlightedAction]);
|
}, [selectedAction, highlightedAction]);
|
||||||
|
|
||||||
|
const revealedStack = React.useMemo(() => {
|
||||||
|
if (revealedError)
|
||||||
|
return revealedError.stack;
|
||||||
|
return activeAction?.stack;
|
||||||
|
}, [activeAction, revealedError]);
|
||||||
|
|
||||||
const onActionSelected = React.useCallback((action: modelUtil.ActionTraceEventInContext) => {
|
const onActionSelected = React.useCallback((action: modelUtil.ActionTraceEventInContext) => {
|
||||||
setSelectedAction(action);
|
setSelectedAction(action);
|
||||||
setHighlightedAction(undefined);
|
setHighlightedAction(undefined);
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,11 @@ class TraceViewerPage {
|
||||||
await this.page.locator(`.action-title:has-text("${title}")`).nth(ordinal).click();
|
await this.page.locator(`.action-title:has-text("${title}")`).nth(ordinal).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@step
|
||||||
|
async hoverAction(title: string, ordinal: number = 0) {
|
||||||
|
await this.page.locator(`.action-title:has-text("${title}")`).nth(ordinal).hover();
|
||||||
|
}
|
||||||
|
|
||||||
@step
|
@step
|
||||||
async selectSnapshot(name: string) {
|
async selectSnapshot(name: string) {
|
||||||
await this.page.click(`.snapshot-tab .tabbed-pane-tab-label:has-text("${name}")`);
|
await this.page.click(`.snapshot-tab .tabbed-pane-tab-label:has-text("${name}")`);
|
||||||
|
|
|
||||||
|
|
@ -864,6 +864,9 @@ test('should show action source', async ({ showTraceViewer }) => {
|
||||||
await page.click('text=Source');
|
await page.click('text=Source');
|
||||||
await expect(page.locator('.source-line-running')).toContainText('await page.getByText(\'Click\').click()');
|
await expect(page.locator('.source-line-running')).toContainText('await page.getByText(\'Click\').click()');
|
||||||
await expect(page.getByTestId('stack-trace-list').locator('.list-view-entry.selected')).toHaveText(/doClick.*trace-viewer\.spec\.ts:[\d]+/);
|
await expect(page.getByTestId('stack-trace-list').locator('.list-view-entry.selected')).toHaveText(/doClick.*trace-viewer\.spec\.ts:[\d]+/);
|
||||||
|
|
||||||
|
await traceViewer.hoverAction('page.waitForNavigation');
|
||||||
|
await expect(page.locator('.source-line-running')).toContainText('page.waitForNavigation()');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should follow redirects', async ({ page, runAndTrace, server, asset }) => {
|
test('should follow redirects', async ({ page, runAndTrace, server, asset }) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue