diff --git a/README.md b/README.md index 83a1916..0f0eb93 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,12 @@ For the Apex side of step 5, see [Alongside Apex coverage](#alongside-apex-cover ## How coverage is measured - **What counts.** Active Flows with the process types Salesforce counts toward deploy-as-active: autolaunched Flows (including record-triggered, platform event and schedule-triggered Flows) and Process Builder processes. Screen Flows don't count. +- **How Salesforce calculates it.** The percentage counts Flows, not elements: a Flow counts once any Apex test runs it. Salesforce divides the Flow versions with coverage (active ones, and the latest inactive versions that have a test) by the active versions without coverage plus the versions with coverage ([Deploy Processes and Flows as Active](https://help.salesforce.com/s/articleView?id=platform.flow_distribute_deploy_active.htm&type=5)). `readiness` calculates it the same way, and shows the active-only figure too when they differ. Element coverage is reported to show what's still untested, but it doesn't count toward the threshold. +- **Which version a test runs.** Apex tests run a Flow's active version, or its latest version when none is active, so a Flow deployed inactive gets coverage on that inactive version. Saving changes to a Flow version deletes its coverage, so run the tests again after editing a Flow ([FlowTestCoverage](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_flowtestcoverage.htm)). +- **The threshold.** Production sets the percentage in Setup > Process Automation Settings, next to "Deploy processes and flows as active". `readiness` uses 75% unless you pass `--threshold`, and says so. - **Where it comes from.** Salesforce records which Flow versions each Apex test runs in the Tooling API `FlowTestCoverage` object when Apex tests run in the org. `readiness`, `gate`, and `transform` read it, so run your Apex tests before using them. - **Run tests with `--code-coverage`.** Without `--code-coverage`, `sf apex run test` skips coverage and Salesforce records no Flow coverage. Check-only deployments (`sf project deploy validate`) don't record it either. When no Flow in the org has any coverage, `readiness`, `gate`, and `transform` warn that this is the likely cause instead of just reporting 0%. -- **Only Apex counts.** Flow Builder tests and Flow Test Mode (Winter '27) don't count toward the 75% requirement, so `scaffold` generates Apex tests, not Flow test metadata. The coverage source is pluggable, so if Salesforce starts counting Test Mode coverage it can be added without changing the commands. +- **Only Apex counts.** Flow Builder tests and Flow Test Mode (Winter '27) don't count toward the requirement, so `scaffold` generates Apex tests, not Flow test metadata. The coverage source is pluggable, so if Salesforce starts counting Test Mode coverage it can be added without changing the commands. ## Readiness report @@ -305,7 +308,7 @@ FLAGS --since= Only count commits after this date: a date (2026-01-31) or " days|weeks|months|years ago". - --threshold= [default: 75] Coverage percentage the org must reach. + --threshold= Coverage percentage the org must reach. Default: 75. GLOBAL FLAGS --flags-dir= Import flag values from a directory. @@ -314,12 +317,15 @@ GLOBAL FLAGS DESCRIPTION Report how close the org is to the coverage needed to deploy Flows as active. - Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can - turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the - org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and, - for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one - Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to - migrate them to Flows, since Salesforce no longer supports Process Builder. + Before you can turn on "Deploy processes and flows as active", Salesforce requires a percentage of active autolaunched + Flows and processes to be run by at least one Apex test. Production sets that percentage in Process Automation + Settings; this command uses 75% unless you pass --threshold. A Flow counts once any test runs it, however many of its + elements run. Salesforce also counts the latest inactive versions that have a test, and this command does the same. It + reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the + uncovered Flows (ranked by how often they change in git) and, for each covered Flow, the Apex tests that run it and + the elements no test runs yet. Listing those elements takes one Tooling API query per partly covered Flow. Process + Builder processes are labeled and counted, with a suggestion to migrate them to Flows, since Salesforce no longer + supports Process Builder. FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without @@ -361,6 +367,11 @@ FLAG DESCRIPTIONS "human" prints tables and warnings to the terminal. "markdown" prints the report as one Markdown document, warnings included, for a pull request comment or a GitHub Actions job summary. Redirect it to a file, for example `>> "$GITHUB_STEP_SUMMARY"`. --json takes precedence over both. + + --threshold= Coverage percentage the org must reach. Default: 75. + + Production sets the percentage Salesforce requires in Setup > Process Automation Settings, next to "Deploy processes + and flows as active". Pass that number; without it, the report uses 75% and says so. ``` _See code: [src/commands/flowcov/readiness.ts](https://github.com/mcarvin8/sf-flow-coverage/blob/main/src/commands/flowcov/readiness.ts)_ diff --git a/messages/flowcov.readiness.md b/messages/flowcov.readiness.md index ec48716..81b74ef 100644 --- a/messages/flowcov.readiness.md +++ b/messages/flowcov.readiness.md @@ -4,7 +4,7 @@ Report how close the org is to the coverage needed to deploy Flows as active. # description -Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and, for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to migrate them to Flows, since Salesforce no longer supports Process Builder. +Before you can turn on "Deploy processes and flows as active", Salesforce requires a percentage of active autolaunched Flows and processes to be run by at least one Apex test. Production sets that percentage in Process Automation Settings; this command uses 75% unless you pass --threshold. A Flow counts once any test runs it, however many of its elements run. Salesforce also counts the latest inactive versions that have a test, and this command does the same. It reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and, for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to migrate them to Flows, since Salesforce no longer supports Process Builder. FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`. @@ -46,7 +46,11 @@ Only count commits after this date: a date (2026-01-31) or " days|weeks|month # flags.threshold.summary -Coverage percentage the org must reach. +Coverage percentage the org must reach. Default: 75. + +# flags.threshold.description + +Production sets the percentage Salesforce requires in Setup > Process Automation Settings, next to "Deploy processes and flows as active". Pass that number; without it, the report uses 75% and says so. # flags.fail-if-not-ready.summary diff --git a/src/commands/flowcov/readiness.ts b/src/commands/flowcov/readiness.ts index 9a6abc7..c39ebca 100644 --- a/src/commands/flowcov/readiness.ts +++ b/src/commands/flowcov/readiness.ts @@ -2,11 +2,11 @@ import { Messages } from '@salesforce/core'; import { Flags, SfCommand } from '@salesforce/sf-plugins-core'; import { describeElements } from '../../core/elementCoverage.js'; import { deployAsActiveAdvice } from '../../core/flowSettings.js'; -import { DEFAULT_THRESHOLD, isProcessBuilder, PROCESS_BUILDER_ADVICE, processTypeLabel } from '../../core/flowTypes.js'; +import { isProcessBuilder, PROCESS_BUILDER_ADVICE, processTypeLabel } from '../../core/flowTypes.js'; import { getFlowChurn } from '../../core/git.js'; import { OUTPUT_FORMATS, readinessMarkdown } from '../../core/markdown.js'; import { OrgCoverageSource } from '../../core/orgCoverageSource.js'; -import { buildReadinessReport } from '../../core/readiness.js'; +import { buildReadinessReport, coverageLines, ELEMENT_COVERAGE_NOTE } from '../../core/readiness.js'; import { dataQuery, metadataRead, toolingQuery } from '../../core/toolingQuery.js'; import type { ReadinessResult } from '../../core/types.js'; @@ -32,7 +32,7 @@ export default class FlowcovReadiness extends SfCommand { }), threshold: Flags.integer({ summary: messages.getMessage('flags.threshold.summary'), - default: DEFAULT_THRESHOLD, + description: messages.getMessage('flags.threshold.description'), min: 0, max: 100, }), @@ -74,9 +74,7 @@ export default class FlowcovReadiness extends SfCommand { } private logReport(result: ReadinessResult): void { - this.log( - `Flow coverage: ${result.coveragePercent}% (${result.coveredFlows} of ${result.totalFlows} active Flows and processes have a test). Threshold: ${result.threshold}%.`, - ); + for (const line of coverageLines(result)) this.log(line); if (result.ready) { this.logSuccess('Ready: the org meets the coverage needed to deploy Flows as active.'); } else { @@ -118,6 +116,7 @@ export default class FlowcovReadiness extends SfCommand { Tests: [...new Set(f.tests.map((t) => `${t.className}.${t.methodName}`))].join(', '), })), }); + this.log(ELEMENT_COVERAGE_NOTE); } if (result.processBuilderProcesses > 0) { diff --git a/src/core/markdown.ts b/src/core/markdown.ts index 18fb8c4..061d299 100644 --- a/src/core/markdown.ts +++ b/src/core/markdown.ts @@ -1,6 +1,7 @@ import { describeElements } from './elementCoverage.js'; import { deployAsActiveAdvice } from './flowSettings.js'; import { isProcessBuilder, PROCESS_BUILDER_ADVICE, processTypeLabel } from './flowTypes.js'; +import { coverageLines, ELEMENT_COVERAGE_NOTE } from './readiness.js'; import type { FlowTestRef, GateResult, ReadinessResult } from './types.js'; /** Output formats the `readiness` and `gate` commands print. */ @@ -47,12 +48,7 @@ export function readinessMarkdown(result: ReadinessResult): string { const status = result.ready ? '**Ready**: the org meets the coverage needed to deploy Flows as active.' : `**Not ready**: add Apex tests for ${result.flowsNeeded} more Flow(s) to reach ${result.threshold}%.`; - lines.push( - status, - '', - `Flow coverage: **${result.coveragePercent}%** (${result.coveredFlows} of ${result.totalFlows} active Flows and processes have a test). Threshold: ${result.threshold}%.`, - '', - ); + lines.push(status, '', ...coverageLines(result, (text) => `**${text}**`).flatMap((line) => [line, ''])); const warnings = [...result.warnings]; if (result.deployAsActive !== undefined) { @@ -114,6 +110,7 @@ export function readinessMarkdown(result: ReadinessResult): string { ]), ), '', + ELEMENT_COVERAGE_NOTE, ); } return `${lines.join('\n').trimEnd()}\n`; diff --git a/src/core/orgCoverageSource.ts b/src/core/orgCoverageSource.ts index 08524c7..4746112 100644 --- a/src/core/orgCoverageSource.ts +++ b/src/core/orgCoverageSource.ts @@ -1,5 +1,5 @@ import { type FlowFingerprint, fingerprintFromMetadata } from './flowFingerprint.js'; -import { COUNTED_PROCESS_TYPES, qualifiedFlowName, splitFlowName } from './flowTypes.js'; +import { COUNTED_PROCESS_TYPES, isCountedProcessType, qualifiedFlowName, splitFlowName } from './flowTypes.js'; import type { CoverageSource, FlowCoverage, FlowTestRef, ToolingQuery } from './types.js'; type FlowRecord = { @@ -116,6 +116,28 @@ export class OrgCoverageSource implements CoverageSource { } } + public async countCoveredInactiveVersions(): Promise { + try { + const rows = await this.query<{ FlowVersionId?: string }>('SELECT FlowVersionId FROM FlowTestCoverage'); + const ids = [...new Set(rows.flatMap((r) => (r.FlowVersionId ? [r.FlowVersionId] : [])))]; + const versions = await this.queryInChunks<{ + Id: string; + Status?: string; + ProcessType?: string; + Definition?: { LatestVersionId?: string | null } | null; + }>(ids, (list) => `SELECT Id, Status, ProcessType, Definition.LatestVersionId FROM Flow WHERE Id IN (${list})`); + return versions.filter( + (v) => + v.Status !== 'Active' && + isCountedProcessType(v.ProcessType) && + v.Definition?.LatestVersionId && + idKey(v.Definition.LatestVersionId) === idKey(v.Id), + ).length; + } catch { + return undefined; + } + } + public getFlowFingerprint(flowVersionId: string): Promise { // The gate's content check and its uncovered-element list both ask for the same versions. const key = idKey(flowVersionId); diff --git a/src/core/readiness.ts b/src/core/readiness.ts index ff738d7..15f9044 100644 --- a/src/core/readiness.ts +++ b/src/core/readiness.ts @@ -15,12 +15,42 @@ export type ReadinessOptions = { dataQuery?: DataQuery; }; +/** Said under the covered Flows, since their element coverage reads like part of the requirement. */ +export const ELEMENT_COVERAGE_NOTE = + "Element coverage shows how much of each Flow the tests run. It doesn't count toward the threshold: a Flow counts once any test runs it."; + +/** + * The report's coverage lines: the headline the requirement goes by, then any details. `strong` + * marks the percentage (bold in Markdown). + */ +export function coverageLines(result: ReadinessResult, strong = (text: string): string => text): string[] { + const threshold = `Threshold: ${result.threshold}%.`; + const lines = + result.coveredInactiveVersions === 0 + ? [ + `Flow coverage: ${strong(`${result.coveragePercent}%`)} (${result.coveredFlows} of ${result.totalFlows} active Flows and processes have a test). ${threshold}`, + ] + : [ + `Flow coverage: ${strong(`${result.salesforceCoveragePercent}%`)} as Salesforce calculates it (${result.coveredFlows + result.coveredInactiveVersions} of ${result.totalFlows + result.coveredInactiveVersions} Flows: ${result.coveredFlows} active and ${result.coveredInactiveVersions} inactive with a test, ${result.uncoveredFlows} active without one). ${threshold}`, + `Active Flows with a test: ${result.coveragePercent}% (${result.coveredFlows} of ${result.totalFlows}). Salesforce also counts the latest inactive versions that have a test.`, + ]; + if (result.thresholdAssumed) { + lines.push( + `${result.threshold}% is the usual requirement. Production's Process Automation Settings set the actual percentage: pass --threshold if it differs.`, + ); + } + return lines; +} + /** - * Measures the org against the deploy-as-active coverage requirement: the share of - * active autolaunched Flows and processes that at least one Apex test runs. + * Measures the org against the deploy-as-active coverage requirement the way Salesforce + * calculates it: the Flow versions an Apex test covers (active ones, and latest inactive ones), + * divided by the active versions without coverage plus the versions with coverage. A Flow counts + * once any test runs it; how many of its elements run doesn't matter. */ export async function buildReadinessReport(options: ReadinessOptions): Promise { const threshold = options.threshold ?? DEFAULT_THRESHOLD; + const coveredInactiveVersions = (await options.source.countCoveredInactiveVersions?.()) ?? 0; const coverage = await options.source.listActiveCountedFlows(); const flows: ReadinessFlow[] = []; @@ -50,15 +80,23 @@ export async function buildReadinessReport(options: ReadinessOptions): Promise f.covered).length; // With no active Flows to cover, Salesforce has nothing to block. const coveragePercent = totalFlows === 0 ? 100 : Math.round((coveredFlows / totalFlows) * 1000) / 10; - const flowsNeeded = Math.max(0, Math.ceil((threshold * totalFlows) / 100) - coveredFlows); + // Covering an active Flow moves it from the uncovered part of the denominator to the covered + // part, so the denominator stays the same. + const covered = coveredFlows + coveredInactiveVersions; + const counted = totalFlows + coveredInactiveVersions; + const salesforceCoveragePercent = counted === 0 ? 100 : Math.round((covered / counted) * 1000) / 10; + const flowsNeeded = Math.max(0, Math.ceil((threshold * counted) / 100) - covered); const warning = await missingCoverageWarning(options.source, totalFlows > 0 && coveredFlows === 0); return { threshold, + thresholdAssumed: options.threshold === undefined, totalFlows, coveredFlows, uncoveredFlows: totalFlows - coveredFlows, coveragePercent, + salesforceCoveragePercent, + coveredInactiveVersions, ready: flowsNeeded === 0, flowsNeeded, processBuilderProcesses: flows.filter((f) => isProcessBuilder(f.processType)).length, diff --git a/src/core/types.ts b/src/core/types.ts index 9b60b45..466e3e1 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -71,6 +71,12 @@ export type CoverageSource = { * Apex tests ran without code coverage on. */ hasAnyFlowCoverage?(): Promise; + /** + * How many Flows count toward the requirement although no version of them is active: the latest + * version is inactive and a test covers it. Salesforce counts these as covered. Undefined when + * the source can't tell. + */ + countCoveredInactiveVersions?(): Promise; }; /** Runs a Tooling API SOQL query and returns every record (all pages). */ @@ -132,10 +138,23 @@ export type ReadinessFlow = { export type ReadinessResult = { threshold: number; + /** True when no threshold was given, so the usual 75% was used. Production can set another. */ + thresholdAssumed: boolean; + /** Active counted Flows. */ totalFlows: number; + /** Active counted Flows a test runs. */ coveredFlows: number; uncoveredFlows: number; + /** Active Flows with a test, 0-100. */ coveragePercent: number; + /** + * Coverage as Salesforce calculates it, 0-100: versions with coverage (active ones, and latest + * inactive ones) divided by active versions without coverage plus versions with coverage. + * `ready` and `flowsNeeded` go by this. Equals `coveragePercent` when no inactive version has coverage. + */ + salesforceCoveragePercent: number; + /** Latest inactive versions with coverage, which Salesforce counts as covered. */ + coveredInactiveVersions: number; ready: boolean; /** Additional Flows that need a test to reach the threshold. */ flowsNeeded: number; diff --git a/test/core/markdown.test.ts b/test/core/markdown.test.ts index ab71fc2..cc075cb 100644 --- a/test/core/markdown.test.ts +++ b/test/core/markdown.test.ts @@ -1,14 +1,18 @@ import { describe, expect, it } from 'vitest'; import { gateMarkdown, readinessMarkdown } from '../../src/core/markdown.js'; +import { ELEMENT_COVERAGE_NOTE } from '../../src/core/readiness.js'; import type { GateResult, ReadinessResult } from '../../src/core/types.js'; const readiness = (overrides: Partial = {}): ReadinessResult => ({ threshold: 75, + thresholdAssumed: false, totalFlows: 2, coveredFlows: 1, uncoveredFlows: 1, coveragePercent: 50, + salesforceCoveragePercent: 50, + coveredInactiveVersions: 0, ready: false, flowsNeeded: 1, processBuilderProcesses: 0, @@ -56,6 +60,8 @@ Flow coverage: **50%** (1 of 2 active Flows and processes have a test). Threshol | Flow | Element Coverage | Tests | | --- | --- | --- | | \`Account_Sync\` | 80% | \`Account_Test.syncs\` | + +${ELEMENT_COVERAGE_NOTE} `); }); diff --git a/test/core/orgCoverageSource.test.ts b/test/core/orgCoverageSource.test.ts index 43f75f5..7dee32b 100644 --- a/test/core/orgCoverageSource.test.ts +++ b/test/core/orgCoverageSource.test.ts @@ -292,3 +292,42 @@ describe('OrgCoverageSource.getFlowFingerprint', () => { ).toBeUndefined(); }); }); + +describe('OrgCoverageSource.countCoveredInactiveVersions', () => { + it('counts latest inactive versions of counted Flows that have coverage', async () => { + const C = '301000000000003AAA'; + const D = '301000000000004AAA'; + const E = '301000000000005AAA'; + const { query, calls } = fakeQuery({ + FlowTestCoverage: [ + { FlowVersionId: A }, + { FlowVersionId: A }, + { FlowVersionId: B }, + { FlowVersionId: C }, + { FlowVersionId: D }, + { FlowVersionId: E }, + {}, + ], + Flow: [ + // Active: already counted as an active Flow. + { Id: A, Status: 'Active', ProcessType: 'AutoLaunchedFlow', Definition: { LatestVersionId: A } }, + // Latest and inactive: counts. + { Id: B, Status: 'Obsolete', ProcessType: 'AutoLaunchedFlow', Definition: { LatestVersionId: B.slice(0, 15) } }, + // Inactive, but a newer version exists. + { Id: C, Status: 'Obsolete', ProcessType: 'AutoLaunchedFlow', Definition: { LatestVersionId: D } }, + // Latest and inactive, but a screen Flow. + { Id: D, Status: 'Draft', ProcessType: 'Flow', Definition: { LatestVersionId: D } }, + // No definition. + { Id: E, Status: 'Draft', ProcessType: 'Workflow', Definition: null }, + ], + }); + expect(await new OrgCoverageSource(query).countCoveredInactiveVersions()).toBe(1); + expect(calls[0]).toBe('SELECT FlowVersionId FROM FlowTestCoverage'); + expect(calls[1]).toContain('SELECT Id, Status, ProcessType, Definition.LatestVersionId FROM Flow WHERE Id IN ('); + }); + + it("gives no count when it can't read coverage", async () => { + const failing = fakeQuery({ FlowTestCoverage: new Error('INSUFFICIENT_ACCESS') }); + expect(await new OrgCoverageSource(failing.query).countCoveredInactiveVersions()).toBeUndefined(); + }); +}); diff --git a/test/core/readiness.test.ts b/test/core/readiness.test.ts index 4d68047..2570274 100644 --- a/test/core/readiness.test.ts +++ b/test/core/readiness.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { buildReadinessReport } from '../../src/core/readiness.js'; +import { buildReadinessReport, coverageLines } from '../../src/core/readiness.js'; import { coverage, fakeSource } from '../helpers.js'; describe('buildReadinessReport', () => { @@ -77,3 +77,73 @@ describe('buildReadinessReport', () => { }); }); }); + +describe('buildReadinessReport and Salesforce coverage', () => { + it('counts latest inactive versions with coverage the way Salesforce does', async () => { + // The example in Salesforce's help: one active version without a test, five active versions + // with one, and five latest inactive versions with one, so 10 of 11. + const flows = [coverage('A', { covered: false }), ...['F', 'G', 'H', 'I', 'J'].map((name) => coverage(name))]; + const result = await buildReadinessReport({ + source: { ...fakeSource(flows), countCoveredInactiveVersions: async () => 5 }, + threshold: 95, + }); + expect(result).toMatchObject({ + coveragePercent: 83.3, + salesforceCoveragePercent: 90.9, + coveredInactiveVersions: 5, + thresholdAssumed: false, + ready: false, + // ceil(95% of 11) = 11, and 10 are covered. + flowsNeeded: 1, + }); + }); + + it('says when it assumed the threshold, and counts nothing extra when the source can not tell', async () => { + const result = await buildReadinessReport({ + source: { ...fakeSource([coverage('A')]), countCoveredInactiveVersions: async () => undefined }, + }); + expect(result).toMatchObject({ + threshold: 75, + thresholdAssumed: true, + coveredInactiveVersions: 0, + salesforceCoveragePercent: 100, + }); + }); +}); + +describe('coverageLines', () => { + const base = { + threshold: 75, + thresholdAssumed: false, + totalFlows: 6, + coveredFlows: 5, + uncoveredFlows: 1, + coveragePercent: 83.3, + salesforceCoveragePercent: 83.3, + coveredInactiveVersions: 0, + ready: true, + flowsNeeded: 0, + processBuilderProcesses: 0, + warnings: [], + flows: [], + }; + + it('shows one line when no inactive version has coverage', () => { + expect(coverageLines(base)).toEqual([ + 'Flow coverage: 83.3% (5 of 6 active Flows and processes have a test). Threshold: 75%.', + ]); + }); + + it('shows how Salesforce counts inactive versions, and when the threshold was assumed', () => { + expect( + coverageLines( + { ...base, salesforceCoveragePercent: 90.9, coveredInactiveVersions: 5, thresholdAssumed: true }, + (t) => `*${t}*`, + ), + ).toEqual([ + 'Flow coverage: *90.9%* as Salesforce calculates it (10 of 11 Flows: 5 active and 5 inactive with a test, 1 active without one). Threshold: 75%.', + 'Active Flows with a test: 83.3% (5 of 6). Salesforce also counts the latest inactive versions that have a test.', + "75% is the usual requirement. Production's Process Automation Settings set the actual percentage: pass --threshold if it differs.", + ]); + }); +});