Skip to content

Commit

Permalink
Broken page counter on the survey preview tab when the Designer tab i…
Browse files Browse the repository at this point in the history
…s hidden fix #5277 (#5281)
  • Loading branch information
andrewtelnov committed Feb 29, 2024
1 parent 3473909 commit 20d35cf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/survey-creator-core/src/components/tabs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class TestSurveyTabViewModel extends Base {
component: "svc-complete-page",
data: this
});
const hasSurveyBefore = !!this.simulator.survey;
this.simulator.survey = newSurvey;
if (this.onSurveyCreatedCallback) this.onSurveyCreatedCallback(this.survey);
this.survey.onComplete.add((sender: SurveyModel) => {
Expand Down Expand Up @@ -126,6 +127,9 @@ export class TestSurveyTabViewModel extends Base {
this.updatePageItem(options.page);
this.updatePrevNextPageActionState();
});
if(hasSurveyBefore) {
this.show();
}
}

public setJSON(json: any, currTheme: any) {
Expand Down
36 changes: 35 additions & 1 deletion packages/survey-creator-core/tests/tabs/test.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { editorLocalization } from "../../src/editorLocalization";
import "survey-core/survey.i18n";

function getTestModel(creator: CreatorTester): TestSurveyTabViewModel {
creator.activeTab = "test";
if(creator.activeTab !== "test") {
creator.activeTab = "test";
}
const testPlugin: TabTestPlugin = <TabTestPlugin>creator.getPlugin("test");
return testPlugin.model;
}
Expand Down Expand Up @@ -169,6 +171,38 @@ test("Enable/disable nextPage action on page visibility change and page actions,
expect(pageList.actions[1].enabled).toBeTruthy(); //TestSurveyTabViewModel.enableInvisiblePages = true
expect(nextPage.enabled).toBeFalsy();
});
test("Page action title when the preview shows only, Bug#5277", (): any => {
const creator: CreatorTester = new CreatorTester({
showJSONEditorTab: false,
showDesignerTab: false
});
creator.JSON = {
pages: [
{
name: "page1",
elements: [
{
type: "text",
name: "q1"
}
]
},
{
name: "page2",
elements: [
{
type: "text",
name: "q2",
}
]
}
]
};
expect(creator.activeTab).toEqual("test");
const model: TestSurveyTabViewModel = getTestModel(creator);
const pageSelectorAction = model.pageActions.filter((item: IAction) => item.id === "pageSelector")[0];
expect(pageSelectorAction.title).toEqual("Page 1");
});
test("Show/hide device similator", (): any => {
let creator: CreatorTester = new CreatorTester();
creator.JSON = {
Expand Down

0 comments on commit 20d35cf

Please sign in to comment.