@@ -34,6 +34,7 @@ import {
3434 ApiSuccessResponse ,
3535 CreateEventTypeInput_2024_06_14 ,
3636 EventTypeOutput_2024_06_14 ,
37+ GuestsDefaultFieldOutput_2024_06_14 ,
3738 NameDefaultFieldInput_2024_06_14 ,
3839 NotesDefaultFieldInput_2024_06_14 ,
3940 UpdateEventTypeInput_2024_06_14 ,
@@ -535,6 +536,7 @@ describe("Event types Endpoints", () => {
535536 body . lockTimeZoneToggleOnBookingPage
536537 ) ;
537538 expect ( createdEventType . color ) . toEqual ( body . color ) ;
539+ expect ( createdEventType . disableGuests ) . toEqual ( false ) ;
538540
539541 const expectedBookingFields = [
540542 { ...defaultResponseBookingFieldName , ...nameBookingField } ,
@@ -1041,6 +1043,7 @@ describe("Event types Endpoints", () => {
10411043 expect ( updatedEventType . description ) . toEqual ( eventType . description ) ;
10421044 expect ( updatedEventType . lengthInMinutes ) . toEqual ( eventType . lengthInMinutes ) ;
10431045 expect ( updatedEventType . locations ) . toEqual ( eventType . locations ) ;
1046+ expect ( updatedEventType . disableGuests ) . toEqual ( false ) ;
10441047
10451048 const expectedBookingFields = [
10461049 { ...defaultResponseBookingFieldName , ...nameBookingField } ,
@@ -1887,6 +1890,96 @@ describe("Event types Endpoints", () => {
18871890 } ) ;
18881891 } ) ;
18891892
1893+ describe ( "toggle disable guests" , ( ) => {
1894+ let eventTypeWithGuestsDisabledId : number ;
1895+
1896+ it ( "should create an event type with guests disabled" , async ( ) => {
1897+ const body : CreateEventTypeInput_2024_06_14 = {
1898+ title : "Coding class guests disabled" ,
1899+ slug : "coding-class-guests-disabled" ,
1900+ description : "Let's learn how to code like a pro." ,
1901+ lengthInMinutes : 60 ,
1902+ disableGuests : true ,
1903+ } ;
1904+
1905+ return request ( app . getHttpServer ( ) )
1906+ . post ( "/api/v2/event-types" )
1907+ . set ( CAL_API_VERSION_HEADER , VERSION_2024_06_14 )
1908+ . send ( body )
1909+ . expect ( 201 )
1910+ . then ( async ( response ) => {
1911+ const responseBody : ApiSuccessResponse < EventTypeOutput_2024_06_14 > = response . body ;
1912+ const createdEventType = responseBody . data ;
1913+ expect ( createdEventType ) . toHaveProperty ( "id" ) ;
1914+ expect ( createdEventType . title ) . toEqual ( body . title ) ;
1915+ expect ( createdEventType . description ) . toEqual ( body . description ) ;
1916+ expect ( createdEventType . lengthInMinutes ) . toEqual ( body . lengthInMinutes ) ;
1917+
1918+ expect ( createdEventType . disableGuests ) . toEqual ( true ) ;
1919+ const guestsBookingField = createdEventType . bookingFields . find (
1920+ ( field ) => field . slug === "guests"
1921+ ) as GuestsDefaultFieldOutput_2024_06_14 | undefined ;
1922+ expect ( guestsBookingField ?. hidden ) . toEqual ( true ) ;
1923+
1924+ eventTypeWithGuestsDisabledId = createdEventType . id ;
1925+ } ) ;
1926+ } ) ;
1927+
1928+ it ( "should update an event type with guests enabled" , async ( ) => {
1929+ const body : UpdateEventTypeInput_2024_06_14 = {
1930+ disableGuests : false ,
1931+ } ;
1932+
1933+ return request ( app . getHttpServer ( ) )
1934+ . patch ( `/api/v2/event-types/${ eventTypeWithGuestsDisabledId } ` )
1935+ . set ( CAL_API_VERSION_HEADER , VERSION_2024_06_14 )
1936+ . send ( body )
1937+ . expect ( 200 )
1938+ . then ( async ( response ) => {
1939+ const responseBody : ApiSuccessResponse < EventTypeOutput_2024_06_14 > = response . body ;
1940+ const updatedEventType = responseBody . data ;
1941+
1942+ expect ( updatedEventType . disableGuests ) . toEqual ( false ) ;
1943+ const guestsBookingField = updatedEventType . bookingFields . find (
1944+ ( field ) => field . slug === "guests"
1945+ ) as GuestsDefaultFieldOutput_2024_06_14 | undefined ;
1946+ expect ( guestsBookingField ?. hidden ) . toEqual ( false ) ;
1947+
1948+ eventTypeWithGuestsDisabledId = updatedEventType . id ;
1949+ } ) ;
1950+ } ) ;
1951+
1952+ it ( "should update an event type with guests disabled" , async ( ) => {
1953+ const body : UpdateEventTypeInput_2024_06_14 = {
1954+ disableGuests : true ,
1955+ } ;
1956+
1957+ return request ( app . getHttpServer ( ) )
1958+ . patch ( `/api/v2/event-types/${ eventTypeWithGuestsDisabledId } ` )
1959+ . set ( CAL_API_VERSION_HEADER , VERSION_2024_06_14 )
1960+ . send ( body )
1961+ . expect ( 200 )
1962+ . then ( async ( response ) => {
1963+ const responseBody : ApiSuccessResponse < EventTypeOutput_2024_06_14 > = response . body ;
1964+ const updatedEventType = responseBody . data ;
1965+
1966+ expect ( updatedEventType . disableGuests ) . toEqual ( true ) ;
1967+ const guestsBookingField = updatedEventType . bookingFields . find (
1968+ ( field ) => field . slug === "guests"
1969+ ) as GuestsDefaultFieldOutput_2024_06_14 | undefined ;
1970+ expect ( guestsBookingField ?. hidden ) . toEqual ( true ) ;
1971+
1972+ eventTypeWithGuestsDisabledId = updatedEventType . id ;
1973+ } ) ;
1974+ } ) ;
1975+
1976+ afterAll ( async ( ) => {
1977+ if ( eventTypeWithGuestsDisabledId ) {
1978+ await eventTypesRepositoryFixture . delete ( eventTypeWithGuestsDisabledId ) ;
1979+ }
1980+ } ) ;
1981+ } ) ;
1982+
18901983 afterAll ( async ( ) => {
18911984 await oauthClientRepositoryFixture . delete ( oAuthClient . id ) ;
18921985 await teamRepositoryFixture . delete ( organization . id ) ;
0 commit comments