From e91d088d428ff9a19f40fc25d1898f3c15d3afb7 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 17 Sep 2024 11:00:00 -0700 Subject: [PATCH] fix(trace-viewer): time delta between local and remote actions --- packages/trace-viewer/src/ui/modelUtil.ts | 2 +- tests/library/trace-viewer.spec.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/trace-viewer/src/ui/modelUtil.ts b/packages/trace-viewer/src/ui/modelUtil.ts index a544d4dc3fab2a..098b387c8fd6ca 100644 --- a/packages/trace-viewer/src/ui/modelUtil.ts +++ b/packages/trace-viewer/src/ui/modelUtil.ts @@ -312,7 +312,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; diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts index 2b00949b199b24..44c1258eb7e8bb 100644 --- a/tests/library/trace-viewer.spec.ts +++ b/tests/library/trace-viewer.spec.ts @@ -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');