[#38] Adding several missing tests and correct CI setup

This commit is contained in:
Camille Moussu
2025-07-18 12:55:42 +02:00
parent 7c8b14e961
commit a52ded03fb
19 changed files with 2938 additions and 1278 deletions
+1 -1
View File
@@ -2,5 +2,5 @@ import React from "react";
import logo from "../../static/images/calendar.svg";
export function Loading() {
return <img src={logo} />;
return <img src={logo} alt="loading" />;
}
+2 -1
View File
@@ -4,6 +4,7 @@ import { Auth } from "./oidcAuth";
import { Loading } from "../../components/Loading/Loading";
import { Error } from "../../components/Error/Error";
import { push } from "redux-first-history";
import { redirectTo } from "../../utils/apiUtils";
export function HandleLogin() {
const userData = useAppSelector((state) => state.user.userData);
@@ -22,7 +23,7 @@ export function HandleLogin() {
})
);
window.location.assign(loginurl.redirectTo);
redirectTo(loginurl.redirectTo);
}
};
+4 -3
View File
@@ -1,4 +1,5 @@
import * as client from "openid-client";
import { getLocation } from "../../utils/apiUtils";
export const clientConfig = {
url: (window as any).SSO_BASE_URL ?? "",
@@ -49,14 +50,14 @@ export async function Logout() {
export async function Callback(code_verifier: string, state: any) {
try {
const openIdClientConfig = await getClientConfig();
const currentUrl = new URL(window.location.href);
const currentLocation = getLocation();
console.log("Callback URL:", currentUrl.toString());
console.log("Callback URL:", currentLocation);
console.log("Code verifier:", code_verifier);
const tokenSet = await client.authorizationCodeGrant(
openIdClientConfig,
currentUrl,
new URL(currentLocation),
{
pkceCodeVerifier: code_verifier,
expectedState: state,
+17 -5
View File
@@ -1,5 +1,17 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
import "@testing-library/jest-dom";
import { TextEncoder, TextDecoder } from "util";
import { clientConfig } from "./features/User/oidcAuth";
global.TextEncoder = TextEncoder;
jest.mock("openid-client", () => ({
discovery: jest.fn(),
randomPKCECodeVerifier: jest.fn(),
calculatePKCECodeChallenge: jest.fn(),
randomState: jest.fn(),
buildAuthorizationUrl: jest.fn(),
buildEndSessionUrl: jest.fn(),
authorizationCodeGrant: jest.fn(),
fetchUserInfo: jest.fn(),
}));
+4
View File
@@ -0,0 +1,4 @@
declare module "*.svg" {
const content: string;
export default content;
}
+9 -1
View File
@@ -29,9 +29,17 @@ export const api = ky.extend({
state: loginurl.state,
})
);
window.location.assign(loginurl.redirectTo);
redirectTo(loginurl.redirectTo);
}
},
],
},
});
export function redirectTo(url: URL) {
window.location.assign(url);
}
export function getLocation() {
return window.location.href;
}