sf-flow-coverage 0.3.0 → 0.4.1

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 (77) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +117 -19
  3. package/lib/commands/flowcov/gate.js +3 -1
  4. package/lib/commands/flowcov/gate.js.map +1 -1
  5. package/lib/commands/flowcov/readiness.js +25 -3
  6. package/lib/commands/flowcov/readiness.js.map +1 -1
  7. package/lib/commands/flowcov/transform.d.ts +15 -0
  8. package/lib/commands/flowcov/transform.js +78 -0
  9. package/lib/commands/flowcov/transform.js.map +1 -0
  10. package/lib/core/apexTemplate.d.ts +15 -2
  11. package/lib/core/apexTemplate.js +311 -199
  12. package/lib/core/apexTemplate.js.map +1 -1
  13. package/lib/core/conditions.d.ts +107 -0
  14. package/lib/core/conditions.js +481 -0
  15. package/lib/core/conditions.js.map +1 -0
  16. package/lib/core/coverageCheck.d.ts +8 -0
  17. package/lib/core/coverageCheck.js +12 -0
  18. package/lib/core/coverageCheck.js.map +1 -0
  19. package/lib/core/coverageFormats.d.ts +7 -0
  20. package/lib/core/coverageFormats.js +77 -0
  21. package/lib/core/coverageFormats.js.map +1 -0
  22. package/lib/core/criteria.d.ts +46 -0
  23. package/lib/core/criteria.js +276 -0
  24. package/lib/core/criteria.js.map +1 -0
  25. package/lib/core/elementCoverage.d.ts +9 -0
  26. package/lib/core/elementCoverage.js +27 -0
  27. package/lib/core/elementCoverage.js.map +1 -0
  28. package/lib/core/flowElementLines.d.ts +13 -0
  29. package/lib/core/flowElementLines.js +44 -0
  30. package/lib/core/flowElementLines.js.map +1 -0
  31. package/lib/core/flowFingerprint.d.ts +10 -0
  32. package/lib/core/flowFingerprint.js +14 -0
  33. package/lib/core/flowFingerprint.js.map +1 -1
  34. package/lib/core/flowGraph.d.ts +63 -13
  35. package/lib/core/flowGraph.js +125 -134
  36. package/lib/core/flowGraph.js.map +1 -1
  37. package/lib/core/flowSettings.d.ts +16 -0
  38. package/lib/core/flowSettings.js +49 -0
  39. package/lib/core/flowSettings.js.map +1 -0
  40. package/lib/core/flowTypes.d.ts +6 -0
  41. package/lib/core/flowTypes.js +17 -0
  42. package/lib/core/flowTypes.js.map +1 -1
  43. package/lib/core/formula.d.ts +48 -0
  44. package/lib/core/formula.js +227 -0
  45. package/lib/core/formula.js.map +1 -0
  46. package/lib/core/gate.js +19 -1
  47. package/lib/core/gate.js.map +1 -1
  48. package/lib/core/orgCoverageSource.d.ts +3 -0
  49. package/lib/core/orgCoverageSource.js +26 -5
  50. package/lib/core/orgCoverageSource.js.map +1 -1
  51. package/lib/core/readiness.d.ts +5 -0
  52. package/lib/core/readiness.js +24 -10
  53. package/lib/core/readiness.js.map +1 -1
  54. package/lib/core/requiredFields.d.ts +35 -7
  55. package/lib/core/requiredFields.js +68 -19
  56. package/lib/core/requiredFields.js.map +1 -1
  57. package/lib/core/scaffold.js +30 -11
  58. package/lib/core/scaffold.js.map +1 -1
  59. package/lib/core/toolingQuery.d.ts +5 -0
  60. package/lib/core/toolingQuery.js +9 -1
  61. package/lib/core/toolingQuery.js.map +1 -1
  62. package/lib/core/transform.d.ts +36 -0
  63. package/lib/core/transform.js +62 -0
  64. package/lib/core/transform.js.map +1 -0
  65. package/lib/core/types.d.ts +52 -2
  66. package/lib/index.d.ts +6 -1
  67. package/lib/index.js +3 -1
  68. package/lib/index.js.map +1 -1
  69. package/messages/flowcov.gate.md +3 -1
  70. package/messages/flowcov.readiness.md +4 -2
  71. package/messages/flowcov.scaffold.md +4 -2
  72. package/messages/flowcov.transform.md +33 -0
  73. package/oclif.manifest.json +98 -4
  74. package/package.json +1 -1
  75. package/lib/core/filterFormula.d.ts +0 -10
  76. package/lib/core/filterFormula.js +0 -153
  77. package/lib/core/filterFormula.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.1](https://github.com/mcarvin8/sf-flow-coverage/compare/v0.4.0...v0.4.1) (2026-11-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **scaffold:** never assign fields a test can't write ([#21](https://github.com/mcarvin8/sf-flow-coverage/issues/21)) ([1cb7087](https://github.com/mcarvin8/sf-flow-coverage/commit/1cb70876381e0f513856b12b0085489468a1dbf2))
9
+
10
+ ## [0.4.0](https://github.com/mcarvin8/sf-flow-coverage/compare/v0.3.0...v0.4.0) (2026-11-20)
11
+
12
+
13
+ ### Features
14
+
15
+ * 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))
16
+ * 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))
17
+ * **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))
18
+ * **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))
19
+ * **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))
20
+ * 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))
21
+
3
22
  ## [0.3.0](https://github.com/mcarvin8/sf-flow-coverage/compare/v0.2.0...v0.3.0) (2026-11-20)
4
23
 
5
24
 
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  Get your Salesforce org ready to deploy Flows as active.
10
10
 
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, 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.
12
12
 
13
13
  <!-- TABLE OF CONTENTS -->
14
14
  <details>
@@ -21,6 +21,7 @@ Most production orgs deploy Flows as inactive and activate them by hand, because
21
21
  - [Readiness report](#readiness-report)
22
22
  - [Pull request gate](#pull-request-gate)
23
23
  - [Test scaffolding](#test-scaffolding)
24
+ - [Coverage reports](#coverage-reports)
24
25
  - [CLI Command Reference](#cli-command-reference)
25
26
  - [Programmatic API](#programmatic-api)
26
27
  - [Issues](#issues)
@@ -33,7 +34,7 @@ Most production orgs deploy Flows as inactive and activate them by hand, because
33
34
 
34
35
  - [Salesforce CLI](https://developer.salesforce.com/tools/salesforcecli)
35
36
  - Node.js 22.22 or later
36
- - 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.
37
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.
38
39
 
39
40
  ## Install
@@ -56,18 +57,23 @@ sf flowcov scaffold --uncovered --target-org prod
56
57
 
57
58
  # 4. In CI, after deploying the branch and running tests, require coverage for each changed Flow
58
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
59
63
  ```
60
64
 
61
65
  ## How coverage is measured
62
66
 
63
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.
64
- - **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.
65
- - **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%.
66
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.
67
71
 
68
72
  ## Readiness report
69
73
 
70
- `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.
71
77
 
72
78
  Pass `--fail-if-not-ready` to exit with code 1 below the threshold.
73
79
 
@@ -81,7 +87,7 @@ Coverage is read from the target org, so in CI:
81
87
  2. Run Apex tests there with `sf apex run test --code-coverage`.
82
88
  3. Run the gate against that org.
83
89
 
84
- 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.
85
91
 
86
92
  ## Test scaffolding
87
93
 
@@ -89,15 +95,33 @@ The gate checks the Flow's active version in the org (or its latest version if n
89
95
 
90
96
  | Flow type | Generated test |
91
97
  | --- | --- |
92
- | 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. |
93
- | 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. |
94
100
  | Platform event | Publishes the event and delivers it with `Test.getEventBus().deliver()`. |
95
101
  | Schedule-triggered | Starts the Flow directly, since Apex tests can't fire the schedule. |
96
102
  | Process Builder | A placeholder test to fill in. |
97
103
 
98
- 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`.
99
111
 
100
- 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`.
112
+ ## Coverage reports
113
+
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.
101
125
 
102
126
  ## CLI Command Reference
103
127
 
@@ -105,6 +129,7 @@ Every generated test has TODOs for anything it couldn't fill in, entry criteria
105
129
  * [`sf flowcov gate`](#sf-flowcov-gate)
106
130
  * [`sf flowcov readiness`](#sf-flowcov-readiness)
107
131
  * [`sf flowcov scaffold`](#sf-flowcov-scaffold)
132
+ * [`sf flowcov transform`](#sf-flowcov-transform)
108
133
 
109
134
  ## `sf flowcov gate`
110
135
 
@@ -142,7 +167,8 @@ DESCRIPTION
142
167
 
143
168
  Coverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there
144
169
  with `sf apex run test --code-coverage` before running the gate. Without `--code-coverage`, Salesforce records no Flow
145
- 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.
146
172
 
147
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
148
174
  latest version. Both usually mean the branch was deployed inactive, so the org's coverage doesn't belong to the
@@ -153,6 +179,9 @@ DESCRIPTION
153
179
  the org. By default this is a warning; use --content-check to fail instead, or to skip the comparison. The comparison
154
180
  doesn't look inside elements, so it can miss a change that only edits an existing element.
155
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.
184
+
156
185
  Exits with code 1 when any Flow fails.
157
186
 
158
187
  EXAMPLES
@@ -209,12 +238,19 @@ DESCRIPTION
209
238
 
210
239
  Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can
211
240
  turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the
212
- org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and
213
- 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.
214
245
 
215
246
  FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for
216
247
  example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without
217
- `--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.
218
254
 
219
255
  EXAMPLES
220
256
  Report readiness for the default org:
@@ -264,12 +300,19 @@ DESCRIPTION
264
300
  record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started
265
301
  with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is
266
302
  available (--target-org or a default org), the command describes each object the test creates and fills in its
267
- required fields, the fields the entry criteria need, and parent records for required lookups.
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.
268
308
 
269
- For record-triggered Flows, the command follows the Flow's elements for the record the test creates. It asserts the
270
- fields the Flow is certain to set, and when the Flow is certain to stop the save with a custom error, the test expects
271
- that error. Fields the Flow sets only on a decision outcome the command can't predict get commented-out assertions.
272
- The generated tests have TODOs for anything the command can't fill in.
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.
273
316
 
274
317
  Only Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.
275
318
 
@@ -288,6 +331,61 @@ EXAMPLES
288
331
  ```
289
332
 
290
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)_
291
389
  <!-- commandsstop -->
292
390
 
293
391
  ## Programmatic API
@@ -58,7 +58,7 @@ export default class FlowcovGate extends SfCommand {
58
58
  }
59
59
  if (candidates.length === 0) {
60
60
  this.log('No Flows changed. Nothing to check.');
61
- return { passed: true, minElementCoverage: flags['min-element-coverage'], flows: [] };
61
+ return { passed: true, minElementCoverage: flags['min-element-coverage'], flows: [], warnings: [] };
62
62
  }
63
63
  const connection = flags['target-org'].getConnection(flags['api-version']);
64
64
  const result = await evaluateGate({
@@ -79,6 +79,8 @@ export default class FlowcovGate extends SfCommand {
79
79
  for (const warning of flow.warnings ?? [])
80
80
  this.warn(`${flow.flowName}: ${warning}`);
81
81
  }
82
+ for (const warning of result.warnings)
83
+ this.warn(warning);
82
84
  if (result.passed) {
83
85
  this.logSuccess(`Flow coverage gate passed for ${result.flows.length} Flow(s).`);
84
86
  }
@@ -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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AC,CAAC;QAEH,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAChC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ;YAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE1D,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,iCAAiC,MAAM,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;YACtE,IAAI,CAAC,IAAI,CAAC,iCAAiC,MAAM,kCAAkC,CAAC,CAAC;YACrF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -1,10 +1,12 @@
1
1
  import { Messages } from '@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,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,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,mBAAmB,CAAC,CAAC;AAEhF,MAAM,CAAC,OAAO,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AAE,EAAE,CAAC,CAAC;oBACxB,IAAI,EAAE,CAAC,CAAC,QAAQ;oBAChB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC9D,kBAAkB,EAAE,GAAG,CAAC,CAAC,sBAAsB,GAAG;oBAClD,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC/F,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBACrF,CAAC,CAAC;aACJ,CAAC,CAAC;QACL,CAAC;QAED,IAAI,MAAM,CAAC,uBAAuB,GAAG,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CACP,GAAG,MAAM,CAAC,uBAAuB,gFAAgF,sBAAsB,EAAE,CAC1I,CAAC;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
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/flowcov/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,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AC;IAC9E,CAAC;CACF"}
@@ -18,9 +18,22 @@ export type GenerateOptions = {
18
18
  changedValues?: RequiredFieldMap;
19
19
  /** The object each lookup field points to, per object. Fills required and `IsNull false` lookups. */
20
20
  lookups?: Record<string, Record<string, string>>;
21
- /** Fields that stay empty when a test doesn't set them, per object. Lets assertions follow the Flow's decisions. */
21
+ /**
22
+ * What a new record holds in each field a test doesn't set, per object: an Apex literal, or
23
+ * `null` for empty. Lets assertions follow the Flow's decisions.
24
+ */
25
+ unsetValues?: Record<string, Record<string, string | null>>;
26
+ /** Fields that stay empty when a test doesn't set them, per object. Same as `null` in `unsetValues`. */
22
27
  nullWhenUnset?: Record<string, string[]>;
28
+ /** Lookup field per relationship name (`Account` to `AccountId`), per object. Meets criteria on related records. */
29
+ relationships?: Record<string, Record<string, string>>;
30
+ /** How many record types each object has, including Master. Lets record type lookups be filled. */
31
+ recordTypes?: Record<string, number>;
32
+ /** Fields a test can't set at all (formula, auto-number), per object. Criteria on them stay TODOs. */
33
+ readOnlyFields?: Record<string, string[]>;
34
+ /** Fields a test can set on insert but not change in an update, per object. Update tests set them in the insert. */
35
+ createOnlyFields?: Record<string, string[]>;
23
36
  };
24
37
  /** Generates a starter Apex test class for a Flow from its metadata. */
25
- export declare function generateApexTest(source: FlowMetadata, options?: GenerateOptions): GeneratedApexTest;
38
+ export declare function generateApexTest(flow: FlowMetadata, options?: GenerateOptions): GeneratedApexTest;
26
39
  export declare function apexClassMetaXml(apiVersion: string): string;