Skip to content

Commit dc51ee4

Browse files
committed
stories: add story for auth page
1 parent 279c920 commit dc51ee4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import AuthPage from 'components/auth/AuthPage';
3+
import { Layout } from 'components/layout';
4+
5+
export default {
6+
title: 'Pages/Auth',
7+
component: AuthPage,
8+
};
9+
10+
export const Default = () => {
11+
return (
12+
<Layout>
13+
<AuthPage />
14+
</Layout>
15+
);
16+
};

app/src/__stories__/StoryWrapper.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { CSSProperties, useMemo } from 'react';
22
import { observer } from 'mobx-react-lite';
33
import { BalanceMode, Unit } from 'util/constants';
4+
import { AuthenticationError } from 'util/errors';
45
import { sampleApiResponses } from 'util/tests/sampleData';
56
import { createStore, StoreProvider } from 'store';
67
import { PersistentSettings } from 'store/stores/settingsStore';
@@ -9,7 +10,10 @@ import { ThemeProvider } from 'components/theme';
910

1011
// mock the GRPC client to return sample data instead of making an actual request
1112
const grpc = {
12-
request: (methodDescriptor: any) => {
13+
request: (methodDescriptor: any, opts: any, metadata: any) => {
14+
// fail any authenticated requests to simulate incorrect login attempts
15+
if (metadata && metadata.authorization) throw new AuthenticationError();
16+
1317
const endpoint = `${methodDescriptor.service.serviceName}.${methodDescriptor.methodName}`;
1418
const data = sampleApiResponses[endpoint] || {};
1519
// the calling function expects the return value to have a `toObject` function
@@ -32,7 +36,11 @@ class StoryAppStorage {
3236

3337
// Create a store that pulls data from the mock GRPC and doesn't use
3438
// the real localStorage to save settings
35-
const createStoryStore = () => createStore(grpc, new StoryAppStorage());
39+
const createStoryStore = () => {
40+
const store = createStore(grpc, new StoryAppStorage());
41+
store.fetchAllData();
42+
return store;
43+
};
3644

3745
/**
3846
* This component is used to wrap every story. It provides the app theme

0 commit comments

Comments
 (0)