Skip to content

Revert "SCAL-239365" #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
309 changes: 1 addition & 308 deletions src/embed/bodyless-conversation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('SpotterAgentEmbed', () => {
fetchMock.resetMocks();
});

test('should render the SpotterAgent embed', async () => {
test('should render the bodyless conversation embed', async () => {
fetchMock.mockResponses(
JSON.stringify({
data: {
Expand Down Expand Up @@ -137,311 +137,4 @@ describe('SpotterAgentEmbed', () => {
const errorResult = await spotterEmbed.sendMessage('userMessage');
expect(errorResult.error instanceof Error).toBeTruthy();
});

test('should apply containerClassName to the container element', async () => {
fetchMock.mockResponses(
JSON.stringify({
data: {
ConvAssist__createConversation: {
convId: 'conversationId',
initialCtx: {
type: 'TS_ANSWER',
tsAnsCtx: {
sessionId: 'sessionId',
genNo: 1,
stateKey: {
transactionId: 'transactionId',
generationNumber: 1,
},
worksheet: {
worksheetId: 'worksheetId',
worksheetName: 'GTM',
},
},
},
},
},
}),
JSON.stringify({
data: {
ConvAssist__sendMessage: {
responses: [
{
msgId: 'msgId',
data: {
asstRespData: {
tool: 'TS_NLS',
asstRespText: '',
nlsAnsData: {
sageQuerySuggestions: [
{
llmReasoning: {
assumptions: 'You want the total [COL|sales] for [COL|item_type] [VAL|jackets] for [VAL|this year].',
clarifications: '',
interpretation: '',
__typename: 'eureka_SageQuerySuggestion_LLMReasoning',
},
tokens: [
'sum sales',
"item type = 'jackets'",
"date = 'this year'",
],
tmlTokens: [
'sum [sales]',
"[date] = [date].'this year'",
"[item type] = [item type].'jackets'",
],
worksheetId: 'worksheetId',
description: '',
title: '',
cached: false,
sqlQuery: "SELECT SUM(sales) FROM __Sample_Retail_Apparel WHERE item_type = 'jackets' AND date = _this_year();",
sessionId: 'sessionId',
genNo: 2,
formulaInfo: [],
tmlPhrases: [],
stateKey: {
transactionId: 'transactionId',
generationNumber: 1,
__typename: 'sage_auto_complete_v2_ACStateKey',
},
__typename: 'eureka_SageQuerySuggestion',
},
],
responseType: 'ANSWER',
__typename: 'convassist_nls_tool_NLSToolAsstRespData',
},
__typename: 'convassist_AsstResponseData',
},
__typename: 'convassist_MessageData',
},
type: 'ASST_RESPONSE',
__typename: 'convassist_MessagePayload',
},
],
__typename: 'convassist_SendMessageResponse',
},
},
}),
);

const viewConfig: SpotterAgentEmbedViewConfig = {
worksheetId: 'worksheetId',
containerClassName: 'custom-conversation-container',
};

const spotterAgentEmbed = new SpotterAgentEmbed(viewConfig);
const result = await spotterAgentEmbed.sendMessage('userMessage');

// Verify that the container has the custom class name
expect(result.container.className).toBe('custom-conversation-container');

// Also verify the iframe src is correct
const iframeSrc = getIFrameSrc(result.container);
expectUrlToHaveParamsWithValues(iframeSrc, {
sessionId: 'sessionId',
genNo: 2,
acSessionId: 'transactionId',
acGenNo: 1,
});
});

test('should not set className when containerClassName is not provided', async () => {
fetchMock.mockResponses(
JSON.stringify({
data: {
ConvAssist__createConversation: {
convId: 'conversationId',
initialCtx: {
type: 'TS_ANSWER',
tsAnsCtx: {
sessionId: 'sessionId',
genNo: 1,
stateKey: {
transactionId: 'transactionId',
generationNumber: 1,
},
worksheet: {
worksheetId: 'worksheetId',
worksheetName: 'GTM',
},
},
},
},
},
}),
JSON.stringify({
data: {
ConvAssist__sendMessage: {
responses: [
{
msgId: 'msgId',
data: {
asstRespData: {
tool: 'TS_NLS',
asstRespText: '',
nlsAnsData: {
sageQuerySuggestions: [
{
llmReasoning: {
assumptions: 'You want the total [COL|sales] for [COL|item_type] [VAL|jackets] for [VAL|this year].',
clarifications: '',
interpretation: '',
__typename: 'eureka_SageQuerySuggestion_LLMReasoning',
},
tokens: [
'sum sales',
"item type = 'jackets'",
"date = 'this year'",
],
tmlTokens: [
'sum [sales]',
"[date] = [date].'this year'",
"[item type] = [item type].'jackets'",
],
worksheetId: 'worksheetId',
description: '',
title: '',
cached: false,
sqlQuery: "SELECT SUM(sales) FROM __Sample_Retail_Apparel WHERE item_type = 'jackets' AND date = _this_year();",
sessionId: 'sessionId',
genNo: 2,
formulaInfo: [],
tmlPhrases: [],
stateKey: {
transactionId: 'transactionId',
generationNumber: 1,
__typename: 'sage_auto_complete_v2_ACStateKey',
},
__typename: 'eureka_SageQuerySuggestion',
},
],
responseType: 'ANSWER',
__typename: 'convassist_nls_tool_NLSToolAsstRespData',
},
__typename: 'convassist_AsstResponseData',
},
__typename: 'convassist_MessageData',
},
type: 'ASST_RESPONSE',
__typename: 'convassist_MessagePayload',
},
],
__typename: 'convassist_SendMessageResponse',
},
},
}),
);

const viewConfig: SpotterAgentEmbedViewConfig = {
worksheetId: 'worksheetId',
// No containerClassName provided
};

const spotterAgentEmbed = new SpotterAgentEmbed(viewConfig);
const result = await spotterAgentEmbed.sendMessage('userMessage');

// Verify that the container has no class name (empty string)
expect(result.container.className).toBe('');
});

test('should handle hideActions parameter correctly', async () => {
fetchMock.mockResponses(
JSON.stringify({
data: {
ConvAssist__createConversation: {
convId: 'conversationId',
initialCtx: {
type: 'TS_ANSWER',
tsAnsCtx: {
sessionId: 'sessionId',
genNo: 1,
stateKey: {
transactionId: 'transactionId',
generationNumber: 1,
},
worksheet: {
worksheetId: 'worksheetId',
worksheetName: 'GTM',
},
},
},
},
},
}),
JSON.stringify({
data: {
ConvAssist__sendMessage: {
responses: [
{
msgId: 'msgId',
data: {
asstRespData: {
tool: 'TS_NLS',
asstRespText: '',
nlsAnsData: {
sageQuerySuggestions: [
{
llmReasoning: {
assumptions: 'You want the total [COL|sales] for [COL|item_type] [VAL|jackets] for [VAL|this year].',
clarifications: '',
interpretation: '',
__typename: 'eureka_SageQuerySuggestion_LLMReasoning',
},
tokens: [
'sum sales',
"item type = 'jackets'",
"date = 'this year'",
],
tmlTokens: [
'sum [sales]',
"[date] = [date].'this year'",
"[item type] = [item type].'jackets'",
],
worksheetId: 'worksheetId',
description: '',
title: '',
cached: false,
sqlQuery: "SELECT SUM(sales) FROM __Sample_Retail_Apparel WHERE item_type = 'jackets' AND date = _this_year();",
sessionId: 'sessionId',
genNo: 2,
formulaInfo: [],
tmlPhrases: [],
stateKey: {
transactionId: 'transactionId',
generationNumber: 1,
__typename: 'sage_auto_complete_v2_ACStateKey',
},
__typename: 'eureka_SageQuerySuggestion',
},
],
responseType: 'ANSWER',
__typename: 'convassist_nls_tool_NLSToolAsstRespData',
},
__typename: 'convassist_AsstResponseData',
},
__typename: 'convassist_MessageData',
},
type: 'ASST_RESPONSE',
__typename: 'convassist_MessagePayload',
},
],
__typename: 'convassist_SendMessageResponse',
},
},
}),
);

const viewConfig: SpotterAgentEmbedViewConfig = {
worksheetId: 'worksheetId',
hiddenActions: [Action.Download, Action.Save], // This should trigger the HideActions branch
};

const spotterAgentEmbed = new SpotterAgentEmbed(viewConfig);
const result = await spotterAgentEmbed.sendMessage('userMessage');

// Verify the iframe src contains the hideActions parameter
const iframeSrc = getIFrameSrc(result.container);
expect(iframeSrc).toContain('hideAction');
});
});
9 changes: 0 additions & 9 deletions src/embed/bodyless-conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export interface SpotterAgentEmbedViewConfig extends ViewConfig {
* The ID of the worksheet to use for the conversation.
*/
worksheetId: string;

/**
* Optional CSS class name to add to the container div.
*/
containerClassName?: string;
}

/**
Expand Down Expand Up @@ -116,10 +111,6 @@ export class SpotterAgentEmbed {
}

const container = document.createElement('div');
if (this.viewConfig.containerClassName) {
container.className = this.viewConfig.containerClassName;
}

const embed = new ConversationMessage(container, {
...this.viewConfig,
sessionId: data.sessionId,
Expand Down
1 change: 0 additions & 1 deletion src/react/all-types-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export {
SpotterEmbed,
ConversationEmbed,
PreRenderedConversationEmbed,
SpotterAgentEmbed,
useEmbedRef,
useInit,
} from './index';
Expand Down
Loading
Loading