Skip to content

Commit

Permalink
cherry-pick(#32661): fix(trace-viewer): time delta between local and … (
Browse files Browse the repository at this point in the history
#32663)

…remote actions
  • Loading branch information
yury-s authored Sep 17, 2024
1 parent 3d2ffd0 commit 937424f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/trace-viewer/src/ui/modelUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function monotonicTimeDeltaBetweenLibraryAndRunner(nonPrimaryContexts: ContextEn
for (const action of context.actions) {
if (!action.startTime)
continue;
const key = matchByStepId ? action.stepId! : `${action.apiName}@${(action as any).wallTime}`;
const key = matchByStepId ? action.callId! : `${action.apiName}@${(action as any).wallTime}`;
const libraryAction = libraryActions.get(key);
if (libraryAction)
return action.startTime - libraryAction.startTime;
Expand Down
Binary file added tests/assets/trace-remote-time-diff.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/library/trace-viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ test('should complain about newer version of trace in old viewer', async ({ show
await expect(traceViewer.page.getByText('The trace was created by a newer version of Playwright and is not supported by this version of the viewer.')).toBeVisible();
});

test('should properly synchronize local and remote time', async ({ showTraceViewer, asset }, testInfo) => {
const traceViewer = await showTraceViewer([asset('trace-remote-time-diff.zip')]);
// The total duration should be sub 10s, rather than 16h.
await expect(traceViewer.page.locator('.timeline-time').last()).toHaveText('8.5s');
});

test('should contain action info', async ({ showTraceViewer }) => {
const traceViewer = await showTraceViewer([traceFile]);
await traceViewer.selectAction('locator.click');
Expand Down

0 comments on commit 937424f

Please sign in to comment.