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
36 changes: 35 additions & 1 deletion src/embed/conversation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('ConversationEmbed', () => {
searchQuery: 'searchQuery',
},
dataPanelV2: true,
hiddenActions: [Action.InConversationTraining]
hiddenActions: [Action.InConversationTraining],
};

const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
Expand Down Expand Up @@ -282,6 +282,40 @@ describe('ConversationEmbed', () => {
);
});

it('should render the conversation embed with past conversations sidebar enabled', async () => {
const viewConfig: SpotterEmbedViewConfig = {
worksheetId: 'worksheetId',
searchOptions: {
searchQuery: 'searchQuery',
},
enablePastConversationsSidebar: true,
};

const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
await conversationEmbed.render();
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&enablePastConversationsSidebar=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
);
});

it('should render the conversation embed with past conversations sidebar disabled', async () => {
const viewConfig: SpotterEmbedViewConfig = {
worksheetId: 'worksheetId',
searchOptions: {
searchQuery: 'searchQuery',
},
enablePastConversationsSidebar: false,
};

const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
await conversationEmbed.render();
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&enablePastConversationsSidebar=false#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
);
});
Comment on lines +285 to +317

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These two test cases for enablePastConversationsSidebar are very similar and can be refactored into a single, more concise parameterized test using it.each. This will reduce code duplication and improve the maintainability of the test suite.

    it.each([
        { enabled: true, desc: 'enabled' },
        { enabled: false, desc: 'disabled' },
    ])('should render the conversation embed with past conversations sidebar $desc', async ({ enabled }) => {
        const viewConfig: SpotterEmbedViewConfig = {
            worksheetId: 'worksheetId',
            searchOptions: {
                searchQuery: 'searchQuery',
            },
            enablePastConversationsSidebar: enabled,
        };

        const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
        await conversationEmbed.render();
        expectUrlMatchesWithParams(
            getIFrameSrc(),
            `http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&enablePastConversationsSidebar=${enabled}#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
        );
    });


it('should ensure deprecated ConversationEmbed class maintains same functionality as SpotterEmbed', async () => {
const viewConfig: SpotterEmbedViewConfig = {
worksheetId: 'worksheetId',
Expand Down
22 changes: 22 additions & 0 deletions src/embed/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAct
* @version SDK: 1.41.0 | ThoughtSpot: 10.13.0.cl
*/
excludeRuntimeParametersfromURL?: boolean;
/**
* enablePastConversationsSidebar : Controls the visibility of the past conversations
* sidebar.
*
* Supported embed types: `SpotterEmbed`
* @default false
* @example
* ```js
* const embed = new SpotterEmbed('#tsEmbed', {
* ... //other embed view config
* enablePastConversationsSidebar : true,
* })
* ```
* @version SDK: 1.43.0 | ThoughtSpot: 10.14.0.cl
*/
enablePastConversationsSidebar?: boolean;
}

/**
Expand Down Expand Up @@ -205,6 +221,7 @@ export class SpotterEmbed extends TsEmbed {
dataPanelV2,
showSpotterLimitations,
hideSampleQuestions,
enablePastConversationsSidebar,
runtimeFilters,
excludeRuntimeFiltersfromURL,
runtimeParameters,
Expand Down Expand Up @@ -246,10 +263,15 @@ export class SpotterEmbed extends TsEmbed {
excludeRuntimeFiltersfromURL,
runtimeParameters,
excludeRuntimeParametersfromURL,
enablePastConversationsSidebar
} = this.viewConfig;
const path = 'insights/conv-assist';
const queryParams = this.getEmbedParamsObject();

if (!isUndefined(enablePastConversationsSidebar)) {
queryParams[Param.EnablePastConversationsSidebar] = !!enablePastConversationsSidebar;
}
Comment on lines +271 to +273

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with how other boolean flags are handled in this class, the logic for adding the enablePastConversationsSidebar parameter should be moved from getIframeSrc() to getEmbedParamsObject(). Currently, flags like disableSourceSelection, hideSampleQuestions, etc., are all processed within getEmbedParamsObject(). Centralizing this logic improves code organization and maintainability.

After moving this block, you can also remove enablePastConversationsSidebar from the destructuring at the top of getIframeSrc().

You can add the following block inside getEmbedParamsObject() before the return statement:

if (!isUndefined(enablePastConversationsSidebar)) {
    queryParams[Param.EnablePastConversationsSidebar] = !!enablePastConversationsSidebar;
}


let query = '';
const queryParamsString = getQueryParamString(queryParams, true);
if (queryParamsString) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4367,6 +4367,7 @@ export enum Param {
LiveboardXLSXCSVDownload = 'isLiveboardXLSXCSVDownloadEnabled',
isPNGInScheduledEmailsEnabled = 'isPNGInScheduledEmailsEnabled',
isLinkParametersEnabled = 'isLinkParametersEnabled',
EnablePastConversationsSidebar = 'enablePastConversationsSidebar',
}

/**
Expand Down
Loading
Loading