Files
calendar/apps/web/playwright/fixtures/workflows.ts
T
Eunjae LeeGitHubClaude Opus 4.5Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
81e4241f85 refactor: apply biome formatting to apps/web (#27692)
* refactor: apply biome formatting to apps/web (batch 1)

Formats apps/web non-modules directories:
- apps/web/app
- apps/web/lib
- apps/web/pages
- apps/web/styles
- apps/web/server
- apps/web/test
- Root-level .ts and .mjs files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to apps/web/modules (batch 2)

Formats smaller apps/web/modules directories:
- onboarding, data-table, users, apps, auth
- integration-attribute-sync, shell, availability
- feature-flags, team, webhooks, getting-started
- feature-opt-in, troubleshooter, schedules, notifications
- signup-view.tsx

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to apps/web/modules (batch 3)

Formats medium apps/web/modules directories:
- bookings
- event-types
- insights
- embed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to apps/web/modules/ee (batch 4)

Formats apps/web/modules/ee directory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to apps/web (batch 5)

Formats remaining apps/web directories:
- apps/web/modules/settings
- apps/web/modules/booking-audit
- apps/web/playwright

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to apps/web/components (batch 6)

Formats remaining apps/web/components files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to new apps/web files from main

Formats newly added/modified files from main merge:
- WorkflowStepContainer.tsx (resolved merge conflicts)
- Newly moved files (blocklist, form-builder, schedules, etc.)
- Other files modified in main

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: apply biome formatting to new apps/web files from main

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-02-10 23:25:24 +05:30

182 lines
5.5 KiB
TypeScript

import type { Locator } from "@playwright/test";
import { expect, type Page } from "@playwright/test";
import prisma from "@calcom/prisma";
import { WorkflowTriggerEvents } from "@calcom/prisma/enums";
import type { Fixtures } from "@calcom/web/playwright/lib/fixtures";
import { localize } from "../lib/localize";
type CreateWorkflowProps = {
name?: string;
isTeam?: true;
trigger?: WorkflowTriggerEvents;
};
const subjectPattern = /^Reminder: /i;
export function createWorkflowPageFixture(page: Page) {
const createWorkflow = async (props: CreateWorkflowProps) => {
const { name, isTeam, trigger } = props;
if (isTeam) {
await page.getByTestId("create-button-dropdown").click();
await page.getByTestId("option-team-1").click();
} else {
await page.getByTestId("create-button").click();
}
await page.getByTestId(`workflow-option-card-scratch`).click();
await page.getByTestId("continue-button").click();
if (name) {
await fillNameInput(name);
}
await page.locator("#trigger-select").click();
await page.getByTestId(`select-option-${trigger ?? WorkflowTriggerEvents.BEFORE_EVENT}`).click();
if (isTeam) {
await page
.getByText(/Apply to all team/i)
.first()
.click();
} else {
await selectEventType("30 min");
}
const workflow = await saveWorkflow();
for (const step of workflow.steps) {
await prisma.workflowStep.update({
where: { id: step.id },
data: { verifiedAt: new Date() },
});
}
await page.getByTestId("go-back-button").click();
};
const saveWorkflow = async () => {
const submitPromise = page.waitForResponse("/api/trpc/workflows/update?batch=1");
const saveButton = page.getByTestId("save-workflow");
await saveButton.click();
const response = await submitPromise;
expect(response.status()).toBe(200);
const responseData = await response.json();
return responseData[0].result.data.json.workflow;
};
const assertListCount = async (count: number) => {
const workflowListCount = page.locator('[data-testid="workflow-list"] > li');
await expect(workflowListCount.first()).toBeVisible();
await page.reload();
await expect(workflowListCount).toHaveCount(count);
};
const fillNameInput = async (name: string) => {
await page.getByTestId("edit-workflow-name-button").click();
const nameInput = page.getByTestId("workflow-name");
await nameInput.fill(name);
await nameInput.blur();
};
const editSelectedWorkflow = async (name: string) => {
const selectedWorkflow = page.getByTestId("workflow-list").getByTestId(nameToTestId(name));
const editButton = selectedWorkflow.getByRole("button").nth(0);
await editButton.click();
};
const hasWorkflowInList = async (name: string, negate?: true) => {
const selectedWorkflow = page.getByTestId("workflow-list").getByTestId(nameToTestId(name));
if (negate) {
await expect(selectedWorkflow).toBeHidden();
} else {
await expect(selectedWorkflow).toBeVisible();
}
};
const deleteAndConfirm = async (workflow: Locator) => {
const deleteButton = workflow.getByTestId("delete-button");
const confirmDeleteText = (await localize("en"))("confirm_delete_workflow");
await deleteButton.click();
await page.getByRole("button", { name: confirmDeleteText }).click();
};
const selectEventType = async (name: string) => {
await page.getByTestId("multi-select-check-boxes").click();
await page.getByText(name, { exact: true }).click();
};
const hasReadonlyBadge = async () => {
const readOnlyBadge = page.getByText((await localize("en"))("readonly"));
await expect(readOnlyBadge).toBeVisible();
};
const selectedWorkflowPage = async (name: string) => {
await page.getByTestId("workflow-list").getByTestId(nameToTestId(name)).click();
};
const workflowOptionsAreDisabled = async (workflow: string, negate?: boolean) => {
const getWorkflowButton = async (buttonTestId: string) =>
page.getByTestId(nameToTestId(workflow)).getByTestId(buttonTestId);
const [editButton, deleteButton] = await Promise.all([
getWorkflowButton("edit-button"),
getWorkflowButton("delete-button"),
]);
expect(editButton.isDisabled()).toBeTruthy();
expect(deleteButton.isDisabled()).toBeTruthy();
};
const assertWorkflowWasTriggered = async (emails: Fixtures["emails"], emailsToBeReceived: string[]) => {
const message = await emails.messages();
emailsToBeReceived.forEach((email) => {
expect(message?.items).toEqual(
expect.arrayContaining([
expect.objectContaining({
subject: expect.stringMatching(subjectPattern),
to: email,
}),
])
);
});
};
const assertWorkflowReminders = async (eventTypeId: number, count: number) => {
const booking = await prisma.booking.findFirst({
where: {
eventTypeId,
},
});
const workflowReminders = await prisma.workflowReminder.findMany({
where: {
bookingUid: booking?.uid ?? "",
},
});
expect(workflowReminders).toHaveLength(count);
};
function nameToTestId(name: string) {
return `workflow-${name.split(" ").join("-").toLowerCase()}`;
}
return {
createWorkflow,
saveWorkflow,
assertListCount,
fillNameInput,
editSelectedWorkflow,
hasWorkflowInList,
deleteAndConfirm,
selectEventType,
hasReadonlyBadge,
selectedWorkflowPage,
workflowOptionsAreDisabled,
assertWorkflowReminders,
assertWorkflowWasTriggered,
};
}