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