Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(ui): Wait with polling if test is still scheduled (#38656)

Chris77d00401f038
diff --git a/packages/trace-viewer/src/ui/uiModeTraceView.tsx b/packages/trace-viewer/src/ui/uiModeTraceView.tsx
index 1135417741..31b6c8f9a1 100644
--- a/packages/trace-viewer/src/ui/uiModeTraceView.tsx
+++ b/packages/trace-viewer/src/ui/uiModeTraceView.tsx
@@ -46,7 +46,7 @@ export const TraceView: React.FC<{
clearTimeout(pollTimer.current);
const result = item.testCase?.results[0];
- if (!result) {
+ if (!result || item.treeItem?.status === 'scheduled') {
setModel(undefined);
return;
}
diff --git a/tests/playwright-test/ui-mode-test-source.spec.ts b/tests/playwright-test/ui-mode-test-source.spec.ts
index 9bc6719ffc..5b958395a8 100644
--- a/tests/playwright-test/ui-mode-test-source.spec.ts
+++ b/tests/playwright-test/ui-mode-test-source.spec.ts
@@ -192,3 +192,22 @@ test('should load error (dupe tests) indicator on sources', async ({ runUITest }
Error: duplicate test title "first", first declared in a.test.ts:3
`);
});
+
+test('should keep showing source when test is pending', async ({ runUITest }, testInfo) => {
+ const { page } = await runUITest({
+ 'a.test.ts': `
+ import { test } from '@playwright/test';
+ test('zero', () => {});
+ test('first', async () => {
+ await new Promise(f => setTimeout(f, ${testInfo.timeout}));
+ });
+ test('second', () => {});
+ `,
+ });
+
+ await page.getByTitle('Run all').click();
+ await page.getByTestId('test-tree').getByText('second').click();
+ await expect(page.getByTestId('status-line')).toHaveText('Running 1/3 passed (33%)');
+ await expect(page.getByTestId('source-code').locator('.source-tab-file-name')).toHaveText('a.test.ts');
+ await expect(page.locator('.CodeMirror .source-line-running')).toHaveText(`7 test('second', () => {});`);
+});