From ff4a1c33052510c3704b33ce0a1b9f62a5892ceb Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Fri, 4 Oct 2024 13:01:22 +0200 Subject: [PATCH] :memo: [#390] Add story for OIDC login --- frontend/src/pages/login/Login.stories.tsx | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/frontend/src/pages/login/Login.stories.tsx b/frontend/src/pages/login/Login.stories.tsx index fe57483a3..6daaba26b 100644 --- a/frontend/src/pages/login/Login.stories.tsx +++ b/frontend/src/pages/login/Login.stories.tsx @@ -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 = { @@ -18,3 +20,31 @@ export const LoginPageStory: Story = { children: "The quick brown fox jumps over the lazy dog.", }, }; + +export const LoginPageWithOIDC: Story = { + render: (args) => ( + + + + ), + 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("/"); + }, +};