mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-20 19:30:41 -05:00
feat: adds e2e tests
This commit is contained in:
+6
-1
@@ -90,6 +90,7 @@ export function AdvancedLogicEditorActions({
|
||||
<div className="block w-9 shrink-0">{idx === 0 ? "Then" : "and"}</div>
|
||||
<div className="flex grow items-center gap-x-2">
|
||||
<InputCombobox
|
||||
id={`action-${idx}-objective`}
|
||||
key="objective"
|
||||
showSearch={false}
|
||||
options={actionObjectiveOptions}
|
||||
@@ -101,6 +102,7 @@ export function AdvancedLogicEditorActions({
|
||||
/>
|
||||
{action.objective !== "calculate" && (
|
||||
<InputCombobox
|
||||
id={`action-${idx}-target`}
|
||||
key="target"
|
||||
showSearch={false}
|
||||
options={getActionTargetOptions(action, localSurvey, questionIdx)}
|
||||
@@ -116,6 +118,7 @@ export function AdvancedLogicEditorActions({
|
||||
{action.objective === "calculate" && (
|
||||
<>
|
||||
<InputCombobox
|
||||
id={`action-${idx}-variableId`}
|
||||
key="variableId"
|
||||
showSearch={false}
|
||||
options={getActionVariableOptions(localSurvey)}
|
||||
@@ -133,6 +136,7 @@ export function AdvancedLogicEditorActions({
|
||||
emptyDropdownText="Add a variable to calculate"
|
||||
/>
|
||||
<InputCombobox
|
||||
id={`action-${idx}-operator`}
|
||||
key="operator"
|
||||
showSearch={false}
|
||||
options={getActionOpeartorOptions(
|
||||
@@ -149,6 +153,7 @@ export function AdvancedLogicEditorActions({
|
||||
comboboxClasses="grow"
|
||||
/>
|
||||
<InputCombobox
|
||||
id={`action-${idx}-value`}
|
||||
key="value"
|
||||
withInput={true}
|
||||
clearable={true}
|
||||
@@ -183,7 +188,7 @@ export function AdvancedLogicEditorActions({
|
||||
)}
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger>
|
||||
<DropdownMenuTrigger id={`actions-${idx}-dropdown`}>
|
||||
<MoreVerticalIcon className="h-4 w-4" />
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
|
||||
+4
-1
@@ -256,6 +256,7 @@ export function AdvancedLogicEditorConditions({
|
||||
)}
|
||||
</div>
|
||||
<InputCombobox
|
||||
id={`condition-${depth}-${index}-conditionValue`}
|
||||
key="conditionValue"
|
||||
showSearch={false}
|
||||
groupedOptions={conditionValueOptions}
|
||||
@@ -266,6 +267,7 @@ export function AdvancedLogicEditorConditions({
|
||||
comboboxClasses="grow"
|
||||
/>
|
||||
<InputCombobox
|
||||
id={`condition-${depth}-${index}-conditionOperator`}
|
||||
key="conditionOperator"
|
||||
showSearch={false}
|
||||
options={conditionOperatorOptions}
|
||||
@@ -277,6 +279,7 @@ export function AdvancedLogicEditorConditions({
|
||||
/>
|
||||
{show && (
|
||||
<InputCombobox
|
||||
id={`condition-${depth}-${index}-conditionMatchValue`}
|
||||
withInput={showInput}
|
||||
inputProps={{
|
||||
type: inputType,
|
||||
@@ -295,7 +298,7 @@ export function AdvancedLogicEditorConditions({
|
||||
/>
|
||||
)}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger>
|
||||
<DropdownMenuTrigger id={`condition-${depth}-${index}-dropdown`}>
|
||||
<MoreVerticalIcon className="h-4 w-4" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
|
||||
+1
-1
@@ -787,7 +787,7 @@ export const getActionTargetOptions = (
|
||||
return {
|
||||
label:
|
||||
ending.type === "endScreen"
|
||||
? getLocalizedValue(ending.headline, "default")
|
||||
? getLocalizedValue(ending.headline, "default") || "End Screen"
|
||||
: ending.label || "Redirect Thank you card",
|
||||
value: ending.id,
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { surveys } from "@/playwright/utils/mock";
|
||||
import { expect } from "@playwright/test";
|
||||
import { test } from "./lib/fixtures";
|
||||
import { createSurvey } from "./utils/helper";
|
||||
import { createSurvey, createSurveyWithLogic } from "./utils/helper";
|
||||
|
||||
test.describe("Survey Create & Submit Response", async () => {
|
||||
test.describe("Survey Create & Submit Response without logic", async () => {
|
||||
let url: string | null;
|
||||
|
||||
test("Create survey and submit response", async ({ page, users }) => {
|
||||
@@ -453,3 +453,256 @@ test.describe("Multi Language Survey Create", async () => {
|
||||
expect(germanSurveyUrl).toContain("lang=de");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Testing Survey with advanced logic", async () => {
|
||||
test.setTimeout(180000);
|
||||
let url: string | null;
|
||||
|
||||
test("Create survey and submit response", async ({ page, users }) => {
|
||||
const user = await users.create();
|
||||
await user.login();
|
||||
|
||||
await page.waitForURL(/\/environments\/[^/]+\/surveys/);
|
||||
|
||||
await test.step("Create Survey", async () => {
|
||||
await createSurveyWithLogic(page, surveys.createWithLogicAndSubmit);
|
||||
|
||||
// Save & Publish Survey
|
||||
await page.getByRole("button", { name: "Settings", exact: true }).click();
|
||||
|
||||
await page.locator("#howToSendCardTrigger").click();
|
||||
await expect(page.locator("#howToSendCardOption-link")).toBeVisible();
|
||||
await page.locator("#howToSendCardOption-link").click();
|
||||
|
||||
await page.getByRole("button", { name: "Publish" }).click();
|
||||
|
||||
// Get URL
|
||||
await page.waitForURL(/\/environments\/[^/]+\/surveys\/[^/]+\/summary(\?.*)?$/);
|
||||
await page.getByLabel("Copy survey link to clipboard").click();
|
||||
url = await page.evaluate("navigator.clipboard.readText()");
|
||||
});
|
||||
|
||||
await test.step("Submit Survey Response", async () => {
|
||||
await page.goto(url!);
|
||||
await page.waitForURL(/\/s\/[A-Za-z0-9]+$/);
|
||||
|
||||
// Welcome Card
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.welcomeCard.headline)).toBeVisible();
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.welcomeCard.description)).toBeVisible();
|
||||
await page.locator("#questionCard--1").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Open Text Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.openTextQuestion.question)).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.openTextQuestion.description)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByPlaceholder(surveys.createWithLogicAndSubmit.openTextQuestion.placeholder)
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByPlaceholder(surveys.createWithLogicAndSubmit.openTextQuestion.placeholder)
|
||||
.fill("This is my Open Text answer");
|
||||
await page.locator("#questionCard-0").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Single Select Question
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.singleSelectQuestion.question)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.singleSelectQuestion.description)
|
||||
).toBeVisible();
|
||||
for (let i = 0; i < surveys.createWithLogicAndSubmit.singleSelectQuestion.options.length; i++) {
|
||||
await expect(
|
||||
page
|
||||
.locator("#questionCard-1 label")
|
||||
.filter({ hasText: surveys.createWithLogicAndSubmit.singleSelectQuestion.options[i] })
|
||||
).toBeVisible();
|
||||
}
|
||||
await expect(page.getByText("Other")).toBeVisible();
|
||||
await expect(page.locator("#questionCard-1").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-1").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await page
|
||||
.locator("#questionCard-1 label")
|
||||
.filter({ hasText: surveys.createWithLogicAndSubmit.singleSelectQuestion.options[0] })
|
||||
.click();
|
||||
await page.locator("#questionCard-1").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Multi Select Question
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.multiSelectQuestion.question)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.multiSelectQuestion.description)
|
||||
).toBeVisible();
|
||||
for (let i = 0; i < surveys.createWithLogicAndSubmit.singleSelectQuestion.options.length; i++) {
|
||||
await expect(
|
||||
page
|
||||
.locator("#questionCard-2 label")
|
||||
.filter({ hasText: surveys.createWithLogicAndSubmit.multiSelectQuestion.options[i] })
|
||||
).toBeVisible();
|
||||
}
|
||||
await expect(page.locator("#questionCard-2").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-2").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
for (let i = 0; i < surveys.createWithLogicAndSubmit.multiSelectQuestion.options.length; i++) {
|
||||
await page
|
||||
.locator("#questionCard-2 label")
|
||||
.filter({ hasText: surveys.createWithLogicAndSubmit.multiSelectQuestion.options[i] })
|
||||
.click();
|
||||
}
|
||||
await page.locator("#questionCard-2").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Picture Select Question
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.pictureSelectQuestion.question)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.pictureSelectQuestion.description)
|
||||
).toBeVisible();
|
||||
await expect(page.locator("#questionCard-3").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-3").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await expect(page.getByRole("img", { name: "puppy-1-small.jpg" })).toBeVisible();
|
||||
await expect(page.getByRole("img", { name: "puppy-2-small.jpg" })).toBeVisible();
|
||||
await page.getByRole("img", { name: "puppy-1-small.jpg" }).click();
|
||||
await page.locator("#questionCard-3").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Rating Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.ratingQuestion.question)).toBeVisible();
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.ratingQuestion.description)).toBeVisible();
|
||||
await expect(
|
||||
page.locator("#questionCard-4").getByText(surveys.createWithLogicAndSubmit.ratingQuestion.lowLabel)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.locator("#questionCard-4").getByText(surveys.createWithLogicAndSubmit.ratingQuestion.highLabel)
|
||||
).toBeVisible();
|
||||
expect(await page.getByRole("group", { name: "Choices" }).locator("label").count()).toBe(5);
|
||||
await expect(page.locator("#questionCard-4").getByRole("button", { name: "Next" })).not.toBeVisible();
|
||||
await expect(page.locator("#questionCard-4").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await page.getByRole("group", { name: "Choices" }).locator("path").nth(3).click();
|
||||
|
||||
// NPS Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.npsQuestion.question)).toBeVisible();
|
||||
await expect(
|
||||
page.locator("#questionCard-5").getByText(surveys.createWithLogicAndSubmit.npsQuestion.lowLabel)
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.locator("#questionCard-5").getByText(surveys.createWithLogicAndSubmit.npsQuestion.highLabel)
|
||||
).toBeVisible();
|
||||
await expect(page.locator("#questionCard-5").getByRole("button", { name: "Next" })).not.toBeVisible();
|
||||
await expect(page.locator("#questionCard-5").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
|
||||
for (let i = 0; i < 11; i++) {
|
||||
await expect(page.locator("#questionCard-5").getByText(`${i}`, { exact: true })).toBeVisible();
|
||||
}
|
||||
await page.locator("#questionCard-5").getByText("5", { exact: true }).click();
|
||||
|
||||
// Ranking Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.ranking.question)).toBeVisible();
|
||||
await page.locator("#questionCard-6").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Matrix Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.matrix.question)).toBeVisible();
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.matrix.description)).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.rows[0] })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.rows[1] })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.rows[2] })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.columns[0] })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.columns[1] })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.columns[2] })
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("cell", { name: surveys.createWithLogicAndSubmit.matrix.columns[3] })
|
||||
).toBeVisible();
|
||||
await expect(page.locator("#questionCard-7").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-7").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await page.getByRole("row", { name: "Roses" }).getByRole("cell").nth(1).click();
|
||||
await page.getByRole("row", { name: "Trees" }).getByRole("cell").nth(1).click();
|
||||
await page.getByRole("row", { name: "Ocean" }).getByRole("cell").nth(1).click();
|
||||
await page.locator("#questionCard-7").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// CTA Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.ctaQuestion.question)).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: surveys.createWithLogicAndSubmit.ctaQuestion.buttonLabel })
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByRole("button", { name: surveys.createWithLogicAndSubmit.ctaQuestion.buttonLabel })
|
||||
.click();
|
||||
|
||||
// Consent Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.consentQuestion.question)).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.consentQuestion.checkboxLabel)
|
||||
).toBeVisible();
|
||||
await expect(page.locator("#questionCard-9").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-9").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await page.getByText(surveys.createWithLogicAndSubmit.consentQuestion.checkboxLabel).check();
|
||||
await page.locator("#questionCard-9").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// File Upload Question
|
||||
await expect(
|
||||
page.getByText(surveys.createWithLogicAndSubmit.fileUploadQuestion.question)
|
||||
).toBeVisible();
|
||||
await expect(page.locator("#questionCard-10").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-10").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await expect(
|
||||
page.locator("label").filter({ hasText: "Click or drag to upload files." }).locator("div").nth(0)
|
||||
).toBeVisible();
|
||||
await page.locator("input[type=file]").setInputFiles({
|
||||
name: "file.txt",
|
||||
mimeType: "text/plain",
|
||||
buffer: Buffer.from("this is test"),
|
||||
});
|
||||
await page.getByText("Uploading...").waitFor({ state: "hidden" });
|
||||
await page.locator("#questionCard-10").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Date Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.date.question)).toBeVisible();
|
||||
await page.getByText("Select a date").click();
|
||||
const date = new Date().getDate();
|
||||
const month = new Date().toLocaleString("default", { month: "long" });
|
||||
await page.getByRole("button", { name: `${month} ${date},` }).click();
|
||||
await page.locator("#questionCard-11").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Cal Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.cal.question)).toBeVisible();
|
||||
await page.locator("#questionCard-12").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Address Question
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.address.question)).toBeVisible();
|
||||
await expect(page.getByPlaceholder(surveys.createWithLogicAndSubmit.address.placeholder)).toBeVisible();
|
||||
await page
|
||||
.getByPlaceholder(surveys.createWithLogicAndSubmit.address.placeholder)
|
||||
.fill("This is my Address");
|
||||
await page.getByRole("button", { name: "Finish" }).click();
|
||||
|
||||
// loading spinner -> wait for it to disappear
|
||||
await page.getByTestId("loading-spinner").waitFor({ state: "hidden" });
|
||||
|
||||
// Thank You Card
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.thankYouCard.headline)).toBeVisible();
|
||||
await expect(page.getByText(surveys.createWithLogicAndSubmit.thankYouCard.description)).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step("Verify Survey Response", async () => {
|
||||
await page.goBack();
|
||||
await page.waitForURL(/\/environments\/[^/]+\/surveys\/[^/]+\/summary(\?.*)?$/);
|
||||
await page.getByRole("button", { name: "Close" }).click();
|
||||
await page.getByRole("link").filter({ hasText: "Responses" }).click();
|
||||
await expect(page.getByRole("table")).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "score" })).toBeVisible();
|
||||
await page.waitForTimeout(5000);
|
||||
await expect(page.getByRole("cell", { name: "32", exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CreateSurveyParams } from "@/playwright/utils/mock";
|
||||
import { CreateSurveyParams, CreateSurveyWithLogicParams } from "@/playwright/utils/mock";
|
||||
import { expect } from "@playwright/test";
|
||||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { Page } from "playwright";
|
||||
@@ -302,3 +302,619 @@ export const createSurvey = async (page: Page, params: CreateSurveyParams) => {
|
||||
await page.getByLabel("Note*").fill(params.thankYouCard.headline);
|
||||
await page.getByLabel("Description").fill(params.thankYouCard.description);
|
||||
};
|
||||
|
||||
export const createSurveyWithLogic = async (page: Page, params: CreateSurveyWithLogicParams) => {
|
||||
const addQuestion = "Add QuestionAdd a new question to your survey";
|
||||
|
||||
await page.getByRole("button", { name: "Start from scratch Create a" }).click();
|
||||
await page.getByRole("button", { name: "Create survey", exact: true }).click();
|
||||
|
||||
await page.waitForURL(/\/environments\/[^/]+\/surveys\/[^/]+\/edit$/);
|
||||
|
||||
// Add variables
|
||||
await page.getByText("Variables").click();
|
||||
await page.getByPlaceholder("Field name e.g, score, price").click();
|
||||
await page.getByPlaceholder("Field name e.g, score, price").fill("score");
|
||||
await page.getByRole("button", { name: "Add variable" }).click();
|
||||
await page
|
||||
.locator("form")
|
||||
.filter({ hasText: "Add variable" })
|
||||
.getByPlaceholder("Field name e.g, score, price")
|
||||
.fill("secret");
|
||||
await page.locator("form").filter({ hasText: "Add variable" }).getByRole("combobox").click();
|
||||
await page.getByLabel("Text", { exact: true }).click();
|
||||
await page.getByRole("button", { name: "Add variable" }).click();
|
||||
|
||||
// Welcome Card
|
||||
await expect(page.locator("#welcome-toggle")).toBeVisible();
|
||||
await page.getByText("Welcome Card").click();
|
||||
await page.locator("#welcome-toggle").check();
|
||||
await page.getByLabel("Note*").fill(params.welcomeCard.headline);
|
||||
await page.locator("form").getByText("Thanks for providing your").fill(params.welcomeCard.description);
|
||||
await page.getByText("Welcome CardOn").click();
|
||||
|
||||
// Open Text Question
|
||||
await page.getByRole("main").getByText("What would you like to know?").click();
|
||||
|
||||
await page.getByLabel("Question*").fill(params.openTextQuestion.question);
|
||||
await page.getByRole("button", { name: "Add Description", exact: true }).click();
|
||||
await page.getByLabel("Description").fill(params.openTextQuestion.description);
|
||||
await page.getByLabel("Placeholder").fill(params.openTextQuestion.placeholder);
|
||||
|
||||
await page.locator("p").filter({ hasText: params.openTextQuestion.question }).click();
|
||||
|
||||
// Single Select Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Single-Select" }).click();
|
||||
await page.getByLabel("Question*").fill(params.singleSelectQuestion.question);
|
||||
await page.getByRole("button", { name: "Add Description", exact: true }).click();
|
||||
await page.getByLabel("Description").fill(params.singleSelectQuestion.description);
|
||||
await page.getByPlaceholder("Option 1").fill(params.singleSelectQuestion.options[0]);
|
||||
await page.getByPlaceholder("Option 2").fill(params.singleSelectQuestion.options[1]);
|
||||
await page.getByRole("button", { name: 'Add "Other"', exact: true }).click();
|
||||
await page.getByLabel("Required").click();
|
||||
|
||||
// Multi Select Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Multi-Select" }).click();
|
||||
await page.getByLabel("Question*").fill(params.multiSelectQuestion.question);
|
||||
await page.getByRole("button", { name: "Add Description", exact: true }).click();
|
||||
await page.getByLabel("Description").fill(params.multiSelectQuestion.description);
|
||||
await page.getByPlaceholder("Option 1").fill(params.multiSelectQuestion.options[0]);
|
||||
await page.getByPlaceholder("Option 2").fill(params.multiSelectQuestion.options[1]);
|
||||
await page.getByPlaceholder("Option 3").fill(params.multiSelectQuestion.options[2]);
|
||||
|
||||
// Picture Select Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Picture Selection" }).click();
|
||||
await page.getByLabel("Question*").fill(params.pictureSelectQuestion.question);
|
||||
await page.getByRole("button", { name: "Add Description", exact: true }).click();
|
||||
await page.getByLabel("Description").fill(params.pictureSelectQuestion.description);
|
||||
await page.getByLabel("Required").click();
|
||||
|
||||
// Rating Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Rating" }).click();
|
||||
await page.getByLabel("Question*").fill(params.ratingQuestion.question);
|
||||
await page.getByRole("button", { name: "Add Description", exact: true }).click();
|
||||
await page.getByLabel("Description").fill(params.ratingQuestion.description);
|
||||
await page.getByPlaceholder("Not good").fill(params.ratingQuestion.lowLabel);
|
||||
await page.getByPlaceholder("Very satisfied").fill(params.ratingQuestion.highLabel);
|
||||
|
||||
// NPS Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Net Promoter Score (NPS)" }).click();
|
||||
await page.getByLabel("Question*").fill(params.npsQuestion.question);
|
||||
await page.getByLabel("Lower label").fill(params.npsQuestion.lowLabel);
|
||||
await page.getByLabel("Upper label").fill(params.npsQuestion.highLabel);
|
||||
|
||||
// Fill Ranking question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Ranking" }).click();
|
||||
await page.getByLabel("Question*").fill(params.ranking.question);
|
||||
await page.getByLabel("Required").click();
|
||||
|
||||
// Matrix Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Matrix" }).click();
|
||||
await page.getByLabel("Question*").fill(params.matrix.question);
|
||||
await page.getByRole("button", { name: "Add Description", exact: true }).click();
|
||||
await page.getByLabel("Description").fill(params.matrix.description);
|
||||
await page.locator("#row-0").click();
|
||||
await page.locator("#row-0").fill(params.matrix.rows[0]);
|
||||
await page.locator("#row-1").click();
|
||||
await page.locator("#row-1").fill(params.matrix.rows[1]);
|
||||
await page.locator("#row-2").click();
|
||||
await page.locator("#row-2").fill(params.matrix.rows[2]);
|
||||
await page.locator("#column-0").click();
|
||||
await page.locator("#column-0").fill(params.matrix.columns[0]);
|
||||
await page.locator("#column-1").click();
|
||||
await page.locator("#column-1").fill(params.matrix.columns[1]);
|
||||
await page.locator("#column-2").click();
|
||||
await page.locator("#column-2").fill(params.matrix.columns[2]);
|
||||
await page.locator("#column-3").click();
|
||||
await page.locator("#column-3").fill(params.matrix.columns[3]);
|
||||
|
||||
// CTA Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Statement (Call to Action)" }).click();
|
||||
await page.getByPlaceholder("Your question here. Recall").fill(params.ctaQuestion.question);
|
||||
await page.getByPlaceholder("Finish").fill(params.ctaQuestion.buttonLabel);
|
||||
await page.getByLabel("Required").click();
|
||||
|
||||
// Consent Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Consent" }).click();
|
||||
await page.getByLabel("Question*").fill(params.consentQuestion.question);
|
||||
await page.getByPlaceholder("I agree to the terms and").fill(params.consentQuestion.checkboxLabel);
|
||||
|
||||
// File Upload Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "File Upload" }).click();
|
||||
await page.getByLabel("Question*").fill(params.fileUploadQuestion.question);
|
||||
|
||||
// Date Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Date" }).click();
|
||||
await page.getByLabel("Question*").fill(params.date.question);
|
||||
|
||||
// Cal Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Schedule a meeting" }).click();
|
||||
await page.getByLabel("Question*").fill(params.cal.question);
|
||||
await page.getByLabel("Required").click();
|
||||
|
||||
// Fill Address Question
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: new RegExp(`^${addQuestion}$`) })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Address" }).click();
|
||||
await page.getByLabel("Question*").fill(params.address.question);
|
||||
|
||||
// Adding logic
|
||||
// Open Text Question
|
||||
await page.locator("p", { hasText: params.openTextQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is submitted" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Assign =" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Require Answer" }).click();
|
||||
await page.locator("#action-1-target").click();
|
||||
await page.getByRole("option", { name: params.singleSelectQuestion.question }).click();
|
||||
await page.locator("#actions-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-2-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-2-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-2-operator").click();
|
||||
await page.getByRole("option", { name: "Assign =" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("This ");
|
||||
|
||||
// Single Select Question
|
||||
await page.locator("p", { hasText: params.singleSelectQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "equals one of" }).click();
|
||||
await page.locator("#condition-0-0-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: params.singleSelectQuestion.options[0] }).click();
|
||||
await page.getByRole("option", { name: params.singleSelectQuestion.options[1] }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("is ");
|
||||
|
||||
// Multi Select Question
|
||||
await page.locator("p", { hasText: params.multiSelectQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "includes all of" }).click();
|
||||
await page.locator("#condition-0-0-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: params.multiSelectQuestion.options[0] }).click();
|
||||
await page.getByRole("option", { name: params.multiSelectQuestion.options[1] }).click();
|
||||
await page.getByRole("option", { name: params.multiSelectQuestion.options[2] }).click();
|
||||
await page.locator("#condition-0-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-1-conditionValue").click();
|
||||
await page.getByRole("option", { name: params.singleSelectQuestion.question }).click();
|
||||
await page.locator("#condition-0-1-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is submitted" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Require Answer" }).click();
|
||||
await page.locator("#action-1-target").click();
|
||||
await page.getByRole("option", { name: params.pictureSelectQuestion.question }).click();
|
||||
await page.locator("#actions-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-2-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-2-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-2-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("a ");
|
||||
|
||||
// Picture Select Question
|
||||
await page.locator("p", { hasText: params.pictureSelectQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is submitted" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("secret ");
|
||||
|
||||
// Rating Question
|
||||
await page.locator("p", { hasText: params.ratingQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: ">=" }).click();
|
||||
await page.locator("#condition-0-0-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: "3" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("message ");
|
||||
|
||||
// NPS Question
|
||||
await page.locator("p", { hasText: params.npsQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: ">", exact: true }).click();
|
||||
await page.locator("#condition-0-0-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: "2" }).click();
|
||||
await page.locator("#condition-0-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-1-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "<", exact: true }).click();
|
||||
await page.locator("#condition-0-1-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: "8" }).click();
|
||||
await page.locator("#condition-0-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-2-conditionValue").click();
|
||||
await page.getByRole("option", { name: params.ratingQuestion.question }).click();
|
||||
await page.locator("#condition-0-2-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "=", exact: true }).click();
|
||||
await page.locator("#condition-0-2-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: "4" }).click();
|
||||
await page.locator("#condition-0-2-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-3-conditionValue").click();
|
||||
await page.getByRole("option", { name: params.ratingQuestion.question }).click();
|
||||
await page.locator("#condition-0-3-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "<=" }).click();
|
||||
await page.locator("#condition-0-3-conditionMatchValue").click();
|
||||
await page.getByRole("option", { name: "1" }).click();
|
||||
await page.locator("#condition-0-3-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Create group" }).click();
|
||||
await page.locator("#condition-1-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.getByText("and").nth(4).click();
|
||||
await page.locator("#condition-1-1-conditionValue").click();
|
||||
await page
|
||||
.getByRole("option")
|
||||
.filter({ hasText: new RegExp(`^${params.pictureSelectQuestion.question}$`) })
|
||||
.click();
|
||||
await page.locator("#condition-1-1-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is submitted" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("for ");
|
||||
|
||||
// Ranking Question
|
||||
await page.locator("p", { hasText: params.ranking.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is skipped" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("e2e ");
|
||||
|
||||
// Matrix Question
|
||||
await page.locator("p", { hasText: params.matrix.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is completely submitted" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Concat +" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).click();
|
||||
await page.getByRole("textbox", { name: "Value" }).fill("tests");
|
||||
await page.locator("#actions-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-2-objective").click();
|
||||
await page.getByRole("option", { name: "Require Answer" }).click();
|
||||
await page.locator("#action-2-target").click();
|
||||
await page.getByRole("option", { name: params.ctaQuestion.question }).click();
|
||||
|
||||
// CTA Question
|
||||
await page.locator("p", { hasText: params.ctaQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is skipped" }).click();
|
||||
await page.locator("#condition-0-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.getByText("and", { exact: true }).click();
|
||||
await page.locator("#condition-0-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Create group" }).click();
|
||||
await page.locator("#condition-1-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-1-1-conditionValue").click();
|
||||
await page.getByRole("option", { name: "secret" }).click();
|
||||
await page.locator("#condition-1-1-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "contains" }).click();
|
||||
await page.getByPlaceholder("Value").click();
|
||||
await page.getByPlaceholder("Value").fill("test");
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("1");
|
||||
|
||||
// Consent Question
|
||||
await page.locator("p", { hasText: params.consentQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("2");
|
||||
|
||||
// File Upload Question
|
||||
await page.locator("p", { hasText: params.fileUploadQuestion.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("1");
|
||||
|
||||
// Date Question
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
const yesterday = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().split("T")[0];
|
||||
const tomorrow = new Date(new Date().setDate(new Date().getDate() + 1)).toISOString().split("T")[0];
|
||||
|
||||
await page.getByRole("main").getByText(params.date.question).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
|
||||
await page.getByPlaceholder("Value").fill(today);
|
||||
await page.locator("#condition-0-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-1-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "does not equal" }).click();
|
||||
await page.locator("#condition-0-1-conditionMatchValue-input").fill(yesterday);
|
||||
await page.locator("#condition-0-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-2-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is before" }).click();
|
||||
await page.locator("#condition-0-2-conditionMatchValue-input").fill(tomorrow);
|
||||
await page.locator("#condition-0-2-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add condition below" }).click();
|
||||
await page.locator("#condition-0-3-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is after" }).click();
|
||||
await page.locator("#condition-0-3-conditionMatchValue-input").fill(yesterday);
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("1");
|
||||
|
||||
// Cal Question
|
||||
await page.locator("p", { hasText: params.cal.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#condition-0-0-conditionOperator").click();
|
||||
await page.getByRole("option", { name: "is skipped" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("1");
|
||||
|
||||
// Address Question
|
||||
await page.locator("p", { hasText: params.address.question }).click();
|
||||
await page.getByRole("button", { name: "Show Advanced Settings" }).click();
|
||||
await page.getByRole("button", { name: "Add logic" }).click();
|
||||
await page.locator("#action-0-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-0-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-0-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-0-value-input").click();
|
||||
await page.locator("#action-0-value-input").fill("1");
|
||||
await page.locator("#actions-0-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-1-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-1-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-1-operator").click();
|
||||
await page.getByRole("option", { name: "Add +" }).click();
|
||||
await page.locator("#action-1-value-input").click();
|
||||
await page.locator("#action-1-value-input").fill("1");
|
||||
await page.locator("#actions-1-dropdown").click();
|
||||
await page.getByRole("menuitem", { name: "Add action below" }).click();
|
||||
await page.locator("#action-2-objective").click();
|
||||
await page.getByRole("option", { name: "Calculate" }).click();
|
||||
await page.locator("#action-2-variableId").click();
|
||||
await page.getByRole("option", { name: "score" }).click();
|
||||
await page.locator("#action-2-operator").click();
|
||||
await page.getByRole("option", { name: "Multiply *" }).click();
|
||||
await page.locator("#action-2-value-input").click();
|
||||
await page.locator("#action-2-value-input").fill("2");
|
||||
|
||||
// Thank You Card
|
||||
await page
|
||||
.locator("div")
|
||||
.filter({ hasText: /^Thank you!Ending card$/ })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.getByLabel("Note*").fill(params.thankYouCard.headline);
|
||||
await page.getByLabel("Description").fill(params.thankYouCard.description);
|
||||
};
|
||||
|
||||
@@ -166,6 +166,77 @@ export const surveys = {
|
||||
description: "This is my Thank you Card Description!",
|
||||
},
|
||||
},
|
||||
createWithLogicAndSubmit: {
|
||||
welcomeCard: {
|
||||
headline: "Welcome to My Testing Survey Welcome Card!",
|
||||
description: "This is the description of my Welcome Card!",
|
||||
},
|
||||
openTextQuestion: {
|
||||
question: "This is my Open Text Question",
|
||||
description: "This is my Open Text Description",
|
||||
placeholder: "This is my Placeholder",
|
||||
},
|
||||
singleSelectQuestion: {
|
||||
question: "This is my Single Select Question",
|
||||
description: "This is my Single Select Description",
|
||||
options: ["Option 1", "Option 2"],
|
||||
},
|
||||
multiSelectQuestion: {
|
||||
question: "This is my Multi Select Question",
|
||||
description: "This is Multi Select Description",
|
||||
options: ["Option 1", "Option 2", "Option 3"],
|
||||
},
|
||||
ratingQuestion: {
|
||||
question: "This is my Rating Question",
|
||||
description: "This is Rating Description",
|
||||
lowLabel: "My Lower Label",
|
||||
highLabel: "My Upper Label",
|
||||
},
|
||||
npsQuestion: {
|
||||
question: "This is my NPS Question",
|
||||
lowLabel: "My Lower Label",
|
||||
highLabel: "My Upper Label",
|
||||
},
|
||||
ctaQuestion: {
|
||||
question: "This is my CTA Question",
|
||||
buttonLabel: "My Button Label",
|
||||
},
|
||||
consentQuestion: {
|
||||
question: "This is my Consent Question",
|
||||
checkboxLabel: "My Checkbox Label",
|
||||
},
|
||||
pictureSelectQuestion: {
|
||||
question: "This is my Picture Select Question",
|
||||
description: "This is Picture Select Description",
|
||||
},
|
||||
fileUploadQuestion: {
|
||||
question: "This is my File Upload Question",
|
||||
},
|
||||
date: {
|
||||
question: "This is my Date Question",
|
||||
},
|
||||
cal: {
|
||||
question: "This is my cal Question",
|
||||
},
|
||||
matrix: {
|
||||
question: "This is my Matrix Question",
|
||||
description: "0: Not at all, 3: Love it",
|
||||
rows: ["Roses", "Trees", "Ocean"],
|
||||
columns: ["0", "1", "2", "3"],
|
||||
},
|
||||
address: {
|
||||
question: "Where do you live?",
|
||||
placeholder: "Address Line 1",
|
||||
},
|
||||
ranking: {
|
||||
question: "This is my Ranking Question",
|
||||
choices: ["Work", "Money", "Travel", "Family", "Friends"],
|
||||
},
|
||||
thankYouCard: {
|
||||
headline: "This is my Thank You Card Headline!",
|
||||
description: "This is my Thank you Card Description!",
|
||||
},
|
||||
},
|
||||
germanCreate: {
|
||||
welcomeCard: {
|
||||
headline: "Willkommen zu meiner Testumfrage Willkommenskarte!", // German translation
|
||||
@@ -240,6 +311,7 @@ export const surveys = {
|
||||
};
|
||||
|
||||
export type CreateSurveyParams = typeof surveys.createAndSubmit;
|
||||
export type CreateSurveyWithLogicParams = typeof surveys.createWithLogicAndSubmit;
|
||||
|
||||
export const actions = {
|
||||
create: {
|
||||
|
||||
@@ -262,7 +262,7 @@ describe("Tests for duplicateSurvey", () => {
|
||||
prisma.actionClass.findFirst.mockResolvedValueOnce(mockActionClass);
|
||||
prisma.actionClass.create.mockResolvedValueOnce(mockActionClass);
|
||||
|
||||
const createdSurvey = await copySurveyToOtherEnvironment(mockId, mockId, mockId, mockId, mockId);
|
||||
const createdSurvey = await copySurveyToOtherEnvironment(mockId, mockId, mockId, mockId);
|
||||
expect(createdSurvey).toEqual(mockSurveyOutput);
|
||||
});
|
||||
});
|
||||
@@ -272,7 +272,7 @@ describe("Tests for duplicateSurvey", () => {
|
||||
|
||||
it("Throws ResourceNotFoundError if the survey does not exist", async () => {
|
||||
prisma.survey.findUnique.mockRejectedValueOnce(new ResourceNotFoundError("Survey", mockId));
|
||||
await expect(copySurveyToOtherEnvironment(mockId, mockId, mockId, mockId, mockId)).rejects.toThrow(
|
||||
await expect(copySurveyToOtherEnvironment(mockId, mockId, mockId, mockId)).rejects.toThrow(
|
||||
ResourceNotFoundError
|
||||
);
|
||||
});
|
||||
@@ -280,9 +280,7 @@ describe("Tests for duplicateSurvey", () => {
|
||||
it("should throw an error if there is an unknown error", async () => {
|
||||
const mockErrorMessage = "Unknown error occurred";
|
||||
prisma.survey.create.mockRejectedValue(new Error(mockErrorMessage));
|
||||
await expect(copySurveyToOtherEnvironment(mockId, mockId, mockId, mockId, mockId)).rejects.toThrow(
|
||||
Error
|
||||
);
|
||||
await expect(copySurveyToOtherEnvironment(mockId, mockId, mockId, mockId)).rejects.toThrow(Error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface TComboboxGroupedOption {
|
||||
}
|
||||
|
||||
export interface InputComboboxProps {
|
||||
id: string;
|
||||
showSearch?: boolean;
|
||||
searchPlaceholder?: string;
|
||||
options?: TComboboxOption[];
|
||||
@@ -46,6 +47,7 @@ export interface InputComboboxProps {
|
||||
}
|
||||
|
||||
export const InputCombobox = ({
|
||||
id = "temp",
|
||||
showSearch = true,
|
||||
searchPlaceholder = "Search...",
|
||||
options,
|
||||
@@ -193,6 +195,7 @@ export const InputCombobox = ({
|
||||
<Input
|
||||
className="min-w-0 rounded-none border-0 border-r border-slate-300 bg-white focus:border-slate-300"
|
||||
{...inputProps}
|
||||
id={`${id}-input`}
|
||||
value={localValue as string | number}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
@@ -200,6 +203,7 @@ export const InputCombobox = ({
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<div
|
||||
id={id}
|
||||
role="combobox"
|
||||
aria-controls="options"
|
||||
aria-expanded={open}
|
||||
|
||||
Reference in New Issue
Block a user