Merge remote-tracking branch 'origin/develop' into hs/refactor-upload-logic

This commit is contained in:
Half-Shot 2026-05-01 16:32:59 +01:00
commit 83239b2d36
7 changed files with 35 additions and 11 deletions

View File

@ -125,7 +125,8 @@ Please see LICENSE files in the repository root for full details.
align-items: center;
padding: 4px 4px 4px 0;
width: 100%;
cursor: pointer;
/* Override the unlayered cursor: grab; rule from react-beautiful-dnd */
cursor: pointer !important;
&.mx_SpaceButton_active {
&:not(.mx_SpaceButton_narrow) .mx_SpaceButton_selectionWrapper {

View File

@ -86,7 +86,7 @@ type CompleteOidcLoginResponse = {
// refreshToken gained from OIDC token issuer, when falsy token cannot be refreshed
refreshToken?: string;
// idToken gained from OIDC token issuer
idToken: string;
idToken?: string;
// this client's id as registered with the OIDC issuer
clientId: string;
// issuer used during authentication

View File

@ -25,10 +25,16 @@ const idTokenClaimsStorageKey = "mx_oidc_id_token_claims";
* @param idToken
* @param idTokenClaims
*/
export const persistOidcAuthenticatedSettings = (clientId: string, issuer: string, idToken: string): void => {
export const persistOidcAuthenticatedSettings = (
clientId: string,
issuer: string,
idToken: string | undefined,
): void => {
localStorage.setItem(clientIdStorageKey, clientId);
localStorage.setItem(tokenIssuerStorageKey, issuer);
localStorage.setItem(idTokenStorageKey, idToken);
if (idToken) {
localStorage.setItem(idTokenStorageKey, idToken);
}
};
/**

View File

@ -48,6 +48,13 @@ describe("persist OIDC settings", () => {
expect(localStorage.setItem).toHaveBeenCalledWith("mx_oidc_token_issuer", issuer);
expect(localStorage.setItem).toHaveBeenCalledWith("mx_oidc_id_token", idToken);
});
it("should not set idToken in localStorage when idToken is undefined", () => {
persistOidcAuthenticatedSettings(clientId, issuer, undefined);
expect(localStorage.setItem).toHaveBeenCalledWith("mx_oidc_client_id", clientId);
expect(localStorage.setItem).toHaveBeenCalledWith("mx_oidc_token_issuer", issuer);
expect(localStorage.getItem("mx_oidc_id_token")).toBeFalsy();
});
});
describe("getStoredOidcTokenIssuer()", () => {

View File

@ -9,6 +9,13 @@ import { describe, it, expect } from "vitest";
import { formatSeconds, formatDateForInput } from "./DateUtils";
function makeDate(year: number, month: number, day: number): Date {
const date = new Date(0);
date.setFullYear(year, month - 1, day);
date.setHours(0, 0, 0, 0);
return date;
}
describe("formatSeconds", () => {
it("correctly formats time with hours", () => {
expect(formatSeconds(60 * 60 * 3 + 60 * 31 + 55)).toBe("03:31:55");
@ -26,10 +33,12 @@ describe("formatSeconds", () => {
});
describe("formatDateForInput", () => {
it.each([["1993-11-01"], ["1066-10-14"], ["0571-04-22"], ["0062-02-05"]])(
"should format %s",
(dateString: string) => {
expect(formatDateForInput(new Date(dateString))).toBe(dateString);
},
);
it.each([
["1993-11-01", makeDate(1993, 11, 1)],
["1066-10-14", makeDate(1066, 10, 14)],
["0571-04-22", makeDate(571, 4, 22)],
["0062-02-05", makeDate(62, 2, 5)],
])("should format %s", (dateString: string, date: Date) => {
expect(formatDateForInput(date)).toBe(dateString);
});
});

View File

@ -110,6 +110,7 @@ export default mergeConfig(
"vite-plugin-node-polyfills/shims/buffer",
"vite-plugin-node-polyfills/shims/process",
"@vector-im/compound-design-tokens/assets/web/icons",
"storybook/preview-api",
],
},
resolve: {

View File

@ -56,6 +56,6 @@ export default defineConfig({
reporters,
pool: "threads",
globals: false,
include: ["src/**/*.test.ts"],
include: ["src/**/*.test.{ts,tsx}"],
},
});