@getjones/test-infra 4.5.30 → 4.5.31
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/package.json +1 -1
- package/src/common/commonFlows/records/records.js +1 -1
- package/src/common/utils/arrayUtils.js +14 -1
- package/src/common/utils/objectUtils.js +24 -1
- package/src/env.js +2 -1
- package/src/resources/coi/realCoiAcord101.pdf +0 -0
- package/src/saas/internal-api/compliance/api/complianceSnapshot/compliance.snapshot.service.js +7 -7
package/package.json
CHANGED
|
@@ -211,7 +211,7 @@ const waitForOcrStatus = async function(recordId, context, { expectedStatus = oc
|
|
|
211
211
|
|
|
212
212
|
const waitForAiAnalysisStatus = async (recordId, context, { expectedStatus = ocrStatuses.SUCCESS, isCheckPreviousCoi = false } = {}) => {
|
|
213
213
|
const timeout = expectedStatus === ocrStatuses.IN_PROGRESS ? 1 : 5;
|
|
214
|
-
let retries =
|
|
214
|
+
let retries = 25;
|
|
215
215
|
let isExpectedStatus = false;
|
|
216
216
|
|
|
217
217
|
do {
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
const formatToStringList = input =>
|
|
2
2
|
Array.isArray(input) ? input.join(',') : input;
|
|
3
3
|
|
|
4
|
+
const shallowSort = input => {
|
|
5
|
+
if (!Array.isArray(input)) {
|
|
6
|
+
return input;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return [... input].sort((a, b) => {
|
|
10
|
+
const aKey = JSON.stringify(a);
|
|
11
|
+
const bKey = JSON.stringify(b);
|
|
12
|
+
return aKey < bKey ? -1 : aKey > bKey ? 1 : 0;
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
4
16
|
module.exports = {
|
|
5
|
-
formatToStringList
|
|
17
|
+
formatToStringList,
|
|
18
|
+
shallowSort
|
|
6
19
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const flatten = require('flat');
|
|
2
|
+
const { diff } = require('deep-diff');
|
|
3
|
+
|
|
1
4
|
const cloneObject = object => {
|
|
2
5
|
return JSON.parse(JSON.stringify(object));
|
|
3
6
|
};
|
|
@@ -27,8 +30,28 @@ const removeNullValuesFromObject = obj => {
|
|
|
27
30
|
);
|
|
28
31
|
};
|
|
29
32
|
|
|
33
|
+
function objectMatchScore(actual, expected) {
|
|
34
|
+
const actualValue = flatten(actual);
|
|
35
|
+
const expectedValue = flatten(expected);
|
|
36
|
+
|
|
37
|
+
const differences = diff(expectedValue, actualValue) || [];
|
|
38
|
+
|
|
39
|
+
const totalKeys = new Set([... Object.keys(expectedValue), ... Object.keys(actualValue)]).size;
|
|
40
|
+
const score = Math.round(((totalKeys - differences.length) / totalKeys) * 100);
|
|
41
|
+
|
|
42
|
+
if (differences.length) {
|
|
43
|
+
console.log(`${differences.length} mismatches, matching score: ${score}%`);
|
|
44
|
+
differences.forEach(d =>
|
|
45
|
+
console.log(`value difference for: ${d.path.join('.')}- expected:`, d.lhs, ', actual:', d.rhs)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { score, differences };
|
|
50
|
+
}
|
|
51
|
+
|
|
30
52
|
module.exports = {
|
|
31
53
|
cloneObject,
|
|
32
54
|
removeObjectKeys,
|
|
33
|
-
removeNullValuesFromObject
|
|
55
|
+
removeNullValuesFromObject,
|
|
56
|
+
objectMatchScore
|
|
34
57
|
};
|
package/src/env.js
CHANGED
|
Binary file
|
package/src/saas/internal-api/compliance/api/complianceSnapshot/compliance.snapshot.service.js
CHANGED
|
@@ -43,24 +43,24 @@ const getSnapshotAiReport = async (recordId, context, { expectError } = {}) => {
|
|
|
43
43
|
return response;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const waitForSnapshotAiAnalysisStatus = async (recordId, context, { expectedStatus = aiAnalysisStatuses.SUCCESS, retries = 15 } = {}) => {
|
|
47
47
|
let { data: aiAnalysisStatus } = await getSnapshotAiAnalysisStatus(recordId, context);
|
|
48
48
|
|
|
49
|
-
while (aiAnalysisStatus !==
|
|
49
|
+
while (aiAnalysisStatus !== expectedStatus && retries > 0) {
|
|
50
50
|
await timeUtils.waitFor(5).seconds;
|
|
51
|
-
console.log(`Waiting for snapshot ai analysis to be
|
|
51
|
+
console.log(`Waiting for snapshot ai analysis to be ${expectedStatus}, retries left: ${retries}`);
|
|
52
52
|
const aiAnalysisStatusResponse = await getSnapshotAiAnalysisStatus(recordId, context);
|
|
53
53
|
aiAnalysisStatus = aiAnalysisStatusResponse.data;
|
|
54
54
|
|
|
55
55
|
if (aiAnalysisStatus === aiAnalysisStatuses.UNKNOWN || aiAnalysisStatus === aiAnalysisStatuses.FAILED) {
|
|
56
|
-
throw new Error(`
|
|
56
|
+
throw new Error(`actual status is ${aiAnalysisStatus}, expected to be ${expectedStatus}`);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
retries--;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
if (aiAnalysisStatus !==
|
|
63
|
-
throw new Error(`
|
|
62
|
+
if (aiAnalysisStatus !== expectedStatus) {
|
|
63
|
+
throw new Error(`actual status is ${aiAnalysisStatus}, expected to be ${expectedStatus}`);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
|
|
@@ -69,5 +69,5 @@ module.exports = {
|
|
|
69
69
|
initiateSnapshotAiAnalysis,
|
|
70
70
|
getSnapshotAiAnalysisStatus,
|
|
71
71
|
getSnapshotAiReport,
|
|
72
|
-
|
|
72
|
+
waitForSnapshotAiAnalysisStatus
|
|
73
73
|
};
|