From 81acb166d5d29ef789e659cfa3b3c7a2def891ef Mon Sep 17 00:00:00 2001 From: Buhle Date: Tue, 14 Nov 2023 15:46:57 +0200 Subject: [PATCH] Check activation after status and set it to null if activation is inactive --- go-app-ussd_tb_check.js | 10 +++++++++- src/ussd_tb_check.js | 10 +++++++++- test/ussd_tb_check.test.js | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/go-app-ussd_tb_check.js b/go-app-ussd_tb_check.js index fc5bb498..8e06470f 100644 --- a/go-app-ussd_tb_check.js +++ b/go-app-ussd_tb_check.js @@ -217,7 +217,13 @@ go.app = function () { self.states.add("state_get_contact", function (name, opts) { var msisdn = utils.normalize_msisdn(self.im.user.addr, "ZA"); - var activation = self.get_activation(); + var activation; + if (self.im.user.answers.activation !== undefined){ + activation = self.im.user.answers.activation; + } + else{ + activation = self.get_activation(); + } if (activation === "tb_study_a_survey_group1" || activation === "tb_study_a_survey_group2") { return self.states.create("state_survey_start"); @@ -1325,10 +1331,12 @@ go.app = function () { var is_active = response.data.is_activation_active; if (is_active){ + self.im.user.answers.state_city = activation; return self.states.create("state_get_contact"); } else{ // Set activation to Null if activation is not active + self.im.user.answers.state_city = undefined; return self.states.create("state_reached_capacity"); } }, diff --git a/src/ussd_tb_check.js b/src/ussd_tb_check.js index 2b64867b..e1069b9b 100644 --- a/src/ussd_tb_check.js +++ b/src/ussd_tb_check.js @@ -100,7 +100,13 @@ go.app = function () { self.states.add("state_get_contact", function (name, opts) { var msisdn = utils.normalize_msisdn(self.im.user.addr, "ZA"); - var activation = self.get_activation(); + var activation; + if (self.im.user.answers.activation !== undefined){ + activation = self.im.user.answers.activation; + } + else{ + activation = self.get_activation(); + } if (activation === "tb_study_a_survey_group1" || activation === "tb_study_a_survey_group2") { return self.states.create("state_survey_start"); @@ -1208,10 +1214,12 @@ go.app = function () { var is_active = response.data.is_activation_active; if (is_active){ + self.im.user.answers.state_city = activation; return self.states.create("state_get_contact"); } else{ // Set activation to Null if activation is not active + self.im.user.answers.state_city = undefined; return self.states.create("state_reached_capacity"); } }, diff --git a/test/ussd_tb_check.test.js b/test/ussd_tb_check.test.js index 1e97dca8..6394ed52 100644 --- a/test/ussd_tb_check.test.js +++ b/test/ussd_tb_check.test.js @@ -56,6 +56,7 @@ describe("ussd_tb_check app", function () { describe("set_activation", function() { it("should set activation for new user", function() { return tester + .setup.user.state("state_get_contact") .setup(function (api) { api.http.fixtures.add({ request: { @@ -2240,7 +2241,7 @@ describe("ussd_tb_check app", function () { it("state_start skip to survey", function() { return tester - .setup.user.state("state_start") + .setup.user.state("state_get_contact") .inputs({ session_event: "continue", to_addr: "*123*123*5#" }) .check.user.state("state_survey_start") .run();