feat(auth): deliver optional authentication across Liqa #24
No files matched your search
@@ -21,13 +21,30 @@ const meta: Meta<typeof LoginForm> = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof LoginForm>;
|
||||
|
||||
async function expectLoginSurfaces(canvasElement: HTMLElement) {
|
||||
const canvas = within(canvasElement);
|
||||
const card = canvasElement.querySelector('section');
|
||||
const notice = canvas.getByText('Your session has expired. Sign in again to continue.');
|
||||
const username = canvas.getByRole('textbox', { name: 'Username' });
|
||||
if (!card) throw new Error('Login card was not rendered.');
|
||||
|
||||
await expect(window.getComputedStyle(notice).marginBottom).not.toBe('0px');
|
||||
await expect(window.getComputedStyle(username).backgroundColor).not.toBe(
|
||||
window.getComputedStyle(card).backgroundColor,
|
||||
);
|
||||
}
|
||||
|
||||
export const Initial: Story = {};
|
||||
|
||||
export const ExpiredSession: Story = { args: { expired: true } };
|
||||
export const ExpiredSession: Story = {
|
||||
args: { expired: true },
|
||||
play: async ({ canvasElement }) => expectLoginSurfaces(canvasElement),
|
||||
};
|
||||
|
||||
export const SignedOut: Story = { args: { signedOut: true } };
|
||||
|
||||
export const DarkTheme: Story = {
|
||||
args: { expired: true },
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div data-theme="dark" style={{ width: 440, padding: 24, background: 'var(--color-bg)' }}>
|
||||
@@ -35,6 +52,7 @@ export const DarkTheme: Story = {
|
||||
</div>
|
||||
),
|
||||
],
|
||||
play: async ({ canvasElement }) => expectLoginSurfaces(canvasElement),
|
||||
};
|
||||
|
||||
export const NarrowViewport: Story = {
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.notice {
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.form .loginInput {
|
||||
background: var(--color-bg-subtle);
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -81,6 +81,7 @@ export function LoginForm({ expired = false, signedOut = false, onSubmit }: Logi
|
||||
>
|
||||
<Input
|
||||
name="username"
|
||||
className={styles.loginInput}
|
||||
label={t('auth.username')}
|
||||
autoComplete="username"
|
||||
autoCapitalize="none"
|
||||
@@ -95,6 +96,7 @@ export function LoginForm({ expired = false, signedOut = false, onSubmit }: Logi
|
||||
/>
|
||||
<Input
|
||||
name="password"
|
||||
className={styles.loginInput}
|
||||
type="password"
|
||||
label={t('auth.password')}
|
||||
autoComplete="current-password"
|
||||
|
||||
Reference in new issue
Block a user