@thoughtspot/visual-embed-sdk 1.20.0-alpha.2 → 1.20.0-prerender.0
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/src/auth.d.ts +75 -5
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +19 -7
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +39 -19
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +19 -7
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +7 -1
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +11 -3
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +76 -5
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts +8 -0
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/util.d.ts +4 -0
- package/dist/src/react/util.d.ts.map +1 -1
- package/dist/src/test/test-utils.d.ts +11 -2
- package/dist/src/test/test-utils.d.ts.map +1 -1
- package/dist/src/types.d.ts +429 -97
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/answerService.d.ts +7 -0
- package/dist/src/utils/answerService.d.ts.map +1 -1
- package/dist/src/utils/authService.d.ts +30 -0
- package/dist/src/utils/authService.d.ts.map +1 -1
- package/dist/src/utils/processData.d.ts +12 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +7 -0
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils.d.ts +12 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed.es.js +818 -285
- package/dist/tsembed.js +791 -284
- package/lib/package.json +4 -3
- package/lib/src/auth.d.ts +75 -5
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +86 -26
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +14 -5
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/config.d.ts +1 -0
- package/lib/src/config.d.ts.map +1 -1
- package/lib/src/config.js +5 -3
- package/lib/src/config.js.map +1 -1
- package/lib/src/config.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +19 -7
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +26 -16
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +12 -12
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +39 -19
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +49 -15
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +1 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +19 -7
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +50 -38
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +37 -30
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +14 -26
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +7 -1
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +6 -7
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +11 -3
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +19 -15
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +16 -19
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +4 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +76 -5
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +150 -72
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +23 -24
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +3 -3
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts +8 -0
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +13 -1
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +4 -6
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +3 -6
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/react/util.d.ts +4 -0
- package/lib/src/react/util.d.ts.map +1 -1
- package/lib/src/react/util.js +4 -0
- package/lib/src/react/util.js.map +1 -1
- package/lib/src/test/test-utils.d.ts +11 -2
- package/lib/src/test/test-utils.d.ts.map +1 -1
- package/lib/src/test/test-utils.js +36 -25
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +429 -97
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +310 -72
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/answerService.d.ts +7 -0
- package/lib/src/utils/answerService.d.ts.map +1 -1
- package/lib/src/utils/answerService.js +7 -0
- package/lib/src/utils/answerService.js.map +1 -1
- package/lib/src/utils/answerService.spec.js.map +1 -1
- package/lib/src/utils/authService.d.ts +30 -0
- package/lib/src/utils/authService.d.ts.map +1 -1
- package/lib/src/utils/authService.js +39 -2
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/processData.d.ts +12 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +33 -5
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +7 -0
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +17 -3
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils/processTrigger.spec.js.map +1 -1
- package/lib/src/utils.d.ts +12 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +24 -19
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +664 -141
- package/package.json +4 -3
- package/src/auth.spec.ts +68 -150
- package/src/auth.ts +141 -101
- package/src/config.spec.ts +2 -4
- package/src/config.ts +5 -3
- package/src/embed/app.spec.ts +25 -14
- package/src/embed/app.ts +49 -37
- package/src/embed/base.spec.ts +6 -12
- package/src/embed/base.ts +74 -57
- package/src/embed/embed.spec.ts +5 -6
- package/src/embed/liveboard.spec.ts +56 -37
- package/src/embed/liveboard.ts +67 -65
- package/src/embed/pinboard.spec.ts +26 -29
- package/src/embed/search-bar.tsx +14 -9
- package/src/embed/search.spec.ts +31 -21
- package/src/embed/search.ts +28 -22
- package/src/embed/searchEmbed-basic-auth.spec.ts +22 -28
- package/src/embed/ts-embed.spec.ts +70 -148
- package/src/embed/ts-embed.ts +180 -157
- package/src/errors.ts +3 -6
- package/src/index.ts +23 -7
- package/src/mixpanel-service.spec.ts +1 -3
- package/src/mixpanel-service.ts +13 -1
- package/src/react/index.spec.tsx +11 -20
- package/src/react/index.tsx +40 -71
- package/src/react/util.ts +8 -4
- package/src/test/test-utils.ts +43 -39
- package/src/types.ts +427 -97
- package/src/utils/answerService.spec.ts +3 -5
- package/src/utils/answerService.ts +21 -17
- package/src/utils/authService.spec.ts +26 -41
- package/src/utils/authService.ts +47 -21
- package/src/utils/processData.spec.ts +26 -59
- package/src/utils/processData.ts +36 -14
- package/src/utils/processTrigger.spec.ts +1 -6
- package/src/utils/processTrigger.ts +18 -9
- package/src/utils.spec.ts +8 -12
- package/src/utils.ts +25 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.20.0-
|
|
3
|
+
"version": "1.20.0-prerender.0",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
"algoliasearch": "^4.10.5",
|
|
57
57
|
"classnames": "^2.3.1",
|
|
58
58
|
"dompurify": "^2.3.4",
|
|
59
|
+
"eslint-plugin-comment-length": "^0.9.2",
|
|
60
|
+
"eslint-plugin-jsdoc": "^40.1.0",
|
|
59
61
|
"eventemitter3": "^4.0.7",
|
|
60
62
|
"gatsby-plugin-vercel": "^1.0.3",
|
|
61
63
|
"html-react-parser": "^1.4.12",
|
|
@@ -128,8 +130,7 @@
|
|
|
128
130
|
"ts-jest": "^26.5.5",
|
|
129
131
|
"ts-loader": "8.0.4",
|
|
130
132
|
"typedoc": "0.21.6",
|
|
131
|
-
"typedoc-
|
|
132
|
-
"typedoc-plugin-toc-group": "0.0.5",
|
|
133
|
+
"typedoc-plugin-toc-group": "thoughtspot/typedoc-plugin-toc-group",
|
|
133
134
|
"typescript": "^4.9.4",
|
|
134
135
|
"url-search-params-polyfill": "^8.1.0",
|
|
135
136
|
"util": "^0.12.4"
|
package/src/auth.spec.ts
CHANGED
|
@@ -105,12 +105,8 @@ describe('Unit test for auth', () => {
|
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
test('endpoints, SAML_LOGIN_TEMPLATE', () => {
|
|
108
|
-
const ssoTemplateUrl = authInstance.EndPoints.SAML_LOGIN_TEMPLATE(
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
expect(ssoTemplateUrl).toBe(
|
|
112
|
-
`/callosum/v1/saml/login?targetURLPath=${thoughtSpotHost}`,
|
|
113
|
-
);
|
|
108
|
+
const ssoTemplateUrl = authInstance.EndPoints.SAML_LOGIN_TEMPLATE(thoughtSpotHost);
|
|
109
|
+
expect(ssoTemplateUrl).toBe(`/callosum/v1/saml/login?targetURLPath=${thoughtSpotHost}`);
|
|
114
110
|
});
|
|
115
111
|
|
|
116
112
|
test('when session info giving response', async () => {
|
|
@@ -133,9 +129,7 @@ describe('Unit test for auth', () => {
|
|
|
133
129
|
|
|
134
130
|
test('doTokenAuth: when authEndpoint and getAuthToken are not there, it throw error', async () => {
|
|
135
131
|
try {
|
|
136
|
-
await authInstance.doTokenAuth(
|
|
137
|
-
embedConfig.doTokenAuthFailureWithoutAuthEndPoint,
|
|
138
|
-
);
|
|
132
|
+
await authInstance.doTokenAuth(embedConfig.doTokenAuthFailureWithoutAuthEndPoint);
|
|
139
133
|
} catch (e) {
|
|
140
134
|
expect(e.message).toBe(
|
|
141
135
|
'Either auth endpoint or getAuthToken function must be provided',
|
|
@@ -144,35 +138,24 @@ describe('Unit test for auth', () => {
|
|
|
144
138
|
});
|
|
145
139
|
|
|
146
140
|
test('doTokenAuth: when user is loggedIn', async () => {
|
|
147
|
-
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
153
|
-
await authInstance.doTokenAuth(
|
|
154
|
-
embedConfig.doTokenAuthSuccess('authToken'),
|
|
155
|
-
);
|
|
141
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(async () => ({
|
|
142
|
+
json: () => mockSessionInfo,
|
|
143
|
+
status: 200,
|
|
144
|
+
}));
|
|
145
|
+
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken'));
|
|
156
146
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
157
147
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
158
148
|
});
|
|
159
149
|
|
|
160
150
|
test('doTokenAuth: when user is not loggedIn & getAuthToken have response', async () => {
|
|
161
|
-
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
Promise.resolve({
|
|
170
|
-
status: 200,
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
173
|
-
await authInstance.doTokenAuth(
|
|
174
|
-
embedConfig.doTokenAuthSuccess('authToken2'),
|
|
175
|
-
);
|
|
151
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
152
|
+
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
153
|
+
text: () => Promise.resolve('abc'),
|
|
154
|
+
}));
|
|
155
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
156
|
+
status: 200,
|
|
157
|
+
}));
|
|
158
|
+
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken2'));
|
|
176
159
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
177
160
|
expect(authService.fetchAuthService).toBeCalledWith(
|
|
178
161
|
thoughtSpotHost,
|
|
@@ -182,32 +165,17 @@ describe('Unit test for auth', () => {
|
|
|
182
165
|
});
|
|
183
166
|
|
|
184
167
|
test('doTokenAuth: when user is not loggedIn & getAuthToken not present, isLoggedIn should called', async () => {
|
|
185
|
-
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
|
|
186
|
-
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Promise.resolve({ text: () => Promise.resolve('abc') }),
|
|
193
|
-
);
|
|
194
|
-
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
|
|
195
|
-
Promise.resolve({
|
|
196
|
-
status: 200,
|
|
197
|
-
ok: true,
|
|
198
|
-
}),
|
|
199
|
-
);
|
|
200
|
-
await authInstance.doTokenAuth(
|
|
201
|
-
embedConfig.doTokenAuthFailureWithoutGetAuthToken,
|
|
202
|
-
);
|
|
168
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
169
|
+
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => Promise.resolve({ text: () => Promise.resolve('abc') }));
|
|
170
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
171
|
+
status: 200,
|
|
172
|
+
ok: true,
|
|
173
|
+
}));
|
|
174
|
+
await authInstance.doTokenAuth(embedConfig.doTokenAuthFailureWithoutGetAuthToken);
|
|
203
175
|
await executeAfterWait(() => {
|
|
204
176
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
205
177
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
206
|
-
expect(authService.fetchAuthService).toBeCalledWith(
|
|
207
|
-
thoughtSpotHost,
|
|
208
|
-
username,
|
|
209
|
-
'abc',
|
|
210
|
-
);
|
|
178
|
+
expect(authService.fetchAuthService).toBeCalledWith(thoughtSpotHost, username, 'abc');
|
|
211
179
|
});
|
|
212
180
|
});
|
|
213
181
|
|
|
@@ -218,20 +186,14 @@ describe('Unit test for auth', () => {
|
|
|
218
186
|
jest.spyOn(window, 'alert').mockClear();
|
|
219
187
|
jest.spyOn(window, 'alert').mockReturnValue(undefined);
|
|
220
188
|
jest.spyOn(authService, 'fetchAuthService').mockReset();
|
|
221
|
-
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
);
|
|
227
|
-
await authInstance.doTokenAuth(
|
|
228
|
-
embedConfig.doTokenAuthSuccess('authToken3'),
|
|
229
|
-
);
|
|
189
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
190
|
+
status: 200,
|
|
191
|
+
ok: true,
|
|
192
|
+
}));
|
|
193
|
+
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken3'));
|
|
230
194
|
|
|
231
195
|
try {
|
|
232
|
-
await authInstance.doTokenAuth(
|
|
233
|
-
embedConfig.doTokenAuthSuccess('authToken3'),
|
|
234
|
-
);
|
|
196
|
+
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken3'));
|
|
235
197
|
expect(false).toBe(true);
|
|
236
198
|
} catch (e) {
|
|
237
199
|
expect(e.message).toContain('Duplicate token');
|
|
@@ -249,49 +211,36 @@ describe('Unit test for auth', () => {
|
|
|
249
211
|
status: 401,
|
|
250
212
|
})
|
|
251
213
|
.mockClear();
|
|
252
|
-
jest.spyOn(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
).mockImplementation(() =>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}),
|
|
261
|
-
);
|
|
262
|
-
const isLoggedIn = await authInstance.doTokenAuth(
|
|
263
|
-
embedConfig.doTokenAuthWithCookieDetect,
|
|
264
|
-
);
|
|
214
|
+
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
215
|
+
text: () => Promise.resolve('abc'),
|
|
216
|
+
}));
|
|
217
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
218
|
+
status: 200,
|
|
219
|
+
ok: true,
|
|
220
|
+
}));
|
|
221
|
+
const isLoggedIn = await authInstance.doTokenAuth(embedConfig.doTokenAuthWithCookieDetect);
|
|
265
222
|
expect(authService.fetchSessionInfoService).toHaveBeenCalledTimes(2);
|
|
266
223
|
expect(isLoggedIn).toBe(false);
|
|
267
224
|
});
|
|
268
225
|
|
|
269
226
|
test('doTokenAuth: when user is not loggedIn & fetchAuthPostService failed than fetchAuthService should call', async () => {
|
|
270
227
|
jest.spyOn(window, 'alert').mockImplementation(() => undefined);
|
|
271
|
-
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
authService,
|
|
276
|
-
'fetchAuthTokenService',
|
|
277
|
-
).mockImplementation(() => ({ text: () => Promise.resolve('abc') }));
|
|
228
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
229
|
+
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
230
|
+
text: () => Promise.resolve('abc'),
|
|
231
|
+
}));
|
|
278
232
|
jest.spyOn(authService, 'fetchAuthPostService').mockImplementation(() =>
|
|
279
|
-
// eslint-disable-next-line prefer-promise-reject-errors
|
|
233
|
+
// eslint-disable-next-line prefer-promise-reject-errors, implicit-arrow-linebreak
|
|
280
234
|
Promise.reject({
|
|
281
235
|
status: 500,
|
|
282
|
-
})
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
236
|
+
}));
|
|
237
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
238
|
+
status: 200,
|
|
239
|
+
type: 'opaqueredirect',
|
|
240
|
+
}));
|
|
241
|
+
expect(await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken2'))).toBe(
|
|
242
|
+
true,
|
|
289
243
|
);
|
|
290
|
-
expect(
|
|
291
|
-
await authInstance.doTokenAuth(
|
|
292
|
-
embedConfig.doTokenAuthSuccess('authToken2'),
|
|
293
|
-
),
|
|
294
|
-
).toBe(true);
|
|
295
244
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
296
245
|
expect(authService.fetchAuthPostService).toBeCalledWith(
|
|
297
246
|
thoughtSpotHost,
|
|
@@ -311,14 +260,8 @@ describe('Unit test for auth', () => {
|
|
|
311
260
|
});
|
|
312
261
|
|
|
313
262
|
it('when user is loggedIn', async () => {
|
|
314
|
-
spyOn(
|
|
315
|
-
|
|
316
|
-
'checkReleaseVersionInBeta',
|
|
317
|
-
);
|
|
318
|
-
jest.spyOn(
|
|
319
|
-
authService,
|
|
320
|
-
'fetchSessionInfoService',
|
|
321
|
-
).mockImplementation(async () => ({
|
|
263
|
+
spyOn(checkReleaseVersionInBetaInstance, 'checkReleaseVersionInBeta');
|
|
264
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(async () => ({
|
|
322
265
|
json: () => mockSessionInfo,
|
|
323
266
|
status: 200,
|
|
324
267
|
}));
|
|
@@ -328,14 +271,11 @@ describe('Unit test for auth', () => {
|
|
|
328
271
|
});
|
|
329
272
|
|
|
330
273
|
it('when user is not loggedIn', async () => {
|
|
331
|
-
jest.spyOn(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
authService,
|
|
337
|
-
'fetchBasicAuthService',
|
|
338
|
-
).mockImplementation(() => ({ status: 200, ok: true }));
|
|
274
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
275
|
+
jest.spyOn(authService, 'fetchBasicAuthService').mockImplementation(() => ({
|
|
276
|
+
status: 200,
|
|
277
|
+
ok: true,
|
|
278
|
+
}));
|
|
339
279
|
|
|
340
280
|
await authInstance.doBasicAuth(embedConfig.doBasicAuth);
|
|
341
281
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
@@ -353,20 +293,14 @@ describe('Unit test for auth', () => {
|
|
|
353
293
|
});
|
|
354
294
|
|
|
355
295
|
it('when user is loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
356
|
-
spyOn(
|
|
357
|
-
checkReleaseVersionInBetaInstance,
|
|
358
|
-
'checkReleaseVersionInBeta',
|
|
359
|
-
);
|
|
296
|
+
spyOn(checkReleaseVersionInBetaInstance, 'checkReleaseVersionInBeta');
|
|
360
297
|
Object.defineProperty(window, 'location', {
|
|
361
298
|
value: {
|
|
362
299
|
href: authInstance.SSO_REDIRECTION_MARKER_GUID,
|
|
363
300
|
hash: '',
|
|
364
301
|
},
|
|
365
302
|
});
|
|
366
|
-
jest.spyOn(
|
|
367
|
-
authService,
|
|
368
|
-
'fetchSessionInfoService',
|
|
369
|
-
).mockImplementation(async () => ({
|
|
303
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(async () => ({
|
|
370
304
|
json: () => mockSessionInfo,
|
|
371
305
|
status: 200,
|
|
372
306
|
}));
|
|
@@ -377,10 +311,7 @@ describe('Unit test for auth', () => {
|
|
|
377
311
|
});
|
|
378
312
|
|
|
379
313
|
it('when user is not loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
380
|
-
jest.spyOn(
|
|
381
|
-
authService,
|
|
382
|
-
'fetchSessionInfoService',
|
|
383
|
-
).mockImplementation(() => Promise.reject());
|
|
314
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
384
315
|
await authInstance.doSamlAuth(embedConfig.doSamlAuth);
|
|
385
316
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
386
317
|
expect(window.location.hash).toBe('');
|
|
@@ -394,10 +325,7 @@ describe('Unit test for auth', () => {
|
|
|
394
325
|
hash: '',
|
|
395
326
|
},
|
|
396
327
|
});
|
|
397
|
-
jest.spyOn(
|
|
398
|
-
authService,
|
|
399
|
-
'fetchSessionInfoService',
|
|
400
|
-
).mockImplementation(() => Promise.reject());
|
|
328
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
401
329
|
await authInstance.doSamlAuth(embedConfig.doSamlAuth);
|
|
402
330
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
403
331
|
expect(global.window.location.href).toBe(samalLoginUrl);
|
|
@@ -412,10 +340,7 @@ describe('Unit test for auth', () => {
|
|
|
412
340
|
});
|
|
413
341
|
spyOn(authInstance, 'samlCompletionPromise');
|
|
414
342
|
global.window.open = jest.fn();
|
|
415
|
-
jest.spyOn(
|
|
416
|
-
authService,
|
|
417
|
-
'fetchSessionInfoService',
|
|
418
|
-
).mockImplementation(() => Promise.reject());
|
|
343
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
419
344
|
expect(await authInstance.samlCompletionPromise).not.toBe(null);
|
|
420
345
|
expect(
|
|
421
346
|
await authInstance.doSamlAuth({
|
|
@@ -438,10 +363,7 @@ describe('Unit test for auth', () => {
|
|
|
438
363
|
});
|
|
439
364
|
|
|
440
365
|
it('when user is not loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
441
|
-
jest.spyOn(
|
|
442
|
-
authService,
|
|
443
|
-
'fetchSessionInfoService',
|
|
444
|
-
).mockImplementation(() => Promise.reject());
|
|
366
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(() => Promise.reject());
|
|
445
367
|
await authInstance.doOIDCAuth(embedConfig.doOidcAuth);
|
|
446
368
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
447
369
|
expect(window.location.hash).toBe('');
|
|
@@ -479,9 +401,7 @@ describe('Unit test for auth', () => {
|
|
|
479
401
|
|
|
480
402
|
it('authenticate: when authType is AuthServerCookieless', async () => {
|
|
481
403
|
spyOn(authInstance, 'doCookielessTokenAuth');
|
|
482
|
-
await authInstance.authenticate(
|
|
483
|
-
embedConfig.authServerCookielessFailure,
|
|
484
|
-
);
|
|
404
|
+
await authInstance.authenticate(embedConfig.authServerCookielessFailure);
|
|
485
405
|
expect(window.location.hash).toBe('');
|
|
486
406
|
expect(authInstance.doCookielessTokenAuth).toBeCalled();
|
|
487
407
|
});
|
|
@@ -494,14 +414,12 @@ describe('Unit test for auth', () => {
|
|
|
494
414
|
});
|
|
495
415
|
|
|
496
416
|
it('authenticate: when authType is None', async () => {
|
|
497
|
-
expect(
|
|
498
|
-
|
|
499
|
-
)
|
|
417
|
+
expect(await authInstance.authenticate(embedConfig.nonAuthSucess)).not.toBeInstanceOf(
|
|
418
|
+
Error,
|
|
419
|
+
);
|
|
500
420
|
});
|
|
501
421
|
|
|
502
422
|
it('user is authenticated when loggedInStatus is true', () => {
|
|
503
|
-
expect(authInstance.isAuthenticated()).toBe(
|
|
504
|
-
authInstance.loggedInStatus,
|
|
505
|
-
);
|
|
423
|
+
expect(authInstance.isAuthenticated()).toBe(authInstance.loggedInStatus);
|
|
506
424
|
});
|
|
507
425
|
});
|