sf-flow-coverage 0.4.2 → 0.5.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 (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +92 -19
  3. package/lib/commands/flowcov/gate.d.ts +3 -0
  4. package/lib/commands/flowcov/gate.js +32 -4
  5. package/lib/commands/flowcov/gate.js.map +1 -1
  6. package/lib/commands/flowcov/readiness.d.ts +1 -0
  7. package/lib/commands/flowcov/readiness.js +16 -4
  8. package/lib/commands/flowcov/readiness.js.map +1 -1
  9. package/lib/commands/flowcov/scaffold.js +5 -1
  10. package/lib/commands/flowcov/scaffold.js.map +1 -1
  11. package/lib/core/apexTemplate.d.ts +6 -0
  12. package/lib/core/apexTemplate.js +107 -13
  13. package/lib/core/apexTemplate.js.map +1 -1
  14. package/lib/core/conditions.d.ts +25 -2
  15. package/lib/core/conditions.js +161 -13
  16. package/lib/core/conditions.js.map +1 -1
  17. package/lib/core/criteria.d.ts +8 -0
  18. package/lib/core/criteria.js +96 -24
  19. package/lib/core/criteria.js.map +1 -1
  20. package/lib/core/exclusions.d.ts +26 -0
  21. package/lib/core/exclusions.js +70 -0
  22. package/lib/core/exclusions.js.map +1 -0
  23. package/lib/core/flowFingerprint.d.ts +6 -0
  24. package/lib/core/flowFingerprint.js +94 -0
  25. package/lib/core/flowFingerprint.js.map +1 -1
  26. package/lib/core/flowSettings.d.ts +2 -1
  27. package/lib/core/flowSettings.js.map +1 -1
  28. package/lib/core/gate.d.ts +3 -0
  29. package/lib/core/gate.js +12 -0
  30. package/lib/core/gate.js.map +1 -1
  31. package/lib/core/lookupFilters.d.ts +33 -0
  32. package/lib/core/lookupFilters.js +139 -0
  33. package/lib/core/lookupFilters.js.map +1 -0
  34. package/lib/core/markdown.d.ts +14 -0
  35. package/lib/core/markdown.js +119 -0
  36. package/lib/core/markdown.js.map +1 -0
  37. package/lib/core/requiredFields.d.ts +6 -0
  38. package/lib/core/requiredFields.js +4 -0
  39. package/lib/core/requiredFields.js.map +1 -1
  40. package/lib/core/scaffold.d.ts +6 -0
  41. package/lib/core/scaffold.js +46 -2
  42. package/lib/core/scaffold.js.map +1 -1
  43. package/lib/core/toolingQuery.js.map +1 -1
  44. package/lib/core/validationRules.d.ts +14 -0
  45. package/lib/core/validationRules.js +30 -0
  46. package/lib/core/validationRules.js.map +1 -0
  47. package/lib/index.d.ts +4 -0
  48. package/lib/index.js +2 -0
  49. package/lib/index.js.map +1 -1
  50. package/messages/flowcov.gate.md +28 -1
  51. package/messages/flowcov.readiness.md +12 -0
  52. package/messages/flowcov.scaffold.md +1 -1
  53. package/oclif.manifest.json +40 -4
  54. package/package.json +1 -1
@@ -3,11 +3,12 @@
3
3
  "flowcov:gate": {
4
4
  "aliases": [],
5
5
  "args": {},
6
- "description": "Salesforce only checks that the org-wide total stays at or above 75%, so a single Flow with no tests can still be deployed as active. This gate checks each changed Flow on its own: every active autolaunched Flow or process changed between --from and --to must be run by at least one Apex test, and optionally reach a minimum element coverage.\n\nCoverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there with `sf apex run test --code-coverage` before running the gate. 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`. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.\n\nThe gate also fails a Flow when the org has no active version of it, or when its active version is older than its latest version. Both usually mean the branch was deployed inactive, so the org's coverage doesn't belong to the version in the pull request.\n\nWith --from, the gate also compares each changed Flow at --to with the org's version: process type, start trigger and entry criteria, and the names of its elements and resources. A difference usually means the branch wasn't deployed to the org. By default this is a warning; use --content-check to fail instead, or to skip the comparison. The comparison doesn't look inside elements, so it can miss a change that only edits an existing element.\n\nFor a Flow that tests run only in part, the --json output lists the elements no test runs, and a Flow that fails --min-element-coverage names them in its reason.\n\nExits with code 1 when any Flow fails.",
6
+ "description": "Salesforce only checks that the org-wide total stays at or above 75%, so a single Flow with no tests can still be deployed as active. This gate checks each changed Flow on its own: every active autolaunched Flow or process changed between --from and --to must be run by at least one Apex test, and optionally reach a minimum element coverage.\n\nCoverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there with `sf apex run test --code-coverage` before running the gate. 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`. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.\n\nThe gate also fails a Flow when the org has no active version of it, or when its active version is older than its latest version. Both usually mean the branch was deployed inactive, so the org's coverage doesn't belong to the version in the pull request.\n\nWith --from, the gate also compares each changed Flow at --to with the org's version: its process type, start element and entry criteria, Flow properties such as the API version and label, and each element and resource: which ones exist and what each one contains, such as a decision's conditions or an assignment's values. Canvas positions and Flow Builder's own settings are ignored. A difference usually means the branch wasn't deployed to the org. By default this is a warning; use --content-check to fail instead, or to skip the comparison.\n\nTo leave out Flows a team has chosen not to test yet, such as legacy Flows, list them in a `.flowcovignore` file in --project-dir or pass --exclude. Excluded Flows are skipped, with the pattern that matched them as the reason. Exclusions only affect the gate: Salesforce still counts every active Flow toward the org-wide total that `sf flowcov readiness` reports.\n\nFor a Flow that tests run only in part, the --json output lists the elements no test runs, and a Flow that fails --min-element-coverage names them in its reason.\n\nExits with code 1 when any Flow fails.",
7
7
  "examples": [
8
8
  "Check the Flows changed in a pull request:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --to HEAD",
9
9
  "Also require 60% element coverage per Flow:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --min-element-coverage 60",
10
10
  "Fail when the org runs a different version of a changed Flow than the branch:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --content-check fail",
11
+ "Skip legacy Flows, and add the results to a GitHub Actions job summary:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --exclude \"Legacy_*\" --output-format markdown >> \"$GITHUB_STEP_SUMMARY\"",
11
12
  "Check named Flows without git:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --flow Account_After_Save --flow Close_Cases"
12
13
  ],
13
14
  "flags": {
@@ -101,6 +102,27 @@
101
102
  "off"
102
103
  ],
103
104
  "type": "option"
105
+ },
106
+ "exclude": {
107
+ "description": "A pattern without \"/\" matches Flow API names, ignoring case; a pattern with \"/\" matches file paths from the repository root. \"*\" matches any characters except \"/\", \"**\" matches any characters, and \"?\" matches one character. A path ending in \"/\" matches everything under it. Patterns add to those in .flowcovignore, which lists one pattern per line with an optional \"# reason\" after it:\n\n # Deferred until the Q3 rewrite\n Legacy_*\n Close_Old_Cases # replaced by Case_Closure next release\n force-app/main/legacy/",
108
+ "name": "exclude",
109
+ "summary": "Flow API name or file path pattern for a Flow the gate skips.",
110
+ "hasDynamicHelp": false,
111
+ "multiple": true,
112
+ "type": "option"
113
+ },
114
+ "output-format": {
115
+ "description": "\"human\" prints tables and warnings to the terminal. \"markdown\" prints the results 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.",
116
+ "name": "output-format",
117
+ "summary": "Format of the report printed to standard output.",
118
+ "default": "human",
119
+ "hasDynamicHelp": false,
120
+ "multiple": false,
121
+ "options": [
122
+ "human",
123
+ "markdown"
124
+ ],
125
+ "type": "option"
104
126
  }
105
127
  },
106
128
  "hasDynamicHelp": true,
@@ -132,7 +154,8 @@
132
154
  "examples": [
133
155
  "Report readiness for the default org:\n<%= config.bin %> <%= command.id %>",
134
156
  "Rank uncovered Flows by changes in the last 6 months:\n<%= config.bin %> <%= command.id %> --target-org prod --since \"6 months ago\"",
135
- "Fail a CI job unless the org is at or above 75%:\n<%= config.bin %> <%= command.id %> --target-org prod --fail-if-not-ready"
157
+ "Fail a CI job unless the org is at or above 75%:\n<%= config.bin %> <%= command.id %> --target-org prod --fail-if-not-ready",
158
+ "Add the report to a GitHub Actions job summary:\n<%= config.bin %> <%= command.id %> --target-org prod --output-format markdown >> \"$GITHUB_STEP_SUMMARY\""
136
159
  ],
137
160
  "flags": {
138
161
  "json": {
@@ -196,6 +219,19 @@
196
219
  "summary": "Exit with code 1 when the org is below the threshold.",
197
220
  "allowNo": false,
198
221
  "type": "boolean"
222
+ },
223
+ "output-format": {
224
+ "description": "\"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.",
225
+ "name": "output-format",
226
+ "summary": "Format of the report printed to standard output.",
227
+ "default": "human",
228
+ "hasDynamicHelp": false,
229
+ "multiple": false,
230
+ "options": [
231
+ "human",
232
+ "markdown"
233
+ ],
234
+ "type": "option"
199
235
  }
200
236
  },
201
237
  "hasDynamicHelp": true,
@@ -223,7 +259,7 @@
223
259
  "flowcov:scaffold": {
224
260
  "aliases": [],
225
261
  "args": {},
226
- "description": "Reads each Flow's metadata file from the project and writes an Apex test class named `<Flow>_FlowTest` that runs it: record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is available (--target-org or a default org), the command describes each object the test creates and fills in its required fields, the fields the entry criteria need, and parent records (and their parents) for required lookups.\n\nEntry criteria are read as one condition, whether they are filters (with AND, OR, or custom logic) or a formula. The command meets one branch of an OR, and handles comparisons with literals, other fields, `$User.Id`, and `TODAY()`; `$Record__Prior` values in update tests; and fields on related records, which it sets on the parent record it inserts.\n\nFor record-triggered Flows, the command follows the Flow's elements for the record the test creates, deciding each decision the record settles (including formula resources, 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 stop the save with a custom error, the test expects that error, and a second test sets the fields that avoid it. For autolaunched Flows, it asserts output variables the Flow is certain to set. What the Flow does only on a decision outcome the command can't predict gets commented-out assertions. The generated tests have TODOs for anything the command can't fill in.\n\nOnly Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.",
262
+ "description": "Reads each Flow's metadata file from the project and writes an Apex test class named `<Flow>_FlowTest` that runs it: record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is available (--target-org or a default org), the command describes each object the test creates and fills in its required fields, the fields the entry criteria need, and parent records (and their parents) for required lookups. It also reads each object's active validation rules: a record the test saves (the triggering record on insert and on update, parents, and input records) gets the field values that keep a rule from blocking it, and a rule it can't avoid gets a TODO that names it. Required lookup filters (on standard and custom lookups) are met the same way: a parent record the test inserts gets the field values the filter needs.\n\nEntry criteria are read as one condition, whether they are filters (with AND, OR, or custom logic) or a formula. The command meets one branch of an OR, and handles comparisons with literals, other fields, `$User.Id`, and `TODAY()`; `$Record__Prior` values in update tests; and fields on related records, which it sets on the parent record it inserts.\n\nFor record-triggered Flows, the command follows the Flow's elements for the record the test creates, deciding each decision the record settles (including formula resources, 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 stop the save with a custom error, the test expects that error, and a second test sets the fields that avoid it. For autolaunched Flows, it asserts output variables the Flow is certain to set. What the Flow does only on a decision outcome the command can't predict gets commented-out assertions. The generated tests have TODOs for anything the command can't fill in.\n\nOnly Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.",
227
263
  "examples": [
228
264
  "Generate a test for one Flow:\n<%= config.bin %> <%= command.id %> --flow Account_After_Save",
229
265
  "Generate tests for every active Flow the org has no coverage for:\n<%= config.bin %> <%= command.id %> --uncovered --target-org prod",
@@ -422,5 +458,5 @@
422
458
  ]
423
459
  }
424
460
  },
425
- "version": "0.4.2"
461
+ "version": "0.5.0"
426
462
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sf-flow-coverage",
3
3
  "description": "Get your Salesforce org ready to deploy Flows as active: find uncovered Flows, gate coverage per Flow in pull requests, and scaffold Apex tests.",
4
- "version": "0.4.2",
4
+ "version": "0.5.0",
5
5
  "dependencies": {
6
6
  "@oclif/core": "5.1.12",
7
7
  "@salesforce/core": "9.4.6",