mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: fix and test ui mode stop (#21769)
This commit is contained in:
parent
e856344235
commit
6efb383433
@ -396,9 +396,13 @@ export class TeleTestCase implements reporterTypes.TestCase {
|
|||||||
return status === 'expected' || status === 'flaky' || status === 'skipped';
|
return status === 'expected' || status === 'flaky' || status === 'skipped';
|
||||||
}
|
}
|
||||||
|
|
||||||
_createTestResult(id: string): reporterTypes.TestResult {
|
_clearResults() {
|
||||||
this.results = [];
|
this.results = [];
|
||||||
this.resultsMap.clear();
|
this.resultsMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
_createTestResult(id: string): reporterTypes.TestResult {
|
||||||
|
this._clearResults();
|
||||||
const result: TeleTestResult = {
|
const result: TeleTestResult = {
|
||||||
retry: this.results.length,
|
retry: this.results.length,
|
||||||
parallelIndex: -1,
|
parallelIndex: -1,
|
||||||
|
@ -122,6 +122,12 @@ export const WatchModeView: React.FC<{}> = ({
|
|||||||
setProgress({ total: testIds.length, passed: 0, failed: 0, skipped: 0 });
|
setProgress({ total: testIds.length, passed: 0, failed: 0, skipped: 0 });
|
||||||
setRunningState({ testIds: new Set(testIds) });
|
setRunningState({ testIds: new Set(testIds) });
|
||||||
sendMessage('run', { testIds }).then(() => {
|
sendMessage('run', { testIds }).then(() => {
|
||||||
|
// Clear pending tests in case of interrupt.
|
||||||
|
for (const test of testModel.rootSuite?.allTests() || []) {
|
||||||
|
if (test.results[0]?.duration === -1)
|
||||||
|
(test as TeleTestCase)._clearResults();
|
||||||
|
}
|
||||||
|
setTestModel({ ...testModel });
|
||||||
setRunningState(undefined);
|
setRunningState(undefined);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -667,8 +673,10 @@ function createTree(rootSuite: Suite | undefined, projectFilters: Map<string, bo
|
|||||||
let status: 'none' | 'running' | 'passed' | 'failed' | 'skipped' = 'none';
|
let status: 'none' | 'running' | 'passed' | 'failed' | 'skipped' = 'none';
|
||||||
if (test.results.some(r => r.duration === -1))
|
if (test.results.some(r => r.duration === -1))
|
||||||
status = 'running';
|
status = 'running';
|
||||||
else if (test.results.length && test.outcome() === 'skipped')
|
else if (test.results.length && test.results[0].status === 'skipped')
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
|
else if (test.results.length && test.results[0].status === 'interrupted')
|
||||||
|
status = 'none';
|
||||||
else if (test.results.length && test.outcome() !== 'expected')
|
else if (test.results.length && test.outcome() !== 'expected')
|
||||||
status = 'failed';
|
status = 'failed';
|
||||||
else if (test.results.length && test.outcome() === 'expected')
|
else if (test.results.length && test.outcome() === 'expected')
|
||||||
|
@ -195,3 +195,41 @@ test('should run by project', async ({ runUITest }) => {
|
|||||||
► ⊘ skipped
|
► ⊘ skipped
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should stop', async ({ runUITest }) => {
|
||||||
|
const page = await runUITest({
|
||||||
|
'a.test.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('test 0', () => { test.skip(); });
|
||||||
|
test('test 1', () => {});
|
||||||
|
test('test 2', async () => { await new Promise(() => {}); });
|
||||||
|
test('test 3', () => {});
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page.getByTitle('Run all')).toBeEnabled();
|
||||||
|
await expect(page.getByTitle('Stop')).toBeDisabled();
|
||||||
|
|
||||||
|
await page.getByTitle('Run all').click();
|
||||||
|
|
||||||
|
await expect.poll(dumpTestTree(page), { timeout: 15000 }).toBe(`
|
||||||
|
▼ ↻ a.test.ts
|
||||||
|
⊘ test 0
|
||||||
|
✅ test 1
|
||||||
|
↻ test 2
|
||||||
|
↻ test 3
|
||||||
|
`);
|
||||||
|
|
||||||
|
await expect(page.getByTitle('Run all')).toBeDisabled();
|
||||||
|
await expect(page.getByTitle('Stop')).toBeEnabled();
|
||||||
|
|
||||||
|
await page.getByTitle('Stop').click();
|
||||||
|
|
||||||
|
await expect.poll(dumpTestTree(page), { timeout: 15000 }).toBe(`
|
||||||
|
▼ ◯ a.test.ts
|
||||||
|
⊘ test 0
|
||||||
|
✅ test 1
|
||||||
|
◯ test 2
|
||||||
|
◯ test 3
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user