mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-05 10:36:06 -06:00
fix: e2e tests
This commit is contained in:
@@ -152,7 +152,7 @@ export const PUT = withV1ApiWrapper({
|
||||
};
|
||||
}
|
||||
|
||||
const validateResult = validateSurveyInput(surveyUpdate);
|
||||
const validateResult = validateSurveyInput({ ...surveyUpdate, updateOnly: true });
|
||||
if (!validateResult.ok) {
|
||||
return {
|
||||
response: responses.badRequestResponse(validateResult.error.message),
|
||||
|
||||
@@ -480,6 +480,7 @@ export const transformBlocksToQuestions = (
|
||||
export const validateSurveyInput = (input: {
|
||||
questions?: TSurveyQuestion[];
|
||||
blocks?: TSurveyBlock[];
|
||||
updateOnly?: boolean;
|
||||
}): Result<{ hasQuestions: boolean; hasBlocks: boolean }, InvalidInputError> => {
|
||||
const hasQuestions = Boolean(input.questions && input.questions.length > 0);
|
||||
const hasBlocks = Boolean(input.blocks && input.blocks.length > 0);
|
||||
@@ -492,7 +493,7 @@ export const validateSurveyInput = (input: {
|
||||
);
|
||||
}
|
||||
|
||||
if (!hasQuestions && !hasBlocks) {
|
||||
if (!hasQuestions && !hasBlocks && !input.updateOnly) {
|
||||
return err(new InvalidInputError("Must provide either questions or blocks. Both cannot be empty."));
|
||||
}
|
||||
|
||||
|
||||
@@ -109,9 +109,9 @@ test.describe("JS Package Test", async () => {
|
||||
|
||||
// Fill the survey
|
||||
await page.getByRole("button", { name: "Happy to help!" }).click();
|
||||
await page.locator("label").filter({ hasText: "Somewhat disappointed" }).click();
|
||||
await page.locator("#questionCard-1 label").filter({ hasText: "Somewhat disappointed" }).click();
|
||||
await page.locator("#questionCard-1").getByRole("button", { name: "Next" }).click();
|
||||
await page.locator("label").filter({ hasText: "Founder" }).click();
|
||||
await page.locator("#questionCard-2 label").filter({ hasText: "Founder" }).click();
|
||||
await page.locator("#questionCard-2").getByRole("button", { name: "Next" }).click();
|
||||
await page
|
||||
.locator("#questionCard-3")
|
||||
@@ -121,7 +121,7 @@ test.describe("JS Package Test", async () => {
|
||||
await page.locator("#questionCard-4").getByLabel("textarea").fill("Much higher response rates!");
|
||||
await page.locator("#questionCard-4").getByRole("button", { name: "Next" }).click();
|
||||
await page.locator("#questionCard-5").getByLabel("textarea").fill("Make this end to end test pass!");
|
||||
await page.locator("#questionCard-5").getByRole("button", { name: "Next" }).click();
|
||||
await page.locator("#questionCard-5").getByRole("button", { name: "Finish" }).click();
|
||||
|
||||
await page.getByTestId("loading-spinner").waitFor({ state: "hidden" });
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
Reference in New Issue
Block a user