@@ -10,7 +10,7 @@ import { describe, expect, it } from "vitest";
10
10
import {
11
11
getRoomIdentifierFromUrl ,
12
12
getUrlParams ,
13
- UserIntent ,
13
+ HeaderStyle ,
14
14
} from "../src/UrlParams" ;
15
15
16
16
const ROOM_NAME = "roomNameHere" ;
@@ -211,24 +211,68 @@ describe("UrlParams", () => {
211
211
} ) ;
212
212
213
213
describe ( "intent" , ( ) => {
214
- it ( "defaults to unknown" , ( ) => {
215
- expect ( getUrlParams ( ) . intent ) . toBe ( UserIntent . Unknown ) ;
214
+ const noIntentDefaults = {
215
+ confineToRoom : false ,
216
+ appPrompt : true ,
217
+ preload : false ,
218
+ header : HeaderStyle . Standard ,
219
+ showControls : true ,
220
+ hideScreensharing : false ,
221
+ allowIceFallback : false ,
222
+ perParticipantE2EE : false ,
223
+ controlledAudioDevices : false ,
224
+ skipLobby : false ,
225
+ returnToLobby : false ,
226
+ sendNotificationType : undefined ,
227
+ } ;
228
+ const startNewCallDefaults = ( platform : string ) : object => ( {
229
+ confineToRoom : true ,
230
+ appPrompt : false ,
231
+ preload : true ,
232
+ header : platform === "desktop" ? HeaderStyle . None : HeaderStyle . AppBar ,
233
+ showControls : true ,
234
+ hideScreensharing : false ,
235
+ allowIceFallback : true ,
236
+ perParticipantE2EE : true ,
237
+ controlledAudioDevices : platform === "desktop" ? false : true ,
238
+ skipLobby : true ,
239
+ returnToLobby : false ,
240
+ sendNotificationType : "notification" ,
241
+ } ) ;
242
+ const joinExistingCallDefaults = ( platform : string ) : object => ( {
243
+ confineToRoom : true ,
244
+ appPrompt : false ,
245
+ preload : true ,
246
+ header : platform === "desktop" ? HeaderStyle . None : HeaderStyle . AppBar ,
247
+ showControls : true ,
248
+ hideScreensharing : false ,
249
+ allowIceFallback : true ,
250
+ perParticipantE2EE : true ,
251
+ controlledAudioDevices : platform === "desktop" ? false : true ,
252
+ skipLobby : false ,
253
+ returnToLobby : false ,
254
+ sendNotificationType : "notification" ,
255
+ } ) ;
256
+ it ( "use no-intent-defaults with unknown intent" , ( ) => {
257
+ expect ( getUrlParams ( ) ) . toMatchObject ( noIntentDefaults ) ;
216
258
} ) ;
217
259
218
260
it ( "ignores intent if it is not a valid value" , ( ) => {
219
- expect ( getUrlParams ( "?intent=foo" ) . intent ) . toBe ( UserIntent . Unknown ) ;
261
+ expect ( getUrlParams ( "?intent=foo" ) ) . toMatchObject ( noIntentDefaults ) ;
220
262
} ) ;
221
263
222
264
it ( "accepts start_call" , ( ) => {
223
- expect ( getUrlParams ( "?intent=start_call" ) . intent ) . toBe (
224
- UserIntent . StartNewCall ,
225
- ) ;
265
+ expect (
266
+ getUrlParams ( "?intent=start_call&widgetId=1234&parentUrl=parent.org" ) ,
267
+ ) . toMatchObject ( startNewCallDefaults ( "desktop" ) ) ;
226
268
} ) ;
227
269
228
270
it ( "accepts join_existing" , ( ) => {
229
- expect ( getUrlParams ( "?intent=join_existing" ) . intent ) . toBe (
230
- UserIntent . JoinExistingCall ,
231
- ) ;
271
+ expect (
272
+ getUrlParams (
273
+ "?intent=join_existing&widgetId=1234&parentUrl=parent.org" ,
274
+ ) ,
275
+ ) . toMatchObject ( joinExistingCallDefaults ( "desktop" ) ) ;
232
276
} ) ;
233
277
} ) ;
234
278
@@ -260,9 +304,5 @@ describe("UrlParams", () => {
260
304
) ;
261
305
expect ( getUrlParams ( "?header=none&hideHeader=false" ) . header ) . toBe ( "none" ) ;
262
306
} ) ;
263
- it ( "converts hideHeader to the correct header value" , ( ) => {
264
- expect ( getUrlParams ( "?hideHeader=true" ) . header ) . toBe ( "none" ) ;
265
- expect ( getUrlParams ( "?hideHeader=false" ) . header ) . toBe ( "standard" ) ;
266
- } ) ;
267
307
} ) ;
268
308
} ) ;
0 commit comments