-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
22,606 additions
and
5,796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
* Copyright (c) 2020 | ||
* | ||
* Rollup configuration for building ThoughtSpot Embed UI SDK module | ||
* | ||
* @summary Rollup config | ||
* @author Ayon Ghosh <[email protected]> | ||
*/ | ||
|
@@ -13,31 +12,31 @@ import commonjs from '@rollup/plugin-commonjs'; | |
import json from '@rollup/plugin-json'; | ||
import replace from '@rollup/plugin-replace'; | ||
|
||
import pkg from './package.json'; | ||
import pkg from './package.json' assert {type: "json"}; | ||
|
||
const plugins = [ | ||
typescript({ | ||
typescript: require('typescript'), | ||
}), | ||
nodeResolve(), | ||
commonjs(), | ||
json({ | ||
compact: true | ||
}), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}) | ||
]; | ||
typescript(), | ||
nodeResolve(), | ||
commonjs(), | ||
json({ | ||
compact: true, | ||
}), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}), | ||
]; | ||
|
||
export default [{ | ||
input: 'src/index.ts', | ||
output: [ | ||
{ | ||
file: 'dist/tsembed.js', | ||
format: 'umd', | ||
inlineDynamicImports: true, | ||
name: 'tsembed', | ||
}, | ||
{ | ||
file: 'dist/tsembed.es.js', | ||
dir: 'dist/es', | ||
format: 'es', | ||
}, | ||
], | ||
|
@@ -51,10 +50,12 @@ export default [{ | |
{ | ||
file: 'dist/tsembed-react.js', | ||
format: 'umd', | ||
inlineDynamicImports: true, | ||
name: 'tsembed', | ||
}, | ||
{ | ||
file: 'dist/tsembed-react.es.js', | ||
dir: 'dist/es/react', | ||
inlineDynamicImports: true, | ||
format: 'es', | ||
}, | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import 'jest-fetch-mock'; | ||
import { BodylessConversation, BodylessConversationViewConfig } from './bodyless-conversation'; | ||
import * as authInstance from '../auth'; | ||
import { init } from '../index'; | ||
import { Action, AuthType, RuntimeFilterOp } from '../types'; | ||
import { | ||
executeAfterWait, | ||
getDocumentBody, | ||
getIFrameSrc, | ||
getRootEl, | ||
fixedEncodeURI, | ||
defaultParamsWithoutHiddenActions as defaultParams, | ||
expectUrlMatchesWithParams, | ||
expectUrlToHaveParamsWithValues, | ||
} from '../test/test-utils'; | ||
|
||
describe('BodylessConversation', () => { | ||
const thoughtSpotHost = 'tshost'; | ||
|
||
beforeAll(() => { | ||
init({ | ||
thoughtSpotHost, | ||
authType: AuthType.None, | ||
}); | ||
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve({})); | ||
spyOn(window, 'alert'); | ||
document.body.innerHTML = getDocumentBody(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fetchMock.resetMocks(); | ||
}); | ||
|
||
test('should render the bodyless conversation embed', 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: BodylessConversationViewConfig = { | ||
worksheetId: 'worksheetId', | ||
}; | ||
|
||
const conversationEmbed = new BodylessConversation(viewConfig); | ||
const result = await conversationEmbed.sendMessage('userMessage'); | ||
console.log(result.container); | ||
const iframeSrc = getIFrameSrc(result.container); | ||
expectUrlToHaveParamsWithValues(iframeSrc, { | ||
sessionId: 'sessionId', | ||
genNo: 2, | ||
acSessionId: 'transactionId', | ||
acGenNo: 1, | ||
}); | ||
|
||
fetchMock.mockRejectOnce( | ||
new Error('error'), | ||
); | ||
const errorResult = await conversationEmbed.sendMessage('userMessage'); | ||
expect(errorResult.error instanceof Error).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.