Skip to content

Commit 2f55d8e

Browse files
toger5robintown
andauthored
UrlParams: Intent system update, split into configuration and propreties (#3376)
* refactor UrlParams to use a preset intent system * change defaults for intend headers * add: getEnumParam to ParamParser * remove deprecated url params * only allow skip lobby in widget (more strict needs test adjustment) * fix tests that now require the url to be a widget url Co-authored-by: Robin <robin@robin.town> --------- Co-authored-by: Robin <robin@robin.town>
1 parent 3145baf commit 2f55d8e

File tree

3 files changed

+260
-137
lines changed

3 files changed

+260
-137
lines changed

src/UrlParams.test.ts

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { describe, expect, it } from "vitest";
1010
import {
1111
getRoomIdentifierFromUrl,
1212
getUrlParams,
13-
UserIntent,
13+
HeaderStyle,
1414
} from "../src/UrlParams";
1515

1616
const ROOM_NAME = "roomNameHere";
@@ -211,24 +211,68 @@ describe("UrlParams", () => {
211211
});
212212

213213
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);
216258
});
217259

218260
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);
220262
});
221263

222264
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"));
226268
});
227269

228270
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"));
232276
});
233277
});
234278

@@ -260,9 +304,5 @@ describe("UrlParams", () => {
260304
);
261305
expect(getUrlParams("?header=none&hideHeader=false").header).toBe("none");
262306
});
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-
});
267307
});
268308
});

0 commit comments

Comments
 (0)