diff --git a/src/itemLogin/ItemLoginAuthorization.stories.tsx b/src/itemLogin/ItemLoginAuthorization.stories.tsx index 0e1d47f9..f4493725 100644 --- a/src/itemLogin/ItemLoginAuthorization.stories.tsx +++ b/src/itemLogin/ItemLoginAuthorization.stories.tsx @@ -13,7 +13,8 @@ import Card from '@/Card/Card.js'; import ItemLoginAuthorization from './ItemLoginAuthorization.js'; import { FORBIDDEN_TEXT } from './constants.js'; -const meta: Meta = { +const item = PackedDocumentItemFactory(); +const meta = { title: 'Actions/ItemLoginAuthorization', component: ItemLoginAuthorization, @@ -21,26 +22,30 @@ const meta: Meta = { signIn: { action: 'onRedirect' }, }, args: { + signIn: () => {}, + itemId: item.id, + children: , }, -}; +} satisfies Meta; export default meta; -type Story = StoryObj; +type Story = StoryObj; -export const Authorized: Story = { +export const Authorized = { args: { currentAccount: { id: 'member', name: 'member' } as CompleteMember, - item: PackedDocumentItemFactory(), + item, }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); expect(canvas.getByText('card')).toBeVisible(); }, -}; -export const LogInForm: Story = { +} satisfies Story; + +export const LogInForm = { args: { itemLoginSchemaType: ItemLoginSchemaType.Username, }, @@ -49,9 +54,9 @@ export const LogInForm: Story = { expect(canvas.getByText('Sign In')).toBeVisible(); }, -}; +} satisfies Story; -export const Loading: Story = { +export const Loading = { args: { isLoading: true, }, @@ -60,9 +65,9 @@ export const Loading: Story = { expect(canvas.getByRole('progressbar')).toBeVisible(); }, -}; +} satisfies Story; -export const Forbidden: Story = { +export const Forbidden = { args: { currentAccount: { id: 'member', name: 'member' } as CompleteMember, }, @@ -71,4 +76,4 @@ export const Forbidden: Story = { expect(canvas.getByText(FORBIDDEN_TEXT)).toBeVisible(); }, -}; +} satisfies Story; diff --git a/src/itemLogin/ItemLoginAuthorization.tsx b/src/itemLogin/ItemLoginAuthorization.tsx index 5bd48af5..1cd20dc2 100644 --- a/src/itemLogin/ItemLoginAuthorization.tsx +++ b/src/itemLogin/ItemLoginAuthorization.tsx @@ -39,7 +39,6 @@ const ItemLoginAuthorization = ({ children, }: ItemLoginAuthorizationProps): ReactNode => { if (isLoading) { - // get item login if the user is not authenticated and the item is empty return ; } diff --git a/src/itemLogin/ItemLoginScreen.stories.tsx b/src/itemLogin/ItemLoginScreen.stories.tsx index 85a1ead8..4f95e17c 100644 --- a/src/itemLogin/ItemLoginScreen.stories.tsx +++ b/src/itemLogin/ItemLoginScreen.stories.tsx @@ -2,18 +2,20 @@ import type { Meta, StoryObj } from '@storybook/react'; import { expect, fn } from '@storybook/test'; import { userEvent, within } from '@storybook/testing-library'; -import { ItemLoginSchemaType } from '@graasp/sdk'; +import { ItemLoginSchemaType, PackedDocumentItemFactory } from '@graasp/sdk'; import { TABLE_CATEGORIES } from '../utils/storybook.js'; import ItemLoginScreen from './ItemLoginScreen.js'; import { FORBIDDEN_TEXT } from './constants.js'; -const meta: Meta = { +const item = PackedDocumentItemFactory(); +const meta = { title: 'Actions/ItemLogin/ItemLoginScreen', component: ItemLoginScreen, args: { signIn: fn(), + itemId: item.id, }, argTypes: { passwordInputId: { @@ -33,11 +35,11 @@ const meta: Meta = { }, signIn: { action: 'signin' }, }, -}; +} satisfies Meta; export default meta; -type Story = StoryObj; +type Story = StoryObj; export const ItemLoginUsernameAndPassword: Story = { args: { @@ -55,7 +57,7 @@ export const ItemLoginUsernameAndPassword: Story = { expect(args.signIn).toHaveBeenCalled(); }, -}; +} satisfies Story; export const ItemLoginUsername: Story = { args: { @@ -72,13 +74,15 @@ export const ItemLoginUsername: Story = { expect(args.signIn).toHaveBeenCalled(); }, -}; +} satisfies Story; -export const Forbidden: Story = { - args: {}, +export const Forbidden = { + args: { + itemId: item.id, + }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); await expect(canvas.getByText(FORBIDDEN_TEXT)).toBeInTheDocument(); }, -}; +} satisfies Story; diff --git a/src/itemLogin/ItemLoginScreen.tsx b/src/itemLogin/ItemLoginScreen.tsx index e2f21f00..03e8c2e2 100644 --- a/src/itemLogin/ItemLoginScreen.tsx +++ b/src/itemLogin/ItemLoginScreen.tsx @@ -37,7 +37,7 @@ export type ItemLoginScreenProps = { /** * item login schema object */ - itemLoginSchemaType: ItemLoginSchemaType; + itemLoginSchemaType?: ItemLoginSchemaType; signIn: (args: { itemId: string } & SignInPropertiesType) => void; /** * content to display when the user doesn't have access