Skip to content

Commit

Permalink
Fixed vr-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Feb 12, 2024
1 parent 5af3311 commit 2efeeaf
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions visualRegressionTests/tests/defaultV2/file.ts
Expand Up @@ -24,37 +24,49 @@ const json = {
maxWidth: "704px",
}]
};
function onOpenFileChooserHandler(s, o) {
var files = [];
for (var i = 0; i < o.input.files.length; i++) {
files.push(o.input.files[i]);
}
o.callback(files);
}

frameworks.forEach(framework => {
fixture`${framework} ${title} ${theme}`
.page`${url_test}${theme}/${framework}`.beforeEach(async t => {
await applyTheme(theme);
await initSurvey(framework, json);
await ClientFunction(() => {
document.body.focus();
})();
});
await applyTheme(theme);
await initSurvey(framework, json, { onOpenFileChooser: onOpenFileChooserHandler });
await ClientFunction(() => {
document.body.focus();
})();
});

test("Check file question", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1920, 1080);
await t.setFilesToUpload(Selector(".sd-file input"), ["files/SingleImage.jpg"]);
await t.click(".sd-file input[type=file] + div label");

const questionRoot = Selector(".sd-question");
await takeElementScreenshot("file-question-single-image.png", questionRoot, t, comparer);
await t.setFilesToUpload(Selector(".sd-file input"), ["files/Flamingo.png"]);
await t.click(".sd-file input[type=file] + div label");
await takeElementScreenshot("file-question-single-file-small-image.png", questionRoot, t, comparer);
await t.setFilesToUpload(Selector(".sd-file input"), ["files/Portfolio.pdf"]);
await t.click(".sd-file input[type=file] + div label");
await takeElementScreenshot("file-question-single-file.png", questionRoot, t, comparer);
await ClientFunction(() => {
const question = (window as any).survey.getQuestionByName("file_question");
question.allowMultiple = true;
question.clear();
})();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/Badger.png", "files/Bird.png", "files/Read Me.txt", "files/Flamingo.png"]);
await t.click(".sd-file input[type=file] + div label");
await takeElementScreenshot("file-question-multiple.png", questionRoot, t, comparer);
await t
.setFilesToUpload(Selector(".sd-file input"), ["files/SingleImage.jpg"])
.click(".sd-file input[type=file] + div label")
.click(Selector(".sd-file #prevPage"));
await takeElementScreenshot("file-question-multiple-navigator.png", questionRoot, t, comparer);
});
Expand All @@ -69,6 +81,7 @@ frameworks.forEach(framework => {
question.imageHeight = "100px";
})();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/SingleImage.jpg"]);
await t.click(".sd-file input[type=file] + div label");
const questionRoot = Selector(".sd-question");
await takeElementScreenshot("file-question-single-small-image.png", questionRoot, t, comparer);

Expand All @@ -87,6 +100,7 @@ frameworks.forEach(framework => {
question.clear();
})();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/Badger.png", "files/Bird.png", "files/Flamingo.png"]);
await t.click(".sd-file input[type=file] + div label");
await takeElementScreenshot("file-question-multiple-small-images.png", questionRoot, t, comparer);

await ClientFunction(() => {
Expand Down Expand Up @@ -131,13 +145,15 @@ frameworks.forEach(framework => {
(window as any).survey.getAllQuestions()[0].setIsMobile(true);
})();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/SingleImage.jpg"]);
await t.click(".sd-file input[type=file] + div label");
const questionRoot = Selector(".sd-question");
await ClientFunction(() => {
const question = (window as any).survey.getQuestionByName("file_question");
question.allowMultiple = true;
question.clear();
})();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/Badger.png", "files/Bird.png", "files/Read Me.txt", "files/Flamingo.png"]);
await t.click(".sd-file input[type=file] + div label");
await ClientFunction(() => {
const question = (window as any).survey.getQuestionByName("file_question");
question.indexToShow = 0;
Expand Down Expand Up @@ -170,7 +186,7 @@ frameworks.forEach(framework => {
frameworks.forEach(framework => {
fixture`${framework} ${title} ${theme}`
.page`${url_test}${theme}/${framework}`.beforeEach(async t => {
});
});
test("Check file question placeholder mobile", async t => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(600, 1000);
Expand All @@ -180,7 +196,7 @@ frameworks.forEach(framework => {
type: "file",
title: "Upload everything what you’d like to.",
name: "file_question",
}]
}, { onOpenFileChooser: onOpenFileChooserHandler }]
});
await resetFocusToBody();
const questionRoot = Selector(".sd-question");
Expand Down Expand Up @@ -214,7 +230,7 @@ frameworks.forEach(framework => {
startWithNewLine: false
}
]
});
}, { onOpenFileChooser: onOpenFileChooserHandler });
await t.resizeWindow(1920, 1080);
await resetFocusToBody();
const questionRoot = Selector(".sd-question");
Expand All @@ -241,7 +257,7 @@ frameworks.forEach(framework => {
frameworks.forEach(framework => {
fixture`${framework} ${title} ${theme}`
.page`${url_test}${theme}/${framework}`.beforeEach(async t => {
});
});
test("Check file question camera", async t => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1980, 1000);
Expand All @@ -256,7 +272,7 @@ frameworks.forEach(framework => {
width: "704px",
maxWidth: "704px",
name: "file_question",
}]
}, { onOpenFileChooser: onOpenFileChooserHandler }]
});
await resetFocusToBody();
const questionRoot = Selector(".sd-question");
Expand All @@ -268,6 +284,7 @@ frameworks.forEach(framework => {
await takeElementScreenshot("file-question-video.png", questionRoot, t, comparer);
await ClientFunction(() => { (window as any).survey.getAllQuestions()[0].setPropertyValue("isPlayingVideo", false); })();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/Read Me.txt"]);
await t.click(".sd-file input[type=file] + div label");
await takeElementScreenshot("file-question-both-mode-answered.png", questionRoot, t, comparer);
});
});
Expand Down

0 comments on commit 2efeeaf

Please sign in to comment.