1
1
import React , { CSSProperties , useMemo } from 'react' ;
2
2
import { observer } from 'mobx-react-lite' ;
3
3
import { BalanceMode , Unit } from 'util/constants' ;
4
+ import { AuthenticationError } from 'util/errors' ;
4
5
import { sampleApiResponses } from 'util/tests/sampleData' ;
5
6
import { createStore , StoreProvider } from 'store' ;
6
7
import { PersistentSettings } from 'store/stores/settingsStore' ;
@@ -9,7 +10,10 @@ import { ThemeProvider } from 'components/theme';
9
10
10
11
// mock the GRPC client to return sample data instead of making an actual request
11
12
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
+
13
17
const endpoint = `${ methodDescriptor . service . serviceName } .${ methodDescriptor . methodName } ` ;
14
18
const data = sampleApiResponses [ endpoint ] || { } ;
15
19
// the calling function expects the return value to have a `toObject` function
@@ -32,7 +36,11 @@ class StoryAppStorage {
32
36
33
37
// Create a store that pulls data from the mock GRPC and doesn't use
34
38
// 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
+ } ;
36
44
37
45
/**
38
46
* This component is used to wrap every story. It provides the app theme
0 commit comments