@truedat/ai 7.5.7 → 7.5.10
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 +39 -59
- package/src/components/AiRoutes.js +39 -46
- package/src/components/TranslationModal.js +8 -10
- package/src/components/__tests__/TranslationModal.spec.js +0 -1
- package/src/components/actions/Action.js +1 -2
- package/src/components/actions/ActionActions.js +4 -5
- package/src/components/actions/ActionBreadcrumbs.js +1 -2
- package/src/components/actions/ActionDetail.js +4 -3
- package/src/components/actions/ActionEdit.js +3 -3
- package/src/components/actions/ActionForm.js +7 -7
- package/src/components/actions/ActionNew.js +1 -1
- package/src/components/actions/Actions.js +1 -2
- package/src/components/actions/ActionsContext.js +3 -7
- package/src/components/actions/ActionsTable.js +1 -2
- package/src/components/actions/__tests__/Action.spec.js +14 -36
- package/src/components/actions/__tests__/ActionActions.spec.js +2 -20
- package/src/components/actions/__tests__/ActionBreadcrumbs.spec.js +1 -10
- package/src/components/actions/__tests__/ActionDetail.spec.js +5 -23
- package/src/components/actions/__tests__/ActionEdit.spec.js +7 -31
- package/src/components/actions/__tests__/ActionForm.spec.js +11 -27
- package/src/components/actions/__tests__/ActionNew.spec.js +7 -53
- package/src/components/actions/__tests__/Actions.spec.js +6 -15
- package/src/components/actions/__tests__/ActionsTable.spec.js +3 -23
- package/src/components/actions/__tests__/__snapshots__/Action.spec.js.snap +39 -11
- package/src/components/actions/__tests__/__snapshots__/ActionActions.spec.js.snap +4 -4
- package/src/components/actions/__tests__/__snapshots__/ActionBreadcrumbs.spec.js.snap +2 -1
- package/src/components/actions/__tests__/__snapshots__/ActionDetail.spec.js.snap +26 -3
- package/src/components/actions/__tests__/__snapshots__/ActionEdit.spec.js.snap +11 -73
- package/src/components/actions/__tests__/__snapshots__/ActionForm.spec.js.snap +91 -13
- package/src/components/actions/__tests__/__snapshots__/ActionNew.spec.js.snap +16 -263
- package/src/components/actions/__tests__/__snapshots__/Actions.spec.js.snap +5 -4
- package/src/components/actions/__tests__/__snapshots__/ActionsTable.spec.js.snap +7 -5
- package/src/components/aiSandbox/AiSandbox.js +3 -6
- package/src/components/aiSandbox/RequestForm.js +6 -4
- package/src/components/prompts/PromptEditor.js +1 -8
- package/src/components/prompts/Prompts.js +2 -6
- package/src/components/prompts/__tests__/PromptEditor.spec.js +62 -54
- package/src/components/prompts/__tests__/Prompts.spec.js +0 -2
- package/src/components/prompts/__tests__/__snapshots__/PromptEditor.spec.js.snap +115 -10
- package/src/components/providers/ProviderEditor.js +1 -5
- package/src/components/providers/Providers.js +1 -2
- package/src/components/providers/__tests__/ProviderEditor.spec.js +54 -75
- package/src/components/providers/__tests__/Providers.spec.js +0 -2
- package/src/components/providers/__tests__/__snapshots__/ProviderEditor.spec.js.snap +0 -4
- package/src/components/providers/providerProperties/AzureOpenai.js +0 -1
- package/src/components/providers/providerProperties/BedrockClaude.js +0 -1
- package/src/components/providers/providerProperties/Gemini.js +0 -1
- package/src/components/providers/providerProperties/Openai.js +0 -1
- package/src/components/resourceMappings/ResourceMappingEditor.js +2 -5
- package/src/components/resourceMappings/ResourceMappingFields.js +3 -2
- package/src/components/resourceMappings/ResourceMappings.js +4 -2
- package/src/components/resourceMappings/__tests__/ResourceMappingEditor.spec.js +51 -93
- package/src/components/resourceMappings/__tests__/ResourceMappings.spec.js +0 -2
- package/src/components/resourceMappings/__tests__/__snapshots__/ResourceMappingEditor.spec.js.snap +4 -4
- package/src/components/resourceMappings/selectors/DataStructureSelector.js +0 -1
- package/src/components/resourceMappings/selectors/index.js +0 -1
- package/src/components/suggestions/SuggestionsWidget.js +1 -1
- package/src/components/suggestions/__tests__/SuggestionsWidget.spec.js +3 -3
- package/src/components/suggestions/__tests__/__snapshots__/SuggestionsWidget.spec.js.snap +0 -3
- package/src/hooks/__mocks__/useActions.js +44 -0
- package/src/hooks/__mocks__/useSuggestions.js +5 -0
- package/src/hooks/__tests__/usePrompts.spec.js +5 -5
- package/src/hooks/__tests__/{useProviders.js → useProviders.spec.js} +5 -5
- package/src/hooks/__tests__/useResourceMappings.spec.js +5 -5
- package/src/hooks/useActions.js +5 -4
- package/src/hooks/usePrompts.js +6 -6
- package/src/hooks/useProviders.js +5 -5
- package/src/hooks/useResourceMappings.js +4 -4
- package/src/index.js +2 -1
|
@@ -15,11 +15,11 @@ exports[`<Actions /> matches the latest snapshot 1`] = `
|
|
|
15
15
|
<div
|
|
16
16
|
class="content"
|
|
17
17
|
>
|
|
18
|
-
|
|
18
|
+
ai.actions.header
|
|
19
19
|
<div
|
|
20
20
|
class="sub header"
|
|
21
21
|
>
|
|
22
|
-
|
|
22
|
+
ai.actions.subheader
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
25
|
</h2>
|
|
@@ -37,10 +37,11 @@ exports[`<Actions /> matches the latest snapshot 1`] = `
|
|
|
37
37
|
>
|
|
38
38
|
<a
|
|
39
39
|
class="ui primary button"
|
|
40
|
+
data-discover="true"
|
|
40
41
|
href="/tasks/new"
|
|
41
42
|
role="button"
|
|
42
43
|
>
|
|
43
|
-
|
|
44
|
+
ai.actions.actions.create
|
|
44
45
|
</a>
|
|
45
46
|
</div>
|
|
46
47
|
</div>
|
|
@@ -55,7 +56,7 @@ exports[`<Actions /> matches the latest snapshot 1`] = `
|
|
|
55
56
|
<div
|
|
56
57
|
class="content"
|
|
57
58
|
>
|
|
58
|
-
|
|
59
|
+
ai.actions.search.results.empty
|
|
59
60
|
</div>
|
|
60
61
|
</h4>
|
|
61
62
|
</div>
|
|
@@ -19,17 +19,17 @@ exports[`<ActionsTable /> matches the latest snapshot 1`] = `
|
|
|
19
19
|
<th
|
|
20
20
|
class=""
|
|
21
21
|
>
|
|
22
|
-
|
|
22
|
+
user.full_name
|
|
23
23
|
</th>
|
|
24
24
|
<th
|
|
25
25
|
class=""
|
|
26
26
|
>
|
|
27
|
-
|
|
27
|
+
type
|
|
28
28
|
</th>
|
|
29
29
|
<th
|
|
30
30
|
class=""
|
|
31
31
|
>
|
|
32
|
-
|
|
32
|
+
is_enabled
|
|
33
33
|
</th>
|
|
34
34
|
<th
|
|
35
35
|
class="two wide descending sorted"
|
|
@@ -48,6 +48,7 @@ exports[`<ActionsTable /> matches the latest snapshot 1`] = `
|
|
|
48
48
|
class=""
|
|
49
49
|
>
|
|
50
50
|
<a
|
|
51
|
+
data-discover="true"
|
|
51
52
|
href="/tasks/1"
|
|
52
53
|
>
|
|
53
54
|
action_1
|
|
@@ -66,7 +67,7 @@ exports[`<ActionsTable /> matches the latest snapshot 1`] = `
|
|
|
66
67
|
<td
|
|
67
68
|
class=""
|
|
68
69
|
>
|
|
69
|
-
|
|
70
|
+
ai.actions.is_enabled.true
|
|
70
71
|
</td>
|
|
71
72
|
<td
|
|
72
73
|
class="center aligned"
|
|
@@ -85,6 +86,7 @@ exports[`<ActionsTable /> matches the latest snapshot 1`] = `
|
|
|
85
86
|
class="warning"
|
|
86
87
|
>
|
|
87
88
|
<a
|
|
89
|
+
data-discover="true"
|
|
88
90
|
href="/tasks/2"
|
|
89
91
|
>
|
|
90
92
|
action_2
|
|
@@ -103,7 +105,7 @@ exports[`<ActionsTable /> matches the latest snapshot 1`] = `
|
|
|
103
105
|
<td
|
|
104
106
|
class="warning"
|
|
105
107
|
>
|
|
106
|
-
|
|
108
|
+
ai.actions.is_enabled.false
|
|
107
109
|
</td>
|
|
108
110
|
<td
|
|
109
111
|
class="warning center aligned"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
4
4
|
import {
|
|
5
5
|
Header,
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
Comment,
|
|
13
13
|
CommentContent,
|
|
14
14
|
CommentAuthor,
|
|
15
|
-
CommentMetadata,
|
|
16
15
|
CommentText,
|
|
17
16
|
CommentGroup,
|
|
18
17
|
} from "semantic-ui-react";
|
|
@@ -70,17 +69,16 @@ export default function AiSandbox() {
|
|
|
70
69
|
/>
|
|
71
70
|
</Form.Field>
|
|
72
71
|
</Form>
|
|
73
|
-
|
|
74
72
|
<CommentGroup style={{ marginTop: 20 }}>
|
|
75
73
|
{messages.map(({ role, content }, key) =>
|
|
76
|
-
role
|
|
74
|
+
role === "system" ? (
|
|
77
75
|
<Message key={key} info>
|
|
78
76
|
<MessageHeader>
|
|
79
77
|
{formatMessage({ id: "ai_sandbox.role.system" })}
|
|
80
78
|
</MessageHeader>
|
|
81
79
|
<p>{content}</p>
|
|
82
80
|
</Message>
|
|
83
|
-
) : role
|
|
81
|
+
) : role === "error" ? (
|
|
84
82
|
<Message key={key} error>
|
|
85
83
|
<MessageHeader>
|
|
86
84
|
{formatMessage({ id: "ai_sandbox.error" })}
|
|
@@ -99,7 +97,6 @@ export default function AiSandbox() {
|
|
|
99
97
|
)
|
|
100
98
|
)}
|
|
101
99
|
</CommentGroup>
|
|
102
|
-
|
|
103
100
|
{selectedProvider ? (
|
|
104
101
|
<RequestForm
|
|
105
102
|
provider={selectedProvider}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import { useIntl } from "react-intl";
|
|
4
4
|
import { Button, Form, Dropdown, Input } from "semantic-ui-react";
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@ export default function AiSandbox({ provider, messages, setMessages }) {
|
|
|
25
25
|
..._.reject({ role: "error" })(messages),
|
|
26
26
|
{ role: selectedRole, content },
|
|
27
27
|
];
|
|
28
|
-
if (selectedRole
|
|
28
|
+
if (selectedRole === "user") {
|
|
29
29
|
chatCompletion({ messages: requestMessages })
|
|
30
30
|
.then(({ data }) =>
|
|
31
31
|
setMessages([
|
|
@@ -37,7 +37,9 @@ export default function AiSandbox({ provider, messages, setMessages }) {
|
|
|
37
37
|
const content = _.propOr("Error", "response.data.error")(response);
|
|
38
38
|
setMessages([{ role: "error", content }]);
|
|
39
39
|
});
|
|
40
|
-
else
|
|
40
|
+
} else {
|
|
41
|
+
setMessages(requestMessages);
|
|
42
|
+
}
|
|
41
43
|
setContent("");
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -62,7 +64,7 @@ export default function AiSandbox({ provider, messages, setMessages }) {
|
|
|
62
64
|
/>
|
|
63
65
|
<Button
|
|
64
66
|
size="small"
|
|
65
|
-
icon={selectedRole
|
|
67
|
+
icon={selectedRole === "user" ? "send" : "write"}
|
|
66
68
|
disabled={isCompleting || !content}
|
|
67
69
|
/>
|
|
68
70
|
</Form>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import
|
|
2
|
+
import { Fragment, useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
import {
|
|
@@ -73,7 +73,6 @@ export default function PromptEditor({
|
|
|
73
73
|
<Header as="h3" dividing>
|
|
74
74
|
{name}
|
|
75
75
|
</Header>
|
|
76
|
-
|
|
77
76
|
<Controller
|
|
78
77
|
control={control}
|
|
79
78
|
name="name"
|
|
@@ -107,7 +106,6 @@ export default function PromptEditor({
|
|
|
107
106
|
/>
|
|
108
107
|
)}
|
|
109
108
|
/>
|
|
110
|
-
|
|
111
109
|
<Controller
|
|
112
110
|
control={control}
|
|
113
111
|
name="resource_type"
|
|
@@ -140,7 +138,6 @@ export default function PromptEditor({
|
|
|
140
138
|
</Form.Field>
|
|
141
139
|
)}
|
|
142
140
|
/>
|
|
143
|
-
|
|
144
141
|
<Controller
|
|
145
142
|
control={control}
|
|
146
143
|
name="language"
|
|
@@ -183,7 +180,6 @@ export default function PromptEditor({
|
|
|
183
180
|
</Form.Field>
|
|
184
181
|
)}
|
|
185
182
|
/>
|
|
186
|
-
|
|
187
183
|
<Controller
|
|
188
184
|
control={control}
|
|
189
185
|
name="system_prompt"
|
|
@@ -217,7 +213,6 @@ export default function PromptEditor({
|
|
|
217
213
|
/>
|
|
218
214
|
)}
|
|
219
215
|
/>
|
|
220
|
-
|
|
221
216
|
<Controller
|
|
222
217
|
control={control}
|
|
223
218
|
name="user_prompt_template"
|
|
@@ -251,7 +246,6 @@ export default function PromptEditor({
|
|
|
251
246
|
/>
|
|
252
247
|
)}
|
|
253
248
|
/>
|
|
254
|
-
|
|
255
249
|
<Controller
|
|
256
250
|
control={control}
|
|
257
251
|
name="provider_id"
|
|
@@ -282,7 +276,6 @@ export default function PromptEditor({
|
|
|
282
276
|
</Form.Field>
|
|
283
277
|
)}
|
|
284
278
|
/>
|
|
285
|
-
|
|
286
279
|
<Divider hidden />
|
|
287
280
|
<Container textAlign="right">
|
|
288
281
|
<Button
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
4
4
|
import {
|
|
5
5
|
Button,
|
|
@@ -40,7 +40,6 @@ export default function Prompts() {
|
|
|
40
40
|
const [isDirty, setDirty] = useState(false);
|
|
41
41
|
|
|
42
42
|
const loading = loadingPrompts || loadingProviders;
|
|
43
|
-
|
|
44
43
|
const prompts = data?.data;
|
|
45
44
|
|
|
46
45
|
const providersOptions = _.flow(
|
|
@@ -55,18 +54,16 @@ export default function Prompts() {
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
const { trigger: createPrompt, isMutating: isCreating } = usePromptCreate();
|
|
58
|
-
|
|
59
57
|
const { trigger: updatePrompt, isMutating: isUpdating } =
|
|
60
58
|
usePromptUpdate(selectedPrompt);
|
|
61
|
-
|
|
62
59
|
const { trigger: setPromptActive, isMutating: isSettingActive } =
|
|
63
60
|
usePromptSetActive(selectedPrompt);
|
|
64
|
-
|
|
65
61
|
const { trigger: deletePrompt, isMutating: isDeleting } =
|
|
66
62
|
usePromptDelete(selectedPrompt);
|
|
67
63
|
|
|
68
64
|
const isSubmitting =
|
|
69
65
|
isCreating || isUpdating || isDeleting || isSettingActive;
|
|
66
|
+
|
|
70
67
|
const onPromptCreate = async (prompt) => {
|
|
71
68
|
const mutatePrompt = selectedPrompt?.id ? updatePrompt : createPrompt;
|
|
72
69
|
await mutatePrompt({ prompt });
|
|
@@ -103,7 +100,6 @@ export default function Prompts() {
|
|
|
103
100
|
</Header.Subheader>
|
|
104
101
|
</Header.Content>
|
|
105
102
|
</Header>
|
|
106
|
-
|
|
107
103
|
<Grid>
|
|
108
104
|
<GridColumn width={4}>
|
|
109
105
|
<Button fluid onClick={setStateNewPrompt} disabled={isDirty}>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { act } from "react-dom/test-utils";
|
|
4
|
-
import { waitFor } from "@testing-library/react";
|
|
5
|
-
import { render } from "@truedat/test/render";
|
|
6
1
|
import userEvent from "@testing-library/user-event";
|
|
7
|
-
import {
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
|
+
import _ from "lodash/fp";
|
|
8
5
|
import PromptEditor from "../PromptEditor";
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
7
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
8
|
+
useLocales: jest.fn(() => ({
|
|
9
|
+
loading: false,
|
|
10
|
+
locales: [{ lang: "es", id: 1 }],
|
|
11
|
+
})),
|
|
12
|
+
}));
|
|
14
13
|
|
|
15
14
|
const props = {
|
|
16
15
|
providersOptions: [{ key: 1, value: 1, text: "Provider1" }],
|
|
@@ -41,28 +40,20 @@ const props = {
|
|
|
41
40
|
setDirty: jest.fn(),
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
const renderComponent = (props) =>
|
|
45
|
-
render(
|
|
46
|
-
<LangProviderWrapper langs={["es"]}>
|
|
47
|
-
<PromptEditor {...props} />
|
|
48
|
-
</LangProviderWrapper>,
|
|
49
|
-
renderOpts
|
|
50
|
-
);
|
|
51
|
-
|
|
52
43
|
describe("<PromptEditor />", () => {
|
|
53
44
|
it("matches the latest snapshot", async () => {
|
|
54
|
-
const
|
|
55
|
-
await
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
const rendered = render(<PromptEditor {...props} />);
|
|
46
|
+
await waitForLoad(rendered);
|
|
47
|
+
|
|
48
|
+
expect(rendered.container).toMatchSnapshot();
|
|
58
49
|
});
|
|
59
50
|
|
|
60
51
|
it("matches snapshot without selected resource mapping", async () => {
|
|
61
52
|
const props = { setDirty: jest.fn() };
|
|
62
|
-
const
|
|
63
|
-
await
|
|
64
|
-
|
|
65
|
-
expect(container).toMatchSnapshot();
|
|
53
|
+
const rendered = render(<PromptEditor {...props} />);
|
|
54
|
+
await waitForLoad(rendered);
|
|
55
|
+
|
|
56
|
+
expect(rendered.container).toMatchSnapshot();
|
|
66
57
|
});
|
|
67
58
|
|
|
68
59
|
it("matches snapshot for translation resource type", async () => {
|
|
@@ -70,10 +61,10 @@ describe("<PromptEditor />", () => {
|
|
|
70
61
|
"selectedPrompt.resource_type",
|
|
71
62
|
"translation"
|
|
72
63
|
)(props);
|
|
73
|
-
const
|
|
74
|
-
await
|
|
75
|
-
|
|
76
|
-
expect(container).toMatchSnapshot();
|
|
64
|
+
const rendered = render(<PromptEditor {...translationProps} />);
|
|
65
|
+
await waitForLoad(rendered);
|
|
66
|
+
|
|
67
|
+
expect(rendered.container).toMatchSnapshot();
|
|
77
68
|
});
|
|
78
69
|
|
|
79
70
|
it("matches snapshot without onDelete", async () => {
|
|
@@ -81,17 +72,20 @@ describe("<PromptEditor />", () => {
|
|
|
81
72
|
...props,
|
|
82
73
|
onDelete: null,
|
|
83
74
|
};
|
|
84
|
-
const
|
|
75
|
+
const rendered = render(<PromptEditor {...thisProps} />);
|
|
76
|
+
await waitForLoad(rendered);
|
|
85
77
|
|
|
86
|
-
|
|
78
|
+
expect(rendered.container).toMatchSnapshot();
|
|
87
79
|
});
|
|
88
80
|
|
|
89
81
|
it("test cancel button", async () => {
|
|
90
82
|
const onCancel = jest.fn();
|
|
91
83
|
const thisProps = { ...props, onCancel };
|
|
92
|
-
const
|
|
84
|
+
const rendered = render(<PromptEditor {...thisProps} />);
|
|
85
|
+
await waitForLoad(rendered);
|
|
93
86
|
|
|
94
|
-
userEvent.
|
|
87
|
+
const user = userEvent.setup({ delay: null });
|
|
88
|
+
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
95
89
|
|
|
96
90
|
await waitFor(() => expect(onCancel).toHaveBeenCalled());
|
|
97
91
|
});
|
|
@@ -99,66 +93,80 @@ describe("<PromptEditor />", () => {
|
|
|
99
93
|
it("test cancel button with confirm", async () => {
|
|
100
94
|
const onCancel = jest.fn();
|
|
101
95
|
const thisProps = { ...props, onCancel };
|
|
102
|
-
const
|
|
96
|
+
const rendered = render(<PromptEditor {...thisProps} />);
|
|
97
|
+
await waitForLoad(rendered);
|
|
103
98
|
|
|
104
|
-
userEvent.
|
|
99
|
+
const user = userEvent.setup({ delay: null });
|
|
100
|
+
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
105
101
|
|
|
106
102
|
await waitFor(() =>
|
|
107
|
-
expect(getByRole("button", { name: /save/i })).toBeEnabled()
|
|
103
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
108
104
|
);
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
111
107
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
112
108
|
|
|
113
|
-
|
|
109
|
+
await user.click(
|
|
110
|
+
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
111
|
+
);
|
|
114
112
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
115
113
|
|
|
116
|
-
|
|
114
|
+
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
117
115
|
expect(onCancel).toHaveBeenCalledTimes(0);
|
|
118
116
|
|
|
119
|
-
expect(container).toMatchSnapshot();
|
|
117
|
+
expect(rendered.container).toMatchSnapshot();
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
await user.click(
|
|
120
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
121
|
+
);
|
|
122
122
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
it("test delete button", async () => {
|
|
126
126
|
const onDelete = jest.fn();
|
|
127
127
|
const thisProps = { ...props, onDelete };
|
|
128
|
-
const
|
|
128
|
+
const rendered = render(<PromptEditor {...thisProps} />);
|
|
129
|
+
await waitForLoad(rendered);
|
|
129
130
|
|
|
130
|
-
userEvent.
|
|
131
|
+
const user = userEvent.setup({ delay: null });
|
|
132
|
+
await user.click(rendered.getByRole("button", { name: /delete/i }));
|
|
131
133
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
await user.click(
|
|
136
|
+
rendered.getByRole("button", { name: /modal-negative-action/i })
|
|
137
|
+
);
|
|
134
138
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
135
139
|
|
|
136
|
-
|
|
140
|
+
await user.click(rendered.getByRole("button", { name: /delete/i }));
|
|
137
141
|
expect(onDelete).toHaveBeenCalledTimes(0);
|
|
138
142
|
|
|
139
|
-
|
|
143
|
+
expect(rendered.container).toMatchSnapshot();
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
await user.click(
|
|
146
|
+
rendered.getByRole("button", { name: /modal-affirmative-action/i })
|
|
147
|
+
);
|
|
142
148
|
expect(onDelete).toHaveBeenCalledTimes(1);
|
|
143
149
|
});
|
|
144
150
|
|
|
145
151
|
it("test submit", async () => {
|
|
146
152
|
const onSubmit = jest.fn();
|
|
147
153
|
const thisProps = { ...props, onSubmit };
|
|
148
|
-
const
|
|
154
|
+
const rendered = render(<PromptEditor {...thisProps} />);
|
|
155
|
+
await waitForLoad(rendered);
|
|
149
156
|
|
|
150
|
-
|
|
157
|
+
const user = userEvent.setup({ delay: null });
|
|
158
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeDisabled();
|
|
151
159
|
|
|
152
|
-
|
|
160
|
+
await user.type(rendered.getAllByRole("textbox")[0], "name");
|
|
153
161
|
|
|
154
162
|
await waitFor(() =>
|
|
155
|
-
expect(getByRole("button", { name: /save/i })).toBeEnabled()
|
|
163
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
156
164
|
);
|
|
157
165
|
|
|
158
|
-
|
|
166
|
+
await user.click(rendered.getByRole("button", { name: /save/i }));
|
|
159
167
|
|
|
160
168
|
await waitFor(() =>
|
|
161
|
-
expect(getByRole("button", { name: /save/i })).toBeEnabled()
|
|
169
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
162
170
|
);
|
|
163
171
|
|
|
164
172
|
expect(onSubmit.mock.calls[0][0]).toEqual({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { waitFor } from "@testing-library/react";
|
|
3
2
|
import { render } from "@truedat/test/render";
|
|
4
3
|
import Prompts from "../Prompts";
|
|
@@ -84,7 +83,6 @@ describe("<Prompts />", () => {
|
|
|
84
83
|
"prompts.action.new": "prompts.action.new",
|
|
85
84
|
},
|
|
86
85
|
},
|
|
87
|
-
fallback: "lazy",
|
|
88
86
|
};
|
|
89
87
|
|
|
90
88
|
it("matches the latest snapshot", async () => {
|
|
@@ -111,6 +111,14 @@ exports[`<PromptEditor /> matches snapshot for translation resource type 1`] = `
|
|
|
111
111
|
role="listbox"
|
|
112
112
|
tabindex="-1"
|
|
113
113
|
>
|
|
114
|
+
<div
|
|
115
|
+
aria-atomic="true"
|
|
116
|
+
aria-live="polite"
|
|
117
|
+
class="divider text"
|
|
118
|
+
role="alert"
|
|
119
|
+
>
|
|
120
|
+
en
|
|
121
|
+
</div>
|
|
114
122
|
<i
|
|
115
123
|
aria-hidden="true"
|
|
116
124
|
class="dropdown icon"
|
|
@@ -119,9 +127,22 @@ exports[`<PromptEditor /> matches snapshot for translation resource type 1`] = `
|
|
|
119
127
|
class="menu transition"
|
|
120
128
|
>
|
|
121
129
|
<div
|
|
122
|
-
aria-checked="
|
|
130
|
+
aria-checked="true"
|
|
123
131
|
aria-selected="true"
|
|
124
|
-
class="selected item"
|
|
132
|
+
class="active selected item"
|
|
133
|
+
role="option"
|
|
134
|
+
style="pointer-events: all;"
|
|
135
|
+
>
|
|
136
|
+
<span
|
|
137
|
+
class="text"
|
|
138
|
+
>
|
|
139
|
+
en
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
<div
|
|
143
|
+
aria-checked="false"
|
|
144
|
+
aria-selected="false"
|
|
145
|
+
class="item"
|
|
125
146
|
role="option"
|
|
126
147
|
style="pointer-events: all;"
|
|
127
148
|
>
|
|
@@ -350,6 +371,14 @@ exports[`<PromptEditor /> matches snapshot without onDelete 1`] = `
|
|
|
350
371
|
role="listbox"
|
|
351
372
|
tabindex="0"
|
|
352
373
|
>
|
|
374
|
+
<div
|
|
375
|
+
aria-atomic="true"
|
|
376
|
+
aria-live="polite"
|
|
377
|
+
class="divider text"
|
|
378
|
+
role="alert"
|
|
379
|
+
>
|
|
380
|
+
en
|
|
381
|
+
</div>
|
|
353
382
|
<i
|
|
354
383
|
aria-hidden="true"
|
|
355
384
|
class="dropdown icon"
|
|
@@ -358,9 +387,22 @@ exports[`<PromptEditor /> matches snapshot without onDelete 1`] = `
|
|
|
358
387
|
class="menu transition"
|
|
359
388
|
>
|
|
360
389
|
<div
|
|
361
|
-
aria-checked="
|
|
390
|
+
aria-checked="true"
|
|
362
391
|
aria-selected="true"
|
|
363
|
-
class="selected item"
|
|
392
|
+
class="active selected item"
|
|
393
|
+
role="option"
|
|
394
|
+
style="pointer-events: all;"
|
|
395
|
+
>
|
|
396
|
+
<span
|
|
397
|
+
class="text"
|
|
398
|
+
>
|
|
399
|
+
en
|
|
400
|
+
</span>
|
|
401
|
+
</div>
|
|
402
|
+
<div
|
|
403
|
+
aria-checked="false"
|
|
404
|
+
aria-selected="false"
|
|
405
|
+
class="item"
|
|
364
406
|
role="option"
|
|
365
407
|
style="pointer-events: all;"
|
|
366
408
|
>
|
|
@@ -586,6 +628,14 @@ exports[`<PromptEditor /> matches the latest snapshot 1`] = `
|
|
|
586
628
|
role="listbox"
|
|
587
629
|
tabindex="0"
|
|
588
630
|
>
|
|
631
|
+
<div
|
|
632
|
+
aria-atomic="true"
|
|
633
|
+
aria-live="polite"
|
|
634
|
+
class="divider text"
|
|
635
|
+
role="alert"
|
|
636
|
+
>
|
|
637
|
+
en
|
|
638
|
+
</div>
|
|
589
639
|
<i
|
|
590
640
|
aria-hidden="true"
|
|
591
641
|
class="dropdown icon"
|
|
@@ -594,9 +644,22 @@ exports[`<PromptEditor /> matches the latest snapshot 1`] = `
|
|
|
594
644
|
class="menu transition"
|
|
595
645
|
>
|
|
596
646
|
<div
|
|
597
|
-
aria-checked="
|
|
647
|
+
aria-checked="true"
|
|
598
648
|
aria-selected="true"
|
|
599
|
-
class="selected item"
|
|
649
|
+
class="active selected item"
|
|
650
|
+
role="option"
|
|
651
|
+
style="pointer-events: all;"
|
|
652
|
+
>
|
|
653
|
+
<span
|
|
654
|
+
class="text"
|
|
655
|
+
>
|
|
656
|
+
en
|
|
657
|
+
</span>
|
|
658
|
+
</div>
|
|
659
|
+
<div
|
|
660
|
+
aria-checked="false"
|
|
661
|
+
aria-selected="false"
|
|
662
|
+
class="item"
|
|
600
663
|
role="option"
|
|
601
664
|
style="pointer-events: all;"
|
|
602
665
|
>
|
|
@@ -825,6 +888,14 @@ exports[`<PromptEditor /> test cancel button with confirm 1`] = `
|
|
|
825
888
|
role="listbox"
|
|
826
889
|
tabindex="0"
|
|
827
890
|
>
|
|
891
|
+
<div
|
|
892
|
+
aria-atomic="true"
|
|
893
|
+
aria-live="polite"
|
|
894
|
+
class="divider text"
|
|
895
|
+
role="alert"
|
|
896
|
+
>
|
|
897
|
+
en
|
|
898
|
+
</div>
|
|
828
899
|
<i
|
|
829
900
|
aria-hidden="true"
|
|
830
901
|
class="dropdown icon"
|
|
@@ -833,9 +904,22 @@ exports[`<PromptEditor /> test cancel button with confirm 1`] = `
|
|
|
833
904
|
class="menu transition"
|
|
834
905
|
>
|
|
835
906
|
<div
|
|
836
|
-
aria-checked="
|
|
907
|
+
aria-checked="true"
|
|
837
908
|
aria-selected="true"
|
|
838
|
-
class="selected item"
|
|
909
|
+
class="active selected item"
|
|
910
|
+
role="option"
|
|
911
|
+
style="pointer-events: all;"
|
|
912
|
+
>
|
|
913
|
+
<span
|
|
914
|
+
class="text"
|
|
915
|
+
>
|
|
916
|
+
en
|
|
917
|
+
</span>
|
|
918
|
+
</div>
|
|
919
|
+
<div
|
|
920
|
+
aria-checked="false"
|
|
921
|
+
aria-selected="false"
|
|
922
|
+
class="item"
|
|
839
923
|
role="option"
|
|
840
924
|
style="pointer-events: all;"
|
|
841
925
|
>
|
|
@@ -1064,6 +1148,14 @@ exports[`<PromptEditor /> test delete button 1`] = `
|
|
|
1064
1148
|
role="listbox"
|
|
1065
1149
|
tabindex="0"
|
|
1066
1150
|
>
|
|
1151
|
+
<div
|
|
1152
|
+
aria-atomic="true"
|
|
1153
|
+
aria-live="polite"
|
|
1154
|
+
class="divider text"
|
|
1155
|
+
role="alert"
|
|
1156
|
+
>
|
|
1157
|
+
en
|
|
1158
|
+
</div>
|
|
1067
1159
|
<i
|
|
1068
1160
|
aria-hidden="true"
|
|
1069
1161
|
class="dropdown icon"
|
|
@@ -1072,9 +1164,22 @@ exports[`<PromptEditor /> test delete button 1`] = `
|
|
|
1072
1164
|
class="menu transition"
|
|
1073
1165
|
>
|
|
1074
1166
|
<div
|
|
1075
|
-
aria-checked="
|
|
1167
|
+
aria-checked="true"
|
|
1076
1168
|
aria-selected="true"
|
|
1077
|
-
class="selected item"
|
|
1169
|
+
class="active selected item"
|
|
1170
|
+
role="option"
|
|
1171
|
+
style="pointer-events: all;"
|
|
1172
|
+
>
|
|
1173
|
+
<span
|
|
1174
|
+
class="text"
|
|
1175
|
+
>
|
|
1176
|
+
en
|
|
1177
|
+
</span>
|
|
1178
|
+
</div>
|
|
1179
|
+
<div
|
|
1180
|
+
aria-checked="false"
|
|
1181
|
+
aria-selected="false"
|
|
1182
|
+
class="item"
|
|
1078
1183
|
role="option"
|
|
1079
1184
|
style="pointer-events: all;"
|
|
1080
1185
|
>
|