Skip to content

Commit

Permalink
Make progressBarType:requiredQuestions stable
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Aug 21, 2023
1 parent e842725 commit 349dd0e
Showing 1 changed file with 71 additions and 8 deletions.
79 changes: 71 additions & 8 deletions testCafe/survey/progressBarType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { Selector, ClientFunction } from "testcafe";

const title = "progressBarType";

const json = {
const json_questions = {
showProgressBar: "top",
progressBarType: "questions",
pages: [
{
elements: [
Expand Down Expand Up @@ -36,6 +37,72 @@ const json = {
]
};

const json_requiredQuestions = {
showProgressBar: "top",
progressBarType: "requiredQuestions",
pages: [
{
elements: [
{
type: "text",
isRequired: true,
inputType: "email",
name: "q1"
},
{
type: "text",
name: "q2"
}
]
},
{
elements: [
{
type: "text",
isRequired: true,
name: "q3"
},
{
type: "text",
name: "q4"
}
]
}
]
};

const json_toc = {
showTOC: true,
pages: [
{
elements: [
{
type: "text",
inputType: "email",
name: "q1"
},
{
type: "text",
name: "q2"
}
]
},
{
elements: [
{
type: "text",
isRequired: true,
name: "q3"
},
{
type: "text",
name: "q4"
}
]
}
]
};

const setProgressBarType_questions = ClientFunction(() => {
window["survey"].progressBarType = "";
window["survey"].render();
Expand All @@ -47,27 +114,23 @@ frameworks.forEach(async framework => {
}
);
test("progressBarType:questions", async t => {
json["progressBarType"] = "questions";
await initSurvey(framework, json);
await initSurvey(framework, json_questions);
await t.wait(1000);
await t.expect(Selector("span").withText("Answered 0/4 questions").exists).ok()
.typeText("input[type=email]", "stub@gmail.com")
.pressKey("tab")
.expect(Selector("span").withText("Answered 1/4 questions").exists).ok();
});
test("progressBarType:requiredQuestions", async t => {
json["progressBarType"] = "requiredQuestions";
await initSurvey(framework, json);
await initSurvey(framework, json_requiredQuestions);
await t.wait(1000);
await t.expect(Selector("span").withText("Answered 0/2 questions").exists).ok()
.typeText("input[type=email]", "stub@gmail.com")
.pressKey("tab")
.expect(Selector("span").withText("Answered 1/2 questions").exists).ok();
});
test("navigation:toc", async t => {
json["showTOC"] = true;
json["pages"][0]["elements"][0]["isRequired"] = false;
await initSurvey(framework, json);
await initSurvey(framework, json_toc);
await t.wait(1000);
const page1 = Selector(".sv-list__item-body").withText("page1");
const page2 = Selector(".sv-list__item-body").withText("page2");
Expand Down

0 comments on commit 349dd0e

Please sign in to comment.