@thoughtspot/visual-embed-sdk 1.44.1-test → 1.44.2
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/cjs/package.json +6 -5
- package/cjs/src/auth.spec.js +43 -42
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.spec.js +3 -3
- package/cjs/src/authToken.spec.js.map +1 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +3 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +12 -5
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.spec.js +11 -15
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.spec.js +2 -2
- package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +2 -2
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +101 -2
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +2 -2
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +3 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +28 -26
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/pinboard.spec.js +1 -1
- package/cjs/src/embed/pinboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +2 -2
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search.spec.js +118 -2
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed-trigger.spec.js +2 -3
- package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +242 -66
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/mixpanel-service.spec.js +1 -1
- package/cjs/src/mixpanel-service.spec.js.map +1 -1
- package/cjs/src/react/index.spec.js +3 -4
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/test/test-utils.js +1 -1
- package/cjs/src/test/test-utils.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +8 -8
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils/graphql/graphql-request.spec.js +1 -1
- package/cjs/src/utils/graphql/graphql-request.spec.js.map +1 -1
- package/cjs/src/utils/graphql/sourceService.spec.js +1 -1
- package/cjs/src/utils/graphql/sourceService.spec.js.map +1 -1
- package/cjs/src/utils/logger.spec.d.ts +5 -20
- package/cjs/src/utils/logger.spec.d.ts.map +1 -1
- package/cjs/src/utils/processData.spec.js +17 -17
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/processTrigger.spec.js +8 -8
- package/cjs/src/utils/processTrigger.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +6 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +32 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +19 -10
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-BXCUJ09L.js → index-CSFjfTVk.js} +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/utils/logger.spec.d.ts +5 -20
- package/dist/src/utils/logger.spec.d.ts.map +1 -1
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +39 -5
- package/dist/tsembed-react.js +38 -4
- package/dist/tsembed.es.js +39 -5
- package/dist/tsembed.js +38 -4
- package/lib/package.json +6 -5
- package/lib/src/auth.spec.js +43 -42
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.spec.js +3 -3
- package/lib/src/authToken.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +4 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +12 -5
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.spec.js +11 -15
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.spec.js +2 -2
- package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +2 -2
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +103 -4
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +2 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +2 -2
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +4 -2
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +28 -26
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +1 -1
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/sage.spec.js +2 -2
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search.spec.js +118 -2
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed-trigger.spec.js +2 -3
- package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +242 -66
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js +1 -1
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.spec.js +3 -4
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +8 -8
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils/graphql/graphql-request.spec.js +1 -1
- package/lib/src/utils/graphql/graphql-request.spec.js.map +1 -1
- package/lib/src/utils/graphql/sourceService.spec.js +1 -1
- package/lib/src/utils/graphql/sourceService.spec.js.map +1 -1
- package/lib/src/utils/logger.spec.d.ts +5 -20
- package/lib/src/utils/logger.spec.d.ts.map +1 -1
- package/lib/src/utils/processData.spec.js +17 -17
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.spec.js +8 -8
- package/lib/src/utils/processTrigger.spec.js.map +1 -1
- package/lib/src/utils.d.ts +6 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +30 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +20 -11
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +6 -5
- package/src/auth.spec.ts +53 -51
- package/src/authToken.spec.ts +3 -3
- package/src/embed/app.spec.ts +12 -5
- package/src/embed/app.ts +4 -2
- package/src/embed/base.spec.ts +16 -20
- package/src/embed/bodyless-conversation.spec.ts +2 -2
- package/src/embed/conversation.spec.ts +2 -2
- package/src/embed/embed.spec.ts +122 -2
- package/src/embed/events.spec.ts +2 -2
- package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
- package/src/embed/liveboard.spec.ts +30 -29
- package/src/embed/liveboard.ts +4 -2
- package/src/embed/pinboard.spec.ts +1 -1
- package/src/embed/sage.spec.ts +2 -2
- package/src/embed/search.spec.ts +133 -2
- package/src/embed/ts-embed-trigger.spec.ts +2 -3
- package/src/embed/ts-embed.spec.ts +317 -76
- package/src/mixpanel-service.spec.ts +1 -1
- package/src/react/index.spec.tsx +4 -5
- package/src/test/test-utils.ts +2 -2
- package/src/utils/authService/authService.spec.ts +17 -17
- package/src/utils/authService/tokenizedAuthService.spec.ts +4 -4
- package/src/utils/graphql/answerService/answerService.spec.ts +3 -3
- package/src/utils/graphql/graphql-request.spec.ts +2 -2
- package/src/utils/graphql/sourceService.spec.ts +1 -1
- package/src/utils/processData.spec.ts +26 -26
- package/src/utils/processTrigger.spec.ts +8 -8
- package/src/utils.spec.ts +22 -11
- package/src/utils.ts +34 -0
package/src/embed/embed.spec.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { logger } from '../utils/logger';
|
|
2
2
|
import {
|
|
3
3
|
init, AuthType, SearchEmbed, EmbedEvent,
|
|
4
|
+
RuntimeFilterOp,
|
|
5
|
+
Action,
|
|
4
6
|
} from '../index';
|
|
5
7
|
import {
|
|
6
8
|
EVENT_WAIT_TIME,
|
|
7
9
|
executeAfterWait,
|
|
10
|
+
expectUrlToHaveParamsWithValues,
|
|
8
11
|
getDocumentBody,
|
|
9
12
|
getIFrameEl,
|
|
13
|
+
getIFrameSrc,
|
|
10
14
|
getRootEl,
|
|
15
|
+
postMessageToParent,
|
|
11
16
|
} from '../test/test-utils';
|
|
12
17
|
import * as authInstance from '../auth';
|
|
13
18
|
|
|
@@ -24,8 +29,8 @@ beforeAll(() => {
|
|
|
24
29
|
thoughtSpotHost,
|
|
25
30
|
authType: AuthType.None,
|
|
26
31
|
});
|
|
27
|
-
spyOn(window, 'alert');
|
|
28
|
-
jest.spyOn(authInstance, 'postLoginService').
|
|
32
|
+
jest.spyOn(window, 'alert');
|
|
33
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
describe('test view config', () => {
|
|
@@ -52,4 +57,119 @@ describe('test view config', () => {
|
|
|
52
57
|
expect(iframe.style.height).toBe(`${height}px`);
|
|
53
58
|
});
|
|
54
59
|
});
|
|
60
|
+
|
|
61
|
+
test('should pass hideResults parameter when configured', async () => {
|
|
62
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
63
|
+
...defaultViewConfig,
|
|
64
|
+
hideResults: true,
|
|
65
|
+
});
|
|
66
|
+
searchEmbed.render();
|
|
67
|
+
|
|
68
|
+
await executeAfterWait(() => {
|
|
69
|
+
const iframeSrc = getIFrameSrc();
|
|
70
|
+
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
71
|
+
hideResult: true,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('should pass forceTable parameter when configured', async () => {
|
|
77
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
78
|
+
...defaultViewConfig,
|
|
79
|
+
forceTable: true,
|
|
80
|
+
});
|
|
81
|
+
searchEmbed.render();
|
|
82
|
+
|
|
83
|
+
await executeAfterWait(() => {
|
|
84
|
+
const iframeSrc = getIFrameSrc();
|
|
85
|
+
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
86
|
+
forceTable: true,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('should pass enableSearchAssist parameter when configured', async () => {
|
|
92
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
93
|
+
...defaultViewConfig,
|
|
94
|
+
enableSearchAssist: true,
|
|
95
|
+
});
|
|
96
|
+
searchEmbed.render();
|
|
97
|
+
|
|
98
|
+
await executeAfterWait(() => {
|
|
99
|
+
const iframeSrc = getIFrameSrc();
|
|
100
|
+
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
101
|
+
enableSearchAssist: true,
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('should pass hideSearchBar parameter when configured', async () => {
|
|
107
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
108
|
+
...defaultViewConfig,
|
|
109
|
+
hideSearchBar: true,
|
|
110
|
+
});
|
|
111
|
+
searchEmbed.render();
|
|
112
|
+
|
|
113
|
+
await executeAfterWait(() => {
|
|
114
|
+
const iframeSrc = getIFrameSrc();
|
|
115
|
+
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
116
|
+
hideSearchBar: true,
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('should register and trigger event listeners', async () => {
|
|
122
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
123
|
+
const mockCallback = jest.fn();
|
|
124
|
+
|
|
125
|
+
searchEmbed.on(EmbedEvent.Load, mockCallback);
|
|
126
|
+
await searchEmbed.render();
|
|
127
|
+
|
|
128
|
+
await executeAfterWait(() => {
|
|
129
|
+
const iframe = getIFrameEl();
|
|
130
|
+
postMessageToParent(iframe.contentWindow, {
|
|
131
|
+
type: EmbedEvent.Load,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
await executeAfterWait(() => {
|
|
136
|
+
expect(mockCallback).toHaveBeenCalled();
|
|
137
|
+
}, EVENT_WAIT_TIME);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('should pass disabledActions parameter when configured', async () => {
|
|
141
|
+
const disabledActions = [Action.Download, Action.Share];
|
|
142
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
143
|
+
...defaultViewConfig,
|
|
144
|
+
disabledActions,
|
|
145
|
+
});
|
|
146
|
+
searchEmbed.render();
|
|
147
|
+
|
|
148
|
+
await executeAfterWait(() => {
|
|
149
|
+
const iframeSrc = getIFrameSrc();
|
|
150
|
+
expect(iframeSrc).toContain('disableAction');
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('should pass runtime filters when configured', async () => {
|
|
155
|
+
const runtimeFilters = [
|
|
156
|
+
{
|
|
157
|
+
columnName: 'revenue',
|
|
158
|
+
operator: RuntimeFilterOp.GT,
|
|
159
|
+
values: [1000],
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
163
|
+
...defaultViewConfig,
|
|
164
|
+
runtimeFilters,
|
|
165
|
+
});
|
|
166
|
+
searchEmbed.render();
|
|
167
|
+
|
|
168
|
+
await executeAfterWait(() => {
|
|
169
|
+
const iframeSrc = getIFrameSrc();
|
|
170
|
+
expect(iframeSrc).toContain('col1=revenue');
|
|
171
|
+
expect(iframeSrc).toContain('op1=GT');
|
|
172
|
+
expect(iframeSrc).toContain('val1=1000');
|
|
173
|
+
});
|
|
174
|
+
});
|
|
55
175
|
});
|
package/src/embed/events.spec.ts
CHANGED
|
@@ -36,8 +36,8 @@ beforeAll(() => {
|
|
|
36
36
|
thoughtSpotHost,
|
|
37
37
|
authType: AuthType.None,
|
|
38
38
|
});
|
|
39
|
-
spyOn(window, 'alert');
|
|
40
|
-
jest.spyOn(authInstance, 'postLoginService').
|
|
39
|
+
jest.spyOn(window, 'alert');
|
|
40
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
describe('test communication between host app and ThoughtSpot', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getIFrameEl, getRootEl } from '../../test/test-utils';
|
|
2
|
-
import { HostEvent } from '../../types';
|
|
2
|
+
import { AuthType, HostEvent } from '../../types';
|
|
3
3
|
import { processTrigger } from '../../utils/processTrigger';
|
|
4
4
|
import * as EmbedConfigService from '../embedConfig';
|
|
5
5
|
import {
|
|
@@ -23,7 +23,7 @@ const createHostEventClient = () => {
|
|
|
23
23
|
describe('HostEventClient', () => {
|
|
24
24
|
const mockThoughtSpotHost = 'http://localhost';
|
|
25
25
|
beforeEach(() => {
|
|
26
|
-
jest.spyOn(EmbedConfigService, 'getEmbedConfig').mockReturnValue({ thoughtSpotHost: mockThoughtSpotHost });
|
|
26
|
+
jest.spyOn(EmbedConfigService, 'getEmbedConfig').mockReturnValue({ thoughtSpotHost: mockThoughtSpotHost, authType: AuthType.None } as any);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
afterEach(() => {
|
|
@@ -27,6 +27,7 @@ import * as processTriggerInstance from '../utils/processTrigger';
|
|
|
27
27
|
import * as auth from '../auth';
|
|
28
28
|
import * as previewService from '../utils/graphql/preview-service';
|
|
29
29
|
import * as SessionInfoService from '../utils/sessionInfoService';
|
|
30
|
+
import { logger } from '../utils/logger';
|
|
30
31
|
|
|
31
32
|
const defaultViewConfig = {
|
|
32
33
|
frameParams: {
|
|
@@ -57,7 +58,7 @@ beforeAll(() => {
|
|
|
57
58
|
thoughtSpotHost,
|
|
58
59
|
authType: AuthType.None,
|
|
59
60
|
});
|
|
60
|
-
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(
|
|
61
|
+
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
describe('Liveboard/viz embed tests', () => {
|
|
@@ -743,7 +744,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
743
744
|
});
|
|
744
745
|
});
|
|
745
746
|
test('should process the trigger, for vizEmbed', async () => {
|
|
746
|
-
const mockProcessTrigger = spyOn(processTriggerInstance, 'processTrigger');
|
|
747
|
+
const mockProcessTrigger = jest.spyOn(processTriggerInstance, 'processTrigger').mockImplementation(jest.fn());
|
|
747
748
|
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
748
749
|
enableVizTransformations: true,
|
|
749
750
|
...defaultViewConfig,
|
|
@@ -753,7 +754,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
753
754
|
liveboardEmbed.render();
|
|
754
755
|
await executeAfterWait(async () => {
|
|
755
756
|
await liveboardEmbed.trigger(HostEvent.Pin);
|
|
756
|
-
expect(mockProcessTrigger).
|
|
757
|
+
expect(mockProcessTrigger).toHaveBeenCalled();
|
|
757
758
|
});
|
|
758
759
|
});
|
|
759
760
|
|
|
@@ -820,7 +821,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
820
821
|
});
|
|
821
822
|
});
|
|
822
823
|
|
|
823
|
-
test('navigateToLiveboard should trigger the navigate event with the correct path', async (
|
|
824
|
+
test('navigateToLiveboard should trigger the navigate event with the correct path', async () => {
|
|
824
825
|
mockMessageChannel();
|
|
825
826
|
// mock getSessionInfo
|
|
826
827
|
|
|
@@ -830,7 +831,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
830
831
|
} as LiveboardViewConfig);
|
|
831
832
|
const onSpy = jest.spyOn(liveboardEmbed, 'trigger');
|
|
832
833
|
await liveboardEmbed.prerenderGeneric();
|
|
833
|
-
executeAfterWait(() => {
|
|
834
|
+
await executeAfterWait(() => {
|
|
834
835
|
const iframe = getIFrameEl();
|
|
835
836
|
postMessageToParent(iframe.contentWindow, {
|
|
836
837
|
type: EmbedEvent.APP_INIT,
|
|
@@ -841,13 +842,12 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
841
842
|
liveboardEmbed.navigateToLiveboard('lb1', 'viz1');
|
|
842
843
|
});
|
|
843
844
|
|
|
844
|
-
executeAfterWait(() => {
|
|
845
|
+
await executeAfterWait(() => {
|
|
845
846
|
expect(onSpy).toHaveBeenCalledWith(HostEvent.Navigate, 'embed/viz/lb1/viz1');
|
|
846
|
-
done();
|
|
847
847
|
}, 1002);
|
|
848
848
|
});
|
|
849
849
|
|
|
850
|
-
test('navigateToLiveboard with preRender', async (
|
|
850
|
+
test('navigateToLiveboard with preRender', async () => {
|
|
851
851
|
mockMessageChannel();
|
|
852
852
|
|
|
853
853
|
// mock getSessionInfo
|
|
@@ -857,7 +857,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
857
857
|
currentOrgId: 1,
|
|
858
858
|
privileges: [],
|
|
859
859
|
mixpanelToken: '1234567890',
|
|
860
|
-
});
|
|
860
|
+
} as any);
|
|
861
861
|
mockGetSessionInfo();
|
|
862
862
|
|
|
863
863
|
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
@@ -866,7 +866,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
866
866
|
} as LiveboardViewConfig);
|
|
867
867
|
const onSpy = jest.spyOn(liveboardEmbed, 'trigger');
|
|
868
868
|
await liveboardEmbed.prerenderGeneric();
|
|
869
|
-
executeAfterWait(() => {
|
|
869
|
+
await executeAfterWait(() => {
|
|
870
870
|
const iframe = getIFrameEl();
|
|
871
871
|
postMessageToParent(iframe.contentWindow, {
|
|
872
872
|
type: EmbedEvent.APP_INIT,
|
|
@@ -875,10 +875,9 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
875
875
|
type: EmbedEvent.AuthInit,
|
|
876
876
|
});
|
|
877
877
|
});
|
|
878
|
-
executeAfterWait(() => {
|
|
878
|
+
await executeAfterWait(() => {
|
|
879
879
|
liveboardEmbed.navigateToLiveboard('lb1', 'viz1');
|
|
880
880
|
expect(onSpy).toHaveBeenCalledWith(HostEvent.Navigate, 'embed/viz/lb1/viz1');
|
|
881
|
-
done();
|
|
882
881
|
}, 1002);
|
|
883
882
|
});
|
|
884
883
|
test('should set runtime parametere values in url params', async () => {
|
|
@@ -958,7 +957,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
958
957
|
const result = liveboardEmbed.trigger(HostEvent.SetActiveTab, {
|
|
959
958
|
tabId: newActiveTabId,
|
|
960
959
|
});
|
|
961
|
-
expect(mockProcessTrigger).not.
|
|
960
|
+
expect(mockProcessTrigger).not.toHaveBeenCalled();
|
|
962
961
|
});
|
|
963
962
|
});
|
|
964
963
|
|
|
@@ -988,14 +987,14 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
988
987
|
authType: AuthType.None,
|
|
989
988
|
});
|
|
990
989
|
});
|
|
991
|
-
test('it should preRender generic with liveboard id is not passed', async (
|
|
990
|
+
test('it should preRender generic with liveboard id is not passed', async () => {
|
|
992
991
|
const consoleSpy = jest.spyOn(console, 'error');
|
|
993
992
|
const libEmbed = new LiveboardEmbed(getRootEl(), {
|
|
994
993
|
preRenderId: 'testPreRender',
|
|
995
994
|
});
|
|
996
995
|
const prerenderGenericSpy = jest.spyOn(libEmbed, 'prerenderGeneric');
|
|
997
996
|
await libEmbed.preRender();
|
|
998
|
-
executeAfterWait(() => {
|
|
997
|
+
await executeAfterWait(() => {
|
|
999
998
|
const iFrame = document.getElementById(
|
|
1000
999
|
libEmbed.getPreRenderIds().child,
|
|
1001
1000
|
) as HTMLIFrameElement;
|
|
@@ -1005,8 +1004,6 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1005
1004
|
expect(iFrame.src).toMatch(/http:\/\/tshost\/.*&isLiveboardEmbed=true.*#$/);
|
|
1006
1005
|
|
|
1007
1006
|
expect(consoleSpy).toHaveBeenCalledTimes(0);
|
|
1008
|
-
|
|
1009
|
-
done();
|
|
1010
1007
|
});
|
|
1011
1008
|
});
|
|
1012
1009
|
|
|
@@ -1054,7 +1051,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1054
1051
|
});
|
|
1055
1052
|
});
|
|
1056
1053
|
|
|
1057
|
-
test('it should navigateToLiveboard with liveboard id is not passed with EmbedListenerReady event', async (
|
|
1054
|
+
test('it should navigateToLiveboard with liveboard id is not passed with EmbedListenerReady event', async () => {
|
|
1058
1055
|
mockMessageChannel();
|
|
1059
1056
|
const consoleSpy = jest.spyOn(console, 'error');
|
|
1060
1057
|
const testPreRenderId = 'testPreRender';
|
|
@@ -1099,7 +1096,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1099
1096
|
const navigateToLiveboardSpy = jest.spyOn(newLibEmbed, 'navigateToLiveboard');
|
|
1100
1097
|
await newLibEmbed.showPreRender();
|
|
1101
1098
|
|
|
1102
|
-
executeAfterWait(() => {
|
|
1099
|
+
await executeAfterWait(() => {
|
|
1103
1100
|
const iFrame = document.getElementById(
|
|
1104
1101
|
libEmbed.getPreRenderIds().child,
|
|
1105
1102
|
) as HTMLIFrameElement;
|
|
@@ -1109,12 +1106,10 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1109
1106
|
expect(iFrame.src).toMatch(/http:\/\/tshost\/.*&isLiveboardEmbed=true.*#$/);
|
|
1110
1107
|
|
|
1111
1108
|
expect(consoleSpy).toHaveBeenCalledTimes(0);
|
|
1112
|
-
|
|
1113
|
-
done();
|
|
1114
1109
|
});
|
|
1115
1110
|
});
|
|
1116
1111
|
|
|
1117
|
-
test('it should navigateToLiveboard with liveboard id is not passed with AuthInit event', async (
|
|
1112
|
+
test('it should navigateToLiveboard with liveboard id is not passed with AuthInit event', async () => {
|
|
1118
1113
|
mockMessageChannel();
|
|
1119
1114
|
const consoleSpy = jest.spyOn(console, 'error');
|
|
1120
1115
|
const testPreRenderId = 'testPreRender';
|
|
@@ -1168,7 +1163,6 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1168
1163
|
expect(navigateToLiveboardSpy).toHaveBeenCalledWith(testLiveboardId, 'testVizId', 'testActiveTabId');
|
|
1169
1164
|
expect(iFrame.src).toMatch(/http:\/\/tshost\/.*&isLiveboardEmbed=true.*#$/);
|
|
1170
1165
|
expect(consoleSpy).toHaveBeenCalledTimes(0);
|
|
1171
|
-
done();
|
|
1172
1166
|
}, 1005);
|
|
1173
1167
|
});
|
|
1174
1168
|
|
|
@@ -1277,6 +1271,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1277
1271
|
liveboardId,
|
|
1278
1272
|
fullHeight: true,
|
|
1279
1273
|
lazyLoadingForFullHeight: true,
|
|
1274
|
+
lazyLoadingMargin: '10px',
|
|
1280
1275
|
} as LiveboardViewConfig);
|
|
1281
1276
|
|
|
1282
1277
|
await liveboardEmbed.render();
|
|
@@ -1330,6 +1325,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1330
1325
|
liveboardId,
|
|
1331
1326
|
fullHeight: true,
|
|
1332
1327
|
lazyLoadingForFullHeight: true,
|
|
1328
|
+
lazyLoadingMargin: '10px',
|
|
1333
1329
|
} as LiveboardViewConfig);
|
|
1334
1330
|
|
|
1335
1331
|
await liveboardEmbed.render();
|
|
@@ -1348,6 +1344,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1348
1344
|
liveboardId,
|
|
1349
1345
|
fullHeight: true,
|
|
1350
1346
|
lazyLoadingForFullHeight: true,
|
|
1347
|
+
lazyLoadingMargin: '10px',
|
|
1351
1348
|
} as LiveboardViewConfig);
|
|
1352
1349
|
|
|
1353
1350
|
const mockTrigger = jest.spyOn(liveboardEmbed, 'trigger');
|
|
@@ -1380,6 +1377,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1380
1377
|
liveboardId,
|
|
1381
1378
|
fullHeight: true,
|
|
1382
1379
|
lazyLoadingForFullHeight: true,
|
|
1380
|
+
lazyLoadingMargin: '10px',
|
|
1383
1381
|
} as LiveboardViewConfig);
|
|
1384
1382
|
|
|
1385
1383
|
const mockTrigger = jest.spyOn(liveboardEmbed, 'trigger');
|
|
@@ -1405,6 +1403,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1405
1403
|
liveboardId,
|
|
1406
1404
|
fullHeight: true,
|
|
1407
1405
|
lazyLoadingForFullHeight: true,
|
|
1406
|
+
lazyLoadingMargin: '10px',
|
|
1408
1407
|
} as LiveboardViewConfig);
|
|
1409
1408
|
|
|
1410
1409
|
await liveboardEmbed.render();
|
|
@@ -1426,6 +1425,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1426
1425
|
liveboardId,
|
|
1427
1426
|
fullHeight: true,
|
|
1428
1427
|
lazyLoadingForFullHeight: true,
|
|
1428
|
+
lazyLoadingMargin: '10px',
|
|
1429
1429
|
} as LiveboardViewConfig);
|
|
1430
1430
|
|
|
1431
1431
|
await liveboardEmbed.render();
|
|
@@ -1454,6 +1454,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1454
1454
|
liveboardId,
|
|
1455
1455
|
fullHeight: true,
|
|
1456
1456
|
lazyLoadingForFullHeight: true,
|
|
1457
|
+
lazyLoadingMargin: '10px',
|
|
1457
1458
|
} as LiveboardViewConfig);
|
|
1458
1459
|
|
|
1459
1460
|
// Set the iframe before render
|
|
@@ -1512,7 +1513,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1512
1513
|
...defaultViewConfig,
|
|
1513
1514
|
});
|
|
1514
1515
|
|
|
1515
|
-
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').
|
|
1516
|
+
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').mockImplementation(() => Promise.resolve(undefined));
|
|
1516
1517
|
|
|
1517
1518
|
// Mock embed container as not loaded initially
|
|
1518
1519
|
liveboardEmbed.isEmbedContainerLoaded = false;
|
|
@@ -1544,7 +1545,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1544
1545
|
};
|
|
1545
1546
|
|
|
1546
1547
|
jest.spyOn(liveboardEmbed as any, 'getPreRenderObj').mockReturnValue(mockPreRenderObj as any);
|
|
1547
|
-
jest.spyOn(liveboardEmbed, 'navigateToLiveboard').
|
|
1548
|
+
jest.spyOn(liveboardEmbed, 'navigateToLiveboard').mockImplementation(() => Promise.resolve(undefined));
|
|
1548
1549
|
|
|
1549
1550
|
// Mock embed container as not loaded initially
|
|
1550
1551
|
liveboardEmbed.isEmbedContainerLoaded = false;
|
|
@@ -1572,7 +1573,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1572
1573
|
...defaultViewConfig,
|
|
1573
1574
|
});
|
|
1574
1575
|
|
|
1575
|
-
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').
|
|
1576
|
+
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').mockImplementation(() => Promise.resolve(undefined));
|
|
1576
1577
|
|
|
1577
1578
|
// Mock embed container as already loaded
|
|
1578
1579
|
liveboardEmbed.isEmbedContainerLoaded = true;
|
|
@@ -1593,7 +1594,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1593
1594
|
});
|
|
1594
1595
|
|
|
1595
1596
|
jest.spyOn(liveboardEmbed as any, 'getPreRenderObj').mockReturnValue(null);
|
|
1596
|
-
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').
|
|
1597
|
+
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').mockImplementation(() => Promise.resolve(undefined));
|
|
1597
1598
|
|
|
1598
1599
|
// Mock embed container as not loaded initially
|
|
1599
1600
|
liveboardEmbed.isEmbedContainerLoaded = false;
|
|
@@ -1621,7 +1622,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1621
1622
|
...defaultViewConfig,
|
|
1622
1623
|
});
|
|
1623
1624
|
|
|
1624
|
-
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').
|
|
1625
|
+
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').mockImplementation(() => Promise.resolve(undefined));
|
|
1625
1626
|
|
|
1626
1627
|
// Mock embed container as already loaded
|
|
1627
1628
|
liveboardEmbed.isEmbedContainerLoaded = true;
|
|
@@ -1639,7 +1640,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1639
1640
|
...defaultViewConfig,
|
|
1640
1641
|
});
|
|
1641
1642
|
|
|
1642
|
-
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').
|
|
1643
|
+
const navigateToLiveboardSpy = jest.spyOn(liveboardEmbed, 'navigateToLiveboard').mockImplementation(() => Promise.resolve(undefined));
|
|
1643
1644
|
|
|
1644
1645
|
// Mock embed container as already loaded
|
|
1645
1646
|
liveboardEmbed.isEmbedContainerLoaded = true;
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
ErrorDetailsTypes,
|
|
24
24
|
EmbedErrorCodes,
|
|
25
25
|
} from '../types';
|
|
26
|
-
import { calculateVisibleElementData, getQueryParamString, isUndefined } from '../utils';
|
|
26
|
+
import { calculateVisibleElementData, getQueryParamString, isUndefined, isValidCssMargin } from '../utils';
|
|
27
27
|
import { getAuthPromise } from './base';
|
|
28
28
|
import { TsEmbed, V1Embed } from './ts-embed';
|
|
29
29
|
import { addPreviewStylesIfNotPresent } from '../utils/global-styles';
|
|
@@ -528,7 +528,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
528
528
|
params[Param.fullHeight] = true;
|
|
529
529
|
if (this.viewConfig.lazyLoadingForFullHeight) {
|
|
530
530
|
params[Param.IsLazyLoadingForEmbedEnabled] = true;
|
|
531
|
-
|
|
531
|
+
if (isValidCssMargin(this.viewConfig.lazyLoadingMargin)) {
|
|
532
|
+
params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
|
|
533
|
+
}
|
|
532
534
|
}
|
|
533
535
|
}
|
|
534
536
|
this.defaultHeight = minimumHeight || defaultHeight || this.defaultHeight;
|
|
@@ -31,7 +31,7 @@ beforeAll(() => {
|
|
|
31
31
|
thoughtSpotHost,
|
|
32
32
|
authType: AuthType.None,
|
|
33
33
|
});
|
|
34
|
-
jest.spyOn(auth, 'postLoginService').
|
|
34
|
+
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
describe('Pinboard/viz embed tests', () => {
|
package/src/embed/sage.spec.ts
CHANGED
|
@@ -28,8 +28,8 @@ beforeAll(() => {
|
|
|
28
28
|
thoughtSpotHost,
|
|
29
29
|
authType: AuthType.None,
|
|
30
30
|
});
|
|
31
|
-
spyOn(window, 'alert');
|
|
32
|
-
jest.spyOn(authInstance, 'postLoginService').
|
|
31
|
+
jest.spyOn(window, 'alert');
|
|
32
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(true as any));
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
describe('Sage embed tests', () => {
|
package/src/embed/search.spec.ts
CHANGED
|
@@ -40,8 +40,8 @@ beforeAll(() => {
|
|
|
40
40
|
thoughtSpotHost,
|
|
41
41
|
authType: AuthType.None,
|
|
42
42
|
});
|
|
43
|
-
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(
|
|
44
|
-
spyOn(window, 'alert');
|
|
43
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
44
|
+
jest.spyOn(window, 'alert').mockImplementation(() => {});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
describe('Search embed tests', () => {
|
|
@@ -666,3 +666,134 @@ describe('Search embed tests', () => {
|
|
|
666
666
|
expect(getIFrameSrc().includes('executeSearch')).toBeFalsy();
|
|
667
667
|
});
|
|
668
668
|
});
|
|
669
|
+
|
|
670
|
+
// Add these tests to src/embed/search.spec.ts
|
|
671
|
+
|
|
672
|
+
// ============================================
|
|
673
|
+
// SearchEmbed tests for uncovered lines 427, 430
|
|
674
|
+
// ============================================
|
|
675
|
+
|
|
676
|
+
// TEST 1: hideResults parameter (line 427)
|
|
677
|
+
test('should pass hideResult parameter when hideResults is true', async () => {
|
|
678
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
679
|
+
...defaultViewConfig,
|
|
680
|
+
hideResults: true,
|
|
681
|
+
});
|
|
682
|
+
searchEmbed.render();
|
|
683
|
+
await executeAfterWait(() => {
|
|
684
|
+
const iframeSrc = getIFrameSrc();
|
|
685
|
+
expect(iframeSrc).toContain('hideResult=true');
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
// TEST 2: forceTable parameter (line 430)
|
|
690
|
+
test('should pass forceTable parameter when forceTable is true', async () => {
|
|
691
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
692
|
+
...defaultViewConfig,
|
|
693
|
+
forceTable: true,
|
|
694
|
+
});
|
|
695
|
+
searchEmbed.render();
|
|
696
|
+
await executeAfterWait(() => {
|
|
697
|
+
const iframeSrc = getIFrameSrc();
|
|
698
|
+
expect(iframeSrc).toContain('forceTable=true');
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
describe('SearchBarEmbed tests', () => {
|
|
703
|
+
test('should pass dataSources parameter when dataSources array is provided', async () => {
|
|
704
|
+
const searchBarEmbed = new SearchBarEmbed(getRootEl() as any, {
|
|
705
|
+
...defaultViewConfig,
|
|
706
|
+
dataSources: ['source-1', 'source-2'],
|
|
707
|
+
});
|
|
708
|
+
searchBarEmbed.render();
|
|
709
|
+
await executeAfterWait(() => {
|
|
710
|
+
const iframeSrc = getIFrameSrc();
|
|
711
|
+
expect(iframeSrc).toContain('dataSources');
|
|
712
|
+
expect(iframeSrc).toContain('source-1');
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
test('should pass dataSource parameter when single dataSource is provided', async () => {
|
|
717
|
+
const searchBarEmbed = new SearchBarEmbed(getRootEl() as any, {
|
|
718
|
+
...defaultViewConfig,
|
|
719
|
+
dataSource: 'single-source-id',
|
|
720
|
+
});
|
|
721
|
+
searchBarEmbed.render();
|
|
722
|
+
await executeAfterWait(() => {
|
|
723
|
+
const iframeSrc = getIFrameSrc();
|
|
724
|
+
expect(iframeSrc).toContain('dataSources');
|
|
725
|
+
expect(iframeSrc).toContain('single-source-id');
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
test('should pass searchTokenString and executeSearch when searchOptions provided', async () => {
|
|
730
|
+
const searchBarEmbed = new SearchBarEmbed(getRootEl() as any, {
|
|
731
|
+
...defaultViewConfig,
|
|
732
|
+
searchOptions: {
|
|
733
|
+
searchTokenString: '[revenue][region]',
|
|
734
|
+
executeSearch: true,
|
|
735
|
+
},
|
|
736
|
+
});
|
|
737
|
+
searchBarEmbed.render();
|
|
738
|
+
await executeAfterWait(() => {
|
|
739
|
+
const iframeSrc = getIFrameSrc();
|
|
740
|
+
expect(iframeSrc).toContain('searchTokenString');
|
|
741
|
+
expect(iframeSrc).toContain('executeSearch=true');
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
test('should set useLastSelectedSources to false when dataSource is provided', async () => {
|
|
746
|
+
const searchBarEmbed = new SearchBarEmbed(getRootEl() as any, {
|
|
747
|
+
...defaultViewConfig,
|
|
748
|
+
dataSource: 'my-source',
|
|
749
|
+
useLastSelectedSources: true, // This should be overridden to false
|
|
750
|
+
});
|
|
751
|
+
searchBarEmbed.render();
|
|
752
|
+
await executeAfterWait(() => {
|
|
753
|
+
const iframeSrc = getIFrameSrc();
|
|
754
|
+
expect(iframeSrc).toContain('useLastSelectedSources=false');
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
test('should include searchOptions in APP_INIT when excludeSearchTokenStringFromURL is true', async () => {
|
|
759
|
+
const searchOptions = {
|
|
760
|
+
searchTokenString: '[quantity][product]',
|
|
761
|
+
executeSearch: true,
|
|
762
|
+
};
|
|
763
|
+
const searchBarEmbed = new SearchBarEmbed(getRootEl() as any, {
|
|
764
|
+
...defaultViewConfig,
|
|
765
|
+
searchOptions,
|
|
766
|
+
excludeSearchTokenStringFromURL: true,
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
const mockEmbedEventPayload = {
|
|
770
|
+
type: EmbedEvent.APP_INIT,
|
|
771
|
+
data: {},
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
searchBarEmbed.render();
|
|
775
|
+
|
|
776
|
+
const mockPort: any = {
|
|
777
|
+
postMessage: jest.fn(),
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
await executeAfterWait(() => {
|
|
781
|
+
const iframe = getIFrameEl();
|
|
782
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
expect(getIFrameSrc().includes('searchTokenString')).toBeFalsy();
|
|
786
|
+
|
|
787
|
+
await executeAfterWait(() => {
|
|
788
|
+
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
789
|
+
type: EmbedEvent.APP_INIT,
|
|
790
|
+
data: expect.objectContaining({
|
|
791
|
+
searchOptions: {
|
|
792
|
+
searchTokenString: '[quantity][product]',
|
|
793
|
+
executeSearch: true,
|
|
794
|
+
},
|
|
795
|
+
}),
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
});
|
|
@@ -13,9 +13,9 @@ import * as authInstance from '../auth';
|
|
|
13
13
|
describe('Trigger', () => {
|
|
14
14
|
beforeEach(() => {
|
|
15
15
|
document.body.innerHTML = getDocumentBody();
|
|
16
|
-
jest.spyOn(authInstance, 'postLoginService').
|
|
16
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(true as any));
|
|
17
17
|
});
|
|
18
|
-
test('should trigger the event', async (
|
|
18
|
+
test('should trigger the event', async () => {
|
|
19
19
|
init({
|
|
20
20
|
thoughtSpotHost: 'https://tshost',
|
|
21
21
|
authType: AuthType.None,
|
|
@@ -36,7 +36,6 @@ describe('Trigger', () => {
|
|
|
36
36
|
type: HostEvent.DownloadAsCsv,
|
|
37
37
|
data: { vizId: 'testId' },
|
|
38
38
|
}), 'https://tshost', expect.anything());
|
|
39
|
-
done();
|
|
40
39
|
});
|
|
41
40
|
});
|
|
42
41
|
});
|