2023-02-16 22:39:57 +00:00
import type { Page } from "@playwright/test" ;
import { expect } from "@playwright/test" ;
2022-07-14 12:40:53 +00:00
2023-02-16 22:39:57 +00:00
import type { Fixtures } from "@calcom/web/playwright/lib/fixtures" ;
import { test } from "@calcom/web/playwright/lib/fixtures" ;
2023-06-13 15:22:19 +00:00
import { gotoRoutingLink } from "@calcom/web/playwright/lib/testUtils" ;
2022-08-13 11:04:57 +00:00
2023-01-04 13:30:46 +00:00
function todo ( title : string ) {
// eslint-disable-next-line playwright/no-skipped-test, @typescript-eslint/no-empty-function
test . skip ( title , ( ) = > { } ) ;
2022-07-14 12:40:53 +00:00
}
2022-08-13 11:04:57 +00:00
test . describe ( "Routing Forms" , ( ) = > {
2022-09-02 19:00:41 +00:00
test . describe ( "Zero State Routing Forms" , ( ) = > {
test ( "should be able to add a new form and view it" , async ( { page } ) = > {
await page . waitForSelector ( '[data-testid="empty-screen"]' ) ;
2022-07-14 12:40:53 +00:00
2022-09-02 19:00:41 +00:00
const formId = await addForm ( page ) ;
2022-07-14 12:40:53 +00:00
2022-09-22 17:23:43 +00:00
await page . click ( '[href="/apps/routing-forms/forms"]' ) ;
2022-07-20 18:30:57 +00:00
2022-09-02 19:00:41 +00:00
await page . waitForSelector ( '[data-testid="routing-forms-list"]' ) ;
// Ensure that it's visible in forms list
expect ( await page . locator ( '[data-testid="routing-forms-list"] > li' ) . count ( ) ) . toBe ( 1 ) ;
2022-08-13 11:04:57 +00:00
2023-05-17 08:47:48 +00:00
await gotoRoutingLink ( { page , formId } ) ;
await expect ( page . locator ( "text=Test Form Name" ) ) . toBeVisible ( ) ;
2022-08-13 11:04:57 +00:00
2022-09-22 17:23:43 +00:00
await page . goto ( ` apps/routing-forms/route-builder/ ${ formId } ` ) ;
2023-05-17 08:47:48 +00:00
await disableForm ( page ) ;
await gotoRoutingLink ( { page , formId } ) ;
await expect ( page . locator ( "text=ERROR 404" ) ) . toBeVisible ( ) ;
2022-09-02 19:00:41 +00:00
} ) ;
2022-08-13 11:04:57 +00:00
2022-09-02 19:00:41 +00:00
test ( "should be able to edit the form" , async ( { page } ) = > {
2023-01-04 13:30:46 +00:00
const formId = await addForm ( page ) ;
2022-09-02 19:00:41 +00:00
const description = "Test Description" ;
2022-07-14 12:40:53 +00:00
2023-04-12 20:58:03 +00:00
const label = "Test Label" ;
const createdFields : Record < number , { label : string ; typeIndex : number } > = { } ;
2023-05-17 08:47:48 +00:00
const { fieldTypesList : types , fields } = await addAllTypesOfFieldsAndSaveForm ( formId , page , {
description ,
label ,
} ) ;
2022-09-02 19:00:41 +00:00
2023-03-15 22:01:04 +00:00
expect ( await page . inputValue ( ` [data-testid="description"] ` ) ) . toBe ( description ) ;
2023-04-12 20:58:03 +00:00
expect ( await page . locator ( '[data-testid="field"]' ) . count ( ) ) . toBe ( types . length ) ;
2023-01-04 13:30:46 +00:00
2023-05-17 08:47:48 +00:00
fields . forEach ( ( item , index ) = > {
createdFields [ index ] = { label : item.label , typeIndex : index } ;
2023-04-12 20:58:03 +00:00
} ) ;
2023-05-17 08:47:48 +00:00
2023-04-12 20:58:03 +00:00
await expectCurrentFormToHaveFields ( page , createdFields , types ) ;
2022-07-14 12:40:53 +00:00
2022-09-22 17:23:43 +00:00
await page . click ( '[href*="/apps/routing-forms/route-builder/"]' ) ;
2023-01-04 13:30:46 +00:00
await selectNewRoute ( page ) ;
2022-09-02 19:00:41 +00:00
await page . click ( '[data-testid="add-rule"]' ) ;
2023-01-04 13:30:46 +00:00
2023-04-12 20:58:03 +00:00
const options = Object . values ( createdFields ) . map ( ( item ) = > item . label ) ;
await verifyFieldOptionsInRule ( options , page ) ;
2023-01-04 13:30:46 +00:00
} ) ;
test . describe ( "F1<-F2 Relationship" , ( ) = > {
2023-05-17 08:47:48 +00:00
test ( "Create relationship by adding F1 as route.Editing F1 should update F2" , async ( { page } ) = > {
2023-01-04 13:30:46 +00:00
const form1Id = await addForm ( page , { name : "F1" } ) ;
const form2Id = await addForm ( page , { name : "F2" } ) ;
await addOneFieldAndDescriptionAndSaveForm ( form1Id , page , {
description : "Form 1 Description" ,
field : {
label : "F1 Field1" ,
typeIndex : 1 ,
} ,
} ) ;
const { types } = await addOneFieldAndDescriptionAndSaveForm ( form2Id , page , {
description : "Form 2 Description" ,
field : {
label : "F2 Field1" ,
//TODO: Maybe choose some other type and choose type by it's name and not index
typeIndex : 1 ,
} ,
} ) ;
// Add F1 as Router to F2
await page . goto ( ` /apps/routing-forms/route-builder/ ${ form2Id } ` ) ;
await selectNewRoute ( page , {
// It should be F1. TODO: Verify that it's F1
routeSelectNumber : 2 ,
} ) ;
await saveCurrentForm ( page ) ;
// Expect F1 fields to be available in F2
await page . goto ( ` /apps/routing-forms/form-edit/ ${ form2Id } ` ) ;
2023-01-07 15:50:28 +00:00
//FIXME: Figure out why this delay is required. Without it field count comes out to be 1 only
await new Promise ( ( resolve ) = > setTimeout ( resolve , 1000 ) ) ;
2023-01-04 13:30:46 +00:00
expect ( await page . locator ( '[data-testid="field"]' ) . count ( ) ) . toBe ( 2 ) ;
await expectCurrentFormToHaveFields ( page , { 1 : { label : "F1 Field1" , typeIndex : 1 } } , types ) ;
// Add 1 more field in F1
await addOneFieldAndDescriptionAndSaveForm ( form1Id , page , {
field : {
label : "F1 Field2" ,
typeIndex : 1 ,
} ,
} ) ;
await page . goto ( ` /apps/routing-forms/form-edit/ ${ form2Id } ` ) ;
2023-01-07 15:50:28 +00:00
//FIXME: Figure out why this delay is required. Without it field count comes out to be 1 only
await new Promise ( ( resolve ) = > setTimeout ( resolve , 1000 ) ) ;
2023-01-04 13:30:46 +00:00
expect ( await page . locator ( '[data-testid="field"]' ) . count ( ) ) . toBe ( 3 ) ;
await expectCurrentFormToHaveFields ( page , { 2 : { label : "F1 Field2" , typeIndex : 1 } } , types ) ;
} ) ;
todo ( "Create relationship by using duplicate with live connect" ) ;
} ) ;
2023-05-17 08:47:48 +00:00
test ( "should be able to submit a prefilled form with all types of fields" , async ( { page } ) = > {
const formId = await addForm ( page ) ;
await page . click ( '[href*="/apps/routing-forms/route-builder/"]' ) ;
await selectNewRoute ( page ) ;
await selectOption ( {
selector : {
selector : ".data-testid-select-routing-action" ,
nth : 0 ,
} ,
option : 2 ,
page ,
} ) ;
await page . fill ( "[name=externalRedirectUrl]" , "https://www.google.com" ) ;
await saveCurrentForm ( page ) ;
const { fields } = await addAllTypesOfFieldsAndSaveForm ( formId , page , {
description : "Description" ,
label : "Test Field" ,
} ) ;
const queryString =
2023-06-05 05:51:19 +00:00
"firstField=456&Test Field Number=456&Test Field Single Selection=456&Test Field Multiple Selection=456&Test Field Multiple Selection=789&Test Field Phone=456&Test Field Email=456@example.com" ;
2023-05-17 08:47:48 +00:00
await gotoRoutingLink ( { page , queryString } ) ;
await page . fill ( '[data-testid="form-field-Test Field Long Text"]' , "manual-fill" ) ;
expect ( await page . locator ( ` [data-testid="form-field-firstField"] ` ) . inputValue ( ) ) . toBe ( "456" ) ;
expect ( await page . locator ( ` [data-testid="form-field-Test Field Number"] ` ) . inputValue ( ) ) . toBe ( "456" ) ;
// TODO: Verify select and multiselect has prefilled values.
// expect(await page.locator(`[data-testid="form-field-Test Field Select"]`).inputValue()).toBe("456");
// expect(await page.locator(`[data-testid="form-field-Test Field MultiSelect"]`).inputValue()).toBe("456");
expect ( await page . locator ( ` [data-testid="form-field-Test Field Phone"] ` ) . inputValue ( ) ) . toBe ( "456" ) ;
expect ( await page . locator ( ` [data-testid="form-field-Test Field Email"] ` ) . inputValue ( ) ) . toBe (
"456@example.com"
) ;
await page . click ( 'button[type="submit"]' ) ;
await page . waitForURL ( ( url ) = > {
return url . hostname . includes ( "google.com" ) ;
} ) ;
const url = new URL ( page . url ( ) ) ;
// Coming from the response filled by booker
expect ( url . searchParams . get ( "firstField" ) ) . toBe ( "456" ) ;
// All other params come from prefill URL
expect ( url . searchParams . get ( "Test Field Number" ) ) . toBe ( "456" ) ;
expect ( url . searchParams . get ( "Test Field Long Text" ) ) . toBe ( "manual-fill" ) ;
2023-06-05 05:51:19 +00:00
expect ( url . searchParams . get ( "Test Field Multiple Selection" ) ) . toBe ( "456" ) ;
expect ( url . searchParams . getAll ( "Test Field Multiple Selection" ) ) . toMatchObject ( [ "456" , "789" ] ) ;
2023-05-17 08:47:48 +00:00
expect ( url . searchParams . get ( "Test Field Phone" ) ) . toBe ( "456" ) ;
expect ( url . searchParams . get ( "Test Field Email" ) ) . toBe ( "456@example.com" ) ;
} ) ;
2023-01-04 13:30:46 +00:00
// TODO: How to install the app just once?
test . beforeEach ( async ( { page , users } ) = > {
2023-01-23 09:58:41 +00:00
const user = await users . create (
{ username : "routing-forms" } ,
{
hasTeam : true ,
}
) ;
2023-06-15 08:58:07 +00:00
await user . apiLogin ( ) ;
2023-01-04 13:30:46 +00:00
// Install app
await page . goto ( ` /apps/routing-forms ` ) ;
await page . click ( '[data-testid="install-app-button"]' ) ;
feat: Enable Apps for Teams & Orgs [CAL-1782] (#9337)
* Initial commit
* Adding feature flag
* Add schema relation for teams and credentials
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Create getUserAdminTeams function & tRPC endpoint
* Get user admin teams on app store page
* Create UserAdminTeams type
* Add user query to getUserAdminTeams
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Add dropdown to install button on app store
* Supporting having the orgId in the session cookie
* On app page, only show dropdown if there are teams
* Add teamId to OAuth state
* Create team credential for OAuth flow
* Create team credential for GCal
* Add create user or team credential for Stripe
* Create webex credentials for users or teams
* Fix type error on useAddAppMutation
* Hubspot create credential on user or team
* Zoho create create credential for user or team
* Zoom create credentials on user or team
* Salesforce create credential on user or teams
* OAuth create credentials for user or teams
* Revert Outlook changes
* Revert GCal changes
* Default app instal, create credential on user or team
* Add teamId to credential creation
* Disable installing for teams for calendars
* Include teams when querying installed apps
* Render team credentials on installed page
* Uninstall team apps
* Type fix on app card
* Add input to include user in teams query
* Add dropdown to install app page for user or team
* Type fixes on category page
* Install app from eventType page to user or team
* Render user and team apps on event type app page
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* Render user and team apps on event type app page
* Add credentialOwner to eventTypeAppCard types
* Type fixes
* Create hook to check if app is enabled
* Clean up console.logs
* Fix useIsAppEnabled by returning not an array
* Convert event type apps to useIsAppEnabled
* Abstract credential owner type
* Remove console.logs
* On installed app page, show apps if only team credential is installed
* Clean up commented lines
* Handle installing app to just an team event from event type page
* Fix early return when creating team app credential
* Zoom add state to callback
* Get team location credentials and save credential id to location
* feat: Onboarding process to create an organization (#9184)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Making sure we check requestedSlug now
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type fix
* Grab team location credentials
* Add isInstalled to eventType apps query
* feat: [CAL-1816] Organization subdomain support (#9345)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* Covering users and subteams, excluding non-org users
* Unpublished teams shows correctly
* Create subdomain in Vercel
* feedback
* Renaming Vercel env vars
* Vercel domain check before creation
* Supporting cal-staging.com
* Change to have vercel detect it
* vercel domain check data message error
* Remove check domain
* Making sure we check requestedSlug now
* Feedback and unneeded code
* Reverting unneeded changes
* Unneeded changes
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Enable payment apps for team credentials
* Fix for team-user apps for event types
* Fix layout and add teamId to app card
* Disable apps on managed event types
* Add managed event type fields to event type apps
* Include organizations in query
* Change createAppCredential to createOAuthAppCredential
* Show app installed on teams
* Making sure we let localhost still work
* UI show installed for which team
* Type fixes
* For team events move use host location to top
* Add around to appStore
* New team event types organizer default conf app
* Fix app card bug
* Clean up
* Search for teamId or userId when deleting credential
* Type fixes
* Type fixes
* Type fixes
* Type fixes
* Address feedback
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* Address feedback
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Fix app card bug
* Fix schema
* Type fixes
* Revert changes to location apps
* Remove console.log
* Fix app store test
* Handle install app dropdown
* Add CalendarApp to `getCalendar`
* Add PaymentApp type fix
* Payment type fix
* Type fixes
* Match with main
* Change type to account for team
* Fix app count for team events
* Type fixes
* More type fixes
* Type fix?
* Fix the type fix
* Remove UserAdminTeams empty array union
* Type fix
* Type fix
* Type fix
* Uses type predicates
* Use teamId. Fixes installation for teams after user installation
* Fix Team Events not working
* Get embed for org events working
* Fix rewrites
* Address feedback
* Type fix
* Fixes
* Add useAppContextWithSchema in useIsAppEnabled
* Type fix for apps using useIsAppEnabled
* Integrations.handler change credentialIds to userCredentialIds
* Remove apps endpoint
* Add LockedIcon and disabled props to event type app context
* Type fixes
* Type fix
* Type fixes
* Show team installed apps for members
* Type fix
* Reverting findFirst
* Revert findFirst
* Avoid a possible 500
* Fix missing tanslation
* Avoid possible 500
* Undo default app for teams
* Type fix
* Fix test
* Update package.json
* feat: Fix invite bug - added tests (#9945)
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* chore: Button Component Tidy up (#9888)
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
* feat: Make Team Private
## What does this PR do?
Fixes https://github.com/calcom/cal.com/issues/8974
1) When user is admin
<img width="1440" alt="Screenshot 2023-07-03 at 6 45 50 PM" src="https://github.com/calcom/cal.com/assets/53316345/ce15158f-d278-4f1a-ba2e-8b63e4274793">
2) When user is not admin and team is private
<img width="1440" alt="Screenshot 2023-07-03 at 6 47 15 PM" src="https://github.com/calcom/cal.com/assets/53316345/ce23560e-690a-4c42-a76d-49691260aa4d">
3)
<img width="1440" alt="Screenshot 2023-07-03 at 6 51 56 PM" src="https://github.com/calcom/cal.com/assets/53316345/13af38f8-5618-4dae-b359-b24dc91e4eb4">
## Type of change
<!-- Please delete bullets that are not relevant. -->
- New feature (non-breaking change which adds functionality)
## How should this be tested?
1) go to Team members page and turn on switch Make Team Private.
Now after making the team private only admin would be able to see all the members list in the settings. There will not be a button to Book a team member instead on the team page like before.
## Mandatory Tasks
- [ ] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Alan <alannnc@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-07-06 16:48:39 +00:00
( await page . waitForSelector ( '[data-testid="install-app-button-personal"]' ) ) . click ( ) ;
2023-05-02 16:58:39 +00:00
await page . waitForURL ( ( url ) = > url . pathname === ` /apps/routing-forms/forms ` ) ;
2023-01-04 13:30:46 +00:00
} ) ;
test . afterEach ( async ( { users } ) = > {
// This also delete forms on cascade
await users . deleteAll ( ) ;
2022-09-02 19:00:41 +00:00
} ) ;
2022-07-14 12:40:53 +00:00
} ) ;
2022-08-13 11:04:57 +00:00
2023-01-04 13:30:46 +00:00
todo ( "should be able to duplicate form" ) ;
2022-08-13 11:04:57 +00:00
test . describe ( "Seeded Routing Form " , ( ) = > {
2023-01-04 13:30:46 +00:00
test . afterEach ( async ( { users } ) = > {
// This also delete forms on cascade
await users . deleteAll ( ) ;
} ) ;
2022-09-02 19:00:41 +00:00
const createUserAndLoginAndInstallApp = async function ( {
users ,
page ,
} : {
users : Fixtures [ "users" ] ;
page : Page ;
} ) {
2023-01-23 09:58:41 +00:00
const user = await users . create (
{ username : "routing-forms" } ,
{ seedRoutingForms : true , hasTeam : true }
) ;
2023-06-15 08:58:07 +00:00
await user . apiLogin ( ) ;
2022-09-02 19:00:41 +00:00
// Install app
2022-09-22 17:23:43 +00:00
await page . goto ( ` /apps/routing-forms ` ) ;
2022-09-02 19:00:41 +00:00
await page . click ( '[data-testid="install-app-button"]' ) ;
feat: Enable Apps for Teams & Orgs [CAL-1782] (#9337)
* Initial commit
* Adding feature flag
* Add schema relation for teams and credentials
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Create getUserAdminTeams function & tRPC endpoint
* Get user admin teams on app store page
* Create UserAdminTeams type
* Add user query to getUserAdminTeams
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Add dropdown to install button on app store
* Supporting having the orgId in the session cookie
* On app page, only show dropdown if there are teams
* Add teamId to OAuth state
* Create team credential for OAuth flow
* Create team credential for GCal
* Add create user or team credential for Stripe
* Create webex credentials for users or teams
* Fix type error on useAddAppMutation
* Hubspot create credential on user or team
* Zoho create create credential for user or team
* Zoom create credentials on user or team
* Salesforce create credential on user or teams
* OAuth create credentials for user or teams
* Revert Outlook changes
* Revert GCal changes
* Default app instal, create credential on user or team
* Add teamId to credential creation
* Disable installing for teams for calendars
* Include teams when querying installed apps
* Render team credentials on installed page
* Uninstall team apps
* Type fix on app card
* Add input to include user in teams query
* Add dropdown to install app page for user or team
* Type fixes on category page
* Install app from eventType page to user or team
* Render user and team apps on event type app page
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* Render user and team apps on event type app page
* Add credentialOwner to eventTypeAppCard types
* Type fixes
* Create hook to check if app is enabled
* Clean up console.logs
* Fix useIsAppEnabled by returning not an array
* Convert event type apps to useIsAppEnabled
* Abstract credential owner type
* Remove console.logs
* On installed app page, show apps if only team credential is installed
* Clean up commented lines
* Handle installing app to just an team event from event type page
* Fix early return when creating team app credential
* Zoom add state to callback
* Get team location credentials and save credential id to location
* feat: Onboarding process to create an organization (#9184)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Making sure we check requestedSlug now
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type fix
* Grab team location credentials
* Add isInstalled to eventType apps query
* feat: [CAL-1816] Organization subdomain support (#9345)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* Covering users and subteams, excluding non-org users
* Unpublished teams shows correctly
* Create subdomain in Vercel
* feedback
* Renaming Vercel env vars
* Vercel domain check before creation
* Supporting cal-staging.com
* Change to have vercel detect it
* vercel domain check data message error
* Remove check domain
* Making sure we check requestedSlug now
* Feedback and unneeded code
* Reverting unneeded changes
* Unneeded changes
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Enable payment apps for team credentials
* Fix for team-user apps for event types
* Fix layout and add teamId to app card
* Disable apps on managed event types
* Add managed event type fields to event type apps
* Include organizations in query
* Change createAppCredential to createOAuthAppCredential
* Show app installed on teams
* Making sure we let localhost still work
* UI show installed for which team
* Type fixes
* For team events move use host location to top
* Add around to appStore
* New team event types organizer default conf app
* Fix app card bug
* Clean up
* Search for teamId or userId when deleting credential
* Type fixes
* Type fixes
* Type fixes
* Type fixes
* Address feedback
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* Address feedback
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Fix app card bug
* Fix schema
* Type fixes
* Revert changes to location apps
* Remove console.log
* Fix app store test
* Handle install app dropdown
* Add CalendarApp to `getCalendar`
* Add PaymentApp type fix
* Payment type fix
* Type fixes
* Match with main
* Change type to account for team
* Fix app count for team events
* Type fixes
* More type fixes
* Type fix?
* Fix the type fix
* Remove UserAdminTeams empty array union
* Type fix
* Type fix
* Type fix
* Uses type predicates
* Use teamId. Fixes installation for teams after user installation
* Fix Team Events not working
* Get embed for org events working
* Fix rewrites
* Address feedback
* Type fix
* Fixes
* Add useAppContextWithSchema in useIsAppEnabled
* Type fix for apps using useIsAppEnabled
* Integrations.handler change credentialIds to userCredentialIds
* Remove apps endpoint
* Add LockedIcon and disabled props to event type app context
* Type fixes
* Type fix
* Type fixes
* Show team installed apps for members
* Type fix
* Reverting findFirst
* Revert findFirst
* Avoid a possible 500
* Fix missing tanslation
* Avoid possible 500
* Undo default app for teams
* Type fix
* Fix test
* Update package.json
* feat: Fix invite bug - added tests (#9945)
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* chore: Button Component Tidy up (#9888)
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
* feat: Make Team Private
## What does this PR do?
Fixes https://github.com/calcom/cal.com/issues/8974
1) When user is admin
<img width="1440" alt="Screenshot 2023-07-03 at 6 45 50 PM" src="https://github.com/calcom/cal.com/assets/53316345/ce15158f-d278-4f1a-ba2e-8b63e4274793">
2) When user is not admin and team is private
<img width="1440" alt="Screenshot 2023-07-03 at 6 47 15 PM" src="https://github.com/calcom/cal.com/assets/53316345/ce23560e-690a-4c42-a76d-49691260aa4d">
3)
<img width="1440" alt="Screenshot 2023-07-03 at 6 51 56 PM" src="https://github.com/calcom/cal.com/assets/53316345/13af38f8-5618-4dae-b359-b24dc91e4eb4">
## Type of change
<!-- Please delete bullets that are not relevant. -->
- New feature (non-breaking change which adds functionality)
## How should this be tested?
1) go to Team members page and turn on switch Make Team Private.
Now after making the team private only admin would be able to see all the members list in the settings. There will not be a button to Book a team member instead on the team page like before.
## Mandatory Tasks
- [ ] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Alan <alannnc@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-07-06 16:48:39 +00:00
( await page . waitForSelector ( '[data-testid="install-app-button-personal"]' ) ) . click ( ) ;
2023-05-02 16:58:39 +00:00
await page . waitForURL ( ( url ) = > url . pathname === ` /apps/routing-forms/forms ` ) ;
2022-09-02 19:00:41 +00:00
return user ;
} ;
2022-11-11 09:57:44 +00:00
test ( "Routing Link - Reporting and CSV Download " , async ( { page , users } ) = > {
2022-09-02 19:00:41 +00:00
const user = await createUserAndLoginAndInstallApp ( { users , page } ) ;
const routingForm = user . routingForms [ 0 ] ;
2022-11-11 09:57:44 +00:00
test . setTimeout ( 120000 ) ;
2022-09-02 19:00:41 +00:00
// Fill form when you are logged out
await users . logout ( ) ;
2022-08-13 11:04:57 +00:00
2022-11-11 09:57:44 +00:00
await fillSeededForm ( page , routingForm . id ) ;
2022-09-02 19:00:41 +00:00
// Log back in to view form responses.
2023-06-15 08:58:07 +00:00
await user . apiLogin ( ) ;
2022-09-02 19:00:41 +00:00
2022-11-11 09:57:44 +00:00
await page . goto ( ` /apps/routing-forms/reporting/ ${ routingForm . id } ` ) ;
// Can't keep waiting forever. So, added a timeout of 5000ms
2023-05-05 16:19:10 +00:00
await page . waitForResponse ( ( response ) = > response . url ( ) . includes ( "appRoutingForms/report" ) , {
2022-11-11 09:57:44 +00:00
timeout : 5000 ,
} ) ;
const headerEls = page . locator ( "[data-testid='reporting-header'] th" ) ;
// Once the response is there, React would soon render it, so 500ms is enough
2023-01-17 16:36:06 +00:00
// FIXME: Sometimes it takes more than 500ms, so added a timeout of 1000ms for now. There might be something wrong with rendering.
2022-11-11 09:57:44 +00:00
await headerEls . first ( ) . waitFor ( {
2023-01-17 16:36:06 +00:00
timeout : 1000 ,
2022-11-11 09:57:44 +00:00
} ) ;
const numHeaderEls = await headerEls . count ( ) ;
const headers = [ ] ;
for ( let i = 0 ; i < numHeaderEls ; i ++ ) {
headers . push ( await headerEls . nth ( i ) . innerText ( ) ) ;
}
const responses = [ ] ;
const responseRows = page . locator ( "[data-testid='reporting-row']" ) ;
const numResponseRows = await responseRows . count ( ) ;
for ( let i = 0 ; i < numResponseRows ; i ++ ) {
const rowLocator = responseRows . nth ( i ) . locator ( "td" ) ;
const numRowEls = await rowLocator . count ( ) ;
const rowResponses = [ ] ;
for ( let j = 0 ; j < numRowEls ; j ++ ) {
rowResponses . push ( await rowLocator . nth ( j ) . innerText ( ) ) ;
}
responses . push ( rowResponses ) ;
}
expect ( headers ) . toEqual ( [ "Test field" , "Multi Select" ] ) ;
expect ( responses ) . toEqual ( [
[ "event-routing" , "" ] ,
[ "external-redirect" , "" ] ,
[ "custom-page" , "" ] ,
] ) ;
2022-08-13 11:04:57 +00:00
const [ download ] = await Promise . all ( [
// Start waiting for the download
page . waitForEvent ( "download" ) ,
// Perform the action that initiates download
page . click ( '[data-testid="download-responses"]' ) ,
] ) ;
const downloadStream = await download . createReadStream ( ) ;
2022-09-02 19:00:41 +00:00
expect ( download . suggestedFilename ( ) ) . toEqual ( ` ${ routingForm . name } - ${ routingForm . id } .csv ` ) ;
2022-08-13 11:04:57 +00:00
const csv : string = await new Promise ( ( resolve ) = > {
let body = "" ;
downloadStream ? . on ( "data" , ( chunk ) = > {
body += chunk ;
} ) ;
downloadStream ? . on ( "end" , ( ) = > {
resolve ( body ) ;
} ) ;
} ) ;
2022-11-08 14:21:53 +00:00
const csvRows = csv . trim ( ) . split ( "\n" ) ;
const csvHeaderRow = csvRows [ 0 ] ;
expect ( csvHeaderRow ) . toEqual ( "Test field,Multi Select,Submission Time" ) ;
2022-08-13 11:04:57 +00:00
2022-11-08 14:21:53 +00:00
const firstResponseCells = csvRows [ 1 ] . split ( "," ) ;
const secondResponseCells = csvRows [ 2 ] . split ( "," ) ;
const thirdResponseCells = csvRows [ 3 ] . split ( "," ) ;
expect ( firstResponseCells . slice ( 0 , - 1 ) . join ( "," ) ) . toEqual ( "event-routing," ) ;
2023-03-02 18:58:31 +00:00
expect ( new Date ( firstResponseCells . at ( - 1 ) as string ) . getDay ( ) ) . toEqual ( new Date ( ) . getDay ( ) ) ;
2022-11-08 14:21:53 +00:00
expect ( secondResponseCells . slice ( 0 , - 1 ) . join ( "," ) ) . toEqual ( "external-redirect," ) ;
2023-03-02 18:58:31 +00:00
expect ( new Date ( secondResponseCells . at ( - 1 ) as string ) . getDay ( ) ) . toEqual ( new Date ( ) . getDay ( ) ) ;
2022-11-08 14:21:53 +00:00
expect ( thirdResponseCells . slice ( 0 , - 1 ) . join ( "," ) ) . toEqual ( "custom-page," ) ;
2023-03-02 18:58:31 +00:00
expect ( new Date ( thirdResponseCells . at ( - 1 ) as string ) . getDay ( ) ) . toEqual ( new Date ( ) . getDay ( ) ) ;
2022-08-13 11:04:57 +00:00
} ) ;
2022-09-02 19:00:41 +00:00
test ( "Router URL should work" , async ( { page , users } ) = > {
const user = await createUserAndLoginAndInstallApp ( { users , page } ) ;
const routingForm = user . routingForms [ 0 ] ;
// Router should be publicly accessible
await users . logout ( ) ;
page . goto ( ` /router?form= ${ routingForm . id } &Test field=event-routing ` ) ;
2023-05-02 16:58:39 +00:00
await page . waitForURL ( ( url ) = > {
return url . pathname . endsWith ( "/pro/30min" ) ;
2022-08-13 11:04:57 +00:00
} ) ;
2022-09-02 19:00:41 +00:00
page . goto ( ` /router?form= ${ routingForm . id } &Test field=external-redirect ` ) ;
2023-05-02 16:58:39 +00:00
await page . waitForURL ( ( url ) = > {
return url . hostname . includes ( "google.com" ) ;
2022-08-13 11:04:57 +00:00
} ) ;
2022-09-02 19:00:41 +00:00
await page . goto ( ` /router?form= ${ routingForm . id } &Test field=custom-page ` ) ;
2023-05-17 08:47:48 +00:00
await expect ( page . locator ( "text=Custom Page Result" ) ) . toBeVisible ( ) ;
2022-08-13 11:04:57 +00:00
2022-09-02 19:00:41 +00:00
await page . goto ( ` /router?form= ${ routingForm . id } &Test field=doesntmatter&multi=Option-2 ` ) ;
2023-05-17 08:47:48 +00:00
await expect ( page . locator ( "text=Multiselect chosen" ) ) . toBeVisible ( ) ;
2022-08-13 11:04:57 +00:00
} ) ;
2022-09-02 19:00:41 +00:00
test ( "Routing Link should validate fields" , async ( { page , users } ) = > {
const user = await createUserAndLoginAndInstallApp ( { users , page } ) ;
const routingForm = user . routingForms [ 0 ] ;
2023-05-17 08:47:48 +00:00
await gotoRoutingLink ( { page , formId : routingForm.id } ) ;
2022-08-13 11:04:57 +00:00
page . click ( 'button[type="submit"]' ) ;
const firstInputMissingValue = await page . evaluate ( ( ) = > {
return document . querySelectorAll ( "input" ) [ 0 ] . validity . valueMissing ;
} ) ;
expect ( firstInputMissingValue ) . toBe ( true ) ;
expect ( await page . locator ( 'button[type="submit"][disabled]' ) . count ( ) ) . toBe ( 0 ) ;
} ) ;
2022-11-14 08:50:09 +00:00
test ( "Test preview should return correct route" , async ( { page , users } ) = > {
const user = await createUserAndLoginAndInstallApp ( { users , page } ) ;
const routingForm = user . routingForms [ 0 ] ;
page . goto ( ` apps/routing-forms/form-edit/ ${ routingForm . id } ` ) ;
await page . click ( '[data-testid="test-preview"]' ) ;
2023-05-30 21:15:57 +00:00
await page . waitForLoadState ( "networkidle" ) ;
2022-11-14 08:50:09 +00:00
// //event redirect
2023-05-17 08:47:48 +00:00
await page . fill ( '[data-testid="form-field-Test field"]' , "event-routing" ) ;
2022-11-14 08:50:09 +00:00
await page . click ( '[data-testid="test-routing"]' ) ;
let routingType = await page . locator ( '[data-testid="test-routing-result-type"]' ) . innerText ( ) ;
let route = await page . locator ( '[data-testid="test-routing-result"]' ) . innerText ( ) ;
2023-05-17 08:47:48 +00:00
expect ( routingType ) . toBe ( "Event Redirect" ) ;
expect ( route ) . toBe ( "pro/30min" ) ;
2022-11-14 08:50:09 +00:00
//custom page
2023-05-17 08:47:48 +00:00
await page . fill ( '[data-testid="form-field-Test field"]' , "custom-page" ) ;
2022-11-14 08:50:09 +00:00
await page . click ( '[data-testid="test-routing"]' ) ;
routingType = await page . locator ( '[data-testid="test-routing-result-type"]' ) . innerText ( ) ;
route = await page . locator ( '[data-testid="test-routing-result"]' ) . innerText ( ) ;
2023-05-17 08:47:48 +00:00
expect ( routingType ) . toBe ( "Custom Page" ) ;
expect ( route ) . toBe ( "Custom Page Result" ) ;
2022-11-14 08:50:09 +00:00
//external redirect
2023-05-17 08:47:48 +00:00
await page . fill ( '[data-testid="form-field-Test field"]' , "external-redirect" ) ;
2022-11-14 08:50:09 +00:00
await page . click ( '[data-testid="test-routing"]' ) ;
routingType = await page . locator ( '[data-testid="test-routing-result-type"]' ) . innerText ( ) ;
route = await page . locator ( '[data-testid="test-routing-result"]' ) . innerText ( ) ;
2023-05-17 08:47:48 +00:00
expect ( routingType ) . toBe ( "External Redirect" ) ;
expect ( route ) . toBe ( "https://google.com" ) ;
2022-11-14 08:50:09 +00:00
//fallback route
2023-05-17 08:47:48 +00:00
await page . fill ( '[data-testid="form-field-Test field"]' , "fallback" ) ;
2022-11-14 08:50:09 +00:00
await page . click ( '[data-testid="test-routing"]' ) ;
routingType = await page . locator ( '[data-testid="test-routing-result-type"]' ) . innerText ( ) ;
route = await page . locator ( '[data-testid="test-routing-result"]' ) . innerText ( ) ;
2023-05-17 08:47:48 +00:00
expect ( routingType ) . toBe ( "Custom Page" ) ;
expect ( route ) . toBe ( "Fallback Message" ) ;
2022-11-14 08:50:09 +00:00
} ) ;
2022-08-13 11:04:57 +00:00
} ) ;
2022-07-14 12:40:53 +00:00
} ) ;
2023-01-04 13:30:46 +00:00
2023-05-17 08:47:48 +00:00
async function disableForm ( page : Page ) {
await page . click ( '[data-testid="toggle-form"] [value="on"]' ) ;
await page . waitForSelector ( ".data-testid-toast-success" ) ;
}
2023-01-04 13:30:46 +00:00
async function expectCurrentFormToHaveFields (
page : Page ,
fields : {
[ key : number ] : { label : string ; typeIndex : number } ;
} ,
types : string [ ]
) {
for ( const [ index , field ] of Object . entries ( fields ) ) {
2023-07-10 13:24:04 +00:00
expect ( await page . inputValue ( ` [data-testid="fields. ${ index } .label"] ` ) ) . toBe ( field . label ) ;
2023-02-16 22:39:57 +00:00
expect ( await page . locator ( ".data-testid-field-type" ) . nth ( + index ) . locator ( "div" ) . nth ( 1 ) . innerText ( ) ) . toBe (
types [ field . typeIndex ]
) ;
2023-01-04 13:30:46 +00:00
}
}
2022-11-11 09:57:44 +00:00
async function fillSeededForm ( page : Page , routingFormId : string ) {
2023-05-17 08:47:48 +00:00
await gotoRoutingLink ( { page , formId : routingFormId } ) ;
await page . fill ( '[data-testid="form-field-Test field"]' , "event-routing" ) ;
2022-11-11 09:57:44 +00:00
page . click ( 'button[type="submit"]' ) ;
2023-05-02 16:58:39 +00:00
await page . waitForURL ( ( url ) = > {
return url . pathname . endsWith ( "/pro/30min" ) ;
2022-11-11 09:57:44 +00:00
} ) ;
2023-05-17 08:47:48 +00:00
await gotoRoutingLink ( { page , formId : routingFormId } ) ;
await page . fill ( '[data-testid="form-field-Test field"]' , "external-redirect" ) ;
2022-11-11 09:57:44 +00:00
page . click ( 'button[type="submit"]' ) ;
2023-05-02 16:58:39 +00:00
await page . waitForURL ( ( url ) = > {
return url . hostname . includes ( "google.com" ) ;
2022-11-11 09:57:44 +00:00
} ) ;
2023-05-17 08:47:48 +00:00
await gotoRoutingLink ( { page , formId : routingFormId } ) ;
await page . fill ( '[data-testid="form-field-Test field"]' , "custom-page" ) ;
2022-11-11 09:57:44 +00:00
await page . click ( 'button[type="submit"]' ) ;
2023-05-17 08:47:48 +00:00
await expect ( page . locator ( "text=Custom Page Result" ) ) . toBeVisible ( ) ;
2022-11-11 09:57:44 +00:00
}
2023-01-04 13:30:46 +00:00
export async function addForm ( page : Page , { name = "Test Form Name" } = { } ) {
await page . goto ( "/apps/routing-forms/forms" ) ;
await page . click ( '[data-testid="new-routing-form"]' ) ;
2023-06-15 08:58:07 +00:00
// Choose to create the Form for the user(which is the first option) and not the team
await page . click ( '[data-testid="option-0"]' ) ;
2023-01-04 13:30:46 +00:00
await page . fill ( "input[name]" , name ) ;
await page . click ( '[data-testid="add-form"]' ) ;
await page . waitForSelector ( '[data-testid="add-field"]' ) ;
const url = page . url ( ) ;
const formId = new URL ( url ) . pathname . split ( "/" ) . at ( - 1 ) ;
if ( ! formId ) {
throw new Error ( "Form ID couldn't be determined from url" ) ;
}
return formId ;
}
2023-05-17 08:47:48 +00:00
async function addAllTypesOfFieldsAndSaveForm (
2023-04-12 20:58:03 +00:00
formId : string ,
page : Page ,
form : { description : string ; label : string }
) {
await page . goto ( ` apps/routing-forms/form-edit/ ${ formId } ` ) ;
await page . click ( '[data-testid="add-field"]' ) ;
await page . fill ( '[data-testid="description"]' , form . description ) ;
2023-05-17 08:47:48 +00:00
const { optionsInUi : fieldTypesList } = await verifySelectOptions (
2023-04-12 20:58:03 +00:00
{ selector : ".data-testid-field-type" , nth : 0 } ,
2023-06-05 05:51:19 +00:00
[ "Email" , "Long Text" , "Multiple Selection" , "Number" , "Phone" , "Single Selection" , "Short Text" ] ,
2023-04-12 20:58:03 +00:00
page
) ;
2023-05-17 08:47:48 +00:00
const fields = [ ] ;
for ( let index = 0 ; index < fieldTypesList . length ; index ++ ) {
const fieldTypeLabel = fieldTypesList [ index ] ;
const nth = index ;
const label = ` ${ form . label } ${ fieldTypeLabel } ` ;
let identifier = "" ;
if ( index !== 0 ) {
identifier = label ;
// Click on the field type dropdown.
await page . locator ( ".data-testid-field-type" ) . nth ( nth ) . click ( ) ;
// Click on the dropdown option.
2023-06-10 02:39:49 +00:00
await page . locator ( ` [data-testid^="select-option-"] ` ) . filter ( { hasText : fieldTypeLabel } ) . click ( ) ;
2023-05-17 08:47:48 +00:00
} else {
// Set the identifier manually for the first field to test out a case when identifier isn't computed from label automatically
// First field type is by default selected. So, no need to choose from dropdown
identifier = "firstField" ;
}
2023-04-12 20:58:03 +00:00
2023-05-17 08:47:48 +00:00
if ( fieldTypeLabel === "MultiSelect" || fieldTypeLabel === "Select" ) {
await page . fill ( ` [name="fields. ${ nth } .selectText"] ` , "123\n456\n789" ) ;
}
2023-04-12 20:58:03 +00:00
await page . fill ( ` [name="fields. ${ nth } .label"] ` , label ) ;
2023-05-17 08:47:48 +00:00
if ( identifier !== label ) {
await page . fill ( ` [name="fields. ${ nth } .identifier"] ` , identifier ) ;
}
if ( index !== fieldTypesList . length - 1 ) {
2023-04-12 20:58:03 +00:00
await page . click ( '[data-testid="add-field"]' ) ;
}
2023-05-17 08:47:48 +00:00
fields . push ( { identifier : identifier , label , type : fieldTypeLabel } ) ;
2023-04-12 20:58:03 +00:00
}
await saveCurrentForm ( page ) ;
return {
2023-05-17 08:47:48 +00:00
fieldTypesList ,
fields ,
2023-04-12 20:58:03 +00:00
} ;
}
2023-01-04 13:30:46 +00:00
export async function addOneFieldAndDescriptionAndSaveForm (
formId : string ,
page : Page ,
form : { description? : string ; field ? : { typeIndex : number ; label : string } }
) {
await page . goto ( ` apps/routing-forms/form-edit/ ${ formId } ` ) ;
await page . click ( '[data-testid="add-field"]' ) ;
if ( form . description ) {
await page . fill ( '[data-testid="description"]' , form . description ) ;
}
// Verify all Options of SelectBox
const { optionsInUi : types } = await verifySelectOptions (
{ selector : ".data-testid-field-type" , nth : 0 } ,
2023-06-05 05:51:19 +00:00
[ "Email" , "Long Text" , "Multiple Selection" , "Number" , "Phone" , "Single Selection" , "Short Text" ] ,
2023-01-04 13:30:46 +00:00
page
) ;
const nextFieldIndex = ( await page . locator ( '[data-testid="field"]' ) . count ( ) ) - 1 ;
if ( form . field ) {
2023-07-10 13:24:04 +00:00
await page . fill ( ` [data-testid="fields. ${ nextFieldIndex } .label"] ` , form . field . label ) ;
2023-01-04 13:30:46 +00:00
await page
. locator ( '[data-testid="field"]' )
. nth ( nextFieldIndex )
. locator ( ".data-testid-field-type" )
. click ( ) ;
await page
. locator ( '[data-testid="field"]' )
. nth ( nextFieldIndex )
. locator ( '[id*="react-select-"][aria-disabled]' )
. nth ( form . field . typeIndex )
. click ( ) ;
}
await saveCurrentForm ( page ) ;
return {
types ,
} ;
}
async function selectOption ( {
page ,
selector ,
option ,
} : {
page : Page ;
selector : { selector : string ; nth : number } ;
2023-05-17 08:47:48 +00:00
/ * *
* Index of option to select . Starts from 1
* /
2023-01-04 13:30:46 +00:00
option : number ;
} ) {
const locatorForSelect = page . locator ( selector . selector ) . nth ( selector . nth ) ;
await locatorForSelect . click ( ) ;
await locatorForSelect
. locator ( '[id*="react-select-"][aria-disabled]' )
. nth ( option - 1 )
. click ( ) ;
}
async function verifyFieldOptionsInRule ( options : string [ ] , page : Page ) {
await verifySelectOptions (
{
selector : ".rule-container .data-testid-field-select" ,
nth : 0 ,
} ,
options ,
page
) ;
}
async function verifySelectOptions (
selector : { selector : string ; nth : number } ,
expectedOptions : string [ ] ,
page : Page
) {
await page . locator ( selector . selector ) . nth ( selector . nth ) . click ( ) ;
const selectOptions = await page
. locator ( selector . selector )
. nth ( selector . nth )
. locator ( '[id*="react-select-"][aria-disabled]' )
. allInnerTexts ( ) ;
const sortedSelectOptions = [ . . . selectOptions ] . sort ( ) ;
const sortedExpectedOptions = [ . . . expectedOptions ] . sort ( ) ;
expect ( sortedSelectOptions ) . toEqual ( sortedExpectedOptions ) ;
return {
optionsInUi : selectOptions ,
} ;
}
async function selectNewRoute ( page : Page , { routeSelectNumber = 1 } = { } ) {
await selectOption ( {
selector : {
selector : ".data-testid-select-router" ,
nth : 0 ,
} ,
option : routeSelectNumber ,
page ,
} ) ;
}
async function saveCurrentForm ( page : Page ) {
await page . click ( '[data-testid="update-form"]' ) ;
await page . waitForSelector ( ".data-testid-toast-success" ) ;
}