Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/embed/conversation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
defaultParamsWithoutHiddenActions as defaultParams,
expectUrlMatchesWithParams,
} from '../test/test-utils';
import { ERROR_MESSAGE } from '../errors';

const thoughtSpotHost = 'tshost';

Expand Down Expand Up @@ -43,4 +44,19 @@ describe('ConversationEmbed', () => {
`http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
);
});

it('should handle error when worksheetId is not provided', async () => {
const viewConfig: ConversationViewConfig = {
worksheetId: '',
searchOptions: {
searchQuery: 'searchQuery',
},
};
const conversationEmbed = new ConversationEmbed(getRootEl(), viewConfig);
(conversationEmbed as any).handleError = jest.fn();
await conversationEmbed.render();
expect((conversationEmbed as any).handleError).toHaveBeenCalledWith(
ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
);
});
});
4 changes: 4 additions & 0 deletions src/embed/conversation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ERROR_MESSAGE } from '../errors';
import { ViewConfig, Param } from '../types';
import { TsEmbed } from './ts-embed';
import { getQueryParamString } from '../utils';
Expand Down Expand Up @@ -49,6 +50,9 @@ export class ConversationEmbed extends TsEmbed {
searchOptions,
} = this.viewConfig;
const path = 'insights/conv-assist';
if (!worksheetId) {
this.handleError(ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND);
}
const queryParams = this.getBaseQueryParams();
queryParams[Param.SpotterEnabled] = true;

Expand Down
1 change: 1 addition & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const ERROR_MESSAGE = {
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND: 'Please select a worksheet to get started',
LIVEBOARD_VIZ_ID_VALIDATION: 'Please select a Liveboard to embed.',
TRIGGER_TIMED_OUT: 'Trigger timed-out in getting a response',
SEARCHEMBED_BETA_WRANING_MESSAGE: 'SearchEmbed is in Beta in this release.',
Expand Down
Loading