app-tutor-ai-consumer 1.55.0 → 1.55.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/modules/messages/hooks/use-send-text-message/use-send-text-message.spec.tsx +58 -0
- package/src/modules/messages/hooks/use-send-text-message/use-send-text-message.tsx +2 -1
- package/src/modules/widget/__tests__/widget-settings-props.builder.ts +7 -13
- package/src/modules/widget/components/scroll-to-bottom-button/scroll-to-bottom-button.tsx +2 -4
- package/src/types.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## [1.55.2](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.55.1...v1.55.2) (2026-02-03)
|
|
2
|
+
|
|
3
|
+
## [1.55.1](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.55.0...v1.55.1) (2026-01-30)
|
|
4
|
+
|
|
1
5
|
# [1.55.0](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.54.0...v1.55.0) (2026-01-30)
|
|
2
6
|
|
|
3
7
|
### Features
|
package/package.json
CHANGED
|
@@ -39,6 +39,8 @@ describe('useSendTextMessage', () => {
|
|
|
39
39
|
const render = () => renderHook(useSendTextMessage)
|
|
40
40
|
|
|
41
41
|
beforeEach(() => {
|
|
42
|
+
vi.clearAllMocks()
|
|
43
|
+
|
|
42
44
|
vi.mocked(useGetProfile).mockReturnValue(getProfileMock as never)
|
|
43
45
|
vi.spyOn(Store, 'useWidgetSettingsAtomValue').mockReturnValue(defaultSettings)
|
|
44
46
|
vi.mocked(UAParser).mockReturnValue(UAParserMock as never)
|
|
@@ -150,4 +152,60 @@ describe('useSendTextMessage', () => {
|
|
|
150
152
|
})
|
|
151
153
|
)
|
|
152
154
|
})
|
|
155
|
+
|
|
156
|
+
it('should send dynamic agent prop when config metadata dynamicAgent is defined', async () => {
|
|
157
|
+
const settings = new WidgetSettingPropsBuilder().withConfig({
|
|
158
|
+
metadata: {
|
|
159
|
+
agentName: 'Agent G',
|
|
160
|
+
agentProductId: defaultSettings.productId,
|
|
161
|
+
courseName: defaultSettings.productName,
|
|
162
|
+
dynamicAgent: true
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
vi.spyOn(Store, 'useWidgetSettingsAtomValue').mockReturnValue(settings)
|
|
166
|
+
|
|
167
|
+
const { result } = render()
|
|
168
|
+
|
|
169
|
+
await waitFor(() => result.current.mutateAsync(message))
|
|
170
|
+
|
|
171
|
+
expect(MessagesService.create).toHaveBeenCalledTimes(1)
|
|
172
|
+
expect(MessagesService.create).toHaveBeenNthCalledWith(1, {
|
|
173
|
+
conversationId: settings.conversationId,
|
|
174
|
+
message: {
|
|
175
|
+
content: {
|
|
176
|
+
type: 'text/plain',
|
|
177
|
+
text: message
|
|
178
|
+
},
|
|
179
|
+
metadata: {
|
|
180
|
+
author: 'user',
|
|
181
|
+
contactId: settings.contactId,
|
|
182
|
+
context: {
|
|
183
|
+
language: settings.locale,
|
|
184
|
+
clubName: settings.clubName,
|
|
185
|
+
productName: settings.productName,
|
|
186
|
+
productId: settings.productId,
|
|
187
|
+
classHashId: settings.classHashId,
|
|
188
|
+
owner_id: settings.owner_id,
|
|
189
|
+
current_media_codes: settings.current_media_codes,
|
|
190
|
+
osVersion: UAParserMock.browser.version,
|
|
191
|
+
platformDetail: UAParserMock.browser.name,
|
|
192
|
+
ucode: settings.user?.ucode,
|
|
193
|
+
user_name: getProfileMock.data.name || settings.user?.name,
|
|
194
|
+
appVersion: APP_VERSION,
|
|
195
|
+
membershipId: settings.membershipId,
|
|
196
|
+
membershipSlug: settings.membershipSlug,
|
|
197
|
+
platform: PLATFORM.WEB,
|
|
198
|
+
agentName: settings.config?.metadata?.agentName,
|
|
199
|
+
agentProductId: settings.config?.metadata?.agentProductId,
|
|
200
|
+
courseName: settings.config?.metadata?.courseName
|
|
201
|
+
},
|
|
202
|
+
externalId: expect.any(String),
|
|
203
|
+
namespace: settings.namespace,
|
|
204
|
+
sessionId: settings.sessionId,
|
|
205
|
+
userId: String(getProfileMock.data.userId),
|
|
206
|
+
dynamicAgent: 'true'
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
})
|
|
153
211
|
})
|
|
@@ -112,7 +112,8 @@ function useSendTextMessage() {
|
|
|
112
112
|
externalId: v4(),
|
|
113
113
|
namespace: settings.namespace,
|
|
114
114
|
sessionId: isAgentMode ? settings.conversationId : settings.sessionId,
|
|
115
|
-
userId
|
|
115
|
+
userId,
|
|
116
|
+
...(settings.config?.metadata?.dynamicAgent ? { dynamicAgent: 'true' } : {})
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
})
|
|
@@ -21,19 +21,7 @@ class WidgetSettingPropsBuilder implements WidgetSettingProps {
|
|
|
21
21
|
classHashId?: string
|
|
22
22
|
owner_id?: string
|
|
23
23
|
current_media_codes?: string
|
|
24
|
-
config?:
|
|
25
|
-
| {
|
|
26
|
-
theme?: Theme
|
|
27
|
-
metadata?: {
|
|
28
|
-
parent?: 'AGENT' | 'TUTOR'
|
|
29
|
-
agentProductId?: number
|
|
30
|
-
agentName?: string
|
|
31
|
-
courseName?: string
|
|
32
|
-
source?: string
|
|
33
|
-
promptId?: string
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
| undefined
|
|
24
|
+
config?: WidgetSettingProps['config']
|
|
37
25
|
|
|
38
26
|
constructor() {
|
|
39
27
|
this.hotmartToken = chance.guid()
|
|
@@ -163,6 +151,12 @@ class WidgetSettingPropsBuilder implements WidgetSettingProps {
|
|
|
163
151
|
|
|
164
152
|
return this
|
|
165
153
|
}
|
|
154
|
+
|
|
155
|
+
withConfig(config: WidgetSettingProps['config']) {
|
|
156
|
+
this.config = { ...(this.config ?? {}), ...config }
|
|
157
|
+
|
|
158
|
+
return this
|
|
159
|
+
}
|
|
166
160
|
}
|
|
167
161
|
|
|
168
162
|
export default WidgetSettingPropsBuilder
|
|
@@ -3,10 +3,8 @@ import clsx from 'clsx'
|
|
|
3
3
|
|
|
4
4
|
import { Icon } from '@/src/lib/components'
|
|
5
5
|
|
|
6
|
-
export interface IScrollToBottomButtonProps
|
|
7
|
-
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
8
|
-
HTMLButtonElement
|
|
9
|
-
> {
|
|
6
|
+
export interface IScrollToBottomButtonProps
|
|
7
|
+
extends DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
10
8
|
show?: boolean
|
|
11
9
|
top?: number
|
|
12
10
|
}
|