|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import fs from 'node:fs'; |
| 3 | +import os from 'node:os'; |
| 4 | +import path from 'node:path'; |
| 5 | +import test from 'node:test'; |
| 6 | + |
| 7 | +import { PUBLIC_COMMANDS } from '../../src/command-catalog.ts'; |
| 8 | +import { ANDROID_EMULATOR_COVERAGE_CLASSIFICATION_SUMMARY } from './android-emulator-e2e/coverage-manifest.ts'; |
| 9 | +import type { LiveContext } from './android-emulator-e2e/live-harness.ts'; |
| 10 | +import { writeCoverageReport } from './android-emulator-e2e/live-coverage-report.ts'; |
| 11 | + |
| 12 | +test('Android coverage report persists the manifest rollup and executed tier', (t) => { |
| 13 | + const artifactDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-android-coverage-')); |
| 14 | + t.after(() => fs.rmSync(artifactDir, { force: true, recursive: true })); |
| 15 | + const context: LiveContext = { |
| 16 | + appId: 'com.example.fixture', |
| 17 | + appPath: '/fixture.apk', |
| 18 | + artifactDir, |
| 19 | + behaviorEvidence: {}, |
| 20 | + commandEvidence: { |
| 21 | + [PUBLIC_COMMANDS.close]: ['session released'], |
| 22 | + }, |
| 23 | + completedScenarios: ['smoke:capture-close'], |
| 24 | + currentScenario: 'smoke:capture-close', |
| 25 | + env: {}, |
| 26 | + serial: 'emulator-5554', |
| 27 | + session: 'coverage-report', |
| 28 | + sessionOpen: false, |
| 29 | + startedAtMs: Date.now(), |
| 30 | + stepHistory: [], |
| 31 | + tier: 'full', |
| 32 | + timings: [], |
| 33 | + }; |
| 34 | + |
| 35 | + const report = JSON.parse(fs.readFileSync(writeCoverageReport(context), 'utf8')) as { |
| 36 | + classificationSummary: typeof ANDROID_EMULATOR_COVERAGE_CLASSIFICATION_SUMMARY; |
| 37 | + tier: LiveContext['tier']; |
| 38 | + }; |
| 39 | + |
| 40 | + assert.deepEqual(report.classificationSummary, ANDROID_EMULATOR_COVERAGE_CLASSIFICATION_SUMMARY); |
| 41 | + assert.equal(report.tier, 'full'); |
| 42 | +}); |
0 commit comments