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.
- package/CHANGELOG.md +19 -0
- package/README.md +117 -19
- package/lib/commands/flowcov/gate.js +3 -1
- package/lib/commands/flowcov/gate.js.map +1 -1
- package/lib/commands/flowcov/readiness.js +25 -3
- package/lib/commands/flowcov/readiness.js.map +1 -1
- package/lib/commands/flowcov/transform.d.ts +15 -0
- package/lib/commands/flowcov/transform.js +78 -0
- package/lib/commands/flowcov/transform.js.map +1 -0
- package/lib/core/apexTemplate.d.ts +15 -2
- package/lib/core/apexTemplate.js +311 -199
- package/lib/core/apexTemplate.js.map +1 -1
- package/lib/core/conditions.d.ts +107 -0
- package/lib/core/conditions.js +481 -0
- package/lib/core/conditions.js.map +1 -0
- package/lib/core/coverageCheck.d.ts +8 -0
- package/lib/core/coverageCheck.js +12 -0
- package/lib/core/coverageCheck.js.map +1 -0
- package/lib/core/coverageFormats.d.ts +7 -0
- package/lib/core/coverageFormats.js +77 -0
- package/lib/core/coverageFormats.js.map +1 -0
- package/lib/core/criteria.d.ts +46 -0
- package/lib/core/criteria.js +276 -0
- package/lib/core/criteria.js.map +1 -0
- package/lib/core/elementCoverage.d.ts +9 -0
- package/lib/core/elementCoverage.js +27 -0
- package/lib/core/elementCoverage.js.map +1 -0
- package/lib/core/flowElementLines.d.ts +13 -0
- package/lib/core/flowElementLines.js +44 -0
- package/lib/core/flowElementLines.js.map +1 -0
- package/lib/core/flowFingerprint.d.ts +10 -0
- package/lib/core/flowFingerprint.js +14 -0
- package/lib/core/flowFingerprint.js.map +1 -1
- package/lib/core/flowGraph.d.ts +63 -13
- package/lib/core/flowGraph.js +125 -134
- package/lib/core/flowGraph.js.map +1 -1
- package/lib/core/flowSettings.d.ts +16 -0
- package/lib/core/flowSettings.js +49 -0
- package/lib/core/flowSettings.js.map +1 -0
- package/lib/core/flowTypes.d.ts +6 -0
- package/lib/core/flowTypes.js +17 -0
- package/lib/core/flowTypes.js.map +1 -1
- package/lib/core/formula.d.ts +48 -0
- package/lib/core/formula.js +227 -0
- package/lib/core/formula.js.map +1 -0
- package/lib/core/gate.js +19 -1
- package/lib/core/gate.js.map +1 -1
- package/lib/core/orgCoverageSource.d.ts +3 -0
- package/lib/core/orgCoverageSource.js +26 -5
- package/lib/core/orgCoverageSource.js.map +1 -1
- package/lib/core/readiness.d.ts +5 -0
- package/lib/core/readiness.js +24 -10
- package/lib/core/readiness.js.map +1 -1
- package/lib/core/requiredFields.d.ts +35 -7
- package/lib/core/requiredFields.js +68 -19
- package/lib/core/requiredFields.js.map +1 -1
- package/lib/core/scaffold.js +30 -11
- package/lib/core/scaffold.js.map +1 -1
- package/lib/core/toolingQuery.d.ts +5 -0
- package/lib/core/toolingQuery.js +9 -1
- package/lib/core/toolingQuery.js.map +1 -1
- package/lib/core/transform.d.ts +36 -0
- package/lib/core/transform.js +62 -0
- package/lib/core/transform.js.map +1 -0
- package/lib/core/types.d.ts +52 -2
- package/lib/index.d.ts +6 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/messages/flowcov.gate.md +3 -1
- package/messages/flowcov.readiness.md +4 -2
- package/messages/flowcov.scaffold.md +4 -2
- package/messages/flowcov.transform.md +33 -0
- package/oclif.manifest.json +98 -4
- package/package.json +1 -1
- package/lib/core/filterFormula.d.ts +0 -10
- package/lib/core/filterFormula.js +0 -153
- package/lib/core/filterFormula.js.map +0 -1
|
@@ -4,6 +4,8 @@ export type DescribeField = {
|
|
|
4
4
|
type: string;
|
|
5
5
|
nillable: boolean;
|
|
6
6
|
createable: boolean;
|
|
7
|
+
/** False for fields that can be set on insert but not changed later, such as most master-detail fields. */
|
|
8
|
+
updateable?: boolean;
|
|
7
9
|
defaultedOnCreate: boolean;
|
|
8
10
|
calculated?: boolean;
|
|
9
11
|
autoNumber?: boolean;
|
|
@@ -14,9 +16,18 @@ export type DescribeField = {
|
|
|
14
16
|
defaultValue?: boolean;
|
|
15
17
|
}> | null;
|
|
16
18
|
referenceTo?: string[] | null;
|
|
19
|
+
/** The field's default value, such as a checkbox's `true` or `false`. */
|
|
20
|
+
defaultValue?: unknown;
|
|
21
|
+
/** For lookups, the relationship name used in paths such as `Account__r.Type`. */
|
|
22
|
+
relationshipName?: string | null;
|
|
17
23
|
};
|
|
18
24
|
/** Describes an sObject's fields. Returns undefined when the object can't be described. */
|
|
19
|
-
export type DescribeObject = (objectName: string) => Promise<DescribeField[] | undefined>;
|
|
25
|
+
export type DescribeObject = (objectName: string) => Promise<DescribeField[] | DescribeResult | undefined>;
|
|
26
|
+
/** An sObject describe: its fields, and its record types when known. */
|
|
27
|
+
export type DescribeResult = {
|
|
28
|
+
fields: DescribeField[];
|
|
29
|
+
recordTypeInfos?: unknown[];
|
|
30
|
+
};
|
|
20
31
|
/** Field name to Apex literal, per object. */
|
|
21
32
|
export type RequiredFieldMap = Record<string, Record<string, string>>;
|
|
22
33
|
/** An Apex literal for a required field, or undefined when no safe value can be made up. */
|
|
@@ -42,20 +53,37 @@ export type ObjectFields = {
|
|
|
42
53
|
changedValues: RequiredFieldMap;
|
|
43
54
|
/** The object each lookup field points to, per object. Only lookups to a single object are listed. */
|
|
44
55
|
lookups: Record<string, Record<string, string>>;
|
|
45
|
-
/**
|
|
46
|
-
|
|
56
|
+
/** Lookup field per relationship name (`Account__r` to `Account__c`), per object. */
|
|
57
|
+
relationships: Record<string, Record<string, string>>;
|
|
58
|
+
/** How many record types each object has, including Master, when the describe says. */
|
|
59
|
+
recordTypes: Record<string, number>;
|
|
60
|
+
/** Fields a test can't set at all (formula, auto-number, system fields), per object. */
|
|
61
|
+
readOnlyFields: Record<string, string[]>;
|
|
62
|
+
/** Fields a test can set on insert but not change in an update, per object. */
|
|
63
|
+
createOnlyFields: Record<string, string[]>;
|
|
64
|
+
/** What a new record holds in each field a test doesn't set, per object (see `unsetFieldValues`). */
|
|
65
|
+
unsetValues: Record<string, Record<string, string | null>>;
|
|
47
66
|
};
|
|
48
67
|
export declare const emptyObjectFields: () => ObjectFields;
|
|
49
68
|
/** Lookup targets a test points at an existing record instead of inserting one. */
|
|
50
69
|
export declare const EXISTING_RECORD_IDS: Record<string, string>;
|
|
70
|
+
/** Parents are inserted this many levels deep at most: parent, grandparent, great-grandparent. */
|
|
71
|
+
export declare const MAX_PARENT_DEPTH = 3;
|
|
51
72
|
/** Whether a generated test can insert a record of `object` to fill a lookup to it. */
|
|
52
73
|
export declare const canInsertParent: (object: string) => boolean;
|
|
53
74
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
75
|
+
* What a new record holds in each field the test doesn't set, as an Apex literal (or `null`):
|
|
76
|
+
* empty for nillable fields with no default, a checkbox's default, and the default picklist
|
|
77
|
+
* value when the object has no record types that could change it (`recordTypes` of 1 or
|
|
78
|
+
* fewer). Lets a test follow the Flow's decisions on fields it doesn't set.
|
|
79
|
+
*/
|
|
80
|
+
export declare function unsetFieldValues(fields: DescribeField[], recordTypes?: number): Record<string, string | null>;
|
|
81
|
+
/** Lookup field per relationship name, for criteria on related records. */
|
|
82
|
+
export declare function relationshipLookups(fields: DescribeField[]): Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* The object each createable lookup points to. A polymorphic lookup (`WhatId`, `OwnerId`) gets
|
|
85
|
+
* the running user when it can point at users, else the first object a test can insert.
|
|
56
86
|
*/
|
|
57
|
-
export declare function nullWhenUnsetFields(fields: DescribeField[]): string[];
|
|
58
|
-
/** Createable lookups to exactly one object (polymorphic lookups like `WhatId` are left out). */
|
|
59
87
|
export declare function lookupTargets(fields: DescribeField[]): Record<string, string>;
|
|
60
88
|
/**
|
|
61
89
|
* Describes each object once, adding to `into` when given. Objects already in `into`, and
|
|
@@ -128,7 +128,11 @@ export const emptyObjectFields = () => ({
|
|
|
128
128
|
fieldValues: {},
|
|
129
129
|
changedValues: {},
|
|
130
130
|
lookups: {},
|
|
131
|
-
|
|
131
|
+
relationships: {},
|
|
132
|
+
recordTypes: {},
|
|
133
|
+
readOnlyFields: {},
|
|
134
|
+
createOnlyFields: {},
|
|
135
|
+
unsetValues: {},
|
|
132
136
|
});
|
|
133
137
|
/** Lookup targets a test points at an existing record instead of inserting one. */
|
|
134
138
|
export const EXISTING_RECORD_IDS = {
|
|
@@ -145,30 +149,64 @@ const NOT_INSERTABLE = new Set([
|
|
|
145
149
|
'RecordType',
|
|
146
150
|
'UserRole',
|
|
147
151
|
]);
|
|
152
|
+
/** Parents are inserted this many levels deep at most: parent, grandparent, great-grandparent. */
|
|
153
|
+
export const MAX_PARENT_DEPTH = 3;
|
|
148
154
|
/** Whether a generated test can insert a record of `object` to fill a lookup to it. */
|
|
149
155
|
export const canInsertParent = (object) => !NOT_INSERTABLE.has(object) && !(object in EXISTING_RECORD_IDS);
|
|
150
156
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
157
|
+
* What a new record holds in each field the test doesn't set, as an Apex literal (or `null`):
|
|
158
|
+
* empty for nillable fields with no default, a checkbox's default, and the default picklist
|
|
159
|
+
* value when the object has no record types that could change it (`recordTypes` of 1 or
|
|
160
|
+
* fewer). Lets a test follow the Flow's decisions on fields it doesn't set.
|
|
153
161
|
*/
|
|
154
|
-
export function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
field.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
export function unsetFieldValues(fields, recordTypes) {
|
|
163
|
+
const values = {};
|
|
164
|
+
for (const field of fields) {
|
|
165
|
+
if (!field.createable || field.calculated || field.autoNumber)
|
|
166
|
+
continue;
|
|
167
|
+
const pickDefault = (field.picklistValues ?? []).find((value) => value.active && value.defaultValue);
|
|
168
|
+
if (field.type === 'boolean' && (field.defaultValue === true || field.defaultValue === false)) {
|
|
169
|
+
values[field.name] = String(field.defaultValue);
|
|
170
|
+
}
|
|
171
|
+
else if (field.type === 'boolean' && (field.defaultValue === 'true' || field.defaultValue === 'false')) {
|
|
172
|
+
values[field.name] = field.defaultValue;
|
|
173
|
+
}
|
|
174
|
+
else if (pickDefault) {
|
|
175
|
+
// Record types can give a picklist a different default.
|
|
176
|
+
if (field.type === 'picklist' && recordTypes !== undefined && recordTypes <= 1) {
|
|
177
|
+
values[field.name] = `'${escapeApexString(pickDefault.value)}'`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (field.nillable && !field.defaultedOnCreate) {
|
|
181
|
+
values[field.name] = null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return values;
|
|
185
|
+
}
|
|
186
|
+
/** Lookup field per relationship name, for criteria on related records. */
|
|
187
|
+
export function relationshipLookups(fields) {
|
|
188
|
+
const relationships = {};
|
|
189
|
+
for (const field of fields) {
|
|
190
|
+
if (field.type === 'reference' && field.relationshipName)
|
|
191
|
+
relationships[field.relationshipName] = field.name;
|
|
192
|
+
}
|
|
193
|
+
return relationships;
|
|
163
194
|
}
|
|
164
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* The object each createable lookup points to. A polymorphic lookup (`WhatId`, `OwnerId`) gets
|
|
197
|
+
* the running user when it can point at users, else the first object a test can insert.
|
|
198
|
+
*/
|
|
165
199
|
export function lookupTargets(fields) {
|
|
166
200
|
const targets = {};
|
|
167
201
|
for (const field of fields) {
|
|
168
202
|
if (field.type !== 'reference' || !field.createable || field.calculated)
|
|
169
203
|
continue;
|
|
170
|
-
|
|
171
|
-
|
|
204
|
+
const options = field.referenceTo ?? [];
|
|
205
|
+
const target = options.length === 1
|
|
206
|
+
? options[0]
|
|
207
|
+
: (options.find((o) => o in EXISTING_RECORD_IDS) ?? options.find((o) => canInsertParent(o)));
|
|
208
|
+
if (target)
|
|
209
|
+
targets[field.name] = target;
|
|
172
210
|
}
|
|
173
211
|
return targets;
|
|
174
212
|
}
|
|
@@ -180,19 +218,30 @@ export async function loadObjectFields(objects, describe, into = emptyObjectFiel
|
|
|
180
218
|
for (const object of [...new Set(objects)]) {
|
|
181
219
|
if (object in into.requiredFields)
|
|
182
220
|
continue;
|
|
183
|
-
let
|
|
221
|
+
let result;
|
|
184
222
|
try {
|
|
185
|
-
|
|
223
|
+
result = await describe(object);
|
|
186
224
|
}
|
|
187
225
|
catch {
|
|
188
|
-
|
|
226
|
+
result = undefined;
|
|
227
|
+
}
|
|
228
|
+
const fields = Array.isArray(result) ? result : result?.fields;
|
|
229
|
+
if (result && !Array.isArray(result) && result.recordTypeInfos) {
|
|
230
|
+
into.recordTypes[object] = result.recordTypeInfos.length;
|
|
189
231
|
}
|
|
190
232
|
if (fields) {
|
|
191
233
|
into.requiredFields[object] = requiredFieldValues(fields);
|
|
192
234
|
into.fieldValues[object] = settableFieldValues(fields);
|
|
193
235
|
into.changedValues[object] = changedFieldValues(fields);
|
|
194
236
|
into.lookups[object] = lookupTargets(fields);
|
|
195
|
-
into.
|
|
237
|
+
into.relationships[object] = relationshipLookups(fields);
|
|
238
|
+
into.unsetValues[object] = unsetFieldValues(fields, into.recordTypes[object]);
|
|
239
|
+
into.readOnlyFields[object] = fields
|
|
240
|
+
.filter((f) => !f.createable || f.calculated || f.autoNumber)
|
|
241
|
+
.map((f) => f.name);
|
|
242
|
+
into.createOnlyFields[object] = fields
|
|
243
|
+
.filter((f) => f.createable && !f.calculated && !f.autoNumber && f.updateable === false)
|
|
244
|
+
.map((f) => f.name);
|
|
196
245
|
}
|
|
197
246
|
}
|
|
198
247
|
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;
|
|
1
|
+
{"version":3,"file":"requiredFields.js","sourceRoot":"","sources":["../../src/core/requiredFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AA+BhD,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,iBAAiB,CAA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;YACzD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9E,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;iBACjC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,CAAC;iBAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,MAAM;iBACnC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,KAAK,KAAK,CAAC;iBACvF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/lib/core/scaffold.js
CHANGED
|
@@ -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 {
|
|
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
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
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] ?? {}) ||
|
|
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
|
-
|
|
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);
|
package/lib/core/scaffold.js.map
CHANGED
|
@@ -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,kBAAkB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE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AAG,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;
|
package/lib/core/toolingQuery.js
CHANGED
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"toolingQuery.js","sourceRoot":"","sources":["../../src/core/toolingQuery.ts"],"names":[],"mappings":"AAMA,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,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,UAAqC;IAC7D,OAAO,KAAK,EAAqC,IAAY,EAAgB,EAAE,CAC7E,CAAC,MAAM,UAAU,CAAC,KAAK,CAAI,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACxF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,UAAwC;IACnE,OAAO,KAAK,EAAE,IAAY,EAAE,QAAgB,EAAoB,EAAE,CAChE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAqD,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,cAAc,CAAC,UAAwC;IACrE,OAAO,KAAK,EAAE,UAAkB,EAA2B,EAAE;QAC3D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;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(warning);
|
|
60
|
+
return report;
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IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/lib/core/types.d.ts
CHANGED
|
@@ -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';
|