mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-02 11:30:31 -05:00
fix: e2e tests, make welcomeCard.headline optional, remove console logs (#2374)
This commit is contained in:
committed by
GitHub
parent
08ce026c7a
commit
f93c5b3c55
@@ -46,6 +46,7 @@ runs:
|
||||
run: |
|
||||
SECRET=$(openssl rand -hex 32)
|
||||
echo "ENCRYPTION_KEY=$SECRET" >> $GITHUB_ENV
|
||||
echo "ENTERPRISE_LICENSE_KEY=$SECRET" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- run: |
|
||||
|
||||
@@ -46,13 +46,11 @@ test.describe("JS Package Test", async () => {
|
||||
expect(page.getByRole("link", { name: "Surveys" })).toBeVisible();
|
||||
await page.getByRole("link", { name: "Surveys" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Surveys" })).toBeVisible();
|
||||
|
||||
await page.screenshot();
|
||||
});
|
||||
|
||||
test("JS Display Survey on Page", async ({ page }) => {
|
||||
let currentDir = process.cwd();
|
||||
let htmlFilePath = currentDir + "/packages/js/index.html";
|
||||
let htmlFilePath = currentDir + "/packages/js-core/index.html";
|
||||
|
||||
let htmlFile = replaceEnvironmentIdInHtml(htmlFilePath, environmentId);
|
||||
await page.goto(htmlFile);
|
||||
@@ -76,7 +74,7 @@ test.describe("JS Package Test", async () => {
|
||||
|
||||
test("JS submits Response to Survey", async ({ page }) => {
|
||||
let currentDir = process.cwd();
|
||||
let htmlFilePath = currentDir + "/packages/js/index.html";
|
||||
let htmlFilePath = currentDir + "/packages/js-core/index.html";
|
||||
|
||||
let htmlFile = "file:///" + htmlFilePath;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ test.describe("Onboarding Flow Test", async () => {
|
||||
await page.getByRole("button", { name: "Skip" }).click();
|
||||
await page.getByRole("button", { name: "Skip" }).click();
|
||||
|
||||
await page.getByRole("button", { name: "I am not sure how to do this" }).click();
|
||||
await page.getByRole("button", { name: "Skip" }).click();
|
||||
await page.locator("input").click();
|
||||
await page.locator("input").fill("test@gmail.com");
|
||||
await page.getByRole("button", { name: "Invite" }).click();
|
||||
|
||||
@@ -23,10 +23,8 @@ test.describe("Survey Create & Submit Response", async () => {
|
||||
|
||||
// Get URL
|
||||
await page.waitForURL(/\/environments\/[^/]+\/surveys\/[^/]+\/summary$/);
|
||||
url = await page
|
||||
.locator("div")
|
||||
.filter({ hasText: /^http:\/\/localhost:3000\/s\/[A-Za-z0-9]+$/ })
|
||||
.innerText();
|
||||
await page.getByLabel("Copy survey link to clipboard").click();
|
||||
url = await page.evaluate("navigator.clipboard.readText()");
|
||||
});
|
||||
|
||||
test("Create Survey with Custom Actions", async ({ page }) => {
|
||||
@@ -195,7 +193,7 @@ test.describe("Survey Create & Submit Response", async () => {
|
||||
|
||||
test.describe("Multi Language Survey Create", async () => {
|
||||
test.describe.configure({ mode: "serial" });
|
||||
const { name, email, password } = users.survey[2];
|
||||
const { name, email, password } = users.survey[3];
|
||||
test("Create Survey", async ({ page }) => {
|
||||
await signUpAndLogin(page, name, email, password);
|
||||
await finishOnboarding(page);
|
||||
@@ -217,7 +215,7 @@ test.describe("Multi Language Survey Create", async () => {
|
||||
await page.getByRole("textbox", { name: "Search items" }).fill("German");
|
||||
await page.getByText("German").nth(1).click();
|
||||
await page.getByRole("button", { name: "Save Changes" }).click();
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
await page.waitForTimeout(2000);
|
||||
await page.getByRole("link", { name: "Surveys" }).click();
|
||||
await page.getByRole("button", { name: "Start from scratch Create a" }).click();
|
||||
await page.locator("#multi-lang-toggle").click();
|
||||
@@ -273,6 +271,8 @@ test.describe("Multi Language Survey Create", async () => {
|
||||
.filter({ hasText: /^Add QuestionAdd a new question to your survey$/ })
|
||||
.nth(1)
|
||||
.click();
|
||||
|
||||
await page.getByRole("button", { name: "Matrix" }).scrollIntoViewIfNeeded();
|
||||
await page.getByRole("button", { name: "Matrix" }).click();
|
||||
|
||||
// Enable translation in german
|
||||
@@ -422,5 +422,8 @@ test.describe("Multi Language Survey Create", async () => {
|
||||
await page.waitForURL(/\/environments\/[^/]+\/surveys\/[^/]+\/summary$/);
|
||||
await page.getByLabel("Select Language").click();
|
||||
await page.getByText("German").click();
|
||||
await page.getByLabel("Copy survey link to clipboard").click();
|
||||
const germanSurveyUrl = await page.evaluate("navigator.clipboard.readText()");
|
||||
expect(germanSurveyUrl).toContain("lang=de");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ export const finishOnboarding = async (page: Page, deleteExampleSurvey: boolean
|
||||
await expect(page.getByText("My Product")).toBeVisible();
|
||||
|
||||
let currentDir = process.cwd();
|
||||
let htmlFilePath = currentDir + "/packages/js/index.html";
|
||||
let htmlFilePath = currentDir + "/packages/js-core/index.html";
|
||||
|
||||
const environmentId =
|
||||
/\/environments\/([^/]+)\/surveys/.exec(page.url())?.[1] ??
|
||||
|
||||
@@ -34,6 +34,11 @@ export const users = {
|
||||
email: "survey3@formbricks.com",
|
||||
password: "Gj2DGji27D&M8u53V",
|
||||
},
|
||||
{
|
||||
name: "Survey User 4",
|
||||
email: "survey4@formbricks.com",
|
||||
password: "UU3efj8vJa&M8u5M1",
|
||||
},
|
||||
],
|
||||
js: [
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
e.parentNode.insertBefore(t, e),
|
||||
setTimeout(function () {
|
||||
formbricks.init({
|
||||
environmentId: "clu9xfvdn0009vhyg9b6858gc",
|
||||
environmentId: "cluqpv56n00lbxl3f8xvytyog",
|
||||
apiHost: "http://localhost:3000",
|
||||
});
|
||||
}, 500);
|
||||
|
||||
@@ -25,7 +25,6 @@ logger.debug("Create command queue");
|
||||
const queue = new CommandQueue();
|
||||
|
||||
const init = async (initConfig: TJsConfigInput) => {
|
||||
console.log("init in formbricks-js-core");
|
||||
ErrorHandler.init(initConfig.errorHandler);
|
||||
queue.add(false, initialize, initConfig);
|
||||
await queue.wait();
|
||||
|
||||
@@ -37,7 +37,7 @@ export const reverseTranslateSurvey = (survey: TSurvey, languageCode: string = "
|
||||
|
||||
// check if the headline is an empty object, if so, add a "default" key
|
||||
// TODO: This is a temporary fix, should be handled propperly
|
||||
if (Object.keys(reversedSurvey.welcomeCard.headline).length === 0) {
|
||||
if (reversedSurvey.welcomeCard.headline && Object.keys(reversedSurvey.welcomeCard.headline).length === 0) {
|
||||
reversedSurvey.welcomeCard.headline = { default: "" };
|
||||
}
|
||||
|
||||
|
||||
+14
-10
@@ -38,16 +38,20 @@ export enum TSurveyQuestionType {
|
||||
Matrix = "matrix",
|
||||
}
|
||||
|
||||
export const ZSurveyWelcomeCard = z.object({
|
||||
enabled: z.boolean(),
|
||||
headline: ZI18nString,
|
||||
html: ZI18nString.optional(),
|
||||
fileUrl: z.string().optional(),
|
||||
buttonLabel: ZI18nString.optional(),
|
||||
timeToFinish: z.boolean().default(true),
|
||||
showResponseCount: z.boolean().default(false),
|
||||
videoUrl: z.string().optional(),
|
||||
});
|
||||
export const ZSurveyWelcomeCard = z
|
||||
.object({
|
||||
enabled: z.boolean(),
|
||||
headline: ZI18nString.optional(),
|
||||
html: ZI18nString.optional(),
|
||||
fileUrl: z.string().optional(),
|
||||
buttonLabel: ZI18nString.optional(),
|
||||
timeToFinish: z.boolean().default(true),
|
||||
showResponseCount: z.boolean().default(false),
|
||||
videoUrl: z.string().optional(),
|
||||
})
|
||||
.refine((schema) => !(schema.enabled && !schema.headline), {
|
||||
message: "Welcome card must have a headline",
|
||||
});
|
||||
|
||||
export const ZSurveyHiddenFields = z.object({
|
||||
enabled: z.boolean(),
|
||||
|
||||
@@ -16,7 +16,7 @@ export default defineConfig({
|
||||
/* Retry on CI only */
|
||||
retries: 0,
|
||||
/* Timeout for each test */
|
||||
timeout: 90000,
|
||||
timeout: 120000,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: 1,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
|
||||
Reference in New Issue
Block a user