@ondc/automation-mock-runner 1.3.36 → 1.3.38
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/dist/lib/configHelper.js
CHANGED
|
@@ -229,7 +229,7 @@ async function buildConfigFromFlowConfig(payloads, flowConfig, domain, version,
|
|
|
229
229
|
flowConfig = JSON.parse(JSON.stringify(flowConfig));
|
|
230
230
|
payloads = [...payloads].sort((a, b) => new Date(a.context.timestamp).getTime() -
|
|
231
231
|
new Date(b.context.timestamp).getTime());
|
|
232
|
-
const config = createInitialMockConfig(domain, version, `${flowConfig.id}
|
|
232
|
+
const config = createInitialMockConfig(domain, version, `${flowConfig.id}`);
|
|
233
233
|
const mockRunner = new MockRunner_1.MockRunner(config);
|
|
234
234
|
let index = 0;
|
|
235
235
|
for (const step of flowConfig.sequence) {
|
|
@@ -257,7 +257,7 @@ async function buildConfigFromFlowConfig(payloads, flowConfig, domain, version,
|
|
|
257
257
|
if (step.input && step.input.length > 0 && step.input[0].jsonSchema) {
|
|
258
258
|
stepConfig.mock.inputs = step.input[0];
|
|
259
259
|
}
|
|
260
|
-
else {
|
|
260
|
+
else if (step.input && step.input.length > 0) {
|
|
261
261
|
stepConfig.mock.inputs.oldInputs = step.input;
|
|
262
262
|
stepConfig.mock.inputs.id = `old_inputs`;
|
|
263
263
|
}
|
|
@@ -35,12 +35,13 @@ function validateGoodConfig(config) {
|
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
37
|
if (step.mock.inputs !== undefined &&
|
|
38
|
+
step.mock.inputs.oldInputs === undefined &&
|
|
38
39
|
Object.keys(step.mock.inputs).length > 0) {
|
|
39
40
|
if (id === undefined || id === null) {
|
|
40
41
|
errors.push(` • ${label}: inputs.id is required when inputs is defined`);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
if (id !== undefined) {
|
|
44
|
+
if (id !== undefined && step.mock.inputs.oldInputs === undefined) {
|
|
44
45
|
if (sampleData === undefined || sampleData === null) {
|
|
45
46
|
errors.push(` • ${label}: inputs.sampleData is required when inputs.id is set`);
|
|
46
47
|
}
|
|
@@ -675,7 +675,7 @@ describe("configHelper", () => {
|
|
|
675
675
|
const config = await (0, configHelper_1.generatePlaygroundConfigFromFlowConfig)(payloads, flowConfig);
|
|
676
676
|
expect(config.meta.domain).toBe("ONDC:TRV14");
|
|
677
677
|
expect(config.meta.version).toBe("1.5.0");
|
|
678
|
-
expect(config.meta.flowId).toBe("
|
|
678
|
+
expect(config.meta.flowId).toBe("sample_flow");
|
|
679
679
|
expect(config.steps).toHaveLength(2);
|
|
680
680
|
const [searchStepConfig, onSearchStepConfig] = config.steps;
|
|
681
681
|
expect(searchStepConfig.api).toBe("search");
|
|
@@ -716,7 +716,7 @@ describe("configHelper", () => {
|
|
|
716
716
|
const config = await (0, configHelper_1.generatePlaygroundConfigFromFlowConfig)(payloads, flowConfig);
|
|
717
717
|
expect(config.meta.domain).toBe("ONDC:FIS12");
|
|
718
718
|
expect(config.meta.version).toBe("1.0.0");
|
|
719
|
-
expect(config.meta.flowId).toBe("
|
|
719
|
+
expect(config.meta.flowId).toBe("core_version_flow");
|
|
720
720
|
});
|
|
721
721
|
it("should handle multiple search requests with different timestamps interspersed with on_search responses", async () => {
|
|
722
722
|
const payloads = [
|