Skip to content

Commit

Permalink
📝 [#390] Add story for OIDC login
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Oct 11, 2024
1 parent 3a6d8ed commit ff4a1c3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions frontend/src/pages/login/Login.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "@maykin-ui/admin-ui/style";
import type { Meta, StoryObj } from "@storybook/react";
import { expect, within } from "@storybook/test";

import { ReactRouterDecorator } from "../../../.storybook/decorators";
import ExtraConfigContext from "../../lib/contexts/ExtraConfigContext";
import { LoginPage } from "./Login";

const meta: Meta<typeof LoginPage> = {
Expand All @@ -18,3 +20,31 @@ export const LoginPageStory: Story = {
children: "The quick brown fox jumps over the lazy dog.",
},
};

export const LoginPageWithOIDC: Story = {
render: (args) => (
<ExtraConfigContext.Provider
value={{
oidc: {
enabled: true,
loginUrl: "http://backend.nl/oidc/authenticate",
},
}}
>
<LoginPage />
</ExtraConfigContext.Provider>
),
play: async (context) => {
const canvas = within(context.canvasElement);

const oidcButton: HTMLBaseElement = await canvas.findByRole("link", {
name: "Organisatie login",
});

const redirectUrl = new URL(oidcButton.href);
const nextUrl = redirectUrl.searchParams.get("next");

expect(nextUrl).not.toBeNull();
expect(new URL(nextUrl as string).pathname).toEqual("/");
},
};

0 comments on commit ff4a1c3

Please sign in to comment.