Skip to content

Commit 9b21723

Browse files
committed
test: cover snapshot annotation quality mapping
1 parent 0423cdb commit 9b21723

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎src/client-shared.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import type {
1010
CaptureSnapshotResult,
1111
SessionCloseResult,
1212
} from './client-types.ts';
13-
import { publicSnapshotCaptureAnnotations } from './snapshot-capture-annotations.ts';
13+
import {
14+
publicSnapshotCaptureAnnotations,
15+
type SnapshotCaptureAnnotations,
16+
} from './snapshot-capture-annotations.ts';
1417
import type { Platform } from './utils/device.ts';
1518
import { successText, withSuccessText } from './utils/success-text.ts';
1619

@@ -173,10 +176,17 @@ export function serializeSnapshotResult(result: CaptureSnapshotResult): Record<s
173176
...(result.appName ? { appName: result.appName } : {}),
174177
...(result.appBundleId ? { appBundleId: result.appBundleId } : {}),
175178
...(result.visibility ? { visibility: result.visibility } : {}),
176-
...publicSnapshotCaptureAnnotations({
177-
...result,
178-
quality: result.snapshotQuality,
179-
}),
179+
...publicSnapshotCaptureAnnotations(snapshotResultAnnotations(result)),
180180
...(result.unchanged ? { unchanged: result.unchanged } : {}),
181181
};
182182
}
183+
184+
function snapshotResultAnnotations(
185+
result: CaptureSnapshotResult,
186+
): Partial<SnapshotCaptureAnnotations> {
187+
const annotations = result as CaptureSnapshotResult & Partial<SnapshotCaptureAnnotations>;
188+
return {
189+
...annotations,
190+
...(result.snapshotQuality ? { quality: result.snapshotQuality } : {}),
191+
};
192+
}

‎src/commands/capture-snapshot.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import {
66
type PublicSnapshotCaptureAnnotations,
77
type SnapshotCaptureAnnotations,
88
} from '../snapshot-capture-annotations.ts';
9-
import {
10-
renderSnapshotQualityWarnings,
11-
} from '../utils/snapshot-quality.ts';
9+
import { renderSnapshotQualityWarnings } from '../utils/snapshot-quality.ts';
1210
import { AppError } from '../utils/errors.ts';
1311
import { buildSnapshotDiff, countSnapshotComparableLines } from '../utils/snapshot-diff.ts';
1412
import type { SnapshotDiffLine, SnapshotDiffSummary } from '../utils/snapshot-diff.ts';
@@ -230,7 +228,9 @@ function buildSnapshotWarnings(params: {
230228
}): string[] {
231229
const warnings = [...(params.annotations.warnings ?? [])];
232230
if (params.annotations.quality) {
233-
warnings.push(...renderSnapshotQualityWarnings(params.annotations.quality, params.snapshot.nodes));
231+
warnings.push(
232+
...renderSnapshotQualityWarnings(params.annotations.quality, params.snapshot.nodes),
233+
);
234234
}
235235
warnings.push(...buildEmptyAndroidInteractiveWarnings(params));
236236
if (!params.annotations.quality) {

0 commit comments

Comments
 (0)