Skip to content

Commit bf4cb85

Browse files
authored
SCAL-229730-test worksheet Id not provided spotter (#44)
1 parent b94c87f commit bf4cb85

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/embed/conversation.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
defaultParamsWithoutHiddenActions as defaultParams,
1515
expectUrlMatchesWithParams,
1616
} from '../test/test-utils';
17+
import { ERROR_MESSAGE } from '../errors';
1718

1819
const thoughtSpotHost = 'tshost';
1920

@@ -43,4 +44,19 @@ describe('ConversationEmbed', () => {
4344
`http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
4445
);
4546
});
47+
48+
it('should handle error when worksheetId is not provided', async () => {
49+
const viewConfig: ConversationViewConfig = {
50+
worksheetId: '',
51+
searchOptions: {
52+
searchQuery: 'searchQuery',
53+
},
54+
};
55+
const conversationEmbed = new ConversationEmbed(getRootEl(), viewConfig);
56+
(conversationEmbed as any).handleError = jest.fn();
57+
await conversationEmbed.render();
58+
expect((conversationEmbed as any).handleError).toHaveBeenCalledWith(
59+
ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
60+
);
61+
});
4662
});

src/embed/conversation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ERROR_MESSAGE } from '../errors';
12
import { ViewConfig, Param } from '../types';
23
import { TsEmbed } from './ts-embed';
34
import { getQueryParamString } from '../utils';
@@ -49,6 +50,9 @@ export class ConversationEmbed extends TsEmbed {
4950
searchOptions,
5051
} = this.viewConfig;
5152
const path = 'insights/conv-assist';
53+
if (!worksheetId) {
54+
this.handleError(ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND);
55+
}
5256
const queryParams = this.getBaseQueryParams();
5357
queryParams[Param.SpotterEnabled] = true;
5458

src/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const ERROR_MESSAGE = {
22
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
3+
SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND: 'Please select a worksheet to get started',
34
LIVEBOARD_VIZ_ID_VALIDATION: 'Please select a Liveboard to embed.',
45
TRIGGER_TIMED_OUT: 'Trigger timed-out in getting a response',
56
SEARCHEMBED_BETA_WRANING_MESSAGE: 'SearchEmbed is in Beta in this release.',

0 commit comments

Comments
 (0)