@elliemae/pui-app-sdk 3.0.0-beta.23 → 3.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analytics/appdynamics.js +1 -1
- package/dist/cjs/data/store.js +2 -0
- package/dist/cjs/data/webpack-hmr.js +42 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/utils/storybook/preview.js +7 -3
- package/dist/es/analytics/appdynamics.js +1 -1
- package/dist/es/data/store.js +2 -0
- package/dist/es/data/webpack-hmr.js +17 -0
- package/dist/es/index.js +5 -1
- package/dist/es/utils/storybook/preview.js +7 -3
- package/dist/types/communication/http-client/tests/{index.test-disable.d.ts → index.test.d.ts} +0 -0
- package/dist/types/data/webpack-hmr.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/storybook/preview.d.ts +1 -0
- package/package.json +35 -35
- package/dist/cjs/communication/http-client/tests/index.test-disable.js +0 -64
- package/dist/es/communication/http-client/tests/index.test-disable.js +0 -46
|
@@ -41,7 +41,7 @@ const getAppDynamicsUserData = () => userData;
|
|
|
41
41
|
const setAppDynamicsUserData = (params) => {
|
|
42
42
|
userData = { ...userData, ...params };
|
|
43
43
|
if (brum) {
|
|
44
|
-
brum.setCustomUserData(() => ({ userData }));
|
|
44
|
+
brum.setCustomUserData?.(() => ({ userData }));
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
module.exports = __toCommonJS(appdynamics_exports);
|
package/dist/cjs/data/store.js
CHANGED
|
@@ -35,6 +35,7 @@ var import_toolkit = require("@reduxjs/toolkit");
|
|
|
35
35
|
var import_redux_injectors = require("redux-injectors");
|
|
36
36
|
var import_redux_saga = __toESM(require("redux-saga"));
|
|
37
37
|
var import_reducers = require("./reducers.js");
|
|
38
|
+
var import_webpack_hmr = require("./webpack-hmr.js");
|
|
38
39
|
const rootReducer = (0, import_reducers.createReducer)();
|
|
39
40
|
let appStore = null;
|
|
40
41
|
const setStore = (store) => {
|
|
@@ -56,6 +57,7 @@ const createStore = (initialState, sagaMiddleware, history, middlewareConfig = {
|
|
|
56
57
|
preloadedState: initialState,
|
|
57
58
|
enhancers
|
|
58
59
|
});
|
|
60
|
+
(0, import_webpack_hmr.enableHotReloading)(baseStore);
|
|
59
61
|
return baseStore;
|
|
60
62
|
};
|
|
61
63
|
const createAppStore = (initialState = {}, history, middlewareConfig) => {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var webpack_hmr_exports = {};
|
|
24
|
+
__export(webpack_hmr_exports, {
|
|
25
|
+
enableHotReloading: () => enableHotReloading
|
|
26
|
+
});
|
|
27
|
+
var import_redux_injectors = require("redux-injectors");
|
|
28
|
+
const import_meta = {};
|
|
29
|
+
const enableHotReloading = (baseStore) => {
|
|
30
|
+
let hotModule = null;
|
|
31
|
+
try {
|
|
32
|
+
hotModule = module?.hot;
|
|
33
|
+
} catch (err) {
|
|
34
|
+
hotModule = import_meta?.webpackHot;
|
|
35
|
+
}
|
|
36
|
+
if (hotModule) {
|
|
37
|
+
hotModule.accept("./reducers", () => {
|
|
38
|
+
(0, import_redux_injectors.forceReducerReload)(baseStore);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
module.exports = __toCommonJS(webpack_hmr_exports);
|
package/dist/cjs/index.js
CHANGED
|
@@ -73,6 +73,7 @@ __export(lib_exports, {
|
|
|
73
73
|
getAuthorizationHeader: () => import_helper.getAuthorizationHeader,
|
|
74
74
|
getHTTPClient: () => import_http_client.getHTTPClient,
|
|
75
75
|
getHostAppDataByKey: () => import_store2.getHostAppDataByKey,
|
|
76
|
+
getLogger: () => import_micro_frontend.getLogger,
|
|
76
77
|
getMicroFrontEndAppConfig: () => import_micro_frontend.getMicroFrontEndAppConfig,
|
|
77
78
|
getNavigationLinks: () => import_utils.getNavigationLinks,
|
|
78
79
|
getRedirectUrl: () => import_url.getRedirectUrl,
|
|
@@ -23,7 +23,8 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
23
23
|
var preview_exports = {};
|
|
24
24
|
__export(preview_exports, {
|
|
25
25
|
decorators: () => decorators,
|
|
26
|
-
getParameters: () => getParameters
|
|
26
|
+
getParameters: () => getParameters,
|
|
27
|
+
loaders: () => loaders
|
|
27
28
|
});
|
|
28
29
|
var import_pui_theme = require("@elliemae/pui-theme");
|
|
29
30
|
var import_store = require("../../data/store.js");
|
|
@@ -32,8 +33,6 @@ var import_app_config = require("../app-config/index.js");
|
|
|
32
33
|
var import_theme = require("./theme.js");
|
|
33
34
|
var import_history = require("../history.js");
|
|
34
35
|
var import_dimsum = require("@elliemae/ds-basic/css/dimsum.css");
|
|
35
|
-
(0, import_app_config.loadAppConfig)(__webpack_public_path__).catch(() => {
|
|
36
|
-
});
|
|
37
36
|
const theme = (0, import_pui_theme.getDefaultTheme)();
|
|
38
37
|
const store = (0, import_store.createAppStore)({}, import_history.browserHistory);
|
|
39
38
|
const appDecorator = import_decorator.withAppDecorator.bind(null, theme, store);
|
|
@@ -68,4 +67,9 @@ const getParameters = (storyBookTheme) => ({
|
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
const decorators = [appDecorator];
|
|
70
|
+
const loaders = [
|
|
71
|
+
async () => {
|
|
72
|
+
await (0, import_app_config.loadAppConfig)(__webpack_public_path__ || "./");
|
|
73
|
+
}
|
|
74
|
+
];
|
|
71
75
|
module.exports = __toCommonJS(preview_exports);
|
|
@@ -9,7 +9,7 @@ const getAppDynamicsUserData = () => userData;
|
|
|
9
9
|
const setAppDynamicsUserData = (params) => {
|
|
10
10
|
userData = { ...userData, ...params };
|
|
11
11
|
if (brum) {
|
|
12
|
-
brum.setCustomUserData(() => ({ userData }));
|
|
12
|
+
brum.setCustomUserData?.(() => ({ userData }));
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
export {
|
package/dist/es/data/store.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "redux-injectors";
|
|
5
5
|
import createSagaMiddleware from "redux-saga";
|
|
6
6
|
import { createReducer } from "./reducers.js";
|
|
7
|
+
import { enableHotReloading } from "./webpack-hmr.js";
|
|
7
8
|
const rootReducer = createReducer();
|
|
8
9
|
let appStore = null;
|
|
9
10
|
const setStore = (store) => {
|
|
@@ -25,6 +26,7 @@ const createStore = (initialState, sagaMiddleware, history, middlewareConfig = {
|
|
|
25
26
|
preloadedState: initialState,
|
|
26
27
|
enhancers
|
|
27
28
|
});
|
|
29
|
+
enableHotReloading(baseStore);
|
|
28
30
|
return baseStore;
|
|
29
31
|
};
|
|
30
32
|
const createAppStore = (initialState = {}, history, middlewareConfig) => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { forceReducerReload } from "redux-injectors";
|
|
2
|
+
const enableHotReloading = (baseStore) => {
|
|
3
|
+
let hotModule = null;
|
|
4
|
+
try {
|
|
5
|
+
hotModule = module?.hot;
|
|
6
|
+
} catch (err) {
|
|
7
|
+
hotModule = import.meta?.webpackHot;
|
|
8
|
+
}
|
|
9
|
+
if (hotModule) {
|
|
10
|
+
hotModule.accept("./reducers", () => {
|
|
11
|
+
forceReducerReload(baseStore);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
enableHotReloading
|
|
17
|
+
};
|
package/dist/es/index.js
CHANGED
|
@@ -35,7 +35,10 @@ import {
|
|
|
35
35
|
setAppConfigValue,
|
|
36
36
|
setAppConfig
|
|
37
37
|
} from "./utils/app-config/config.js";
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
getMicroFrontEndAppConfig,
|
|
40
|
+
getLogger
|
|
41
|
+
} from "./utils/micro-frontend/index.js";
|
|
39
42
|
import { loadAppConfig } from "./utils/app-config/index.js";
|
|
40
43
|
import { AppRoot } from "./view/app-root/index.js";
|
|
41
44
|
import { ErrorBoundary } from "./view/error-boundary/index.js";
|
|
@@ -143,6 +146,7 @@ export {
|
|
|
143
146
|
getAuthorizationHeader,
|
|
144
147
|
getHTTPClient,
|
|
145
148
|
getHostAppDataByKey,
|
|
149
|
+
getLogger,
|
|
146
150
|
getMicroFrontEndAppConfig,
|
|
147
151
|
getNavigationLinks,
|
|
148
152
|
getRedirectUrl,
|
|
@@ -5,8 +5,6 @@ import { loadAppConfig } from "../app-config/index.js";
|
|
|
5
5
|
import { createTheme } from "./theme.js";
|
|
6
6
|
import { browserHistory } from "../history.js";
|
|
7
7
|
import "@elliemae/ds-basic/css/dimsum.css";
|
|
8
|
-
loadAppConfig(__webpack_public_path__).catch(() => {
|
|
9
|
-
});
|
|
10
8
|
const theme = getDefaultTheme();
|
|
11
9
|
const store = createAppStore({}, browserHistory);
|
|
12
10
|
const appDecorator = withAppDecorator.bind(null, theme, store);
|
|
@@ -41,7 +39,13 @@ const getParameters = (storyBookTheme) => ({
|
|
|
41
39
|
}
|
|
42
40
|
});
|
|
43
41
|
const decorators = [appDecorator];
|
|
42
|
+
const loaders = [
|
|
43
|
+
async () => {
|
|
44
|
+
await loadAppConfig(__webpack_public_path__ || "./");
|
|
45
|
+
}
|
|
46
|
+
];
|
|
44
47
|
export {
|
|
45
48
|
decorators,
|
|
46
|
-
getParameters
|
|
49
|
+
getParameters,
|
|
50
|
+
loaders
|
|
47
51
|
};
|
package/dist/types/communication/http-client/tests/{index.test-disable.d.ts → index.test.d.ts}
RENAMED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const enableHotReloading: (baseStore: {}) => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { CMicroAppGuest } from './utils/micro-frontend/guest.js';
|
|
|
23
23
|
export { CMicroAppHost } from './utils/micro-frontend/host.js';
|
|
24
24
|
export { enableReactAppForHostIntegration } from './utils/app-host-integration/react.js';
|
|
25
25
|
export { getAppConfigValue, setAppConfigValue, setAppConfig, } from './utils/app-config/config.js';
|
|
26
|
-
export { getMicroFrontEndAppConfig } from './utils/micro-frontend/index.js';
|
|
26
|
+
export { getMicroFrontEndAppConfig, getLogger, } from './utils/micro-frontend/index.js';
|
|
27
27
|
export { loadAppConfig } from './utils/app-config/index.js';
|
|
28
28
|
export { AppRoot } from './view/app-root/index.js';
|
|
29
29
|
export { ErrorBoundary } from './view/error-boundary/index.js';
|
|
@@ -28,3 +28,4 @@ export declare const getParameters: (storyBookTheme: {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
export declare const decorators: ((story: () => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => JSX.Element)[];
|
|
31
|
+
export declare const loaders: (() => Promise<void>)[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/pui-app-sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.27",
|
|
4
4
|
"description": "ICE MT UI Platform Application SDK ",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"url": "http://git.elliemae.io/platform-ui/pui-app-sdk.git"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
|
-
"
|
|
65
|
+
"pnpm": ">=6",
|
|
66
66
|
"node": ">=16"
|
|
67
67
|
},
|
|
68
68
|
"author": "ICE MT",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"test:watch": "pui-cli test -w",
|
|
95
95
|
"test:staged": "jest --coverage --passWithNoTests --bail --findRelatedTests",
|
|
96
96
|
"upgrade": "ncu -u && npm run setup",
|
|
97
|
-
"prepare": "husky install"
|
|
97
|
+
"prepare": "[ -n \"$CI\" ] || husky install"
|
|
98
98
|
},
|
|
99
99
|
"jestSonar": {
|
|
100
100
|
"sonar56x": true,
|
|
@@ -103,48 +103,48 @@
|
|
|
103
103
|
"indent": 4
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@elliemae/app-react-dependencies": "^3.0.0-beta.
|
|
107
|
-
"@elliemae/ds-basic": "^
|
|
108
|
-
"@elliemae/ds-button": "^
|
|
109
|
-
"@elliemae/ds-controlled-form": "^
|
|
110
|
-
"@elliemae/ds-date-picker": "^
|
|
111
|
-
"@elliemae/ds-date-range-picker": "^
|
|
112
|
-
"@elliemae/ds-dialog": "^
|
|
113
|
-
"@elliemae/ds-form": "^
|
|
114
|
-
"@elliemae/ds-form-layout-blocks": "^
|
|
115
|
-
"@elliemae/ds-grid": "^
|
|
116
|
-
"@elliemae/ds-loading-indicator": "^
|
|
117
|
-
"@elliemae/ds-modal": "^
|
|
118
|
-
"@elliemae/ds-popperjs": "^
|
|
119
|
-
"@elliemae/ds-toast": "^
|
|
106
|
+
"@elliemae/app-react-dependencies": "^3.0.0-beta.4",
|
|
107
|
+
"@elliemae/ds-basic": "^3.0.0-alpha.0",
|
|
108
|
+
"@elliemae/ds-button": "^3.0.0-alpha.0",
|
|
109
|
+
"@elliemae/ds-controlled-form": "^3.0.0-alpha.0",
|
|
110
|
+
"@elliemae/ds-date-picker": "^3.0.0-alpha.0",
|
|
111
|
+
"@elliemae/ds-date-range-picker": "^3.0.0-alpha.0",
|
|
112
|
+
"@elliemae/ds-dialog": "^3.0.0-alpha.0",
|
|
113
|
+
"@elliemae/ds-form": "^3.0.0-alpha.0",
|
|
114
|
+
"@elliemae/ds-form-layout-blocks": "^3.0.0-alpha.0",
|
|
115
|
+
"@elliemae/ds-grid": "^3.0.0-alpha.0",
|
|
116
|
+
"@elliemae/ds-loading-indicator": "^3.0.0-alpha.0",
|
|
117
|
+
"@elliemae/ds-modal": "^3.0.0-alpha.0",
|
|
118
|
+
"@elliemae/ds-popperjs": "^3.0.0-alpha.0",
|
|
119
|
+
"@elliemae/ds-toast": "^3.0.0-alpha.0",
|
|
120
120
|
"@elliemae/em-ssf-guest": "^1.11.1",
|
|
121
121
|
"@elliemae/pui-diagnostics": "^2.7.3",
|
|
122
122
|
"@elliemae/pui-micro-frontend-base": "^1.10.1",
|
|
123
123
|
"@elliemae/pui-theme": "^2.3.0",
|
|
124
|
-
"@elliemae/pui-user-monitoring": "^1.
|
|
124
|
+
"@elliemae/pui-user-monitoring": "^1.13.0"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
|
-
"@elliemae/app-react-dependencies": "~3.0.0-beta.
|
|
127
|
+
"@elliemae/app-react-dependencies": "~3.0.0-beta.4",
|
|
128
128
|
"@elliemae/browserslist-config-elliemae-latest-browsers": "~1.2.1",
|
|
129
|
-
"@elliemae/ds-basic": "
|
|
130
|
-
"@elliemae/ds-button": "
|
|
131
|
-
"@elliemae/ds-controlled-form": "
|
|
132
|
-
"@elliemae/ds-date-picker": "
|
|
133
|
-
"@elliemae/ds-date-range-picker": "
|
|
134
|
-
"@elliemae/ds-dialog": "
|
|
135
|
-
"@elliemae/ds-form": "
|
|
136
|
-
"@elliemae/ds-form-layout-blocks": "
|
|
137
|
-
"@elliemae/ds-grid": "
|
|
138
|
-
"@elliemae/ds-loading-indicator": "
|
|
139
|
-
"@elliemae/ds-modal": "
|
|
140
|
-
"@elliemae/ds-popperjs": "
|
|
141
|
-
"@elliemae/ds-toast": "
|
|
129
|
+
"@elliemae/ds-basic": "3.0.0-alpha.0",
|
|
130
|
+
"@elliemae/ds-button": "3.0.0-alpha.0",
|
|
131
|
+
"@elliemae/ds-controlled-form": "3.0.0-alpha.0",
|
|
132
|
+
"@elliemae/ds-date-picker": "3.0.0-alpha.0",
|
|
133
|
+
"@elliemae/ds-date-range-picker": "3.0.0-alpha.0",
|
|
134
|
+
"@elliemae/ds-dialog": "3.0.0-alpha.0",
|
|
135
|
+
"@elliemae/ds-form": "3.0.0-alpha.0",
|
|
136
|
+
"@elliemae/ds-form-layout-blocks": "3.0.0-alpha.0",
|
|
137
|
+
"@elliemae/ds-grid": "3.0.0-alpha.0",
|
|
138
|
+
"@elliemae/ds-loading-indicator": "3.0.0-alpha.0",
|
|
139
|
+
"@elliemae/ds-modal": "3.0.0-alpha.0",
|
|
140
|
+
"@elliemae/ds-popperjs": "3.0.0-alpha.0",
|
|
141
|
+
"@elliemae/ds-toast": "3.0.0-alpha.0",
|
|
142
142
|
"@elliemae/em-ssf-guest": "~1.11.1",
|
|
143
|
-
"@elliemae/pui-cli": "~6.0.0-beta.
|
|
143
|
+
"@elliemae/pui-cli": "~6.0.0-beta.52",
|
|
144
144
|
"@elliemae/pui-diagnostics": "~2.7.3",
|
|
145
|
-
"@elliemae/pui-e2e-test-sdk": "~6.
|
|
145
|
+
"@elliemae/pui-e2e-test-sdk": "~6.10.0",
|
|
146
146
|
"@elliemae/pui-micro-frontend-base": "~1.10.1",
|
|
147
147
|
"@elliemae/pui-theme": "~2.3.0",
|
|
148
|
-
"@elliemae/pui-user-monitoring": "~1.
|
|
148
|
+
"@elliemae/pui-user-monitoring": "~1.13.0"
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(module2))
|
|
11
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (module2, isNodeMode) => {
|
|
17
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
-
};
|
|
19
|
-
var import_constants = __toESM(require("../../../utils/constants.js"));
|
|
20
|
-
var import__ = require("../index.js");
|
|
21
|
-
var import_response_interceptor = require("../response-interceptor.js");
|
|
22
|
-
describe("http client test cases", () => {
|
|
23
|
-
const callApi = ({
|
|
24
|
-
apiUrl,
|
|
25
|
-
options = {},
|
|
26
|
-
baseURL = "http://localhost:3001"
|
|
27
|
-
}) => {
|
|
28
|
-
const httpClient = (0, import__.getAuthHTTPClient)({ baseURL });
|
|
29
|
-
return httpClient.get(apiUrl, options);
|
|
30
|
-
};
|
|
31
|
-
const refreshToken = () => new Promise((resolve) => {
|
|
32
|
-
const authorizationHeader = "pui";
|
|
33
|
-
sessionStorage.setItem(import_constants.default.AUTHORIZATION, authorizationHeader);
|
|
34
|
-
resolve(authorizationHeader);
|
|
35
|
-
});
|
|
36
|
-
it("should download large file without timing out", async () => {
|
|
37
|
-
jest.setTimeout(3e5);
|
|
38
|
-
const { data } = await callApi({
|
|
39
|
-
apiUrl: "annual_report_2009.pdf",
|
|
40
|
-
options: { timeout: 2e5 },
|
|
41
|
-
baseURL: "https://www.iso.org/files/live/sites/isoorg/files/archive/pdf/en"
|
|
42
|
-
});
|
|
43
|
-
expect(data).toBeDefined();
|
|
44
|
-
});
|
|
45
|
-
it("should throw connection aborted error for large file download", async () => {
|
|
46
|
-
jest.setTimeout(3e5);
|
|
47
|
-
await expect(callApi({
|
|
48
|
-
apiUrl: "annual_report_2009.pdf",
|
|
49
|
-
baseURL: "https://www.iso.org/files/live/sites/isoorg/files/archive/pdf/en"
|
|
50
|
-
})).rejects.toEqual(new Error("timeout of 10000ms exceeded"));
|
|
51
|
-
});
|
|
52
|
-
it("should return success response", async () => {
|
|
53
|
-
const { data } = await callApi({ apiUrl: "/hello" });
|
|
54
|
-
expect(data.name).toEqual("pui-app-sdk");
|
|
55
|
-
});
|
|
56
|
-
it("should return unauthorized 401 response", async () => {
|
|
57
|
-
await expect(callApi({ apiUrl: "/private" })).rejects.toThrow("Request failed with status code 401");
|
|
58
|
-
});
|
|
59
|
-
it("should return success after refreshing authorization token", async () => {
|
|
60
|
-
(0, import_response_interceptor.onAuthorizationFailure)(refreshToken);
|
|
61
|
-
const { data } = await callApi({ apiUrl: "/private" });
|
|
62
|
-
expect(data.message).toEqual("you are viewing a private message");
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import enums from "../../../utils/constants.js";
|
|
2
|
-
import { getAuthHTTPClient } from "../index.js";
|
|
3
|
-
import { onAuthorizationFailure } from "../response-interceptor.js";
|
|
4
|
-
describe("http client test cases", () => {
|
|
5
|
-
const callApi = ({
|
|
6
|
-
apiUrl,
|
|
7
|
-
options = {},
|
|
8
|
-
baseURL = "http://localhost:3001"
|
|
9
|
-
}) => {
|
|
10
|
-
const httpClient = getAuthHTTPClient({ baseURL });
|
|
11
|
-
return httpClient.get(apiUrl, options);
|
|
12
|
-
};
|
|
13
|
-
const refreshToken = () => new Promise((resolve) => {
|
|
14
|
-
const authorizationHeader = "pui";
|
|
15
|
-
sessionStorage.setItem(enums.AUTHORIZATION, authorizationHeader);
|
|
16
|
-
resolve(authorizationHeader);
|
|
17
|
-
});
|
|
18
|
-
it("should download large file without timing out", async () => {
|
|
19
|
-
jest.setTimeout(3e5);
|
|
20
|
-
const { data } = await callApi({
|
|
21
|
-
apiUrl: "annual_report_2009.pdf",
|
|
22
|
-
options: { timeout: 2e5 },
|
|
23
|
-
baseURL: "https://www.iso.org/files/live/sites/isoorg/files/archive/pdf/en"
|
|
24
|
-
});
|
|
25
|
-
expect(data).toBeDefined();
|
|
26
|
-
});
|
|
27
|
-
it("should throw connection aborted error for large file download", async () => {
|
|
28
|
-
jest.setTimeout(3e5);
|
|
29
|
-
await expect(callApi({
|
|
30
|
-
apiUrl: "annual_report_2009.pdf",
|
|
31
|
-
baseURL: "https://www.iso.org/files/live/sites/isoorg/files/archive/pdf/en"
|
|
32
|
-
})).rejects.toEqual(new Error("timeout of 10000ms exceeded"));
|
|
33
|
-
});
|
|
34
|
-
it("should return success response", async () => {
|
|
35
|
-
const { data } = await callApi({ apiUrl: "/hello" });
|
|
36
|
-
expect(data.name).toEqual("pui-app-sdk");
|
|
37
|
-
});
|
|
38
|
-
it("should return unauthorized 401 response", async () => {
|
|
39
|
-
await expect(callApi({ apiUrl: "/private" })).rejects.toThrow("Request failed with status code 401");
|
|
40
|
-
});
|
|
41
|
-
it("should return success after refreshing authorization token", async () => {
|
|
42
|
-
onAuthorizationFailure(refreshToken);
|
|
43
|
-
const { data } = await callApi({ apiUrl: "/private" });
|
|
44
|
-
expect(data.message).toEqual("you are viewing a private message");
|
|
45
|
-
});
|
|
46
|
-
});
|