|
| 1 | +import fs from 'node:fs'; |
| 2 | +import path from 'node:path'; |
| 3 | +import { expect, test } from 'vitest'; |
| 4 | +import { |
| 5 | + affectsIosXctests, |
| 6 | + selectIosXctests, |
| 7 | + uncoveredRunnerCacheInputs, |
| 8 | +} from '../ios-xctest-impact.ts'; |
| 9 | + |
| 10 | +test('every runner build-cache input triggers the PR XCTest lane', () => { |
| 11 | + const action = fs.readFileSync( |
| 12 | + path.resolve('.github/actions/setup-apple-runner-build/action.yml'), |
| 13 | + 'utf8', |
| 14 | + ); |
| 15 | + expect(uncoveredRunnerCacheInputs(action)).toEqual([]); |
| 16 | + expect( |
| 17 | + uncoveredRunnerCacheInputs(action.replace('apple/runner/**', 'new-native-input/**')), |
| 18 | + ).toEqual(['new-native-input/**']); |
| 19 | +}); |
| 20 | + |
| 21 | +test('the PR workflow applies the impact decision to the XCTest step', () => { |
| 22 | + const workflow = fs.readFileSync(path.resolve('.github/workflows/ios.yml'), 'utf8'); |
| 23 | + expect(workflow).toContain('node --experimental-strip-types scripts/ios-xctest-impact.ts'); |
| 24 | + expect(workflow).toMatch( |
| 25 | + /- name: Run targeted iOS runner XCTest regressions\n\s+if: steps\.xctest-impact\.outputs\.run == 'true'/, |
| 26 | + ); |
| 27 | +}); |
| 28 | + |
| 29 | +test('native runner and golden-table changes run XCTest; TypeScript runtime changes use live E2E', () => { |
| 30 | + for (const file of [ |
| 31 | + 'apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift', |
| 32 | + 'apple/snapshot-presentation/Sources/Presenter.swift', |
| 33 | + 'contracts/fixtures/scroll-gesture.json', |
| 34 | + '.github/workflows/ios.yml', |
| 35 | + 'scripts/ios-xctest-impact.ts', |
| 36 | + ]) { |
| 37 | + expect(affectsIosXctests(file), file).toBe(true); |
| 38 | + } |
| 39 | + for (const file of [ |
| 40 | + 'packages/platform-apple/src/snapshot-source/cache.ts', |
| 41 | + 'apple/fold-helper/fold-helper.c', |
| 42 | + 'test/integration/ios-simulator-e2e/live-runner.ts', |
| 43 | + ]) { |
| 44 | + expect(selectIosXctests('pull_request', [file]), file).toMatchObject({ run: false }); |
| 45 | + } |
| 46 | +}); |
| 47 | + |
| 48 | +test('pushes and uncertain diffs keep the full XCTest selection', () => { |
| 49 | + expect(selectIosXctests('push', ['src/index.ts']).run).toBe(true); |
| 50 | + expect(selectIosXctests('pull_request', null).run).toBe(true); |
| 51 | + expect(selectIosXctests('pull_request', []).run).toBe(true); |
| 52 | + expect(selectIosXctests('pull_request', ['src/index.ts', 'package.json']).run).toBe(true); |
| 53 | +}); |
0 commit comments