Skip to content

Commit 777ded9

Browse files
authored
refactor(test): fold the last two coverage-summary copies into the shared builder (#1992)
tvOS (#1919) and macOS (#1922) each carried a private copy of buildCoverageClassificationSummary; Android, web, and Linux already import the shared one from test/integration/support/coverage-classification.ts. Fold the remaining two onto it and drop their structurally identical local summary types, completing the factoring that #1426's ground rule triggered at the fourth copy. Refs #1426
1 parent 2964477 commit 777ded9

2 files changed

Lines changed: 2 additions & 74 deletions

File tree

‎test/integration/macos-e2e/coverage-manifest.ts‎

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PUBLIC_COMMANDS } from '../../../src/command-catalog.ts';
2+
import { buildCoverageClassificationSummary } from '../support/coverage-classification.ts';
23
import {
34
MACOS_LIVE_SCENARIOS,
45
type MacOsLiveScenario,
@@ -32,14 +33,6 @@ export type MacOsPlatformCoverageEntry =
3233
trackingIssue: number;
3334
};
3435

35-
export type MacOsPlatformCoverageClassificationSummary = {
36-
capabilityDenial: number;
37-
contract: number;
38-
gap: number;
39-
live: number;
40-
total: number;
41-
};
42-
4336
export const MACOS_COVERAGE_GAP_ISSUE = 1916;
4437

4538
const C = PUBLIC_COMMANDS;
@@ -267,32 +260,3 @@ function liveScenario(scenarioId: MacOsLiveScenarioId): MacOsLiveScenario {
267260
if (!scenario) throw new Error(`Unknown macOS coverage scenario: ${scenarioId}`);
268261
return scenario;
269262
}
270-
271-
function buildCoverageClassificationSummary(
272-
entries: readonly MacOsPlatformCoverageEntry[],
273-
): MacOsPlatformCoverageClassificationSummary {
274-
const summary: MacOsPlatformCoverageClassificationSummary = {
275-
capabilityDenial: 0,
276-
contract: 0,
277-
gap: 0,
278-
live: 0,
279-
total: entries.length,
280-
};
281-
for (const entry of entries) {
282-
switch (entry.level) {
283-
case 'live':
284-
summary.live += 1;
285-
break;
286-
case 'command-contract':
287-
summary.contract += 1;
288-
break;
289-
case 'capability-denial':
290-
summary.capabilityDenial += 1;
291-
break;
292-
case 'known-gap':
293-
summary.gap += 1;
294-
break;
295-
}
296-
}
297-
return summary;
298-
}

‎test/integration/tvos-e2e/coverage-manifest.ts‎

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PUBLIC_COMMANDS } from '../../../src/command-catalog.ts';
2+
import { buildCoverageClassificationSummary } from '../support/coverage-classification.ts';
23

34
type PublicCommand = (typeof PUBLIC_COMMANDS)[keyof typeof PUBLIC_COMMANDS];
45

@@ -37,14 +38,6 @@ export type TvOsPlatformCoverageEntry =
3738
trackingIssue: number;
3839
};
3940

40-
export type TvOsPlatformCoverageClassificationSummary = {
41-
capabilityDenial: number;
42-
contract: number;
43-
gap: number;
44-
live: number;
45-
total: number;
46-
};
47-
4841
export const TVOS_COVERAGE_GAP_ISSUE = 1914;
4942
export const TVOS_REMOTE_TEST_NAME =
5043
'Provider-backed integration tvOS remote flow maps navigation commands to runner remote presses';
@@ -219,32 +212,3 @@ export const TVOS_PLATFORM_COVERAGE = {
219212
export const TVOS_PLATFORM_COVERAGE_CLASSIFICATION_SUMMARY = buildCoverageClassificationSummary(
220213
Object.values(TVOS_PLATFORM_COVERAGE),
221214
);
222-
223-
function buildCoverageClassificationSummary(
224-
entries: readonly TvOsPlatformCoverageEntry[],
225-
): TvOsPlatformCoverageClassificationSummary {
226-
const summary: TvOsPlatformCoverageClassificationSummary = {
227-
capabilityDenial: 0,
228-
contract: 0,
229-
gap: 0,
230-
live: 0,
231-
total: entries.length,
232-
};
233-
for (const entry of entries) {
234-
switch (entry.level) {
235-
case 'live':
236-
summary.live += 1;
237-
break;
238-
case 'command-contract':
239-
summary.contract += 1;
240-
break;
241-
case 'capability-denial':
242-
summary.capabilityDenial += 1;
243-
break;
244-
case 'known-gap':
245-
summary.gap += 1;
246-
break;
247-
}
248-
}
249-
return summary;
250-
}

0 commit comments

Comments
 (0)