sf-flow-coverage 0.3.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 (77) hide show
  1. package/CHANGELOG.md +12 -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 +11 -2
  11. package/lib/core/apexTemplate.js +307 -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 +40 -0
  23. package/lib/core/criteria.js +262 -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 +29 -7
  55. package/lib/core/requiredFields.js +60 -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
@@ -128,7 +128,9 @@ export const emptyObjectFields = () => ({
128
128
  fieldValues: {},
129
129
  changedValues: {},
130
130
  lookups: {},
131
- nullWhenUnset: {},
131
+ relationships: {},
132
+ recordTypes: {},
133
+ unsetValues: {},
132
134
  });
133
135
  /** Lookup targets a test points at an existing record instead of inserting one. */
134
136
  export const EXISTING_RECORD_IDS = {
@@ -145,30 +147,64 @@ const NOT_INSERTABLE = new Set([
145
147
  'RecordType',
146
148
  'UserRole',
147
149
  ]);
150
+ /** Parents are inserted this many levels deep at most: parent, grandparent, great-grandparent. */
151
+ export const MAX_PARENT_DEPTH = 3;
148
152
  /** Whether a generated test can insert a record of `object` to fill a lookup to it. */
149
153
  export const canInsertParent = (object) => !NOT_INSERTABLE.has(object) && !(object in EXISTING_RECORD_IDS);
150
154
  /**
151
- * Fields a new record leaves empty unless the test sets them: createable, nillable, and with no
152
- * default value. Lets a test know how the Flow's decisions read the fields it doesn't set.
155
+ * What a new record holds in each field the test doesn't set, as an Apex literal (or `null`):
156
+ * empty for nillable fields with no default, a checkbox's default, and the default picklist
157
+ * value when the object has no record types that could change it (`recordTypes` of 1 or
158
+ * fewer). Lets a test follow the Flow's decisions on fields it doesn't set.
153
159
  */
154
- export function nullWhenUnsetFields(fields) {
155
- return fields
156
- .filter((field) => field.createable &&
157
- field.nillable &&
158
- !field.defaultedOnCreate &&
159
- !field.calculated &&
160
- !field.autoNumber &&
161
- !(field.picklistValues ?? []).some((value) => value.defaultValue))
162
- .map((field) => field.name);
160
+ export function unsetFieldValues(fields, recordTypes) {
161
+ const values = {};
162
+ for (const field of fields) {
163
+ if (!field.createable || field.calculated || field.autoNumber)
164
+ continue;
165
+ const pickDefault = (field.picklistValues ?? []).find((value) => value.active && value.defaultValue);
166
+ if (field.type === 'boolean' && (field.defaultValue === true || field.defaultValue === false)) {
167
+ values[field.name] = String(field.defaultValue);
168
+ }
169
+ else if (field.type === 'boolean' && (field.defaultValue === 'true' || field.defaultValue === 'false')) {
170
+ values[field.name] = field.defaultValue;
171
+ }
172
+ else if (pickDefault) {
173
+ // Record types can give a picklist a different default.
174
+ if (field.type === 'picklist' && recordTypes !== undefined && recordTypes <= 1) {
175
+ values[field.name] = `'${escapeApexString(pickDefault.value)}'`;
176
+ }
177
+ }
178
+ else if (field.nillable && !field.defaultedOnCreate) {
179
+ values[field.name] = null;
180
+ }
181
+ }
182
+ return values;
183
+ }
184
+ /** Lookup field per relationship name, for criteria on related records. */
185
+ export function relationshipLookups(fields) {
186
+ const relationships = {};
187
+ for (const field of fields) {
188
+ if (field.type === 'reference' && field.relationshipName)
189
+ relationships[field.relationshipName] = field.name;
190
+ }
191
+ return relationships;
163
192
  }
164
- /** Createable lookups to exactly one object (polymorphic lookups like `WhatId` are left out). */
193
+ /**
194
+ * The object each createable lookup points to. A polymorphic lookup (`WhatId`, `OwnerId`) gets
195
+ * the running user when it can point at users, else the first object a test can insert.
196
+ */
165
197
  export function lookupTargets(fields) {
166
198
  const targets = {};
167
199
  for (const field of fields) {
168
200
  if (field.type !== 'reference' || !field.createable || field.calculated)
169
201
  continue;
170
- if (field.referenceTo?.length === 1)
171
- targets[field.name] = field.referenceTo[0];
202
+ const options = field.referenceTo ?? [];
203
+ const target = options.length === 1
204
+ ? options[0]
205
+ : (options.find((o) => o in EXISTING_RECORD_IDS) ?? options.find((o) => canInsertParent(o)));
206
+ if (target)
207
+ targets[field.name] = target;
172
208
  }
173
209
  return targets;
174
210
  }
@@ -180,19 +216,24 @@ export async function loadObjectFields(objects, describe, into = emptyObjectFiel
180
216
  for (const object of [...new Set(objects)]) {
181
217
  if (object in into.requiredFields)
182
218
  continue;
183
- let fields;
219
+ let result;
184
220
  try {
185
- fields = await describe(object);
221
+ result = await describe(object);
186
222
  }
187
223
  catch {
188
- fields = undefined;
224
+ result = undefined;
225
+ }
226
+ const fields = Array.isArray(result) ? result : result?.fields;
227
+ if (result && !Array.isArray(result) && result.recordTypeInfos) {
228
+ into.recordTypes[object] = result.recordTypeInfos.length;
189
229
  }
190
230
  if (fields) {
191
231
  into.requiredFields[object] = requiredFieldValues(fields);
192
232
  into.fieldValues[object] = settableFieldValues(fields);
193
233
  into.changedValues[object] = changedFieldValues(fields);
194
234
  into.lookups[object] = lookupTargets(fields);
195
- into.nullWhenUnset[object] = nullWhenUnsetFields(fields);
235
+ into.relationships[object] = relationshipLookups(fields);
236
+ into.unsetValues[object] = unsetFieldValues(fields, into.recordTypes[object]);
196
237
  }
197
238
  }
198
239
  return into;
@@ -1 +1 @@
1
- {"version":3,"file":"requiredFields.js","sourceRoot":"","sources":["../../src/core/requiredFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAsBhD,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAEtE,SAAS,SAAS,CAAC,KAAoB,EAAE,IAAY;IACnD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1E,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC;AACrD,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,iBAAiB,CAAC,KAAoB;IACpD,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU,CAAC;QAChB,KAAK,iBAAiB;YACpB,OAAO,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClC,KAAK,OAAO;YACV,OAAO,oBAAoB,CAAC;QAC9B,KAAK,OAAO;YACV,OAAO,cAAc,CAAC;QACxB,KAAK,KAAK;YACR,OAAO,uBAAuB,CAAC;QACjC,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC;QACb,KAAK,MAAM;YACT,OAAO,cAAc,CAAC;QACxB,KAA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C;AACd,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { apexClassMetaXml, flowKind, generateApexTest } from './apexTemplate.js';
4
- import { parseFilterFormula } from './filterFormula.js';
4
+ import { entryCondition, fieldPaths } from './conditions.js';
5
5
  import { isCountedProcessType } from './flowTypes.js';
6
6
  import { parseFlowXml } from './flowXml.js';
7
7
  import { findFlowFiles, readProjectConfig } from './projectFiles.js';
8
- import { canInsertParent, emptyObjectFields, loadObjectFields, } from './requiredFields.js';
8
+ import { canInsertParent, emptyObjectFields, loadObjectFields, MAX_PARENT_DEPTH, } from './requiredFields.js';
9
9
  export const DEFAULT_APEX_API_VERSION = '65.0';
10
10
  /** sObjects a generated test creates records of. */
11
11
  function objectsToCreate(flow) {
@@ -17,23 +17,31 @@ function objectsToCreate(flow) {
17
17
  objects.push(flow.object);
18
18
  return objects;
19
19
  }
20
- /** Entry-criteria fields on the triggering record, from filters and a simple formula. */
21
- function criteriaFields(flow) {
22
- const formulaFilters = flow.filterFormula ? (parseFilterFormula(flow.filterFormula) ?? []) : [];
23
- return new Set([...flow.filters, ...formulaFilters].map((f) => f.field));
20
+ /**
21
+ * Lookup fields the entry criteria read on the triggering record: lookups compared directly
22
+ * (`Account__c`) and the lookups behind related fields (`Account__r.Type`).
23
+ */
24
+ function criteriaLookups(flow, relationships) {
25
+ const lookups = new Set();
26
+ for (const path of fieldPaths(entryCondition(flow))) {
27
+ if (path.length === 1)
28
+ lookups.add(path[0]);
29
+ else if (relationships[path[0]])
30
+ lookups.add(relationships[path[0]]);
31
+ }
32
+ return lookups;
24
33
  }
25
34
  /**
26
35
  * Objects a generated test inserts as parents: targets of lookups that are required, or that
27
- * the entry criteria reference, on the records the test creates. One level deep: a parent's
28
- * own required lookups stay TODOs.
36
+ * the entry criteria reference, on the records the test creates.
29
37
  */
30
38
  function parentObjects(flows, fields) {
31
39
  const parents = [];
32
40
  for (const flow of flows) {
33
- const criteria = criteriaFields(flow);
34
41
  for (const object of objectsToCreate(flow)) {
42
+ const criteria = object === flow.object ? criteriaLookups(flow, fields.relationships[object] ?? {}) : new Set();
35
43
  for (const [field, target] of Object.entries(fields.lookups[object] ?? {})) {
36
- const used = field in (fields.requiredFields[object] ?? {}) || (object === flow.object && criteria.has(field));
44
+ const used = field in (fields.requiredFields[object] ?? {}) || criteria.has(field);
37
45
  if (used && canInsertParent(target))
38
46
  parents.push(target);
39
47
  }
@@ -41,6 +49,12 @@ function parentObjects(flows, fields) {
41
49
  }
42
50
  return parents;
43
51
  }
52
+ /** Targets of the required lookups on the given (already described) parent objects. */
53
+ function grandparentObjects(objects, fields) {
54
+ return objects.flatMap((object) => Object.entries(fields.lookups[object] ?? {})
55
+ .filter(([field, target]) => field in (fields.requiredFields[object] ?? {}) && canInsertParent(target))
56
+ .map(([, target]) => target));
57
+ }
44
58
  async function exists(path) {
45
59
  try {
46
60
  await access(path);
@@ -85,7 +99,12 @@ export async function scaffoldTests(options) {
85
99
  const objectFields = emptyObjectFields();
86
100
  if (options.describe) {
87
101
  await loadObjectFields(flows.flatMap((f) => objectsToCreate(f.flow)), options.describe, objectFields);
88
- await loadObjectFields(parentObjects(flows.map((f) => f.flow), objectFields), options.describe, objectFields);
102
+ let level = parentObjects(flows.map((f) => f.flow), objectFields);
103
+ for (let depth = 1; depth <= MAX_PARENT_DEPTH && level.length > 0; depth++) {
104
+ const fresh = [...new Set(level)].filter((object) => !(object in objectFields.requiredFields));
105
+ await loadObjectFields(fresh, options.describe, objectFields);
106
+ level = grandparentObjects(fresh, objectFields);
107
+ }
89
108
  }
90
109
  for (const { flowName, flow } of flows) {
91
110
  const test = generateApexTest(flow, objectFields);
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/core/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAA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IACH,CAAC;IAED,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YAChD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,4CAA4C,EAAE,CAAC,CAAC;YACpG,SAAS;QACX,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5C,MAAM,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC9C,MAAM,SAAS,CAAC,GAAG,SAAS,WAAW,EAAE,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;QACjF,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,7 +1,12 @@
1
1
  import type { Connection } from '@salesforce/core';
2
+ import type { DataQuery, MetadataRead } from './flowSettings.js';
2
3
  import type { DescribeObject } from './requiredFields.js';
3
4
  import type { ToolingQuery } from './types.js';
4
5
  /** Adapts an org connection to the ToolingQuery used by OrgCoverageSource, fetching every page. */
5
6
  export declare function toolingQuery(connection: Pick<Connection, 'tooling'>): ToolingQuery;
7
+ /** Adapts an org connection to a data API query, fetching every page. */
8
+ export declare function dataQuery(connection: Pick<Connection, 'query'>): DataQuery;
9
+ /** Adapts an org connection to the MetadataRead used to read org settings. */
10
+ export declare function metadataRead(connection: Pick<Connection, 'metadata'>): MetadataRead;
6
11
  /** Adapts an org connection to the DescribeObject used by scaffolding to fill required fields. */
7
12
  export declare function describeObject(connection: Pick<Connection, 'describe'>): DescribeObject;
@@ -6,11 +6,19 @@ export function toolingQuery(connection) {
6
6
  return result.records;
7
7
  };
8
8
  }
9
+ /** Adapts an org connection to a data API query, fetching every page. */
10
+ export function dataQuery(connection) {
11
+ return async (soql) => (await connection.query(soql, { autoFetch: true, maxFetch: MAX_FETCH })).records;
12
+ }
13
+ /** Adapts an org connection to the MetadataRead used to read org settings. */
14
+ export function metadataRead(connection) {
15
+ return async (type, fullName) => connection.metadata.read(type, fullName);
16
+ }
9
17
  /** Adapts an org connection to the DescribeObject used by scaffolding to fill required fields. */
10
18
  export function describeObject(connection) {
11
19
  return async (objectName) => {
12
20
  const result = await connection.describe(objectName);
13
- return result.fields;
21
+ return { fields: result.fields, recordTypeInfos: result.recordTypeInfos };
14
22
  };
15
23
  }
16
24
  //# sourceMappingURL=toolingQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolingQuery.js","sourceRoot":"","sources":["../../src/core/toolingQuery.ts"],"names":[],"mappings":"AAKA,MAAM,SAAS,GAAG,SAAS,CAAC;AAE5B,mGAAmG;AACnG,MAAM,UAAU,YAAY,CAAC,UAAuC;IAClE,OAAO,KAAK,EAAqC,IAAY,EAAgB,EAAE;QAC7E,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,CAAI,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;QACjG,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,cAAc,CAAC,U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C;QACrD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAoC,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;IAC1G,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { CoverageSource } from './types.js';
2
+ /** One executable element of a Flow as a line in its source file. */
3
+ export type FlowCoverageLine = {
4
+ line: number;
5
+ covered: boolean;
6
+ element: string;
7
+ type: string;
8
+ };
9
+ /** Element coverage of one Flow, mapped onto its source file. */
10
+ export type FlowFileCoverage = {
11
+ flowName: string;
12
+ /** Source file path relative to the project directory, with `/` separators. */
13
+ path: string;
14
+ lines: FlowCoverageLine[];
15
+ };
16
+ export type FlowFileCoverageReport = {
17
+ files: FlowFileCoverage[];
18
+ /** Active Flows left out, and why. */
19
+ skipped: Array<{
20
+ flowName: string;
21
+ reason: string;
22
+ }>;
23
+ /** Flows whose source file may not match the version the org covered. */
24
+ warnings: string[];
25
+ };
26
+ export type FlowFileCoverageOptions = {
27
+ source: CoverageSource;
28
+ /** Project root: searched for Flow files; output paths are relative to it. */
29
+ projectDir: string;
30
+ };
31
+ /**
32
+ * Maps the org's element coverage onto the project's Flow files: each executable element is a
33
+ * line (the line of its `<name>`), covered when any Apex test ran it. Covers every active Flow
34
+ * that counts toward deploy-as-active and has a source file in the project.
35
+ */
36
+ export declare function buildFlowFileCoverage(options: FlowFileCoverageOptions): Promise<FlowFileCoverageReport>;
@@ -0,0 +1,62 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { relative, sep } from 'node:path';
3
+ import { missingCoverageWarning } from './coverageCheck.js';
4
+ import { flowElementLines } from './flowElementLines.js';
5
+ import { findFlowFiles } from './projectFiles.js';
6
+ /**
7
+ * Maps the org's element coverage onto the project's Flow files: each executable element is a
8
+ * line (the line of its `<name>`), covered when any Apex test ran it. Covers every active Flow
9
+ * that counts toward deploy-as-active and has a source file in the project.
10
+ */
11
+ export async function buildFlowFileCoverage(options) {
12
+ const flows = await options.source.listActiveCountedFlows();
13
+ const flowFiles = await findFlowFiles(options.projectDir);
14
+ const report = { files: [], skipped: [], warnings: [] };
15
+ for (const flow of [...flows].sort((a, b) => a.flowName.localeCompare(b.flowName))) {
16
+ const file = flowFiles.get(flow.flowName);
17
+ if (!file) {
18
+ report.skipped.push({ flowName: flow.flowName, reason: 'No source file in the project.' });
19
+ continue;
20
+ }
21
+ if (flow.covered && !flow.coveredElementNames) {
22
+ report.skipped.push({ flowName: flow.flowName, reason: 'The org did not report which elements tests ran.' });
23
+ continue;
24
+ }
25
+ const path = relative(options.projectDir, file).split(sep).join('/');
26
+ const elements = flowElementLines(await readFile(file, 'utf8'));
27
+ if (elements.length === 0) {
28
+ report.skipped.push({ flowName: flow.flowName, reason: 'The source file has no elements.' });
29
+ continue;
30
+ }
31
+ const covered = new Set((flow.coveredElementNames ?? []).map((name) => name.toLowerCase()));
32
+ const local = new Set(elements.map((e) => e.name.toLowerCase()));
33
+ // Salesforce counts elements only for versions some test ran, so uncovered Flows can't be compared.
34
+ const version = `version ${flow.versionNumber ?? '?'} in the org`;
35
+ const missing = [...covered].filter((name) => !local.has(name));
36
+ let mismatch;
37
+ if (flow.covered && elements.length !== flow.elementsTotal) {
38
+ mismatch = `${path} has ${elements.length} elements, but ${version} has ${flow.elementsTotal}`;
39
+ }
40
+ else if (missing.length > 0) {
41
+ mismatch = `tests ran elements of ${version} that ${path} doesn't have (${missing.join(', ')})`;
42
+ }
43
+ if (mismatch) {
44
+ report.warnings.push(`${flow.flowName}: ${mismatch}. Its line coverage may be off; retrieve or deploy the Flow so they match.`);
45
+ }
46
+ report.files.push({
47
+ flowName: flow.flowName,
48
+ path,
49
+ lines: elements.map((e) => ({
50
+ line: e.line,
51
+ covered: covered.has(e.name.toLowerCase()),
52
+ element: e.name,
53
+ type: e.type,
54
+ })),
55
+ });
56
+ }
57
+ const warning = await missingCoverageWarning(options.source, report.files.length > 0 && flows.every((flow) => !flow.covered));
58
+ if (warning)
59
+ report.warnings.unshift(war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AM,CAAC;AAChB,CAAC"}
@@ -1,5 +1,12 @@
1
1
  import type { FlowFingerprint } from './flowFingerprint.js';
2
2
  import type { FlowGraph } from './flowGraph.js';
3
+ /** A Flow element no Apex test ran. */
4
+ export type UncoveredElement = {
5
+ /** Element API name, as in the Flow's metadata. */
6
+ name: string;
7
+ /** Element type, such as `decision` or `recordUpdate`. */
8
+ type: string;
9
+ };
3
10
  /** One Apex test method that ran a Flow version. */
4
11
  export type FlowTestRef = {
5
12
  className: string;
@@ -20,6 +27,11 @@ export type FlowCoverage = {
20
27
  /** Elements covered across all tests, 0-100. */
21
28
  elementCoveragePercent: number;
22
29
  tests: FlowTestRef[];
30
+ /**
31
+ * Lowercased names of the elements any test ran (FlowElementTestCoverage reports them in lower
32
+ * case). Undefined when element coverage can't be read.
33
+ */
34
+ coveredElementNames?: string[];
23
35
  /**
24
36
  * How this version relates to the Flow's other versions, when known (set by `getFlowCoverage`):
25
37
  * - `current`: it is the active version and the latest one.
@@ -49,6 +61,11 @@ export type CoverageSource = {
49
61
  * source can't read the version's content.
50
62
  */
51
63
  getFlowFingerprint?(flowVersionId: string): Promise<FlowFingerprint | undefined>;
64
+ /**
65
+ * Whether the org has any Flow coverage at all, for any Flow version. False usually means
66
+ * Apex tests ran without code coverage on.
67
+ */
68
+ hasAnyFlowCoverage?(): Promise<boolean>;
52
69
  };
53
70
  /** Runs a Tooling API SOQL query and returns every record (all pages). */
54
71
  export type ToolingQuery = <T extends Record<string, unknown>>(soql: string) => Promise<T[]>;
@@ -59,8 +76,6 @@ export type FlowFilter = {
59
76
  apexValue?: string;
60
77
  /** Raw value text, for TODO comments. */
61
78
  rawValue?: string;
62
- /** The entry-criteria formula term this filter was read from, for TODO comments. */
63
- formulaTerm?: string;
64
79
  };
65
80
  export type FlowVariable = {
66
81
  name: string;
@@ -99,6 +114,8 @@ export type ReadinessFlow = {
99
114
  tests: FlowTestRef[];
100
115
  /** Commits that touched the Flow's source file, when the project is a git repo. */
101
116
  changes?: number;
117
+ /** Elements no test ran, for Flows some test runs. Undefined when they can't be read. */
118
+ uncoveredElements?: UncoveredElement[];
102
119
  };
103
120
  export type ReadinessResult = {
104
121
  threshold: number;
@@ -109,6 +126,14 @@ export type ReadinessResult = {
109
126
  ready: boolean;
110
127
  /** Additional Flows that need a test to reach the threshold. */
111
128
  flowsNeeded: number;
129
+ /** Active Process Builder processes among the counted Flows. Salesforce no longer supports Process Builder. */
130
+ processBuilderProcesses: number;
131
+ /** Whether "Deploy processes and flows as active" is on. Undefined when it could not be read. */
132
+ deployAsActive?: boolean;
133
+ /** Whether the org is a sandbox or scratch org, where the setting doesn't apply. Undefined when unknown. */
134
+ isSandbox?: boolean;
135
+ /** Problems with the report as a whole, such as no Flow coverage recorded in the org. */
136
+ warnings: string[];
112
137
  /** Uncovered first (most-changed first), then covered. */
113
138
  flows: ReadinessFlow[];
114
139
  };
@@ -123,6 +148,8 @@ export type GateFlowResult = {
123
148
  tests: FlowTestRef[];
124
149
  /** Problems that don't change `status`, such as an org version that differs from source. */
125
150
  warnings?: string[];
151
+ /** Elements no test ran, for Flows some test runs. Undefined when they can't be read. */
152
+ uncoveredElements?: UncoveredElement[];
126
153
  };
127
154
  /** What the gate does when the org's Flow content differs from source. */
128
155
  export type ContentCheck = 'warn' | 'fail' | 'off';
@@ -130,6 +157,29 @@ export type GateResult = {
130
157
  passed: boolean;
131
158
  minElementCoverage: number;
132
159
  flows: GateFlowResult[];
160
+ /** Problems with the run as a whole, such as no Flow coverage recorded in the org. */
161
+ warnings: string[];
162
+ };
163
+ export type TransformResult = {
164
+ /** Each coverage report written. */
165
+ files: Array<{
166
+ format: string;
167
+ path: string;
168
+ }>;
169
+ /** Flows in the reports, with their element counts. */
170
+ flows: Array<{
171
+ flowName: string;
172
+ path: string;
173
+ elementsCovered: number;
174
+ elementsTotal: number;
175
+ }>;
176
+ /** Active Flows left out of the reports, and why. */
177
+ skipped: Array<{
178
+ flowName: string;
179
+ reason: string;
180
+ }>;
181
+ /** Flows whose source file may not match the version the org covered. */
182
+ warnings: string[];
133
183
  };
134
184
  export type ScaffoldedTest = {
135
185
  flowName: string;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export { apexClassMetaXml, apexTestClassName, generateApexTest } from './core/apexTemplate.js';
2
+ export type { CoverageFormat } from './core/coverageFormats.js';
3
+ export { COVERAGE_FORMATS, formatCoverage } from './core/coverageFormats.js';
4
+ export type { DataQuery, MetadataRead } from './core/flowSettings.js';
2
5
  export { COUNTED_PROCESS_TYPES, DEFAULT_THRESHOLD, isCountedProcessType } from './core/flowTypes.js';
3
6
  export { parseFlowXml } from './core/flowXml.js';
4
7
  export type { GateCandidate, GateOptions } from './core/gate.js';
@@ -10,5 +13,7 @@ export type { DescribeField, DescribeObject, RequiredFieldMap } from './core/req
10
13
  export { requiredFieldValues } from './core/requiredFields.js';
11
14
  export type { ScaffoldOptions } from './core/scaffold.js';
12
15
  export { scaffoldTests } from './core/scaffold.js';
13
- export { describeObject, toolingQuery } from './core/toolingQuery.js';
16
+ export { dataQuery, describeObject, metadataRead, toolingQuery } from './core/toolingQuery.js';
17
+ export type { FlowCoverageLine, FlowFileCoverage, FlowFileCoverageOptions, FlowFileCoverageReport, } from './core/transform.js';
18
+ export { buildFlowFileCoverage } from './core/transform.js';
14
19
  export type * from './core/types.js';
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { apexClassMetaXml, apexTestClassName, generateApexTest } from './core/apexTemplate.js';
2
+ export { COVERAGE_FORMATS, formatCoverage } from './core/coverageFormats.js';
2
3
  export { COUNTED_PROCESS_TYPES, DEFAULT_THRESHOLD, isCountedProcessType } from './core/flowTypes.js';
3
4
  export { parseFlowXml } from './core/flowXml.js';
4
5
  export { collectChangedFlows, evaluateGate } from './core/gate.js';
@@ -6,5 +7,6 @@ export { OrgCoverageSource } from './core/orgCoverageSource.js';
6
7
  export { buildReadinessReport } from './core/readiness.js';
7
8
  export { requiredFieldValues } from './core/requiredFields.js';
8
9
  export { scaffoldTests } from './core/scaffold.js';
9
- export { describeObject, toolingQuery } from './core/toolingQuery.js';
10
+ export { dataQuery, describeObject, metadataRead, toolingQuery } from './core/toolingQuery.js';
11
+ export { buildFlowFileCoverage } from './core/transform.js';
10
12
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAO/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -6,12 +6,14 @@ Require Apex test coverage for every Flow a pull request changes.
6
6
 
7
7
  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.
8
8
 
9
- Coverage 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. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.
9
+ Coverage 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.
10
10
 
11
11
  The 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.
12
12
 
13
13
  With --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.
14
14
 
15
+ For 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.
16
+
15
17
  Exits with code 1 when any Flow fails.
16
18
 
17
19
  # examples
@@ -4,9 +4,11 @@ Report how close the org is to the coverage needed to deploy Flows as active.
4
4
 
5
5
  # description
6
6
 
7
- Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and the Apex tests that already run each covered Flow.
7
+ Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and, for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to migrate them to Flows, since Salesforce no longer supports Process Builder.
8
8
 
9
- FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without `--code-coverage`, Salesforce records no Flow coverage.
9
+ FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`.
10
+
11
+ The report also says whether "Deploy processes and flows as active" is already on, and what that means: turn it on once the org is ready, or keep coverage up so deployments of active Flows keep working. The setting only affects production; in a sandbox or scratch org the report says so.
10
12
 
11
13
  # examples
12
14
 
@@ -4,9 +4,11 @@ Generate starter Apex tests for Flows.
4
4
 
5
5
  # description
6
6
 
7
- 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 for required lookups.
7
+ 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.
8
8
 
9
- For record-triggered Flows, the command follows the Flow's elements for the record the test creates. It asserts the fields the Flow is certain to set, and when the Flow is certain to stop the save with a custom error, the test expects that error. Fields the Flow sets only on a decision outcome the command can't predict get commented-out assertions. The generated tests have TODOs for anything the command can't fill in.
9
+ Entry 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.
10
+
11
+ For 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.
10
12
 
11
13
  Only Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.
12
14