From 06429e27fb90bc112c27a794785e80e818c3ae3b Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Wed, 9 Oct 2024 22:47:16 +0530 Subject: [PATCH] test: Add Attributes Routing e2e and some more unit tests (#17032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial commit * routingForm to Booking a particular team member working * Happy path working * Fixes * Fix router query params forwarding * Add basicConfig within app * Tests * More tests * Update packages/app-store/routing-forms/components/SingleForm.tsx Co-authored-by: Omar López * WIP * Fix lint issues * Fix tests -TS and add new logic * Add getEventTypeRedirectUrl tests * Remove booking title changes code * More changes * Add tests for getRoutedUsers * More tests * Update testUtils.ts --------- Co-authored-by: Omar López Co-authored-by: Keith Williams --- apps/web/playwright/fixtures/users.ts | 7 +- packages/app-store/routing-forms/TODO.md | 3 +- .../pages/route-builder/[...appPages].tsx | 1 + .../playwright/tests/basic.e2e.ts | 177 +++++++++++++++++- .../playwright/tests/testUtils.ts | 20 +- packages/lib/bookings/getRoutedUsers.test.ts | 128 +++++++++++++ .../server/routers/viewer/slots/util.test.ts | 90 +++++++++ .../trpc/server/routers/viewer/slots/util.ts | 6 +- 8 files changed, 423 insertions(+), 9 deletions(-) create mode 100644 packages/lib/bookings/getRoutedUsers.test.ts create mode 100644 packages/trpc/server/routers/viewer/slots/util.test.ts diff --git a/apps/web/playwright/fixtures/users.ts b/apps/web/playwright/fixtures/users.ts index d7150cf16e..26a4488d3c 100644 --- a/apps/web/playwright/fixtures/users.ts +++ b/apps/web/playwright/fixtures/users.ts @@ -153,6 +153,7 @@ const createTeamAndAddUser = async ( isDnsSetup, index, orgRequestedSlug, + schedulingType, }: { user: { id: number; email: string; username: string | null; role?: MembershipRole }; isUnpublished?: boolean; @@ -163,6 +164,7 @@ const createTeamAndAddUser = async ( organizationId?: number | null; index?: number; orgRequestedSlug?: string; + schedulingType?: SchedulingType; }, workerInfo: WorkerInfo ) => { @@ -189,7 +191,9 @@ const createTeamAndAddUser = async ( data.slug = !isUnpublished ? slug : undefined; if (isOrg && hasSubteam) { const team = await createTeamAndAddUser({ user }, workerInfo); - await createTeamEventType(user, team); + await createTeamEventType(user, team, { + schedulingType: schedulingType, + }); await createTeamWorkflow(user, team); data.children = { connect: [{ id: team.id }] }; } @@ -532,6 +536,7 @@ export const createUsersFixture = ( hasSubteam: scenario.hasSubteam, organizationId: opts?.organizationId, orgRequestedSlug: scenario.orgRequestedSlug, + schedulingType: scenario.schedulingType, }, workerInfo ); diff --git a/packages/app-store/routing-forms/TODO.md b/packages/app-store/routing-forms/TODO.md index e7ce90225f..0fee3b24fc 100644 --- a/packages/app-store/routing-forms/TODO.md +++ b/packages/app-store/routing-forms/TODO.md @@ -13,6 +13,7 @@ - [ ] Warnings are needed with recommendation to create new attribute instead in unsupported scenarios. We need to test for more such changes to Attribute types. - [ ] When choosing 'Value of Field' option in RAQB, show a warning somewhere if all options of the Form field aren't present in the attribute option. - So, if Form Field is 'What is Comapny Size' with options Enterprise, Large, Medium, Small and Attribute for which Value of 'What is compnay size' has options Enterprise, Large, Medium. It would show a warning that 'Small' option is not present in the attribute. +- [ ] When logic can't be built(Short text maps to an attribute with given set of options but the short text value doesn't match any of the options), the team member matching route throws error but Test Preview still shows the previous value - It show should the error in there. ### Performance Tests and Improvements - [ ] Test with ~1000 team members and ~100 attributes. @@ -30,7 +31,7 @@ - [x] Basic Tests - [ ] getAttributes - [ ] Querying Logic Test -- [ ] getRoutedUsers tests +- [x] getRoutedUsers tests - [ ] getAvailableSlots - [ ] should use routedTeamMemberIds in availability query diff --git a/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx b/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx index 1a1bfcf506..15c90a6e03 100644 --- a/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx @@ -444,6 +444,7 @@ const Route = ({