Skip to content

Commit

Permalink
work for #8530
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Jul 11, 2024
1 parent e8a2abc commit e8b8870
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3330,7 +3330,9 @@ export class SurveyModel extends SurveyElementCore
}
private updateActivePage(): void {
const newPage = this.isShowStartingPage ? this.startedPage : this.currentPage;
this.setPropertyValue("activePage", newPage);
if (newPage !== this.activePage) {
this.setPropertyValue("activePage", newPage);
}
}
private onStateAndCurrentPageChanged(): void {
this.updateActivePage();
Expand Down Expand Up @@ -6073,11 +6075,11 @@ export class SurveyModel extends SurveyElementCore
isCompleted: string,
response: any
) {
self.isLoading = false;
if (success) {
self.isCompletedBefore = isCompleted == "completed";
self.loadSurveyFromServiceJson(json);
}
self.isLoading = false;
}
);
} else {
Expand All @@ -6086,10 +6088,10 @@ export class SurveyModel extends SurveyElementCore
result: string,
response: any
) {
self.isLoading = false;
if (success) {
self.loadSurveyFromServiceJson(result);
}
self.isLoading = false;
});
}
}
Expand Down
43 changes: 43 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6587,6 +6587,49 @@ QUnit.test("surveyId + clientId", function (assert) {
assert.equal(q1.name, "q1", "The survey created from the string");
});

QUnit.test("surveyId + clientId several page render", function (assert) {
let log = "";
let curState = "";
const json = { questions: [{ type: "text", name: "q1" }] };
class dxSurveyServiceTester extends dxSurveyService {
public getSurveyJsonAndIsCompleted(surveyId: string, clientId: string, onLoad: (success: boolean, surveyJson: any, result: string, response: any) => void) {
if (onLoad) {
onLoad(true, json, clientId, "");
}
}
}
class SurveyTester extends SurveyModel {
protected createSurveyService(): dxSurveyService {
return new dxSurveyServiceTester();
}
protected propertyValueChanged(name: string, oldValue: any, newValue: any, arrayChanges?: ArrayChanges, target?: Base): void {
super.propertyValueChanged(name, oldValue, newValue, arrayChanges);
if (name === "isLoading" || name === "state" || name === "activePage") {
log += ("-> " + name + ":" + newValue);
}
}
protected onLoadSurveyFromService(): void {
super.onLoadSurveyFromService();
curState = this.state;
assert.equal(curState, "loading");
}
protected setPropertyValueDirectly(name: string, val: any): void {
if (name === "activePage" && !!val) {
assert.ok(this.activePage === undefined, "this.activePage undefined");
assert.ok(!!val, "new activePage");
}
super.setPropertyValueDirectly(name, val);
}
}

let survey = new SurveyTester({ surveyId: "surveyDummyId", clientId: "completed" });
assert.equal(survey.state, "completedbefore", "The survey is running");
assert.equal(log, "-> state:empty-> state:loading-> isLoading:true-> activePage:page1-> state:completedbefore-> isLoading:false");

let q1 = survey.getQuestionByName("q1");
assert.equal(q1.name, "q1", "The survey created from the string");
});

QUnit.test(
"Question description and text processing, variable, Bug #632",
function (assert) {
Expand Down

0 comments on commit e8b8870

Please sign in to comment.