Skip to content

Commit 972b92e

Browse files
authored
fix(ci): isolate desktop shard CLI regressions (#9324)
1 parent 8e73220 commit 972b92e

1 file changed

Lines changed: 21 additions & 26 deletions

File tree

‎scripts/desktop-e2e.test.ts‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { tmpdir } from 'node:os'
44
import { join, resolve } from 'node:path'
55
import { expect, it } from 'vitest'
66

7-
it('executes imported test factories and unmeasured files exactly once across desktop shards', () => {
7+
it.each([
8+
{ index: 1, title: 'brand-new.test.ts' },
9+
{ index: 2, title: 'factory' },
10+
{ index: 3, title: 'ordinary.spec.ts' },
11+
])('executes only $title on desktop shard $index/3', ({ index, title }) => {
812
const root = resolve(import.meta.dirname, '..')
913
const fixture = mkdtempSync(join(tmpdir(), 'desktop-shard-'))
1014
try {
@@ -31,34 +35,25 @@ it('executes imported test factories and unmeasured files exactly once across de
3135
)
3236
}
3337
const cases: { title: string; status: string }[] = []
34-
for (const index of [1, 2, 3]) {
35-
const reportPath = join(fixture, `${index}.json`)
36-
const result = spawnSync('bun', ['run', join(root, 'scripts/desktop-e2e.ts'), `${index}/3`], {
37-
cwd: fixture,
38-
env: { ...process.env, PLAYWRIGHT_JSON_OUTPUT_FILE: reportPath },
39-
encoding: 'utf8',
40-
timeout: 10_000,
41-
})
42-
expect(result.status, result.stdout + result.stderr).toBe(0)
43-
const report = JSON.parse(readFileSync(reportPath, 'utf8')) as {
44-
suites: { specs: { title: string; tests: { results: { status: string }[] }[] }[] }[]
45-
}
46-
for (const suite of report.suites) {
47-
for (const spec of suite.specs) {
48-
for (const test of spec.tests) {
49-
for (const run of test.results) cases.push({ title: spec.title, status: run.status })
50-
}
38+
const reportPath = join(fixture, `${index}.json`)
39+
const result = spawnSync('bun', ['run', join(root, 'scripts/desktop-e2e.ts'), `${index}/3`], {
40+
cwd: fixture,
41+
env: { ...process.env, PLAYWRIGHT_JSON_OUTPUT_FILE: reportPath },
42+
encoding: 'utf8',
43+
timeout: 10_000,
44+
})
45+
expect(result.status, result.stdout + result.stderr).toBe(0)
46+
const report = JSON.parse(readFileSync(reportPath, 'utf8')) as {
47+
suites: { specs: { title: string; tests: { results: { status: string }[] }[] }[] }[]
48+
}
49+
for (const suite of report.suites) {
50+
for (const spec of suite.specs) {
51+
for (const test of spec.tests) {
52+
for (const run of test.results) cases.push({ title: spec.title, status: run.status })
5153
}
5254
}
5355
}
54-
expect(cases).toEqual(
55-
expect.arrayContaining([
56-
{ title: 'factory', status: 'passed' },
57-
{ title: 'brand-new.test.ts', status: 'passed' },
58-
{ title: 'ordinary.spec.ts', status: 'passed' },
59-
])
60-
)
61-
expect(cases).toHaveLength(3)
56+
expect(cases).toEqual([{ title, status: 'passed' }])
6257
} finally {
6358
rmSync(fixture, { recursive: true, force: true })
6459
}

0 commit comments

Comments
 (0)