sf-flow-coverage 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +142 -17
  3. package/lib/commands/flowcov/gate.d.ts +1 -0
  4. package/lib/commands/flowcov/gate.js +15 -2
  5. package/lib/commands/flowcov/gate.js.map +1 -1
  6. package/lib/commands/flowcov/readiness.js +25 -3
  7. package/lib/commands/flowcov/readiness.js.map +1 -1
  8. package/lib/commands/flowcov/transform.d.ts +15 -0
  9. package/lib/commands/flowcov/transform.js +78 -0
  10. package/lib/commands/flowcov/transform.js.map +1 -0
  11. package/lib/core/apexTemplate.d.ts +16 -1
  12. package/lib/core/apexTemplate.js +462 -104
  13. package/lib/core/apexTemplate.js.map +1 -1
  14. package/lib/core/conditions.d.ts +107 -0
  15. package/lib/core/conditions.js +481 -0
  16. package/lib/core/conditions.js.map +1 -0
  17. package/lib/core/coverageCheck.d.ts +8 -0
  18. package/lib/core/coverageCheck.js +12 -0
  19. package/lib/core/coverageCheck.js.map +1 -0
  20. package/lib/core/coverageFormats.d.ts +7 -0
  21. package/lib/core/coverageFormats.js +77 -0
  22. package/lib/core/coverageFormats.js.map +1 -0
  23. package/lib/core/criteria.d.ts +40 -0
  24. package/lib/core/criteria.js +262 -0
  25. package/lib/core/criteria.js.map +1 -0
  26. package/lib/core/elementCoverage.d.ts +9 -0
  27. package/lib/core/elementCoverage.js +27 -0
  28. package/lib/core/elementCoverage.js.map +1 -0
  29. package/lib/core/flowElementLines.d.ts +13 -0
  30. package/lib/core/flowElementLines.js +44 -0
  31. package/lib/core/flowElementLines.js.map +1 -0
  32. package/lib/core/flowFingerprint.d.ts +37 -0
  33. package/lib/core/flowFingerprint.js +142 -0
  34. package/lib/core/flowFingerprint.js.map +1 -0
  35. package/lib/core/flowGraph.d.ts +144 -0
  36. package/lib/core/flowGraph.js +279 -0
  37. package/lib/core/flowGraph.js.map +1 -0
  38. package/lib/core/flowSettings.d.ts +16 -0
  39. package/lib/core/flowSettings.js +49 -0
  40. package/lib/core/flowSettings.js.map +1 -0
  41. package/lib/core/flowTypes.d.ts +6 -0
  42. package/lib/core/flowTypes.js +17 -0
  43. package/lib/core/flowTypes.js.map +1 -1
  44. package/lib/core/flowValues.d.ts +14 -0
  45. package/lib/core/flowValues.js +43 -0
  46. package/lib/core/flowValues.js.map +1 -0
  47. package/lib/core/flowXml.d.ts +1 -1
  48. package/lib/core/flowXml.js +6 -39
  49. package/lib/core/flowXml.js.map +1 -1
  50. package/lib/core/formula.d.ts +48 -0
  51. package/lib/core/formula.js +227 -0
  52. package/lib/core/formula.js.map +1 -0
  53. package/lib/core/gate.d.ts +10 -1
  54. package/lib/core/gate.js +64 -7
  55. package/lib/core/gate.js.map +1 -1
  56. package/lib/core/orgCoverageSource.d.ts +9 -0
  57. package/lib/core/orgCoverageSource.js +68 -12
  58. package/lib/core/orgCoverageSource.js.map +1 -1
  59. package/lib/core/readiness.d.ts +5 -0
  60. package/lib/core/readiness.js +24 -10
  61. package/lib/core/readiness.js.map +1 -1
  62. package/lib/core/requiredFields.d.ts +53 -3
  63. package/lib/core/requiredFields.js +158 -10
  64. package/lib/core/requiredFields.js.map +1 -1
  65. package/lib/core/scaffold.js +50 -4
  66. package/lib/core/scaffold.js.map +1 -1
  67. package/lib/core/toolingQuery.d.ts +5 -0
  68. package/lib/core/toolingQuery.js +9 -1
  69. package/lib/core/toolingQuery.js.map +1 -1
  70. package/lib/core/transform.d.ts +36 -0
  71. package/lib/core/transform.js +62 -0
  72. package/lib/core/transform.js.map +1 -0
  73. package/lib/core/types.d.ts +79 -1
  74. package/lib/index.d.ts +6 -1
  75. package/lib/index.js +3 -1
  76. package/lib/index.js.map +1 -1
  77. package/messages/flowcov.gate.md +19 -1
  78. package/messages/flowcov.readiness.md +4 -2
  79. package/messages/flowcov.scaffold.md +5 -1
  80. package/messages/flowcov.transform.md +33 -0
  81. package/oclif.manifest.json +113 -4
  82. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/mcarvin8/sf-flow-coverage/compare/v0.3.0...v0.4.0) (2026-11-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * list the Flow elements no test runs ([#14](https://github.com/mcarvin8/sf-flow-coverage/issues/14)) ([83fc31e](https://github.com/mcarvin8/sf-flow-coverage/commit/83fc31e48735ed4caebc60d992259adc0bd34eaf))
9
+ * point Process Builder processes toward migration ([#17](https://github.com/mcarvin8/sf-flow-coverage/issues/17)) ([7fab878](https://github.com/mcarvin8/sf-flow-coverage/commit/7fab8789d040de2bcb2aa2db23cee2d4390e5ee9))
10
+ * **readiness:** report the deploy-as-active setting ([#19](https://github.com/mcarvin8/sf-flow-coverage/issues/19)) ([998079e](https://github.com/mcarvin8/sf-flow-coverage/commit/998079e8cec269c50990804c64d8c1efef5facfd))
11
+ * **scaffold:** one condition engine for criteria, parents, and assertions ([#20](https://github.com/mcarvin8/sf-flow-coverage/issues/20)) ([20aa739](https://github.com/mcarvin8/sf-flow-coverage/commit/20aa739984ae13346a107e1c05b0c1c0cddc3ee7))
12
+ * **transform:** write Flow coverage as SonarQube, Cobertura, and lcov ([#16](https://github.com/mcarvin8/sf-flow-coverage/issues/16)) ([a7537fa](https://github.com/mcarvin8/sf-flow-coverage/commit/a7537fa979068a8079b42c57d665ed12f0c06eda))
13
+ * warn when the org has no Flow coverage at all ([#18](https://github.com/mcarvin8/sf-flow-coverage/issues/18)) ([ae438cc](https://github.com/mcarvin8/sf-flow-coverage/commit/ae438cce382bd1200505c06e21adc4dfcc4f94ae))
14
+
15
+ ## [0.3.0](https://github.com/mcarvin8/sf-flow-coverage/compare/v0.2.0...v0.3.0) (2026-11-20)
16
+
17
+
18
+ ### Features
19
+
20
+ * **gate:** compare changed Flows with the org version via --content-check ([#9](https://github.com/mcarvin8/sf-flow-coverage/issues/9)) ([841c417](https://github.com/mcarvin8/sf-flow-coverage/commit/841c4170e361a0669727b851823ecfe4d00b9a0d))
21
+ * **gate:** fail Flows whose org version was likely deployed inactive ([#7](https://github.com/mcarvin8/sf-flow-coverage/issues/7)) ([5564801](https://github.com/mcarvin8/sf-flow-coverage/commit/55648016d9be109bdc853ef300d70d6c33bb117e))
22
+ * **scaffold:** assert what record-triggered Flows do ([#13](https://github.com/mcarvin8/sf-flow-coverage/issues/13)) ([9ef29b5](https://github.com/mcarvin8/sf-flow-coverage/commit/9ef29b5245b6f25d660005231b3e94907c32a2ed))
23
+ * **scaffold:** insert parent records for required and criteria lookups ([#12](https://github.com/mcarvin8/sf-flow-coverage/issues/12)) ([cc57296](https://github.com/mcarvin8/sf-flow-coverage/commit/cc57296d58439531b5f2f2963e2da02ddc158484))
24
+ * **scaffold:** meet comparison, string, and IsChanged entry criteria ([#10](https://github.com/mcarvin8/sf-flow-coverage/issues/10)) ([5451dbb](https://github.com/mcarvin8/sf-flow-coverage/commit/5451dbb66921d59ad00812ed18c060dfeb1c992e))
25
+ * **scaffold:** meet simple entry-criteria formulas ([#11](https://github.com/mcarvin8/sf-flow-coverage/issues/11)) ([1a5b8e4](https://github.com/mcarvin8/sf-flow-coverage/commit/1a5b8e4257462e51092077d9746dcc6ad3af1e9d))
26
+
3
27
  ## [0.2.0](https://github.com/mcarvin8/sf-flow-coverage/compare/v0.1.0...v0.2.0) (2026-11-20)
4
28
 
5
29
 
package/README.md CHANGED
@@ -4,10 +4,11 @@
4
4
  [![Downloads/week](https://img.shields.io/npm/dw/sf-flow-coverage.svg)](https://npmjs.org/package/sf-flow-coverage)
5
5
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/mcarvin8/sf-flow-coverage/refs/heads/main/LICENSE.md)
6
6
  [![codecov](https://codecov.io/gh/mcarvin8/sf-flow-coverage/graph/badge.svg?token=7R49P3RQ47)](https://codecov.io/gh/mcarvin8/sf-flow-coverage)
7
+ [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fmcarvin8%2Fsf-flow-coverage%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/mcarvin8/sf-flow-coverage/main)
7
8
 
8
9
  Get your Salesforce org ready to deploy Flows as active.
9
10
 
10
- Most production orgs deploy Flows as inactive and activate them by hand, because turning on **Deploy processes and flows as active** requires 75% Apex test coverage across every active autolaunched Flow and process, and few teams know how far they are from that bar. `sf-flow-coverage` shows you the gap and helps you close it: it reports your org-wide Flow coverage and which active Flows have none, generates starter Apex tests for uncovered Flows, and adds a per-Flow coverage gate to pull requests so you stay above the threshold once the setting is on. Salesforce only checks that the org-wide total stays above 75%, so a single Flow with no tests can still go live.
11
+ Most production orgs deploy Flows as inactive and activate them by hand, because turning on **Deploy processes and flows as active** requires 75% Apex test coverage across every active autolaunched Flow and process, and few teams know how far they are from that bar. `sf-flow-coverage` shows you the gap and helps you close it: it reports your org-wide Flow coverage and which active Flows have none, generates starter Apex tests for uncovered Flows, adds a per-Flow coverage gate to pull requests so you stay above the threshold once the setting is on, and exports Flow coverage to SonarQube, Cobertura, and lcov so it shows up next to your Apex coverage. Salesforce only checks that the org-wide total stays above 75%, so a single Flow with no tests can still go live.
11
12
 
12
13
  <!-- TABLE OF CONTENTS -->
13
14
  <details>
@@ -20,6 +21,7 @@ Most production orgs deploy Flows as inactive and activate them by hand, because
20
21
  - [Readiness report](#readiness-report)
21
22
  - [Pull request gate](#pull-request-gate)
22
23
  - [Test scaffolding](#test-scaffolding)
24
+ - [Coverage reports](#coverage-reports)
23
25
  - [CLI Command Reference](#cli-command-reference)
24
26
  - [Programmatic API](#programmatic-api)
25
27
  - [Issues](#issues)
@@ -32,7 +34,7 @@ Most production orgs deploy Flows as inactive and activate them by hand, because
32
34
 
33
35
  - [Salesforce CLI](https://developer.salesforce.com/tools/salesforcecli)
34
36
  - Node.js 22.22 or later
35
- - An authenticated Salesforce org for `readiness` and `gate`. `scaffold` works without one, but with one it fills in required fields from the org.
37
+ - An authenticated Salesforce org for `readiness`, `gate`, and `transform`. `scaffold` works without one, but with one it fills in required fields from the org.
36
38
  - No `git` binary. Git history is read with [tsgit](https://github.com/scolladon/tsgit), a pure TypeScript git implementation. `gate --from` and the change counts in `readiness` still need to run inside a git repository checkout.
37
39
 
38
40
  ## Install
@@ -55,18 +57,23 @@ sf flowcov scaffold --uncovered --target-org prod
55
57
 
56
58
  # 4. In CI, after deploying the branch and running tests, require coverage for each changed Flow
57
59
  sf flowcov gate --target-org ci-sandbox --from origin/main --to HEAD
60
+
61
+ # 5. Publish Flow coverage to SonarQube next to your Apex coverage
62
+ sf flowcov transform --target-org ci-sandbox --format sonar
58
63
  ```
59
64
 
60
65
  ## How coverage is measured
61
66
 
62
67
  - **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.
63
- - **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. All three commands read it, so run your Apex tests before using them.
64
- - **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.
68
+ - **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.
69
+ - **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%.
65
70
  - **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.
66
71
 
67
72
  ## Readiness report
68
73
 
69
- `sf flowcov readiness` reports the org-wide percentage against the threshold and how many more Flows need a test to reach it. Uncovered Flows are ranked by how often their source file changed in git (run it from your Salesforce DX repo, or pass `--project-dir`), so the Flows most likely to be deployed next are at the top. Covered Flows list the Apex test methods that run them and their element coverage.
74
+ `sf flowcov readiness` reports the org-wide percentage against the threshold and how many more Flows need a test to reach it. Uncovered Flows are ranked by how often their source file changed in git (run it from your Salesforce DX repo, or pass `--project-dir`), so the Flows most likely to be deployed next are at the top. Covered Flows list the Apex test methods that run them, their element coverage, and the elements no test runs yet. Process Builder processes are labeled, with a suggestion to migrate them to Flows (Salesforce no longer supports Process Builder) rather than write tests for them.
75
+
76
+ It also reads whether **Deploy processes and flows as active** is already on and says what to do: turn it on once production is ready, or keep coverage up so deployments of active Flows keep working. The setting only affects production, so in a sandbox or scratch org the report points you to production instead.
70
77
 
71
78
  Pass `--fail-if-not-ready` to exit with code 1 below the threshold.
72
79
 
@@ -80,7 +87,7 @@ Coverage is read from the target org, so in CI:
80
87
  2. Run Apex tests there with `sf apex run test --code-coverage`.
81
88
  3. Run the gate against that org.
82
89
 
83
- The gate checks the Flow's active version in the org (or its latest version if none is active), and prints that version in the result.
90
+ The gate checks the Flow's active version in the org (or its latest version if none is active), and prints that version in the result. It fails a Flow when the org has no active version of it, or a newer inactive one: both usually mean the branch was deployed inactive. With `--from`, it also compares each changed Flow with the org's version and warns (or, with `--content-check fail`, fails) when the branch wasn't deployed. A Flow that fails `--min-element-coverage` names the elements no test runs.
84
91
 
85
92
  ## Test scaffolding
86
93
 
@@ -88,15 +95,33 @@ The gate checks the Flow's active version in the org (or its latest version if n
88
95
 
89
96
  | Flow type | Generated test |
90
97
  | --- | --- |
91
- | Record-triggered (create, update, delete) | Builds a record of the trigger object, sets entry criteria that are simple `EqualTo` filters, and inserts, updates, or deletes it. Create-and-update Flows get one test method for each. |
92
- | Autolaunched (no trigger) | Starts the Flow with `Flow.Interview.createInterview`, with a placeholder for every input variable and a read of every output variable. |
98
+ | Record-triggered (create, update, delete) | Builds a record of the trigger object that meets the entry criteria, inserts, updates, or deletes it, and asserts what the Flow does (see below). Create-and-update Flows get one test method for each. |
99
+ | Autolaunched (no trigger) | Starts the Flow with `Flow.Interview.createInterview`, with a placeholder for every input variable, and asserts the output variables it is certain to set. |
93
100
  | Platform event | Publishes the event and delivers it with `Test.getEventBus().deliver()`. |
94
101
  | Schedule-triggered | Starts the Flow directly, since Apex tests can't fire the schedule. |
95
102
  | Process Builder | A placeholder test to fill in. |
96
103
 
97
- With a target org (`--target-org` or your default org), the command describes each object the test creates and fills in its required fields: text, numbers, dates, and the default picklist value. It also meets "is not null" entry criteria (`IsNull` `false`) by giving those fields a value. Lookups it can't make up are left as TODOs. Without an org, only common standard objects (Account, Contact, Opportunity, and so on) get required fields.
104
+ Entry criteria are read as one condition, whether they are filters (with AND, OR, or custom logic such as `1 OR (2 AND 3)`) or a formula. The command meets one branch of an `OR` or `IF`, and handles every filter operator, comparisons with literals, other fields, `$User.Id`, and `TODAY()`/`NOW()`/`DATE()`, `$Record__Prior` and `PRIORVALUE` in update tests, and fields on related records such as `{!$Record.Account__r.Type}`, which it sets on the parent record it inserts.
105
+
106
+ With a target org (`--target-org` or your default org), the command describes each object the test creates and fills in its required fields: text, numbers, dates, and the default picklist value. It meets "is not null" criteria by giving those fields a value, and fills required lookups with a parent record it inserts, up to three levels of parents deep (or the running user, the standard price book, the default business hours, or one of the object's record types). Without an org, only common standard objects (Account, Contact, Opportunity, and so on) get required fields.
107
+
108
+ For record-triggered Flows, the command follows the Flow's elements for the record the test creates, deciding each decision the record settles. That includes formula resources, checkbox defaults, picklist defaults on objects without record types, and lookups on data the test doesn't create, which find nothing in an Apex test. It asserts the fields the Flow is certain to set and the records it is certain to create. When the Flow is certain to block the save with a custom error, the test expects that error, and a second test sets the fields that avoid it. What the Flow does only on a decision outcome it can't predict gets commented-out assertions.
109
+
110
+ Every generated test has TODOs for anything it couldn't fill in, such as entry criteria it couldn't meet and assertions it couldn't work out. Expect some generated tests to fail until you fill these in: a failure from the Flow's own validation still shows the Flow ran. Existing classes aren't overwritten unless you pass `--force`.
111
+
112
+ ## Coverage reports
98
113
 
99
- Every generated test has TODOs for anything it couldn't fill in, entry criteria it couldn't set (formulas, cross-object fields, other operators), and real assertions. Expect some generated tests to fail until you fill these in: a failure from the Flow's own validation still shows the Flow ran. Existing classes aren't overwritten unless you pass `--force`.
114
+ `sf flowcov transform` writes the org's Flow coverage as files other coverage tools read, so Flow coverage shows up next to Apex coverage in SonarQube, GitLab, Azure DevOps, or Codecov:
115
+
116
+ | `--format` | File | Read by |
117
+ | --- | --- | --- |
118
+ | `sonar` | `flow-coverage-sonar.xml` | SonarQube `sonar.coverageReportPaths` |
119
+ | `cobertura` | `flow-coverage-cobertura.xml` | GitLab, Azure DevOps, Codecov |
120
+ | `lcov` | `flow-coverage.info` | Codecov, Coveralls, most lcov tools |
121
+
122
+ Each executable element of a Flow becomes one line: the line of its `<name>` in the `.flow-meta.xml` file, covered when any Apex test ran it. A Flow's line coverage therefore equals its element coverage. Paths are relative to `--project-dir`. For SonarQube, the Flow files must be indexed (for example, `sonar.inclusions=**/*.cls,**/*.trigger,**/*.flow-meta.xml`) for their coverage to be imported.
123
+
124
+ The command warns when a Flow file's elements don't match the version the org covered, since the line numbers would then point at the wrong elements.
100
125
 
101
126
  ## CLI Command Reference
102
127
 
@@ -104,6 +129,7 @@ Every generated test has TODOs for anything it couldn't fill in, entry criteria
104
129
  * [`sf flowcov gate`](#sf-flowcov-gate)
105
130
  * [`sf flowcov readiness`](#sf-flowcov-readiness)
106
131
  * [`sf flowcov scaffold`](#sf-flowcov-scaffold)
132
+ * [`sf flowcov transform`](#sf-flowcov-transform)
107
133
 
108
134
  ## `sf flowcov gate`
109
135
 
@@ -112,13 +138,16 @@ Require Apex test coverage for every Flow a pull request changes.
112
138
  ```
113
139
  USAGE
114
140
  $ sf flowcov gate -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--from <value> | --flow
115
- <value>...] [--to <value>] [-d <value>] [--min-element-coverage <value>]
141
+ <value>...] [--to <value>] [-d <value>] [--min-element-coverage <value>] [--content-check warn|fail|off]
116
142
 
117
143
  FLAGS
118
144
  -d, --project-dir=<value> [default: .] Git repository to read changed Flows from.
119
145
  -o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
120
146
  configuration variable is already set.
121
147
  --api-version=<value> Override the api version used for api requests made by this command
148
+ --content-check=<option> [default: warn] What to do when a changed Flow's content differs from the org's
149
+ version.
150
+ <options: warn|fail|off>
122
151
  --flow=<value>... Flow API name to check. Use instead of --from to skip git.
123
152
  --from=<value> Git ref the pull request merges into (the gate compares from the merge base of
124
153
  this ref).
@@ -138,7 +167,20 @@ DESCRIPTION
138
167
 
139
168
  Coverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there
140
169
  with `sf apex run test --code-coverage` before running the gate. Without `--code-coverage`, Salesforce records no Flow
141
- coverage. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.
170
+ coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without
171
+ `--code-coverage`. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.
172
+
173
+ The gate also fails a Flow when the org has no active version of it, or when its active version is older than its
174
+ latest version. Both usually mean the branch was deployed inactive, so the org's coverage doesn't belong to the
175
+ version in the pull request.
176
+
177
+ With --from, the gate also compares each changed Flow at --to with the org's version: process type, start trigger and
178
+ entry criteria, and the names of its elements and resources. A difference usually means the branch wasn't deployed to
179
+ the org. By default this is a warning; use --content-check to fail instead, or to skip the comparison. The comparison
180
+ doesn't look inside elements, so it can miss a change that only edits an existing element.
181
+
182
+ For a Flow that tests run only in part, the --json output lists the elements no test runs, and a Flow that fails
183
+ --min-element-coverage names them in its reason.
142
184
 
143
185
  Exits with code 1 when any Flow fails.
144
186
 
@@ -151,9 +193,19 @@ EXAMPLES
151
193
 
152
194
  $ sf flowcov gate --target-org ci-sandbox --from origin/main --min-element-coverage 60
153
195
 
196
+ Fail when the org runs a different version of a changed Flow than the branch:
197
+
198
+ $ sf flowcov gate --target-org ci-sandbox --from origin/main --content-check fail
199
+
154
200
  Check named Flows without git:
155
201
 
156
202
  $ sf flowcov gate --target-org ci-sandbox --flow Account_After_Save --flow Close_Cases
203
+
204
+ FLAG DESCRIPTIONS
205
+ --content-check=warn|fail|off What to do when a changed Flow's content differs from the org's version.
206
+
207
+ "warn" prints a warning, "fail" fails a Flow that would otherwise pass, and "off" skips the comparison (and its one
208
+ Tooling API query per Flow). Only applies with --from.
157
209
  ```
158
210
 
159
211
  _See code: [src/commands/flowcov/gate.ts](https://github.com/mcarvin8/sf-flow-coverage/blob/main/src/commands/flowcov/gate.ts)_
@@ -186,12 +238,19 @@ DESCRIPTION
186
238
 
187
239
  Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can
188
240
  turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the
189
- org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and
190
- the Apex tests that already run each covered Flow.
241
+ org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and,
242
+ for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one
243
+ Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to
244
+ migrate them to Flows, since Salesforce no longer supports Process Builder.
191
245
 
192
246
  FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for
193
247
  example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without
194
- `--code-coverage`, Salesforce records no Flow coverage.
248
+ `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command
249
+ warns that the tests most likely ran without `--code-coverage`.
250
+
251
+ The report also says whether "Deploy processes and flows as active" is already on, and what that means: turn it on
252
+ once the org is ready, or keep coverage up so deployments of active Flows keep working. The setting only affects
253
+ production; in a sandbox or scratch org the report says so.
195
254
 
196
255
  EXAMPLES
197
256
  Report readiness for the default org:
@@ -241,8 +300,19 @@ DESCRIPTION
241
300
  record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started
242
301
  with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is
243
302
  available (--target-org or a default org), the command describes each object the test creates and fills in its
244
- required fields and any fields the entry criteria require to be set (IsNull false). The generated tests have TODOs for
245
- anything it can't fill in and placeholder assertions.
303
+ required fields, the fields the entry criteria need, and parent records (and their parents) for required lookups.
304
+
305
+ Entry criteria are read as one condition, whether they are filters (with AND, OR, or custom logic) or a formula. The
306
+ command meets one branch of an OR, and handles comparisons with literals, other fields, `$User.Id`, and `TODAY()`;
307
+ `$Record__Prior` values in update tests; and fields on related records, which it sets on the parent record it inserts.
308
+
309
+ For record-triggered Flows, the command follows the Flow's elements for the record the test creates, deciding each
310
+ decision the record settles (including formula resources, and lookups on data the test doesn't create, which find
311
+ nothing in an Apex test). It asserts the fields the Flow is certain to set and the records it is certain to create.
312
+ When the Flow is certain to stop the save with a custom error, the test expects that error, and a second test sets the
313
+ fields that avoid it. For autolaunched Flows, it asserts output variables the Flow is certain to set. What the Flow
314
+ does only on a decision outcome the command can't predict gets commented-out assertions. The generated tests have
315
+ TODOs for anything the command can't fill in.
246
316
 
247
317
  Only Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.
248
318
 
@@ -261,6 +331,61 @@ EXAMPLES
261
331
  ```
262
332
 
263
333
  _See code: [src/commands/flowcov/scaffold.ts](https://github.com/mcarvin8/sf-flow-coverage/blob/main/src/commands/flowcov/scaffold.ts)_
334
+
335
+ ## `sf flowcov transform`
336
+
337
+ Write Flow element coverage as SonarQube, Cobertura, or lcov coverage reports.
338
+
339
+ ```
340
+ USAGE
341
+ $ sf flowcov transform -o <value> --format sonar|cobertura|lcov... [--json] [--flags-dir <value>] [--api-version
342
+ <value>] [--output-dir <value>] [-d <value>]
343
+
344
+ FLAGS
345
+ -d, --project-dir=<value> [default: .] Project root with the Flow metadata files. Report paths are relative to it.
346
+ -o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
347
+ configuration variable is already set.
348
+ --api-version=<value> Override the api version used for api requests made by this command
349
+ --format=<option>... (required) Coverage format to write: sonar (SonarQube generic coverage), cobertura, or
350
+ lcov.
351
+ <options: sonar|cobertura|lcov>
352
+ --output-dir=<value> [default: coverage] Folder to write the coverage reports to.
353
+
354
+ GLOBAL FLAGS
355
+ --flags-dir=<value> Import flag values from a directory.
356
+ --json Format output as json.
357
+
358
+ DESCRIPTION
359
+ Write Flow element coverage as SonarQube, Cobertura, or lcov coverage reports.
360
+
361
+ Reads Flow coverage from the target org and maps it onto the project's Flow metadata files, so Flow coverage shows up
362
+ next to Apex coverage in tools such as SonarQube, GitLab, Azure DevOps, or Codecov. Each executable element of a Flow
363
+ (every element except the start element and resources such as variables and formulas) becomes one line: the line of
364
+ its `<name>` in the `.flow-meta.xml` file, covered when any Apex test ran the element. A Flow's line coverage
365
+ therefore equals its element coverage.
366
+
367
+ Covers every active Flow and process that counts toward "Deploy processes and flows as active" and has a source file
368
+ in the project. Paths in the reports are relative to --project-dir; run the command from the root your coverage tool
369
+ expects. For SonarQube, the Flow files must be indexed (for example, include `**/*.flow-meta.xml` in
370
+ `sonar.inclusions`) for their coverage to be imported.
371
+
372
+ Coverage is read from FlowTestCoverage, which Salesforce fills in when Apex tests run in the org with coverage on (`sf
373
+ apex run test --code-coverage`). Without `--code-coverage`, and in check-only deployments, Salesforce records no Flow
374
+ coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without
375
+ `--code-coverage`. When a Flow file's elements don't match the version the org covered, the command warns that its
376
+ line coverage may be off.
377
+
378
+ EXAMPLES
379
+ Write a SonarQube generic coverage report to the coverage folder:
380
+
381
+ $ sf flowcov transform --target-org ci-sandbox --format sonar
382
+
383
+ Write Cobertura and lcov reports to a folder of your choice:
384
+
385
+ $ sf flowcov transform --target-org ci-sandbox --format cobertura --format lcov --output-dir reports
386
+ ```
387
+
388
+ _See code: [src/commands/flowcov/transform.ts](https://github.com/mcarvin8/sf-flow-coverage/blob/main/src/commands/flowcov/transform.ts)_
264
389
  <!-- commandsstop -->
265
390
 
266
391
  ## Programmatic API
@@ -12,6 +12,7 @@ export default class FlowcovGate extends SfCommand<GateResult> {
12
12
  flow: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
13
  'project-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
14
  'min-element-coverage': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'content-check': import("@oclif/core/interfaces").OptionFlag<"fail" | "off" | "warn", import("@oclif/core/interfaces").CustomOptions>;
15
16
  };
16
17
  run(): Promise<GateResult>;
17
18
  }
@@ -37,6 +37,12 @@ export default class FlowcovGate extends SfCommand {
37
37
  min: 0,
38
38
  max: 100,
39
39
  }),
40
+ 'content-check': Flags.option({
41
+ summary: messages.getMessage('flags.content-check.summary'),
42
+ description: messages.getMessage('flags.content-check.description'),
43
+ options: ['warn', 'fail', 'off'],
44
+ default: 'warn',
45
+ })(),
40
46
  };
41
47
  async run() {
42
48
  const { flags } = await this.parse(FlowcovGate);
@@ -52,13 +58,14 @@ export default class FlowcovGate extends SfCommand {
52
58
  }
53
59
  if (candidates.length === 0) {
54
60
  this.log('No Flows changed. Nothing to check.');
55
- return { passed: true, minElementCoverage: flags['min-element-coverage'], flows: [] };
61
+ return { passed: true, minElementCoverage: flags['min-element-coverage'], flows: [], warnings: [] };
56
62
  }
57
63
  const connection = flags['target-org'].getConnection(flags['api-version']);
58
64
  const result = await evaluateGate({
59
65
  source: new OrgCoverageSource(toolingQuery(connection)),
60
66
  candidates,
61
67
  minElementCoverage: flags['min-element-coverage'],
68
+ contentCheck: flags['content-check'],
62
69
  });
63
70
  this.table({
64
71
  data: result.flows.map((f) => ({
@@ -68,12 +75,18 @@ export default class FlowcovGate extends SfCommand {
68
75
  Reason: f.reason,
69
76
  })),
70
77
  });
78
+ for (const flow of result.flows) {
79
+ for (const warning of flow.warnings ?? [])
80
+ this.warn(`${flow.flowName}: ${warning}`);
81
+ }
82
+ for (const warning of result.warnings)
83
+ this.warn(warning);
71
84
  if (result.passed) {
72
85
  this.logSuccess(`Flow coverage gate passed for ${result.flows.length} Flow(s).`);
73
86
  }
74
87
  else {
75
88
  const failed = result.flows.filter((f) => f.status === 'fail').length;
76
- this.warn(`Flow coverage gate failed: ${failed} Flow(s) need Apex test coverage.`);
89
+ this.warn(`Flow coverage gate failed for ${failed} Flow(s). See the Reason column.`);
77
90
  process.exitCode = 1;
78
91
  }
79
92
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"gate.js","sourceRoot":"","sources":["../../../src/commands/flowcov/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAsB,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,QAAQ,CAAC,kCAAkC,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;AAE3E,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAqB;IACrD,MAAM,CAAmB,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,CAAmB,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1E,MAAM,CAAmB,QAAQ,GAAG,QAAQ,CAAC,WAAW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@salesforce/core';
2
2
  import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
3
- import { DEFAULT_THRESHOLD } from '../../core/flowTypes.js';
3
+ import { describeElements } from '../../core/elementCoverage.js';
4
+ import { deployAsActiveAdvice } from '../../core/flowSettings.js';
5
+ import { DEFAULT_THRESHOLD, isProcessBuilder, PROCESS_BUILDER_ADVICE, processTypeLabel } from '../../core/flowTypes.js';
4
6
  import { getFlowChurn } from '../../core/git.js';
5
7
  import { OrgCoverageSource } from '../../core/orgCoverageSource.js';
6
8
  import { buildReadinessReport } from '../../core/readiness.js';
7
- import { toolingQuery } from '../../core/toolingQuery.js';
9
+ import { dataQuery, metadataRead, toolingQuery } from '../../core/toolingQuery.js';
8
10
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
9
11
  const messages = Messages.loadMessages('sf-flow-coverage', 'flowcov.readiness');
10
12
  export default class FlowcovReadiness extends SfCommand {
@@ -41,10 +43,14 @@ export default class FlowcovReadiness extends SfCommand {
41
43
  const churn = await getFlowChurn(flags['project-dir'], flags.since);
42
44
  const result = await buildReadinessReport({
43
45
  source: new OrgCoverageSource(toolingQuery(connection)),
46
+ metadataRead: metadataRead(connection),
47
+ dataQuery: dataQuery(connection),
44
48
  churn,
45
49
  threshold: flags.threshold,
46
50
  });
47
51
  this.spinner.stop();
52
+ for (const warning of result.warnings)
53
+ this.warn(warning);
48
54
  this.logReport(result);
49
55
  if (flags['fail-if-not-ready'] && !result.ready)
50
56
  process.exitCode = 1;
@@ -58,6 +64,15 @@ export default class FlowcovReadiness extends SfCommand {
58
64
  else {
59
65
  this.warn(`Not ready: add Apex tests for ${result.flowsNeeded} more Flow(s) to reach ${result.threshold}%.`);
60
66
  }
67
+ if (result.deployAsActive !== undefined) {
68
+ const sandbox = result.isSandbox === true;
69
+ const advice = deployAsActiveAdvice(result.deployAsActive, result.ready, result.threshold, sandbox);
70
+ // On in production but below the threshold, deployments fail: that's worth a warning.
71
+ if (result.deployAsActive && !result.ready && !sandbox)
72
+ this.warn(advice);
73
+ else
74
+ this.log(advice);
75
+ }
61
76
  const showChanges = result.flows.some((f) => f.changes !== undefined);
62
77
  const uncovered = result.flows.filter((f) => !f.covered);
63
78
  if (uncovered.length > 0) {
@@ -65,23 +80,30 @@ export default class FlowcovReadiness extends SfCommand {
65
80
  title: 'Uncovered Flows',
66
81
  data: uncovered.map((f) => ({
67
82
  Flow: f.flowName,
68
- Type: f.processType,
83
+ Type: processTypeLabel(f.processType),
69
84
  Version: f.versionNumber ?? '',
70
85
  ...(showChanges ? { Changes: f.changes ?? 0 } : {}),
71
86
  })),
72
87
  });
73
88
  }
74
89
  const covered = result.flows.filter((f) => f.covered);
90
+ const showUncovered = covered.some((f) => (f.uncoveredElements?.length ?? 0) > 0);
91
+ const showType = covered.some((f) => isProcessBuilder(f.processType));
75
92
  if (covered.length > 0) {
76
93
  this.table({
77
94
  title: 'Covered Flows',
78
95
  data: covered.map((f) => ({
79
96
  Flow: f.flowName,
97
+ ...(showType ? { Type: processTypeLabel(f.processType) } : {}),
80
98
  'Element Coverage': `${f.elementCoveragePercent}%`,
99
+ ...(showUncovered ? { 'Uncovered Elements': describeElements(f.uncoveredElements ?? []) } : {}),
81
100
  Tests: [...new Set(f.tests.map((t) => `${t.className}.${t.methodName}`))].join(', '),
82
101
  })),
83
102
  });
84
103
  }
104
+ if (result.processBuilderProcesses > 0) {
105
+ this.warn(`${result.processBuilderProcesses} of the active Flows are Process Builder processes (Type "Process Builder"). ${PROCESS_BUILDER_ADVICE}`);
106
+ }
85
107
  }
86
108
  }
87
109
  //# sourceMappingURL=readiness.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readiness.js","sourceRoot":"","sources":["../../../src/commands/flowcov/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,M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QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import type { TransformResult } from '../../core/types.js';
3
+ export default class FlowcovTransform extends SfCommand<TransformResult> {
4
+ static readonly summary: string;
5
+ static readonly description: string;
6
+ static readonly examples: string[];
7
+ static readonly flags: {
8
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ format: import("@oclif/core/interfaces").OptionFlag<("cobertura" | "lcov" | "sonar")[], import("@oclif/core/interfaces").CustomOptions>;
11
+ 'output-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'project-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ };
14
+ run(): Promise<TransformResult>;
15
+ }
@@ -0,0 +1,78 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { Messages } from '@salesforce/core';
4
+ import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
5
+ import { COVERAGE_FILE_NAMES, COVERAGE_FORMATS, formatCoverage } from '../../core/coverageFormats.js';
6
+ import { OrgCoverageSource } from '../../core/orgCoverageSource.js';
7
+ import { toolingQuery } from '../../core/toolingQuery.js';
8
+ import { buildFlowFileCoverage } from '../../core/transform.js';
9
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
10
+ const messages = Messages.loadMessages('sf-flow-coverage', 'flowcov.transform');
11
+ export default class FlowcovTransform extends SfCommand {
12
+ static summary = messages.getMessage('summary');
13
+ static description = messages.getMessage('description');
14
+ static examples = messages.getMessages('examples');
15
+ static flags = {
16
+ 'target-org': Flags.requiredOrg(),
17
+ 'api-version': Flags.orgApiVersion(),
18
+ format: Flags.option({
19
+ summary: messages.getMessage('flags.format.summary'),
20
+ options: COVERAGE_FORMATS,
21
+ multiple: true,
22
+ required: true,
23
+ })(),
24
+ 'output-dir': Flags.directory({
25
+ summary: messages.getMessage('flags.output-dir.summary'),
26
+ default: 'coverage',
27
+ }),
28
+ 'project-dir': Flags.directory({
29
+ summary: messages.getMessage('flags.project-dir.summary'),
30
+ char: 'd',
31
+ default: '.',
32
+ exists: true,
33
+ }),
34
+ };
35
+ async run() {
36
+ const { flags } = await this.parse(FlowcovTransform);
37
+ const connection = flags['target-org'].getConnection(flags['api-version']);
38
+ this.spinner.start('Reading Flow coverage');
39
+ const report = await buildFlowFileCoverage({
40
+ source: new OrgCoverageSource(toolingQuery(connection)),
41
+ projectDir: flags['project-dir'],
42
+ });
43
+ this.spinner.stop();
44
+ await mkdir(flags['output-dir'], { recursive: true });
45
+ const files = [];
46
+ for (const format of [...new Set(flags.format)]) {
47
+ const path = join(flags['output-dir'], COVERAGE_FILE_NAMES[format]);
48
+ await writeFile(path, formatCoverage(format, report.files), 'utf8');
49
+ files.push({ format, path });
50
+ }
51
+ for (const warning of report.warnings)
52
+ this.warn(warning);
53
+ const flows = report.files.map((file) => ({
54
+ flowName: file.flowName,
55
+ path: file.path,
56
+ elementsCovered: file.lines.filter((l) => l.covered).length,
57
+ elementsTotal: file.lines.length,
58
+ }));
59
+ if (flows.length > 0) {
60
+ this.table({
61
+ data: flows.map((f) => ({
62
+ Flow: f.flowName,
63
+ File: f.path,
64
+ 'Elements Covered': `${f.elementsCovered} of ${f.elementsTotal}`,
65
+ })),
66
+ });
67
+ }
68
+ if (report.skipped.length > 0) {
69
+ this.log(`Skipped ${report.skipped.length} active Flow(s):`);
70
+ for (const skipped of report.skipped)
71
+ this.log(` ${skipped.flowName}: ${skipped.reason}`);
72
+ }
73
+ for (const file of files)
74
+ this.logSuccess(`Wrote ${file.format} coverage for ${flows.length} Flow(s) to ${file.path}.`);
75
+ return { files, flows, skipped: report.skipped, warnings: report.warnings };
76
+ }
77
+ }
78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