mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-24 11:39:22 -05:00
feat: Refactor Triggers and combine Action Classes and Inline Triggers (#2562)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com> Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Johannes <johannes@formbricks.com>
This commit is contained in:
@@ -36,7 +36,7 @@ const createNoCodeActionByCSSSelector = async (
|
||||
// User fills the CSS Selector to track
|
||||
await expect(page.locator("[name='noCodeConfig.cssSelector.value']")).toBeVisible();
|
||||
await page.locator("[name='noCodeConfig.cssSelector.value']").fill(selector);
|
||||
await page.getByRole("button", { name: "Create Action", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Create action", exact: true }).click();
|
||||
await page.waitForLoadState("networkidle");
|
||||
await page.waitForTimeout(500);
|
||||
};
|
||||
@@ -76,20 +76,20 @@ const createNoCodeActionByPageURL = async (
|
||||
await page.locator("#PageURL").click();
|
||||
|
||||
// User opens the dropdown and selects the URL match type
|
||||
await expect(page.locator("[name='noCodeConfig.[pageUrl].rule']")).toBeVisible();
|
||||
await page.locator("[name='noCodeConfig.[pageUrl].rule']").selectOption({ label: matcher.label });
|
||||
await expect(page.locator("[name='noCodeConfig.pageUrl.rule']")).toBeVisible();
|
||||
await page.locator("[name='noCodeConfig.pageUrl.rule']").selectOption({ label: matcher.label });
|
||||
|
||||
// User fills the Page URL to track
|
||||
await page.locator("[name='noCodeConfig.[pageUrl].value']").fill(matcher.value);
|
||||
await page.locator("[name='noCodeConfig.pageUrl.value']").fill(matcher.value);
|
||||
|
||||
// User fills the Test URL to track
|
||||
await page.locator("[name='noCodeConfig.[pageUrl].testUrl']").fill(testURL);
|
||||
await page.locator("[name='noCodeConfig.pageUrl.testUrl']").fill(testURL);
|
||||
|
||||
// User clicks the Test Match button
|
||||
await page.getByRole("button", { name: "Test Match", exact: true }).click();
|
||||
|
||||
// User clicks the Create Action button
|
||||
await page.getByRole("button", { name: "Create Action", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Create action", exact: true }).click();
|
||||
await page.waitForLoadState("networkidle");
|
||||
await page.waitForTimeout(500);
|
||||
};
|
||||
@@ -127,7 +127,7 @@ const createNoCodeActionByInnerText = async (
|
||||
// User fills the Inner Text to track
|
||||
await expect(page.locator("[name='noCodeConfig.innerHtml.value']")).toBeVisible();
|
||||
await page.locator("[name='noCodeConfig.innerHtml.value']").fill(innerText);
|
||||
await page.getByRole("button", { name: "Create Action", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Create action", exact: true }).click();
|
||||
await page.waitForLoadState("networkidle");
|
||||
await page.waitForTimeout(500);
|
||||
};
|
||||
@@ -215,16 +215,14 @@ test.describe("Create and Edit No Code Action by Page URL", async () => {
|
||||
await expect(page.getByLabel("Description")).toBeVisible();
|
||||
await page.getByLabel("Description").fill(actions.edit.noCode.pageURL.description);
|
||||
|
||||
await expect(page.locator("[name='noCodeConfig.[pageUrl].rule']")).toBeVisible();
|
||||
await expect(page.locator("[name='noCodeConfig.pageUrl.rule']")).toBeVisible();
|
||||
await page
|
||||
.locator("[name='noCodeConfig.[pageUrl].rule']")
|
||||
.locator("[name='noCodeConfig.pageUrl.rule']")
|
||||
.selectOption({ label: actions.edit.noCode.pageURL.matcher.label });
|
||||
|
||||
await page
|
||||
.locator("[name='noCodeConfig.[pageUrl].value']")
|
||||
.fill(actions.edit.noCode.pageURL.matcher.value);
|
||||
await page.locator("[name='noCodeConfig.pageUrl.value']").fill(actions.edit.noCode.pageURL.matcher.value);
|
||||
|
||||
await page.locator("[name='noCodeConfig.[pageUrl].testUrl']").fill(actions.edit.noCode.pageURL.testURL);
|
||||
await page.locator("[name='noCodeConfig.pageUrl.testUrl']").fill(actions.edit.noCode.pageURL.testURL);
|
||||
await page.getByRole("button", { name: "Test Match", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Save changes", exact: true }).click();
|
||||
});
|
||||
@@ -287,13 +285,16 @@ test.describe("Create and Edit Code Action", async () => {
|
||||
// User selects the Code tab
|
||||
await page.getByRole("button", { name: "Code", exact: true }).click();
|
||||
|
||||
await expect(page.getByLabel("Identifier")).toBeVisible();
|
||||
await page.getByLabel("Identifier").fill(actions.create.code.name);
|
||||
await expect(page.getByLabel("What did your user do?")).toBeVisible();
|
||||
await page.getByLabel("What did your user do?").fill(actions.create.code.name);
|
||||
|
||||
await expect(page.getByLabel("Description")).toBeVisible();
|
||||
await page.getByLabel("Description").fill(actions.create.code.description);
|
||||
|
||||
await page.getByRole("button", { name: "Create Action", exact: true }).click();
|
||||
await expect(page.getByLabel("Key")).toBeVisible();
|
||||
await page.getByLabel("Key").fill(actions.create.code.key);
|
||||
|
||||
await page.getByRole("button", { name: "Create action", exact: true }).click();
|
||||
await page.waitForLoadState("networkidle");
|
||||
await page.waitForTimeout(500);
|
||||
});
|
||||
|
||||
@@ -30,8 +30,8 @@ test.describe("JS Package Test", async () => {
|
||||
|
||||
await expect(page.getByText("Survey Trigger")).toBeVisible();
|
||||
|
||||
await page.getByRole("combobox").click();
|
||||
await page.getByLabel("New Session").click();
|
||||
await page.getByRole("button", { name: "Add action" }).click();
|
||||
await page.getByText("New SessionGets fired when a").click();
|
||||
await page.getByRole("button", { name: "Publish" }).click();
|
||||
|
||||
environmentId =
|
||||
|
||||
@@ -25,44 +25,6 @@ test.describe("Survey Create & Submit Response", async () => {
|
||||
url = await page.evaluate("navigator.clipboard.readText()");
|
||||
});
|
||||
|
||||
test("Create Survey with Custom Actions", async ({ page }) => {
|
||||
const { name, email, password } = users.survey[1];
|
||||
|
||||
await createSurvey(page, name, email, password, surveys.createAndSubmit);
|
||||
// Save & Publish Survey
|
||||
await page.getByRole("button", { name: "Continue to Settings" }).click();
|
||||
await page.locator("#howToSendCardTrigger").click();
|
||||
await page.locator("#howToSendCardOption-website").click();
|
||||
await page.getByRole("button", { name: "Custom Actions" }).click();
|
||||
|
||||
await expect(page.locator("#codeAction")).toBeVisible();
|
||||
await page.locator("#codeAction").click();
|
||||
|
||||
await expect(page.locator("#codeActionIdentifierInput")).toBeVisible();
|
||||
await page.locator("#codeActionIdentifierInput").fill("my-custom-code-action");
|
||||
|
||||
await expect(page.locator("#noCodeAction")).toBeVisible();
|
||||
await page.locator("#noCodeAction").click();
|
||||
|
||||
await expect(page.locator("#cssSelectorToggle")).toBeVisible();
|
||||
await expect(page.locator("#pageURLToggle")).toBeVisible();
|
||||
await expect(page.locator("#innerHTMLToggle")).toBeVisible();
|
||||
|
||||
await page.locator("#cssSelectorToggle").click();
|
||||
await expect(page.locator("#cssSelectorInput")).toBeVisible();
|
||||
await page.locator("#cssSelectorInput").fill(".my-custom-class");
|
||||
|
||||
await page.locator("#pageURLToggle").click();
|
||||
await expect(page.locator("#pageURLInput")).toBeVisible();
|
||||
await page.locator("#pageURLInput").fill("custom-url");
|
||||
|
||||
await page.locator("#innerHTMLToggle").click();
|
||||
await expect(page.locator("#innerHTMLInput")).toBeVisible();
|
||||
await page.locator("#innerHTMLInput").fill("Download");
|
||||
|
||||
await page.getByRole("button", { name: "Publish" }).click();
|
||||
});
|
||||
|
||||
test("Submit Survey Response", async ({ page }) => {
|
||||
await page.goto(url!);
|
||||
await page.waitForURL(/\/s\/[A-Za-z0-9]+$/);
|
||||
|
||||
@@ -243,7 +243,7 @@ export const actions = {
|
||||
name: "Create Action (Page URL)",
|
||||
description: "This is my Create Action (Page URL)",
|
||||
matcher: {
|
||||
label: "Starts with",
|
||||
label: "Contains",
|
||||
value: "custom-url",
|
||||
},
|
||||
testURL: "http://localhost:3000/custom-url",
|
||||
@@ -257,6 +257,7 @@ export const actions = {
|
||||
code: {
|
||||
name: "Create Action (Code)",
|
||||
description: "This is my Create Action (Code)",
|
||||
key: "Create Action (Code)",
|
||||
},
|
||||
},
|
||||
edit: {
|
||||
|
||||
Reference in New Issue
Block a user