Repository navigation
Expand file tree
/
Copy pathci-changes.test.ts
More file actions
607 lines (606 loc) · 23.1 KB
/
Copy pathci-changes.test.ts
File metadata and controls
607 lines (606 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
import { spawnSync } from 'node:child_process'
import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
import { afterEach, describe, expect, it } from 'vitest'
const root = fileURLToPath(new URL('../', import.meta.url))
const script = resolve(root, '.github/scripts/ci-changes.sh')
const fixtures: string[] = []
interface Plan {
base: string
files: string[]
flags: Record<string, boolean>
fallback?: string
http: { group: string }[]
production: { group: string }[]
typecheckPackages: string[]
testPackages: string[]
docsGroups: string[]
}
function git(cwd: string, ...args: string[]) {
const result = spawnSync('git', args, { cwd, encoding: 'utf8' })
if (result.status !== 0) throw new Error(`git ${args.join(' ')}: ${result.stderr}`)
return result.stdout.trim()
}
function write(repo: string, file: string, content: string) {
mkdirSync(dirname(join(repo, file)), { recursive: true })
writeFileSync(join(repo, file), content)
}
/** Real Git and Turbo fixture: changed files, transitive packages, and configured task boundaries. */
function fixture() {
const repo = mkdtempSync(join(tmpdir(), 'ci-changes-'))
fixtures.push(repo)
git(repo, 'init', '--quiet')
git(repo, 'config', 'user.email', 'test@example.com')
git(repo, 'config', 'user.name', 'Test')
git(repo, 'config', 'commit.gpgsign', 'false')
write(
repo,
'package.json',
JSON.stringify({
name: 'ci-fixture',
private: true,
packageManager: 'bun@1.4.2',
workspaces: ['apps/*', 'packages/*'],
})
)
const packages = [
['apps/sim', '@sim/app', { '@sim/auth': 'workspace:*', '@sim/db': 'workspace:*' }],
['apps/realtime', '@sim/realtime', { '@sim/auth': 'workspace:*' }],
['apps/desktop', '@sim/desktop', {}],
['apps/extension', '@sim/extension', {}],
['apps/docs', 'docs', { '@sim/workflow-renderer': 'workspace:*' }],
['packages/auth', '@sim/auth', { '@sim/security': 'workspace:*' }],
['packages/security', '@sim/security', {}],
['packages/db', '@sim/db', {}],
['packages/sim-setup', 'sim-setup', {}],
['packages/sim-cli', 'sim', {}],
[
'packages/workflow-renderer',
'@sim/workflow-renderer',
{ '@sim/workflow-types': 'workspace:*' },
],
['packages/workflow-types', '@sim/workflow-types', {}],
] as const
const appScripts = JSON.parse(
readFileSync(resolve(root, 'apps/sim/package.json'), 'utf8')
).scripts
const workspaces: Record<string, unknown> = { '': { name: 'ci-fixture' } }
for (const [path, name, dependencies] of packages) {
const scripts: Record<string, string> = {
test: 'echo test',
build: 'echo build',
'type-check': 'echo types',
}
if (name === '@sim/app')
for (const key of Object.keys(appScripts))
if (key.startsWith('ci:')) scripts[key] = 'echo fixture'
write(
repo,
`${path}/package.json`,
JSON.stringify({ name, version: '1.0.0', scripts, dependencies })
)
write(repo, `${path}/src/index.ts`, 'export const value = 1\n')
workspaces[path] = { name, version: '1.0.0', dependencies }
}
write(
repo,
'bun.lock',
JSON.stringify({ lockfileVersion: 1, configVersion: 1, workspaces, packages: {} })
)
for (const file of [
'turbo.json',
'apps/sim/turbo.json',
'apps/desktop/turbo.json',
'.github/ci-suites.json',
'.github/scripts/ci-plan.gql',
]) {
mkdirSync(dirname(join(repo, file)), { recursive: true })
copyFileSync(resolve(root, file), join(repo, file))
}
git(repo, 'add', '-A')
git(repo, 'commit', '--quiet', '-m', 'base')
return { repo, base: git(repo, 'rev-parse', 'HEAD') }
}
function classify(repo: string, base: string, environment: Record<string, string> = {}): Plan {
const report = join(repo, 'plan.json')
const result = spawnSync('bash', [script, base], {
cwd: repo,
encoding: 'utf8',
env: {
...process.env,
GITHUB_EVENT_NAME: 'workflow_dispatch',
GITHUB_REF: 'refs/heads/fixture',
GITHUB_SHA: '',
...environment,
PATH: `${resolve(root, 'node_modules/.bin')}:${process.env.PATH}`,
CI_PLAN_PATH: report,
},
})
expect(result.status, result.stderr).toBe(0)
const plan: Plan = JSON.parse(readFileSync(report, 'utf8'))
for (const [flag, value] of Object.entries(plan.flags))
expect(result.stdout).toContain(`${flag}=${value}\n`)
return plan
}
function pullRequestFixture(files: string[], depth = 2) {
const { repo: source, base } = fixture()
git(source, 'checkout', '--quiet', '-b', 'contribution')
for (const file of files) {
write(source, file, `${file}\n`)
git(source, 'add', '-A')
git(source, 'commit', '--quiet', '-m', `contribute ${file}`)
}
git(source, 'checkout', '--quiet', '-b', 'target', base)
write(source, 'apps/sim/lib/upstream.ts', 'export const upstream = true\n')
git(source, 'add', '-A')
git(source, 'commit', '--quiet', '-m', 'advance target')
const target = git(source, 'rev-parse', 'HEAD')
git(source, 'merge', '--quiet', '--no-ff', '-m', 'synthetic PR merge', 'contribution')
const head = git(source, 'rev-parse', 'HEAD')
const repo = mkdtempSync(join(tmpdir(), 'ci-pr-merge-'))
fixtures.push(repo)
git(repo, 'init', '--quiet')
git(repo, 'remote', 'add', 'origin', pathToFileURL(source).href)
git(repo, 'fetch', '--quiet', `--depth=${depth}`, 'origin', head)
git(repo, 'checkout', '--quiet', '--detach', 'FETCH_HEAD')
expect(git(repo, 'rev-parse', '--is-shallow-repository')).toBe('true')
return {
repo,
base,
target,
environment: {
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: 'refs/pull/42/merge',
GITHUB_SHA: head,
},
}
}
function classifyFiles(files: string[]): Plan {
const { repo, base } = fixture()
for (const file of files) write(repo, file, `${file}\n`)
git(repo, 'add', '-A')
git(repo, 'commit', '--quiet', '-m', 'change')
return classify(repo, base)
}
function groups(plan: Plan) {
return [...new Set([...plan.http, ...plan.production].map((suite) => suite.group))].sort()
}
afterEach(() => {
for (const repo of fixtures.splice(0)) rmSync(repo, { recursive: true, force: true })
})
describe('CI task attribution through real Turborepo', () => {
it('scopes a shallow multi-commit PR against its tested target after the event base goes stale', () => {
const files = ['packages/sim-setup/src/index.ts', 'packages/sim-setup/src/second.ts']
const { repo, base, target, environment } = pullRequestFixture(files)
const plan = classify(repo, base, environment)
expect(plan.fallback).toBeUndefined()
expect(plan.base).toBe(target)
expect(plan.files).toEqual(files)
expect(groups(plan)).toEqual([])
expect(plan.testPackages).toEqual(['sim-setup'])
expect(plan.typecheckPackages).toEqual(['sim-setup'])
expect(plan.flags).toMatchObject({
test: true,
test_app: false,
integration: false,
build: false,
desktop_live: false,
e2e_build: false,
docs: false,
})
})
it('keeps an earlier server change when the final PR commit only changes the setup package', () => {
const files = ['apps/sim/lib/server.ts', 'packages/sim-setup/src/second.ts']
const { repo, base, target, environment } = pullRequestFixture(files)
const plan = classify(repo, base, environment)
expect(plan.fallback).toBeUndefined()
expect(plan.base).toBe(target)
expect(plan.files).toEqual(files)
expect(plan.testPackages).toContain('sim-setup')
expect(plan.flags).toMatchObject({
test_app: true,
integration: true,
build: true,
desktop_live: true,
e2e_build: true,
})
})
it.each<[string, Record<string, string>]>([
['a branch ref', { GITHUB_REF: 'refs/heads/staging' }],
['a missing ref', { GITHUB_REF: '' }],
['a different triggering SHA', { GITHUB_SHA: 'f'.repeat(40) }],
['a missing triggering SHA', { GITHUB_SHA: '' }],
])('runs everything for a PR checkout with %s', (_label, invalid) => {
const { repo, target, environment } = pullRequestFixture(['packages/sim-setup/src/index.ts'])
const plan = classify(repo, target, { ...environment, ...invalid })
expect(plan.fallback).toBeDefined()
expect(Object.values(plan.flags).every(Boolean)).toBe(true)
})
it('runs everything if a PR event checks out a non-merge commit', () => {
const { repo, base } = fixture()
write(repo, 'packages/sim-setup/src/index.ts', 'export const value = 2\n')
git(repo, 'commit', '--quiet', '-am', 'setup package change')
const plan = classify(repo, base, {
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: 'refs/pull/42/merge',
GITHUB_SHA: git(repo, 'rev-parse', 'HEAD'),
})
expect(plan.fallback).toBeDefined()
expect(Object.values(plan.flags).every(Boolean)).toBe(true)
})
it('runs everything if a shallow PR checkout does not contain its merge parents', () => {
const { repo, base, environment } = pullRequestFixture(['packages/sim-setup/src/index.ts'], 1)
const plan = classify(repo, base, environment)
expect(plan.fallback).toBeDefined()
expect(Object.values(plan.flags).every(Boolean)).toBe(true)
})
it('runs standalone package tests without provisioning the app, browsers, or database', () => {
const plan = classifyFiles(['packages/sim-setup/src/index.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.testPackages).toEqual(['sim-setup'])
expect(plan.typecheckPackages).toEqual(['sim-setup'])
expect(plan.flags).toMatchObject({
test: true,
test_app: false,
integration: false,
build: false,
desktop_live: false,
e2e_build: false,
docs: false,
})
})
it('selects integration and browser checks for workspace code shared with desktop execution', () => {
const plan = classifyFiles([
'apps/sim/app/workspace/[workspaceId]/home/hooks/stream/dispatch-stream-event.ts',
])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([
'assistant-actions',
'browser-extension-access',
'browser-extension-composer',
'browser-extension-navigation',
'mobile',
'organization-search',
'seo',
])
expect(plan.flags).toMatchObject({
desktop_live: true,
integration: true,
test_app: true,
build: true,
e2e_build: true,
})
})
it('selects SEO and rendering checks for content without database or Electron suites', () => {
const plan = classifyFiles(['apps/sim/content/library/example/index.mdx'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual(['seo'])
expect(plan.flags).toMatchObject({
integration: false,
desktop_live: false,
test_app: true,
build: true,
})
})
it.each([
['apps/sim/public/library/example/cover.jpg'],
['apps/sim/content/library/example/index.mdx', 'apps/sim/public/library/example/cover.jpg'],
])('keeps library media on the rendering and SEO path: %j', (...files) => {
const plan = classifyFiles(files)
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual(['seo'])
expect(plan.docsGroups).toEqual([])
expect(plan.flags).toMatchObject({
integration: false,
desktop_live: false,
production: false,
test_app: true,
build: true,
e2e_build: true,
})
})
it('keeps landing route-group edits on the rendering and SEO path', () => {
const plan = classifyFiles(['apps/sim/app/(landing)/pricing/page.tsx'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual(['seo'])
expect(plan.flags).toMatchObject({
integration: false,
desktop_live: false,
test_app: true,
build: true,
e2e_build: true,
})
})
it.each(['delete', 'move'])('keeps SEO coverage when library media is removed: %s', (change) => {
const { repo } = fixture()
const media = 'apps/sim/public/library/example/cover.jpg'
write(repo, media, 'fixture media')
git(repo, 'add', '-A')
git(repo, 'commit', '--quiet', '-m', 'media base')
const base = git(repo, 'rev-parse', 'HEAD')
if (change === 'delete') git(repo, 'rm', media)
else git(repo, 'mv', media, 'apps/sim/public/library/example/renamed.jpg')
git(repo, 'commit', '--quiet', '-m', change)
const plan = classify(repo, base)
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual(['seo'])
expect(plan.flags).toMatchObject({
build: true,
e2e_build: true,
integration: false,
desktop_live: false,
docs: false,
})
})
it.each([
'apps/sim/app/workspace/[workspaceId]/upgrade/components/comparison-table/comparison-data.ts',
'apps/sim/providers/models.ts',
'apps/sim/blocks/registry.ts',
])('runs SEO when landing pages consume changed workspace or backend code: %s', (file) => {
const plan = classifyFiles([file])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toContain('seo')
})
it('preserves the implicit app test dependency on docs content', () => {
const plan = classifyFiles(['apps/docs/content/docs/integrations/netsuite.mdx'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.flags).toMatchObject({
test_app: true,
build: false,
integration: false,
desktop_live: false,
docs: true,
})
expect(plan.testPackages).toEqual(['docs'])
})
it('selects docs acceptance for a transitive rendering dependency', () => {
const plan = classifyFiles(['packages/workflow-types/src/index.ts'])
expect(plan.fallback).toBeUndefined()
expect(plan.flags.docs).toBe(true)
expect(plan.docsGroups).toEqual(['http', 'corpus', 'chromium', 'webkit'])
})
it('keeps docs unit-only edits out of production acceptance', () => {
const plan = classifyFiles(['apps/docs/lib/content/links.test.ts'])
expect(plan.fallback).toBeUndefined()
expect(plan.flags.docs).toBe(false)
expect(plan.testPackages).toEqual(['docs'])
})
it('selects docs acceptance for its standalone browser harness', () => {
const plan = classifyFiles(['apps/docs/scripts/test-navigation-e2e.ts'])
expect(plan.fallback).toBeUndefined()
expect(plan.flags.docs).toBe(true)
})
it('selects only the platform docs boundary for a consumer harness change', () => {
const plan = classifyFiles(['apps/sim/scripts/test-docs-search-provider-e2e.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.docsGroups).toEqual(['platform'])
expect(plan.flags).toMatchObject({
docs: true,
docs_site: false,
docs_platform: true,
test_app: false,
e2e_build: false,
integration: false,
desktop_live: false,
})
})
it('selects platform docs for backend changes without site browser checks', () => {
const plan = classifyFiles(['apps/sim/lib/mothership/docs/search.ts'])
expect(plan.fallback).toBeUndefined()
expect(plan.flags).toMatchObject({ docs: true, docs_site: false, docs_platform: true })
expect(plan.docsGroups).toEqual(['platform'])
})
it('keeps desktop smoke weights out of live runtime attribution', () => {
const plan = classifyFiles(['apps/desktop/e2e-durations.json'])
expect(plan.fallback).toBeUndefined()
expect(plan.flags).toMatchObject({ desktop_live: false, e2e_build: false })
})
it('does not build or run E2E for an app unit-test-only edit', () => {
const plan = classifyFiles(['apps/sim/lib/auth/session.test.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.flags).toMatchObject({
test_app: true,
integration: false,
build: false,
desktop_live: false,
})
})
it('runs a new integration file even when its source domain did not change', () => {
const plan = classifyFiles(['apps/sim/lib/auth/session.integration.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.flags).toMatchObject({ integration: true, test_app: false, build: false })
})
it.each([
'packages/db/vitest.config.ts',
'packages/db/vitest.integration.setup.ts',
'apps/realtime/vitest.config.ts',
'apps/realtime/vitest.integration.setup.ts',
])('runs integration checks when sibling collection or setup changes: %s', (file) => {
const plan = classifyFiles([file])
expect(plan.fallback).toBeUndefined()
expect(plan.flags.integration).toBe(true)
})
it.each([
['test-desktop-inbox-e2e.ts', 'desktop-inbox'],
['test-assistant-actions-e2e.ts', 'assistant-actions'],
['test-organization-search-e2e.ts', 'organization-search'],
])('selects the owning organization acceptance job for %s', (file, group) => {
const plan = classifyFiles([`apps/sim/scripts/${file}`])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([group])
expect(plan.flags).toMatchObject({
http: true,
production: false,
integration: false,
e2e_build: true,
})
})
it.each([
['test-mobile-e2e.ts', 'mobile'],
['test-project-file-sharing-e2e.ts', 'project-files'],
['test-scim-e2e.ts', 'scim'],
['test-landing-seo-e2e.ts', 'seo'],
])('runs the affected acceptance boundary for %s', (file, group) => {
const plan = classifyFiles([`apps/sim/scripts/${file}`])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([group])
expect(plan.flags.http).toBe(group !== 'mobile')
expect(plan.flags.production).toBe(group === 'mobile')
expect(plan.flags).toMatchObject({
test: false,
build: false,
integration: false,
e2e_build: true,
})
})
it('selects every isolated extension group for an extension harness change', () => {
const plan = classifyFiles(['apps/sim/scripts/test-browser-extension-e2e.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([
'browser-extension-access',
'browser-extension-composer',
'browser-extension-navigation',
])
expect(plan.flags).toMatchObject({
http: true,
production: false,
integration: false,
test: false,
build: false,
e2e_build: true,
})
})
it('propagates a transitive security dependency to every affected boundary', () => {
const plan = classifyFiles(['packages/security/src/index.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([
'assistant-actions',
'browser-extension-access',
'browser-extension-composer',
'browser-extension-navigation',
'cli',
'desktop-inbox',
'mobile',
'organization-search',
'project-files',
'scim',
'seo',
'stop-after',
])
expect(plan.typecheckPackages).toContain('@sim/app')
expect(plan.typecheckPackages).toContain('@sim/realtime')
expect(plan.flags).toMatchObject({
integration: true,
desktop_live: true,
test_app: true,
build: true,
})
})
it.each([
'apps/sim/new-domain/feature.ts',
'apps/sim/public/new-domain/config.json',
'apps/sim/public/favicon/favicon.ico',
'apps/sim/tools/service/__fixtures__/README.md',
])('keeps unclassified runtime files in the shared boundary: %s', (path) => {
const plan = classifyFiles([path])
expect(plan.fallback).toBeUndefined()
expect(plan.flags).toMatchObject({ integration: true, desktop_live: true, e2e_build: true })
})
it.each([
'.github/workflows/checks.yml',
'scripts/check-example.ts',
'unknown-root.json',
'apps/pii/server.py',
])('runs all checks for unclassified or orchestration changes: %s', (file) => {
const plan = classifyFiles([file])
expect(plan.fallback).toBeTruthy()
expect(Object.values(plan.flags).every(Boolean)).toBe(true)
})
it('keeps the implicit CLI embed dependency in HTTP acceptance', () => {
const plan = classifyFiles(['packages/sim-cli/src/embed.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual(['cli'])
expect(plan.testPackages).toEqual(['sim'])
expect(plan.flags).toMatchObject({ e2e_build: true, integration: false, desktop_live: false })
})
it('runs the shell execution check when its standalone harness changes', () => {
const plan = classifyFiles(['apps/sim/scripts/test-shell-placeholders-e2e.ts'])
expect(plan.flags.test_app).toBe(true)
})
it('keeps new, unclassified acceptance harnesses in the shared boundary', () => {
const plan = classifyFiles(['apps/sim/scripts/test-new-feature-e2e.ts'])
expect(plan.flags).toMatchObject({ test_app: true, integration: true, desktop_live: true })
})
it('keeps guidance-only edits on the lint/audit path', () => {
const plan = classifyFiles([
'apps/sim/AGENTS.md',
'packages/security/CLAUDE.md',
'.claude/rules/example.md',
])
expect(plan.fallback).toBeUndefined()
expect(Object.values(plan.flags).some(Boolean)).toBe(false)
})
it('selects Electron without unrelated app suites for shell-only edits', () => {
const plan = classifyFiles(['apps/desktop/src/main/menu.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.flags).toMatchObject({
desktop_live: true,
e2e_build: true,
integration: false,
test_app: false,
build: false,
})
expect(plan.testPackages).toEqual(['@sim/desktop'])
})
it('keeps shell-only smoke edits out of the live Sim execution gate', () => {
const plan = classifyFiles(['apps/desktop/e2e/browser-tools.spec.ts'])
expect(plan.fallback).toBeUndefined()
expect(groups(plan)).toEqual([])
expect(plan.flags).toMatchObject({
desktop_live: false,
e2e_build: false,
integration: false,
build: false,
})
})
it.each([
'apps/desktop/e2e/desktop-tools-live-sim.spec.ts',
'apps/desktop/e2e/fixtures/live-sim.ts',
'apps/desktop/playwright.config.ts',
])('keeps live execution coverage when its harness changes: %s', (file) => {
const plan = classifyFiles([file])
expect(plan.fallback).toBeUndefined()
expect(plan.flags).toMatchObject({ desktop_live: true, e2e_build: true })
})
it('runs everything if the real task query cannot parse configuration', () => {
const { repo, base } = fixture()
write(repo, 'turbo.json', '{invalid')
git(repo, 'commit', '--quiet', '-am', 'invalid graph')
const plan = classify(repo, base)
expect(plan.fallback).toContain('turbo:')
expect(Object.values(plan.flags).every(Boolean)).toBe(true)
})
it('accounts for both sides of a move out of runtime code', () => {
const { repo, base } = fixture()
git(repo, 'mv', 'apps/sim/src/index.ts', 'apps/docs/src/moved.ts')
git(repo, 'commit', '--quiet', '-am', 'move')
const plan = classify(repo, base)
expect(plan.flags).toMatchObject({ integration: true, desktop_live: true, test_app: true })
})
it.each(['', '0'.repeat(40)])('runs all checks without a usable base: %j', (base) => {
const { repo } = fixture()
expect(Object.values(classify(repo, base).flags).every(Boolean)).toBe(true)
})
it('runs all checks on an empty diff', () => {
const { repo, base } = fixture()
expect(Object.values(classify(repo, base).flags).every(Boolean)).toBe(true)
})
})