Skip to content

Commit

Permalink
Check activation after status and set it to null if activation is ina…
Browse files Browse the repository at this point in the history
…ctive
  • Loading branch information
Buhle79 committed Nov 14, 2023
1 parent de4867b commit 81acb16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 9 additions & 1 deletion go-app-ussd_tb_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
},
Expand Down
10 changes: 9 additions & 1 deletion src/ussd_tb_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
},
Expand Down
3 changes: 2 additions & 1 deletion test/ussd_tb_check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 81acb16

Please sign in to comment.