Feat/update login flow reload page (#467)
* update spacing event modal * update spacing create calendar modal * fix evenchip description color * using variant instead of sx * update login flow * fix: add useEffect import back to Calendar.tsx
This commit is contained in:
@@ -28,21 +28,50 @@ describe("HandleLogin", () => {
|
||||
|
||||
jest.spyOn(oidcAuth, "Auth").mockResolvedValue(loginUrlMock);
|
||||
|
||||
renderWithProviders(<HandleLogin />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(oidcAuth.Auth).toHaveBeenCalled();
|
||||
expect(sessionStorage.getItem("redirectState")).toEqual(
|
||||
JSON.stringify({
|
||||
code_verifier: "verifier123",
|
||||
state: "state123",
|
||||
})
|
||||
);
|
||||
expect(apiUtils.redirectTo).toHaveBeenCalledWith(loginUrlMock.redirectTo);
|
||||
renderWithProviders(<HandleLogin />, {
|
||||
user: {
|
||||
userData: null,
|
||||
tokens: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
calendars: {
|
||||
list: {},
|
||||
pending: false,
|
||||
error: null,
|
||||
},
|
||||
});
|
||||
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(oidcAuth.Auth).toHaveBeenCalled();
|
||||
},
|
||||
{ timeout: 3000 }
|
||||
);
|
||||
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(sessionStorage.getItem("redirectState")).toEqual(
|
||||
JSON.stringify({
|
||||
code_verifier: "verifier123",
|
||||
state: "state123",
|
||||
})
|
||||
);
|
||||
},
|
||||
{ timeout: 3000 }
|
||||
);
|
||||
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(apiUtils.redirectTo).toHaveBeenCalledWith(
|
||||
loginUrlMock.redirectTo
|
||||
);
|
||||
},
|
||||
{ timeout: 3000 }
|
||||
);
|
||||
});
|
||||
|
||||
test("shows Loading when userData exists and calendars pending is true", () => {
|
||||
test("does not render loading element when userData exists and calendars pending is true", () => {
|
||||
const preloadedState = {
|
||||
user: {
|
||||
userData: {
|
||||
@@ -51,14 +80,18 @@ describe("HandleLogin", () => {
|
||||
sid: "aiYbWZSk2g0F+LrQeD7Dg4QcUMR8R/zTZdZBiA7N6Ro",
|
||||
openpaasId: "667037022b752d0026472254",
|
||||
},
|
||||
tokens: { access_token: "test" },
|
||||
loading: false,
|
||||
},
|
||||
calendars: { list: {}, pending: true },
|
||||
loading: { isLoading: true },
|
||||
};
|
||||
|
||||
renderWithProviders(<HandleLogin />, preloadedState);
|
||||
expect(screen.getByTestId("loading")).toBeInTheDocument();
|
||||
// HandleLogin now returns null, loading is shown at App level via appLoading state
|
||||
expect(screen.queryByTestId("loading")).not.toBeInTheDocument();
|
||||
});
|
||||
test("shows Loading when userData exists and calendars pending is false", () => {
|
||||
test("does not render loading element when userData exists and calendars pending is false", () => {
|
||||
const preloadedState = {
|
||||
user: {
|
||||
userData: {
|
||||
@@ -67,11 +100,16 @@ describe("HandleLogin", () => {
|
||||
sid: "aiYbWZSk2g0F+LrQeD7Dg4QcUMR8R/zTZdZBiA7N6Ro",
|
||||
openpaasId: "667037022b752d0026472254",
|
||||
},
|
||||
tokens: { access_token: "test" },
|
||||
loading: false,
|
||||
},
|
||||
calendars: { list: {}, pending: false },
|
||||
loading: { isLoading: false },
|
||||
};
|
||||
renderWithProviders(<HandleLogin />, preloadedState);
|
||||
|
||||
expect(screen.getByTestId("loading")).toBeInTheDocument();
|
||||
// HandleLogin now returns null, loading is shown at App level via appLoading state
|
||||
expect(screen.queryByTestId("loading")).not.toBeInTheDocument();
|
||||
});
|
||||
test("goes to error page when there is error in user data", () => {
|
||||
const dispatch = appHooks.useAppDispatch();
|
||||
|
||||
Reference in New Issue
Block a user