Skip to content

Commit

Permalink
Change the progress bar calculation if type is "pages" fix #6563 (#6565)
Browse files Browse the repository at this point in the history
* Change the progress bar calculation if type is "pages" fix #6563

* Fix etalon for progress-bar images #6563
  • Loading branch information
andrewtelnov authored Jul 23, 2023
1 parent c6404eb commit 2f09f6a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3275,7 +3275,7 @@ export class SurveyModel extends SurveyElementCore
: 100;
}
const visPages = this.visiblePages;
var index = visPages.indexOf(this.currentPage) + 1;
var index = visPages.indexOf(this.currentPage);
return Math.ceil((index * 100) / visPages.length);
}
/**
Expand Down
28 changes: 28 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,34 @@ QUnit.test(
);
}
);
QUnit.test("survey.progressBarType = 'pages', Bug #6563",
function (assert) {
var survey = new SurveyModel({
progressBarType: "pages",
pages: [
{ elements: [{ type: "text", name: "q1" }] },
{ elements: [{ type: "text", name: "q2" }] },
{ elements: [{ type: "text", name: "q3" }] },
{ elements: [{ type: "text", name: "q1" }] },
]
});
assert.equal(survey.getProgress(), 0, "page1 #1");
assert.equal(survey.progressValue, 0, "page1 #2");
assert.equal(survey.progressText, "Page 1 of 4", "page1, #3");
survey.nextPage();
assert.equal(survey.getProgress(), 25, "page2 #1");
assert.equal(survey.progressValue, 25, "page2 #2");
assert.equal(survey.progressText, "Page 2 of 4", "page2, #3");
survey.nextPage();
assert.equal(survey.getProgress(), 50, "page3 #1");
assert.equal(survey.progressValue, 50, "page3 #2");
assert.equal(survey.progressText, "Page 3 of 4", "page3, #3");
survey.nextPage();
assert.equal(survey.getProgress(), 75, "page4 #1");
assert.equal(survey.progressValue, 75, "page4 #2");
assert.equal(survey.progressText, "Page 4 of 4", "page4, #3");
}
);
QUnit.test("Next, Prev, Next", function (assert) {
var survey = new SurveyModel();
survey.addPage(createPageWithQuestion("Page 1"));
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2f09f6a

Please sign in to comment.