mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-03 12:49:30 +00:00
2bc9656957
* Adapt OAuth2 implementation to Matrix Spec v1.18 * Handle more cases of oidc->oauth * Fix test * Fix read back of oauth2 context * Iterate * Fix tests * Discard changes to apps/web/playwright/e2e/settings/account-user-settings-tab.spec.ts * Fix test * Fix test * Fix test * Potential fix for pull request finding 'Unused variable, import, function or class' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Iterate * Iterate * Fix test --------- Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
/*
|
|
Copyright 2020-2024 New Vector Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
import { parseAppUrl, parseQsFromFragment, searchParamsToQueryDict } from "./url_utils";
|
|
|
|
// @ts-ignore
|
|
const location: Location = {
|
|
hash: "",
|
|
search: "",
|
|
};
|
|
|
|
describe("parseQsFromFragment", () => {
|
|
it("should parse correctly", () => {
|
|
location.hash = "#/home?foo=bar";
|
|
expect(parseQsFromFragment(location)).toEqual({
|
|
location: "/home",
|
|
params: new URLSearchParams({
|
|
foo: "bar",
|
|
}),
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("searchParamsToQueryDict", () => {
|
|
it("should handle arrays correctly", () => {
|
|
const u = new URLSearchParams("a=b&b=c&c=d&a=e&a=f");
|
|
expect(searchParamsToQueryDict(u)).toEqual({
|
|
a: ["b", "e", "f"],
|
|
b: "c",
|
|
c: "d",
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("parseUrlParameters", () => {
|
|
it("should parse legacy sso parameters from query", () => {
|
|
const u = new URL("https://app.element.io?loginToken=foobar");
|
|
const parsed = parseAppUrl(u);
|
|
expect(parsed.params.legacy_sso?.loginToken).toEqual("foobar");
|
|
});
|
|
|
|
it("should parse oauth2 parameters from fragment", () => {
|
|
const u = new URL("https://app.element.io/#code=foobar&state=barfoo");
|
|
const parsed = parseAppUrl(u);
|
|
expect(parsed.params.oauth2?.code).toEqual("foobar");
|
|
expect(parsed.params.oauth2?.state).toEqual("barfoo");
|
|
});
|
|
|
|
it("should parse guest parameters", () => {
|
|
const u = new URL("https://app.element.io?foo=bar#/room/!roomId:server?guest_access_token=foobar");
|
|
const parsed = parseAppUrl(u);
|
|
expect(parsed.params.guest?.guest_access_token).toEqual("foobar");
|
|
});
|
|
});
|