feat: add 5 new workflow triggers for booking events (#23068)
* feat: add 5 new workflow triggers for booking events
- Add BOOKING_REJECTED, BOOKING_REQUESTED, BOOKING_PAYMENT_INITIATED, BOOKING_PAID, BOOKING_NO_SHOW_UPDATED to WorkflowTriggerEvents enum
- Update workflow constants to include new trigger options
- Implement workflow trigger logic for booking rejected and requested events
- Add translations for new workflow triggers following {enum}_trigger format
- Generate updated Prisma types for new schema changes
Co-Authored-By: [email protected] <[email protected]>
* fix: type check, remove as any
* feat: add workflow trigger for BOOKING_REQUESTED in handleNewBooking.ts
- Add WorkflowTriggerEvents import to handleNewBooking.ts
- Implement workflow trigger logic for BOOKING_REQUESTED in else block
- Filter workflows by BOOKING_REQUESTED trigger and call scheduleWorkflowReminders
- Use proper calendar event object construction without type casting
- Add error handling for workflow reminder scheduling
Co-Authored-By: [email protected] <[email protected]>
* fix: resolve type errors in workflow trigger implementations
- Add proper database includes for user information in handleConfirmation.ts
- Fix ExtendedCalendarEvent type structure with correct hosts mapping
- Add missing properties to calendar event objects in handleMarkNoShow.ts
- Ensure all workflow triggers follow proper type patterns
Co-Authored-By: [email protected] <[email protected]>
* feat: add workflow test configurations for new booking triggers
- Add workflow configurations for BOOKING_REQUESTED and BOOKING_PAYMENT_INITIATED in fresh-booking.test.ts
- Add workflow configuration for BOOKING_REJECTED in confirm.handler.test.ts
- Enable previously skipped confirm.handler.test.ts
- Remove workflow test assertions temporarily until triggers are fully functional
- Maintain webhook test coverage while adding workflow test infrastructure
Co-Authored-By: [email protected] <[email protected]>
* fix: add missing mockSuccessfulVideoMeetingCreation import to confirm.handler.test.ts
- Import mockSuccessfulVideoMeetingCreation from bookingScenario utils
- Add mock call to BOOKING_REJECTED workflow test case
- Resolves ReferenceError that was causing unit test CI failure
Co-Authored-By: [email protected] <[email protected]>
* refactor: improve _scheduleWorkflowReminders readability and add missing booking trigger events
- Extract complex conditional logic into helper functions (isImmediateTrigger, isTimeBased, shouldProcessWorkflow)
- Add missing workflow trigger events with immediate execution logic
- Update test workflows to use different actions (EMAIL_ATTENDEE, SMS_ATTENDEE) for better differentiation
- Fix translation function mock in confirm.handler.test.ts using mockNoTranslations utility
- Maintain existing functionality while improving code maintainability
Co-Authored-By: [email protected] <[email protected]>
* filter outside scheduleWorkflowReminder
* fix type check
* chore: add more tests
* test: add comprehensive unit tests for handleMarkNoShow with webhook and workflow coverage
- Create handleMarkNoShow.test.ts following confirm.handler.test.ts pattern
- Add expectBookingNoShowUpdatedWebhookToHaveBeenFired utility function
- Test both webhook and workflow triggers for BOOKING_NO_SHOW_UPDATED
- Cover attendee/host no-show scenarios, multiple attendees, and error cases
- All 6 unit tests pass with proper mocking of external dependencies
Co-Authored-By: [email protected] <[email protected]>
* Revert "test: add comprehensive unit tests for handleMarkNoShow with webhook and workflow coverage"
This reverts commit 764299220279f0c012392dec24d3150246bfc4ad.
* fix: add new workflow triggers to api/v2
* update swagger docs
* fix: e2e
* fix type check
* fix tests, add test for before after events
* fix unit tests
* revert confirm.handler.test
* fix: unit tests
* review fixes
* refactor WorkflowService
* remove logs
* remove unused
* fix: type check
* fix: missed before after events for recurring
* fix: calendarEvent handleMarkNoShow
* fix error message
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* review fixes
* add missing BOOKING_PAID workflow trigger
* fix pathname
* fix: test for BOOKING_REQUESTED
* review fixes
* Update packages/features/bookings/lib/handleSeats/handleSeats.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Carina Wollendorfer <[email protected]>
This commit is contained in:
27 files changed
+1007
-85
No files matched your search
@@ -3,6 +3,7 @@ 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";
|
||||
|
||||
@@ -12,6 +13,8 @@ type CreateWorkflowProps = {
|
||||
trigger?: WorkflowTriggerEvents;
|
||||
};
|
||||
|
||||
const subjectPattern = /^Reminder: /i;
|
||||
|
||||
export function createWorkflowPageFixture(page: Page) {
|
||||
const createWorkflow = async (props: CreateWorkflowProps) => {
|
||||
const { name, isTeam, trigger } = props;
|
||||
@@ -25,8 +28,8 @@ export function createWorkflowPageFixture(page: Page) {
|
||||
await fillNameInput(name);
|
||||
}
|
||||
if (trigger) {
|
||||
page.locator("div").filter({ hasText: WorkflowTriggerEvents.BEFORE_EVENT }).nth(1);
|
||||
page.getByText(trigger);
|
||||
await page.locator("#trigger-select").click();
|
||||
await page.getByTestId(`select-option-${trigger ?? WorkflowTriggerEvents.BEFORE_EVENT}`).click();
|
||||
await selectEventType("30 min");
|
||||
}
|
||||
const workflow = await saveWorkflow();
|
||||
@@ -112,6 +115,20 @@ export function createWorkflowPageFixture(page: Page) {
|
||||
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: {
|
||||
@@ -143,5 +160,6 @@ export function createWorkflowPageFixture(page: Page) {
|
||||
selectedWorkflowPage,
|
||||
workflowOptionsAreDisabled,
|
||||
assertWorkflowReminders,
|
||||
assertWorkflowWasTriggered,
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { bookEventOnThisPage } from "./lib/testUtils";
|
||||
test.describe("Workflow Tab - Event Type", () => {
|
||||
test.describe("Check the functionalities of the Workflow Tab", () => {
|
||||
test.describe("User Workflows", () => {
|
||||
test.beforeEach(async ({ page, users }) => {
|
||||
test.beforeEach(async ({ page, users, emails }) => {
|
||||
await loginUser(users);
|
||||
await page.goto("/workflows");
|
||||
});
|
||||
@@ -42,16 +42,28 @@ test.describe("Workflow Tab - Event Type", () => {
|
||||
await assertListCount(1);
|
||||
});
|
||||
|
||||
test("Create an action and check if workflow is triggered", async ({ page, users, workflowPage }) => {
|
||||
test("Create an action and check if workflow reminder is added", async ({
|
||||
page,
|
||||
users,
|
||||
workflowPage,
|
||||
emails,
|
||||
}) => {
|
||||
const { createWorkflow, assertWorkflowReminders } = workflowPage;
|
||||
const [user] = users.get();
|
||||
const [eventType] = user.eventTypes;
|
||||
|
||||
await createWorkflow({ name: "A New Workflow", trigger: WorkflowTriggerEvents.NEW_EVENT });
|
||||
await createWorkflow({
|
||||
name: "A New Before Event Workflow",
|
||||
trigger: WorkflowTriggerEvents.BEFORE_EVENT,
|
||||
});
|
||||
await createWorkflow({
|
||||
name: "A New After Event Workflow",
|
||||
trigger: WorkflowTriggerEvents.AFTER_EVENT,
|
||||
});
|
||||
await page.goto(`/${user.username}/${eventType.slug}`);
|
||||
await page.click('[data-testid="incrementMonth"]');
|
||||
await bookEventOnThisPage(page);
|
||||
await assertWorkflowReminders(eventType.id, 1);
|
||||
await assertWorkflowReminders(eventType.id, 2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user