fix: e2e tests

This commit is contained in:
pandeymangg
2025-11-26 23:02:52 +05:30
parent a08f2db40c
commit d7692a1b76
3 changed files with 6 additions and 5 deletions

View File

@@ -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),

View File

@@ -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."));
}

View File

@@ -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");