Skip to content

Commit 4e432a9

Browse files
vishalshrm539Vishal
andauthored
Avoid unintended n/w calls (#380)
Co-authored-by: Vishal <[email protected]>
1 parent 17a1463 commit 4e432a9

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

.storybook/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type { StorybookConfig } from '@storybook/angular';
2+
import path from 'path';
3+
24
const config: StorybookConfig = {
35
stories: ['../src/**/*.mdx', '../src/app/_components/custom-sdk/**/*.stories.@(js|jsx|ts|tsx)'],
46
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
@@ -11,6 +13,13 @@ const config: StorybookConfig = {
1113
},
1214
docs: {
1315
autodocs: 'tag'
14-
}
16+
},
17+
webpackFinal: async (config) => {
18+
if (config.resolve?.alias) {
19+
config.resolve.alias['@pega/auth/lib/sdk-auth-manager'] = path.resolve(__dirname, '../__mocks__/authManager.tsx');
20+
}
21+
22+
return config;
23+
},
1524
};
1625
export default config;

.storybook/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"emitDecoratorMetadata": false
88
},
99
"exclude": ["../src/test.ts", "../src/**/*.spec.ts"],
10-
"include": ["../src/**/*", "./preview.ts"],
10+
"include": ["../src/**/*", "./preview.ts", "../__mocks__/*"],
1111
"files": ["./typings.d.ts"]
1212
}

__mocks__/authManager.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/** This file contains the Mocks for the various auth-manager APIs */
2+
export function getHomeUrl() {
3+
/* nothing */
4+
}
5+
export function authIsMainRedirect() {
6+
/* nothing */
7+
}
8+
export function authRedirectCallback() {
9+
/* nothing */
10+
}
11+
export function sdkIsLoggedIn() {
12+
/* nothing */
13+
}
14+
export function loginIfNecessary() {
15+
/* nothing */
16+
}
17+
export function sdkSetAuthHeader() {
18+
/* nothing */
19+
}
20+
export function sdkSetCustomTokenParamsCB() {
21+
/* nothing */
22+
}
23+
export function getSdkConfig() {
24+
/* nothing */
25+
}
26+
export function SdkConfigAccess() {
27+
/* nothing */
28+
}
29+
export function getAvailablePortals() {
30+
/* nothing */
31+
}
32+
export function logout() {
33+
/* nothing */
34+
}

0 commit comments

Comments
 (0)