From 10f01389115a957e537ac7ca4e98c4388f3f4705 Mon Sep 17 00:00:00 2001
From: jonycoo
Date: Thu, 26 Oct 2023 16:48:08 +0200
Subject: [PATCH] fix Story Status after Scenario execution
---
backend/src/serverHelper.js | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/backend/src/serverHelper.js b/backend/src/serverHelper.js
index b8789907a..9fee04b51 100644
--- a/backend/src/serverHelper.js
+++ b/backend/src/serverHelper.js
@@ -337,9 +337,17 @@ async function updateStoryTestStatus(storyId, storyLastTestStatus, scenarioStatu
async function updateScenarioTestStatus(uploadedReport) {
try {
- await mongo.updateScenarioStatus(uploadedReport.storyId, uploadedReport.scenarioId, uploadedReport.status);
+ let storyStatus = uploadedReport.status;
+ if (uploadedReport.status === true) {
+ const scenarios = await mongo.getOneStory(uploadedReport.storyId).then((story) => story.scenarios);
+ const updateIndex = scenarios.findIndex((scen) => scen.scenario_id === uploadedReport.scenarioId);
+ console.log(scenarios, storyStatus, updateIndex, uploadedReport.scenarioId);
+ scenarios[updateIndex].lastTestPassed = uploadedReport.status;
+ storyStatus = scenarios.every((scen) => !!scen.lastTestPassed === true);
+ }
+ updateStoryTestStatus(uploadedReport.storyId, storyStatus, [{ scenarioId: uploadedReport.scenarioId, status: uploadedReport.status }]);
} catch (e) {
- console.log('Could not Update Scenario LastTestPassed.');
+ console.log('Could not Update Scenario LastTestPassed.', e);
}
}