@truedat/ai 8.6.7 → 8.7.1
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/package.json +3 -3
- package/src/components/ConceptSuggestions.js +10 -4
- package/src/components/StructureSuggestions.js +8 -9
- package/src/components/ThinkingOutLoud.js +5 -0
- package/src/components/TranslationModal.js +15 -15
- package/src/components/__tests__/ConceptSuggestions.spec.js +32 -20
- package/src/components/__tests__/StructureSuggestions.spec.js +25 -19
- package/src/components/__tests__/SuggestLinkButton.spec.js +3 -1
- package/src/components/__tests__/TranslationModal.spec.js +3 -3
- package/src/components/actions/ActionActions.js +2 -2
- package/src/components/actions/ActionDetail.js +1 -1
- package/src/components/actions/ActionEdit.js +2 -1
- package/src/components/actions/ActionForm.js +1 -1
- package/src/components/actions/ActionsContext.js +1 -1
- package/src/components/actions/ActionsTable.js +1 -1
- package/src/components/actions/__tests__/ActionsTable.spec.js +1 -1
- package/src/components/aiSandbox/AiSandbox.js +2 -2
- package/src/components/aiSandbox/RequestForm.js +1 -1
- package/src/components/assistant/Assistant.js +8 -6
- package/src/components/assistant/AssistantChat.js +4 -0
- package/src/components/assistant/AssistantConversations.js +1 -1
- package/src/components/assistant/AssistantPage.js +5 -5
- package/src/components/assistant/AssistantPageChat.js +31 -14
- package/src/components/assistant/__tests__/Assistant.spec.js +3 -3
- package/src/components/assistant/__tests__/AssistantChat.spec.js +15 -11
- package/src/components/assistant/__tests__/AssistantConversations.spec.js +12 -12
- package/src/components/assistant/hooks/useAgentConversation.js +2 -2
- package/src/components/assistant/hooks/useAssistantSocket.js +2 -0
- package/src/components/index.js +8 -1
- package/src/components/prompts/PromptEditor.js +7 -7
- package/src/components/prompts/Prompts.js +1 -1
- package/src/components/prompts/__tests__/PromptEditor.spec.js +8 -8
- package/src/components/providers/ProviderEditor.js +6 -10
- package/src/components/providers/Providers.js +5 -1
- package/src/components/providers/__tests__/ProviderEditor.spec.js +7 -7
- package/src/components/providers/providerProperties/Anthropic.js +1 -1
- package/src/components/providers/providerProperties/AzureOpenai.js +2 -2
- package/src/components/providers/providerProperties/BedrockClaude.js +2 -2
- package/src/components/providers/providerProperties/Gemini.js +1 -1
- package/src/components/providers/providerProperties/Openai.js +2 -2
- package/src/components/resourceMappings/ResourceMappingEditor.js +2 -2
- package/src/components/resourceMappings/ResourceMappingFields.js +1 -1
- package/src/components/resourceMappings/__tests__/ResourceMappingEditor.spec.js +7 -7
- package/src/components/resourceMappings/__tests__/ResourceMappings.spec.js +1 -1
- package/src/components/resourceMappings/selectors/DataStructureSelector.js +2 -2
- package/src/components/suggestions/__tests__/SuggestionsWidget.spec.js +9 -9
- package/src/hooks/__tests__/useAgentConversations.spec.js +10 -2
- package/src/hooks/useActions.js +1 -1
- package/src/hooks/useAgentConversations.js +4 -1
- package/src/hooks/useAgentLayerRun.js +1 -1
- package/src/hooks/useProviders.js +1 -1
- package/src/hooks/useResourceMappings.js +1 -1
- package/src/hooks/useSuggestions.js +1 -1
- package/src/hooks/useTranslations.js +2 -2
|
@@ -59,7 +59,7 @@ describe("<PromptEditor />", () => {
|
|
|
59
59
|
it("matches snapshot for translation resource type", async () => {
|
|
60
60
|
const translationProps = _.set(
|
|
61
61
|
"selectedPrompt.resource_type",
|
|
62
|
-
"translation"
|
|
62
|
+
"translation",
|
|
63
63
|
)(props);
|
|
64
64
|
const rendered = render(<PromptEditor {...translationProps} />);
|
|
65
65
|
await waitForLoad(rendered);
|
|
@@ -100,14 +100,14 @@ describe("<PromptEditor />", () => {
|
|
|
100
100
|
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
101
101
|
|
|
102
102
|
await waitFor(() =>
|
|
103
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
103
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
104
104
|
);
|
|
105
105
|
|
|
106
106
|
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
107
107
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
108
108
|
|
|
109
109
|
await user.click(
|
|
110
|
-
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
110
|
+
rendered.getByRole("button", { name: /modal-negative-action/i }),
|
|
111
111
|
);
|
|
112
112
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
113
113
|
|
|
@@ -117,7 +117,7 @@ describe("<PromptEditor />", () => {
|
|
|
117
117
|
expect(rendered.container).toMatchSnapshot();
|
|
118
118
|
|
|
119
119
|
await user.click(
|
|
120
|
-
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
120
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i }),
|
|
121
121
|
);
|
|
122
122
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
123
123
|
});
|
|
@@ -133,7 +133,7 @@ describe("<PromptEditor />", () => {
|
|
|
133
133
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
134
134
|
|
|
135
135
|
await user.click(
|
|
136
|
-
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
136
|
+
rendered.getByRole("button", { name: /modal-negative-action/i }),
|
|
137
137
|
);
|
|
138
138
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
139
139
|
|
|
@@ -143,7 +143,7 @@ describe("<PromptEditor />", () => {
|
|
|
143
143
|
expect(rendered.container).toMatchSnapshot();
|
|
144
144
|
|
|
145
145
|
await user.click(
|
|
146
|
-
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
146
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i }),
|
|
147
147
|
);
|
|
148
148
|
expect(onDelete).toHaveBeenCalledTimes(1);
|
|
149
149
|
});
|
|
@@ -160,13 +160,13 @@ describe("<PromptEditor />", () => {
|
|
|
160
160
|
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
161
161
|
|
|
162
162
|
await waitFor(() =>
|
|
163
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
163
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
164
164
|
);
|
|
165
165
|
|
|
166
166
|
await user.click(rendered.getByRole("button", { name: /save/i }));
|
|
167
167
|
|
|
168
168
|
await waitFor(() =>
|
|
169
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
169
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
170
170
|
);
|
|
171
171
|
|
|
172
172
|
expect(onSubmit.mock.calls[0][0]).toEqual({
|
|
@@ -45,11 +45,11 @@ export default function ProviderEditor({
|
|
|
45
45
|
const usedAgents = _.flow(
|
|
46
46
|
_.filter((p) => p.id !== selectedProvider?.id),
|
|
47
47
|
_.map(_.prop("agents")),
|
|
48
|
-
_.filter(Boolean)
|
|
48
|
+
_.filter(Boolean),
|
|
49
49
|
)(providers);
|
|
50
50
|
|
|
51
51
|
const availableAgentOptions = _.filter(
|
|
52
|
-
(o) => !_.includes(o.value)(usedAgents)
|
|
52
|
+
(o) => !_.includes(o.value)(usedAgents),
|
|
53
53
|
)(allAgentOptions);
|
|
54
54
|
|
|
55
55
|
const form = useForm({
|
|
@@ -90,7 +90,7 @@ export default function ProviderEditor({
|
|
|
90
90
|
prop: formatMessage({
|
|
91
91
|
id: "providers.form.name",
|
|
92
92
|
}),
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
94
|
),
|
|
95
95
|
}}
|
|
96
96
|
render={({
|
|
@@ -123,7 +123,7 @@ export default function ProviderEditor({
|
|
|
123
123
|
prop: formatMessage({
|
|
124
124
|
id: "providers.form.type",
|
|
125
125
|
}),
|
|
126
|
-
}
|
|
126
|
+
},
|
|
127
127
|
),
|
|
128
128
|
}}
|
|
129
129
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
@@ -148,18 +148,14 @@ export default function ProviderEditor({
|
|
|
148
148
|
name="agents"
|
|
149
149
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
150
150
|
<Form.Field>
|
|
151
|
-
<label>
|
|
152
|
-
{formatMessage({ id: "providers.form.agents" })}
|
|
153
|
-
</label>
|
|
151
|
+
<label>{formatMessage({ id: "providers.form.agents" })}</label>
|
|
154
152
|
<Dropdown
|
|
155
153
|
clearable
|
|
156
154
|
selection
|
|
157
155
|
disabled={availableAgentOptions.length === 0 && !value}
|
|
158
156
|
onBlur={onBlur}
|
|
159
157
|
options={availableAgentOptions}
|
|
160
|
-
onChange={(_e, { value: v }) =>
|
|
161
|
-
onChange(v === "" ? null : v)
|
|
162
|
-
}
|
|
158
|
+
onChange={(_e, { value: v }) => onChange(v === "" ? null : v)}
|
|
163
159
|
value={value ?? ""}
|
|
164
160
|
placeholder={formatMessage({
|
|
165
161
|
id: "providers.form.agents.placeholder",
|
|
@@ -107,7 +107,11 @@ export default function Providers() {
|
|
|
107
107
|
id: "providers.form.name.new",
|
|
108
108
|
})}
|
|
109
109
|
{provider.agents && (
|
|
110
|
-
<Label
|
|
110
|
+
<Label
|
|
111
|
+
color={agentColors[provider.agents]}
|
|
112
|
+
size="small"
|
|
113
|
+
style={{ marginLeft: "0.5em" }}
|
|
114
|
+
>
|
|
111
115
|
{formatMessage({
|
|
112
116
|
id: `providers.agent.${provider.agents}`,
|
|
113
117
|
defaultMessage: provider.agents,
|
|
@@ -87,14 +87,14 @@ describe("<ProviderEditor />", () => {
|
|
|
87
87
|
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
88
88
|
|
|
89
89
|
await waitFor(() =>
|
|
90
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
90
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
94
94
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
95
95
|
|
|
96
96
|
await user.click(
|
|
97
|
-
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
97
|
+
rendered.getByRole("button", { name: /modal-negative-action/i }),
|
|
98
98
|
);
|
|
99
99
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
100
100
|
|
|
@@ -104,7 +104,7 @@ describe("<ProviderEditor />", () => {
|
|
|
104
104
|
expect(rendered.container).toMatchSnapshot();
|
|
105
105
|
|
|
106
106
|
await user.click(
|
|
107
|
-
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
107
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i }),
|
|
108
108
|
);
|
|
109
109
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
110
110
|
});
|
|
@@ -120,7 +120,7 @@ describe("<ProviderEditor />", () => {
|
|
|
120
120
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
121
121
|
|
|
122
122
|
await user.click(
|
|
123
|
-
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
123
|
+
rendered.getByRole("button", { name: /modal-negative-action/i }),
|
|
124
124
|
);
|
|
125
125
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
126
126
|
|
|
@@ -130,7 +130,7 @@ describe("<ProviderEditor />", () => {
|
|
|
130
130
|
expect(rendered.container).toMatchSnapshot();
|
|
131
131
|
|
|
132
132
|
await user.click(
|
|
133
|
-
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
133
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i }),
|
|
134
134
|
);
|
|
135
135
|
expect(onDelete).toHaveBeenCalledTimes(1);
|
|
136
136
|
});
|
|
@@ -147,13 +147,13 @@ describe("<ProviderEditor />", () => {
|
|
|
147
147
|
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
148
148
|
|
|
149
149
|
await waitFor(() =>
|
|
150
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
150
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
await user.click(rendered.getByRole("button", { name: /save/i }));
|
|
154
154
|
|
|
155
155
|
await waitFor(() =>
|
|
156
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
156
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
157
157
|
);
|
|
158
158
|
|
|
159
159
|
expect(onSubmit.mock.calls[0][0]).toEqual({
|
|
@@ -18,7 +18,7 @@ export default function AzureOpenai() {
|
|
|
18
18
|
prop: formatMessage({
|
|
19
19
|
id: "providerProperties.form.resourceName",
|
|
20
20
|
}),
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
),
|
|
23
23
|
}}
|
|
24
24
|
render={({
|
|
@@ -51,7 +51,7 @@ export default function AzureOpenai() {
|
|
|
51
51
|
prop: formatMessage({
|
|
52
52
|
id: "providerProperties.form.deployment",
|
|
53
53
|
}),
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
55
|
),
|
|
56
56
|
}}
|
|
57
57
|
render={({
|
|
@@ -18,7 +18,7 @@ export default function BedrockClaude() {
|
|
|
18
18
|
prop: formatMessage({
|
|
19
19
|
id: "providerProperties.form.model",
|
|
20
20
|
}),
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
),
|
|
23
23
|
}}
|
|
24
24
|
render={({
|
|
@@ -141,7 +141,7 @@ export default function BedrockClaude() {
|
|
|
141
141
|
prop: formatMessage({
|
|
142
142
|
id: "providerProperties.form.organizationKey",
|
|
143
143
|
}),
|
|
144
|
-
}
|
|
144
|
+
},
|
|
145
145
|
),
|
|
146
146
|
}}
|
|
147
147
|
render={({
|
|
@@ -18,7 +18,7 @@ export default function Openai() {
|
|
|
18
18
|
prop: formatMessage({
|
|
19
19
|
id: "providerProperties.form.model",
|
|
20
20
|
}),
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
),
|
|
23
23
|
}}
|
|
24
24
|
render={({
|
|
@@ -51,7 +51,7 @@ export default function Openai() {
|
|
|
51
51
|
prop: formatMessage({
|
|
52
52
|
id: "providerProperties.form.organizationKey",
|
|
53
53
|
}),
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
55
|
),
|
|
56
56
|
}}
|
|
57
57
|
render={({
|
|
@@ -63,7 +63,7 @@ export default function ResourceMappingEditor({
|
|
|
63
63
|
prop: formatMessage({
|
|
64
64
|
id: "resourceMappings.form.name",
|
|
65
65
|
}),
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
67
|
),
|
|
68
68
|
}}
|
|
69
69
|
render={({
|
|
@@ -96,7 +96,7 @@ export default function ResourceMappingEditor({
|
|
|
96
96
|
prop: formatMessage({
|
|
97
97
|
id: "resourceMappings.form.resource_type",
|
|
98
98
|
}),
|
|
99
|
-
}
|
|
99
|
+
},
|
|
100
100
|
),
|
|
101
101
|
}}
|
|
102
102
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
@@ -76,14 +76,14 @@ describe("<ResourceMappingEditor />", () => {
|
|
|
76
76
|
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
77
77
|
|
|
78
78
|
await waitFor(() =>
|
|
79
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
79
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
83
83
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
84
84
|
|
|
85
85
|
await user.click(
|
|
86
|
-
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
86
|
+
rendered.getByRole("button", { name: /modal-negative-action/i }),
|
|
87
87
|
);
|
|
88
88
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
89
89
|
|
|
@@ -93,7 +93,7 @@ describe("<ResourceMappingEditor />", () => {
|
|
|
93
93
|
expect(rendered.container).toMatchSnapshot();
|
|
94
94
|
|
|
95
95
|
await user.click(
|
|
96
|
-
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
96
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i }),
|
|
97
97
|
);
|
|
98
98
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
99
99
|
});
|
|
@@ -109,7 +109,7 @@ describe("<ResourceMappingEditor />", () => {
|
|
|
109
109
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
110
110
|
|
|
111
111
|
await user.click(
|
|
112
|
-
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
112
|
+
rendered.getByRole("button", { name: /modal-negative-action/i }),
|
|
113
113
|
);
|
|
114
114
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
115
115
|
|
|
@@ -119,7 +119,7 @@ describe("<ResourceMappingEditor />", () => {
|
|
|
119
119
|
expect(rendered.container).toMatchSnapshot();
|
|
120
120
|
|
|
121
121
|
await user.click(
|
|
122
|
-
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
122
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i }),
|
|
123
123
|
);
|
|
124
124
|
expect(onDelete).toHaveBeenCalledTimes(1);
|
|
125
125
|
});
|
|
@@ -136,13 +136,13 @@ describe("<ResourceMappingEditor />", () => {
|
|
|
136
136
|
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
137
137
|
|
|
138
138
|
await waitFor(() =>
|
|
139
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
139
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
await user.click(rendered.getByRole("button", { name: /save/i }));
|
|
143
143
|
|
|
144
144
|
await waitFor(() =>
|
|
145
|
-
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
145
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
expect(onSubmit.mock.calls[0][0]).toEqual({
|
|
@@ -18,7 +18,7 @@ export default function DataStructureSelector() {
|
|
|
18
18
|
prop: formatMessage({
|
|
19
19
|
id: "resourceMappings.form.selector.data_structure.type",
|
|
20
20
|
}),
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
),
|
|
23
23
|
}}
|
|
24
24
|
render={({
|
|
@@ -51,7 +51,7 @@ export default function DataStructureSelector() {
|
|
|
51
51
|
prop: formatMessage({
|
|
52
52
|
id: "resourceMappings.form.selector.data_structure.system_external_id",
|
|
53
53
|
}),
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
55
|
),
|
|
56
56
|
}}
|
|
57
57
|
render={({
|
|
@@ -44,7 +44,7 @@ describe("<SuggestionsWidget />", () => {
|
|
|
44
44
|
<Suspense fallback={null}>
|
|
45
45
|
<SuggestionsWidget {...props} />
|
|
46
46
|
</Suspense>,
|
|
47
|
-
{ messages }
|
|
47
|
+
{ messages },
|
|
48
48
|
);
|
|
49
49
|
expect(container).toMatchSnapshot();
|
|
50
50
|
});
|
|
@@ -88,12 +88,12 @@ describe("<SuggestionsWidget />", () => {
|
|
|
88
88
|
<Suspense fallback={null}>
|
|
89
89
|
<SuggestionsWidget {...props} />
|
|
90
90
|
</Suspense>,
|
|
91
|
-
{ messages }
|
|
91
|
+
{ messages },
|
|
92
92
|
);
|
|
93
93
|
|
|
94
94
|
userEvent.click(await findByText(/actions.ai_suggestion/i));
|
|
95
95
|
await waitFor(() =>
|
|
96
|
-
expect(queryByText(/actions.ai_suggestion/i)).not.toBeInTheDocument()
|
|
96
|
+
expect(queryByText(/actions.ai_suggestion/i)).not.toBeInTheDocument(),
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
expect(container).toMatchSnapshot();
|
|
@@ -105,13 +105,13 @@ describe("<SuggestionsWidget />", () => {
|
|
|
105
105
|
userEvent.click(await findByText(/actions.apply_ai_suggestion/i));
|
|
106
106
|
await waitFor(() =>
|
|
107
107
|
expect(
|
|
108
|
-
queryByText(/actions.apply_ai_suggestion/i)
|
|
109
|
-
).not.toBeInTheDocument()
|
|
108
|
+
queryByText(/actions.apply_ai_suggestion/i),
|
|
109
|
+
).not.toBeInTheDocument(),
|
|
110
110
|
);
|
|
111
111
|
expect(applySuggestions).toHaveBeenCalledWith(
|
|
112
112
|
expect.objectContaining({
|
|
113
113
|
editable_field: { origin: "ai", value: "editable_field_value" },
|
|
114
|
-
})
|
|
114
|
+
}),
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
expect(container).toMatchSnapshot();
|
|
@@ -125,12 +125,12 @@ describe("<SuggestionsWidget />", () => {
|
|
|
125
125
|
<Suspense fallback={null}>
|
|
126
126
|
<SuggestionsWidget {...props} />
|
|
127
127
|
</Suspense>,
|
|
128
|
-
{ messages }
|
|
128
|
+
{ messages },
|
|
129
129
|
);
|
|
130
130
|
|
|
131
131
|
userEvent.click(await findByText(/actions.ai_suggestion/i));
|
|
132
132
|
await waitFor(() =>
|
|
133
|
-
expect(queryByText(/error message/i)).toBeInTheDocument()
|
|
133
|
+
expect(queryByText(/error message/i)).toBeInTheDocument(),
|
|
134
134
|
);
|
|
135
135
|
expect(container).toMatchSnapshot();
|
|
136
136
|
});
|
|
@@ -143,7 +143,7 @@ describe("<SuggestionsWidget />", () => {
|
|
|
143
143
|
<Suspense fallback={null}>
|
|
144
144
|
<SuggestionsWidget {...props} />
|
|
145
145
|
</Suspense>,
|
|
146
|
-
{ messages }
|
|
146
|
+
{ messages },
|
|
147
147
|
);
|
|
148
148
|
|
|
149
149
|
userEvent.click(await findByText(/actions.ai_suggestion/i));
|
|
@@ -23,7 +23,11 @@ describe("useAgentConversations", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it("calls useSWR with the correct endpoint and fetcher", () => {
|
|
26
|
-
useSWR.mockReturnValue({
|
|
26
|
+
useSWR.mockReturnValue({
|
|
27
|
+
data: undefined,
|
|
28
|
+
error: null,
|
|
29
|
+
mutate: mockMutate,
|
|
30
|
+
});
|
|
27
31
|
renderHook(() => useAgentConversations());
|
|
28
32
|
|
|
29
33
|
expect(useSWR).toHaveBeenCalledWith(API_AGENT_LAYER_CONVERSATIONS, apiJson);
|
|
@@ -54,7 +58,11 @@ describe("useAgentConversations", () => {
|
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
it("returns empty array when data is undefined", () => {
|
|
57
|
-
useSWR.mockReturnValue({
|
|
61
|
+
useSWR.mockReturnValue({
|
|
62
|
+
data: undefined,
|
|
63
|
+
error: null,
|
|
64
|
+
mutate: mockMutate,
|
|
65
|
+
});
|
|
58
66
|
|
|
59
67
|
const { result } = renderHook(() => useAgentConversations());
|
|
60
68
|
expect(result.current.conversations).toEqual([]);
|
package/src/hooks/useActions.js
CHANGED
|
@@ -3,7 +3,10 @@ import { apiJson } from "@truedat/core/services/api";
|
|
|
3
3
|
import { API_AGENT_LAYER_CONVERSATIONS } from "../api";
|
|
4
4
|
|
|
5
5
|
const useAgentConversations = () => {
|
|
6
|
-
const { data, error, mutate } = useSWR(
|
|
6
|
+
const { data, error, mutate } = useSWR(
|
|
7
|
+
API_AGENT_LAYER_CONVERSATIONS,
|
|
8
|
+
apiJson,
|
|
9
|
+
);
|
|
7
10
|
return {
|
|
8
11
|
conversations: data?.data?.data ?? data?.data ?? [],
|
|
9
12
|
loading: !error && !data,
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export const useAvailabilityCheck = () => {
|
|
9
9
|
return useSWRMutations(API_TRANSLATIONS_AVAILABILITY_CHECK, (url, { arg }) =>
|
|
10
|
-
apiJsonPost(url, arg)
|
|
10
|
+
apiJsonPost(url, arg),
|
|
11
11
|
);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const useRequestTranslation = () => {
|
|
15
15
|
return useSWRMutations(API_TRANSLATIONS_REQUEST, (url, { arg }) =>
|
|
16
|
-
apiJsonPost(url, arg)
|
|
16
|
+
apiJsonPost(url, arg),
|
|
17
17
|
);
|
|
18
18
|
};
|