A Playwright test for "Copy Typeform Redirect URL link" action (#5716)
Co-authored-by: niteshsingh1357 <niteshsingh1357@gmail.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: RubensRafael <rubensrafael2@live.com> Co-authored-by: José Romary Brandão Jr <joseromarybrandao@gmail.com> Co-authored-by: csangam <coolmagnas@gmail.com> Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com> Co-authored-by: gitstart <gitstart@gitstart.com> Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com> Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com> Co-authored-by: gitstart-app[bot] <57568882+gitstart-app[bot]@users.noreply.github.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Fixes https://github.com/calcom/cal.com/issues/4570
This commit is contained in:
parent
7b18272d60
commit
546f0c3881
|
@ -135,7 +135,7 @@ export const FormActionsDropdown = ({ form, children }: { form: RoutingForm; chi
|
|||
return (
|
||||
<dropdownCtx.Provider value={{ dropdown: true }}>
|
||||
<Dropdown>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<DropdownMenuTrigger data-testid="form-dropdown" asChild>
|
||||
<Button
|
||||
type="button"
|
||||
size="icon"
|
||||
|
|
|
@ -120,6 +120,7 @@ const Actions = ({
|
|||
{typeformApp?.isInstalled ? (
|
||||
<FormActionsDropdown form={form}>
|
||||
<FormAction
|
||||
data-testid="copy-redirect-url"
|
||||
routingForm={form}
|
||||
action="copyRedirectUrl"
|
||||
color="minimal"
|
||||
|
@ -172,6 +173,7 @@ const Actions = ({
|
|||
</FormAction>
|
||||
{typeformApp ? (
|
||||
<FormAction
|
||||
data-testid="copy-redirect-url"
|
||||
routingForm={form}
|
||||
action="copyRedirectUrl"
|
||||
color="minimal"
|
||||
|
|
|
@ -131,6 +131,7 @@ export default function RoutingForms({
|
|||
</FormAction>
|
||||
{typeformApp?.isInstalled ? (
|
||||
<FormAction
|
||||
data-testid="copy-redirect-url"
|
||||
routingForm={form}
|
||||
action="copyRedirectUrl"
|
||||
color="minimal"
|
||||
|
|
|
@ -8,7 +8,7 @@ async function gotoRoutingLink(page: Page, formId: string) {
|
|||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
|
||||
async function addForm(page: Page) {
|
||||
export async function addForm(page: Page) {
|
||||
await page.click('[data-testid="new-routing-form"]');
|
||||
await page.fill("input[name]", "Test Form Name");
|
||||
await page.click('[data-testid="add-form"]');
|
||||
|
@ -41,7 +41,7 @@ async function verifySelectOptions(
|
|||
};
|
||||
}
|
||||
|
||||
async function fillForm(
|
||||
export async function fillForm(
|
||||
page: Page,
|
||||
form: { description: string; field?: { typeIndex: number; label: string } }
|
||||
) {
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
import { Page, expect } from "@playwright/test";
|
||||
|
||||
import {
|
||||
addForm as addRoutingForm,
|
||||
fillForm as fillRoutingForm,
|
||||
} from "@calcom/app-store/ee/routing-forms/playwright/tests/basic.e2e";
|
||||
import { CAL_URL } from "@calcom/lib/constants";
|
||||
import { Fixtures, test } from "@calcom/web/playwright/lib/fixtures";
|
||||
|
||||
const installApps = async (page: Page, users: Fixtures["users"]) => {
|
||||
const user = await users.create({ username: "routing-forms" });
|
||||
await user.login();
|
||||
await page.goto(`/apps/routing-forms`);
|
||||
await page.click('[data-testid="install-app-button"]');
|
||||
await page.waitForNavigation({
|
||||
url: (url) => url.pathname === `/apps/routing-forms/forms`,
|
||||
});
|
||||
await page.goto(`/apps/typeform`);
|
||||
await page.click('[data-testid="install-app-button"]');
|
||||
await page.waitForNavigation({
|
||||
url: (url) => url.pathname === `/apps/typeform/how-to-use`,
|
||||
});
|
||||
};
|
||||
|
||||
test.describe("Typeform App", () => {
|
||||
test.afterEach(async ({ users }) => {
|
||||
// This also delete forms on cascade
|
||||
await users.deleteAll();
|
||||
});
|
||||
|
||||
test.describe("Typeform Redirect Link", () => {
|
||||
test("should copy link in editing area", async ({ page, context, users }) => {
|
||||
await installApps(page, users);
|
||||
context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
|
||||
await page.goto(`/apps/routing-forms/forms`);
|
||||
const formId = await addRoutingForm(page);
|
||||
await fillRoutingForm(page, {
|
||||
description: "",
|
||||
field: { label: "test", typeIndex: 1 },
|
||||
});
|
||||
|
||||
await page.click('[data-testid="form-dropdown"]');
|
||||
await page.click('[data-testid="copy-redirect-url"]');
|
||||
const text = await page.evaluate(async () => {
|
||||
return navigator.clipboard.readText();
|
||||
});
|
||||
expect(text).toBe(`${CAL_URL}/router?form=${formId}&test={Recalled_Response_For_This_Field}`);
|
||||
});
|
||||
|
||||
test("should copy link in RoutingForms list", async ({ page, context, users }) => {
|
||||
await installApps(page, users);
|
||||
context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
|
||||
await page.goto("/apps/routing-forms/forms");
|
||||
const formId = await addRoutingForm(page);
|
||||
await fillRoutingForm(page, {
|
||||
description: "",
|
||||
field: { label: "test", typeIndex: 1 },
|
||||
});
|
||||
|
||||
await page.goto("/apps/routing-forms/forms");
|
||||
await page.click('[data-testid="form-dropdown"]');
|
||||
await page.click('[data-testid="copy-redirect-url"]');
|
||||
const text = await page.evaluate(async () => {
|
||||
return navigator.clipboard.readText();
|
||||
});
|
||||
expect(text).toBe(`${CAL_URL}/router?form=${formId}&test={Recalled_Response_For_This_Field}`);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user