File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff 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
1819const 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} ) ;
Original file line number Diff line number Diff line change 1+ import { ERROR_MESSAGE } from '../errors' ;
12import { ViewConfig , Param } from '../types' ;
23import { TsEmbed } from './ts-embed' ;
34import { 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
Original file line number Diff line number Diff line change 11export 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.' ,
You can’t perform that action at this time.
0 commit comments