@truedat/dd 5.18.3 → 5.20.0
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 +5 -5
- package/src/api/queries.js +19 -1
- package/src/components/Grant.js +9 -27
- package/src/components/GrantRemoval.js +26 -34
- package/src/components/GrantRemovalDirectButton.js +89 -0
- package/src/components/GrantRemovalWorkflow.js +107 -0
- package/src/components/GrantRemovalWorkflowDropdown.js +144 -0
- package/src/components/GrantRequest.js +2 -1
- package/src/components/GrantRequestCancel.js +5 -2
- package/src/components/GrantRequestHeader.js +13 -7
- package/src/components/GrantRequestRow.js +8 -1
- package/src/components/GrantRequests.js +8 -3
- package/src/components/GrantRequestsTable.js +1 -1
- package/src/components/StructureGrantDropdown.js +7 -40
- package/src/components/StructureGrantSummaryButton.js +2 -2
- package/src/components/StructureGrants.js +21 -17
- package/src/components/StructureNoteActions.js +1 -0
- package/src/components/StructureNoteSuggestions.js +179 -0
- package/src/components/StructureNotesEdit.js +19 -2
- package/src/components/__tests__/Grant.spec.js +11 -7
- package/src/components/__tests__/GrantRemoval.spec.js +19 -54
- package/src/components/__tests__/GrantRemovalDirectButton.spec.js +66 -0
- package/src/components/__tests__/GrantRemovalWorkflow.spec.js +157 -0
- package/src/components/__tests__/GrantRequest.spec.js +2 -0
- package/src/components/__tests__/GrantRequestHeader.spec.js +2 -5
- package/src/components/__tests__/StructureGrantDropdown.spec.js +1 -16
- package/src/components/__tests__/StructureGrantSummaryButton.spec.js +3 -2
- package/src/components/__tests__/StructureGrants.spec.js +5 -1
- package/src/components/__tests__/StructureNoteSuggestions.spec.js +151 -0
- package/src/components/__tests__/StructureNotesEdit.spec.js +34 -0
- package/src/components/__tests__/__snapshots__/Grant.spec.js.snap +5 -4
- package/src/components/__tests__/__snapshots__/GrantRequest.spec.js.snap +3 -3
- package/src/components/__tests__/__snapshots__/GrantRequestHeader.spec.js.snap +4 -4
- package/src/components/__tests__/__snapshots__/GrantRequestsSearchResults.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/StructureGrantDropdown.spec.js.snap +0 -52
- package/src/components/__tests__/__snapshots__/StructureGrantListButton.spec.js.snap +0 -14
- package/src/components/__tests__/__snapshots__/StructureGrantSummaryButton.spec.js.snap +0 -14
- package/src/components/__tests__/__snapshots__/StructureGrants.spec.js.snap +4 -5
- package/src/components/__tests__/__snapshots__/StructureNoteSuggestions.spec.js.snap +316 -0
- package/src/components/__tests__/__snapshots__/StructureNotesEdit.spec.js.snap +49 -0
- package/src/hooks/useGrantRequest.js +10 -1
- package/src/messages/en.js +23 -8
- package/src/messages/es.js +26 -9
- package/src/reducers/structure.js +1 -0
- package/src/sagas/__tests__/createGrantRequestStatus.spec.js +1 -1
- package/src/sagas/createGrantRequestStatus.js +24 -8
- package/src/selectors/getGrantRequestsColumns.js +32 -5
- package/src/selectors/getGrantRequestsSearchColumns.js +20 -14
- package/src/selectors/utils/decorators.js +68 -0
- package/src/components/__tests__/__snapshots__/GrantRemoval.spec.js.snap +0 -9
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { LATEST_GRANT_REQUEST_BY_GRANT_QUERY } from "@truedat/dd/api/queries";
|
|
4
|
+
import GrantRemovalWorkflow from "../GrantRemovalWorkflow";
|
|
5
|
+
|
|
6
|
+
describe("<GrantRemovalWorkflow />", () => {
|
|
7
|
+
const latestGrantRequestByGrantMock = (variables, grantRequestStatus) => {
|
|
8
|
+
const latestGrantRequest = !grantRequestStatus
|
|
9
|
+
? null
|
|
10
|
+
: {
|
|
11
|
+
__typename: "GrantRequest",
|
|
12
|
+
id: 17,
|
|
13
|
+
group: {
|
|
14
|
+
__typename: "GrantRequestGroup",
|
|
15
|
+
grant: null,
|
|
16
|
+
},
|
|
17
|
+
requestType: "GRANT_REMOVAL",
|
|
18
|
+
status: {
|
|
19
|
+
__typename: "GrantRequestStatus",
|
|
20
|
+
status: grantRequestStatus,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
request: {
|
|
26
|
+
query: LATEST_GRANT_REQUEST_BY_GRANT_QUERY,
|
|
27
|
+
variables,
|
|
28
|
+
},
|
|
29
|
+
result: {
|
|
30
|
+
data: {
|
|
31
|
+
latestGrantRequest,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const grant = {
|
|
38
|
+
id: 17,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const latestRequestVars = { id: grant.id, requestType: "GRANT_REMOVAL" };
|
|
42
|
+
|
|
43
|
+
it("Shows workflow button at start state", async () => {
|
|
44
|
+
const renderOpts = {
|
|
45
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, null)],
|
|
46
|
+
};
|
|
47
|
+
const { findByRole } = render(
|
|
48
|
+
<GrantRemovalWorkflow
|
|
49
|
+
grant={{ ...grant, pending_removal: false }}
|
|
50
|
+
actions={{}}
|
|
51
|
+
/>,
|
|
52
|
+
renderOpts
|
|
53
|
+
);
|
|
54
|
+
expect(await findByRole("button")).toHaveClass("orange");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("Shows workflow button at pending state", async () => {
|
|
58
|
+
const renderOpts = {
|
|
59
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "pending")],
|
|
60
|
+
};
|
|
61
|
+
const { findByRole, queryByText } = render(
|
|
62
|
+
<GrantRemovalWorkflow
|
|
63
|
+
grant={{ ...grant, pending_removal: false }}
|
|
64
|
+
actions={{}}
|
|
65
|
+
/>,
|
|
66
|
+
renderOpts
|
|
67
|
+
);
|
|
68
|
+
const button = await findByRole("button");
|
|
69
|
+
expect(button).toHaveClass("yellow");
|
|
70
|
+
const cancelRequestOption = queryByText(/Cancel request/);
|
|
71
|
+
expect(cancelRequestOption).toBeInTheDocument();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("Shows workflow button at rejected state", async () => {
|
|
75
|
+
const renderOpts = {
|
|
76
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "rejected")],
|
|
77
|
+
};
|
|
78
|
+
const { findByRole } = render(
|
|
79
|
+
<GrantRemovalWorkflow
|
|
80
|
+
grant={{ ...grant, pending_removal: false }}
|
|
81
|
+
actions={{}}
|
|
82
|
+
/>,
|
|
83
|
+
renderOpts
|
|
84
|
+
);
|
|
85
|
+
expect(await findByRole("button")).toHaveClass("red");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("Shows workflow button at approved state", async () => {
|
|
89
|
+
const renderOpts = {
|
|
90
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "approved")],
|
|
91
|
+
};
|
|
92
|
+
const { findByRole } = render(
|
|
93
|
+
<GrantRemovalWorkflow
|
|
94
|
+
grant={{ ...grant, pending_removal: true }}
|
|
95
|
+
actions={{}}
|
|
96
|
+
/>,
|
|
97
|
+
renderOpts
|
|
98
|
+
);
|
|
99
|
+
expect(await findByRole("button")).toHaveClass("brown");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("Workflow bypass: request approved, initially pending_removal true but someone with permissions set pending_removal to false", async () => {
|
|
103
|
+
const renderOpts = {
|
|
104
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "approved")],
|
|
105
|
+
};
|
|
106
|
+
const { findByRole } = render(
|
|
107
|
+
<GrantRemovalWorkflow
|
|
108
|
+
grant={{ ...grant, pending_removal: false }}
|
|
109
|
+
actions={{}}
|
|
110
|
+
/>,
|
|
111
|
+
renderOpts
|
|
112
|
+
);
|
|
113
|
+
expect(await findByRole("button")).toHaveClass("grey");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("Workflow bypass: request pending, initially pending_removal to false but someone with permissions set pending_removal to true", async () => {
|
|
117
|
+
const renderOpts = {
|
|
118
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "pending")],
|
|
119
|
+
};
|
|
120
|
+
const { findByRole } = render(
|
|
121
|
+
<GrantRemovalWorkflow
|
|
122
|
+
grant={{ ...grant, pending_removal: true }}
|
|
123
|
+
actions={{}}
|
|
124
|
+
/>,
|
|
125
|
+
renderOpts
|
|
126
|
+
);
|
|
127
|
+
expect(await findByRole("button")).toHaveClass("grey");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("Workflow bypass: request rejected, initially pending_removal to false but someone with permissions set pending_removal to true", async () => {
|
|
131
|
+
const renderOpts = {
|
|
132
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "rejected")],
|
|
133
|
+
};
|
|
134
|
+
const { findByRole } = render(
|
|
135
|
+
<GrantRemovalWorkflow
|
|
136
|
+
grant={{ ...grant, pending_removal: true }}
|
|
137
|
+
actions={{}}
|
|
138
|
+
/>,
|
|
139
|
+
renderOpts
|
|
140
|
+
);
|
|
141
|
+
expect(await findByRole("button")).toHaveClass("grey");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("Workflow bypass: request processing, initially pending_removal to false but someone with permissions set pending_removal to true", async () => {
|
|
145
|
+
const renderOpts = {
|
|
146
|
+
mocks: [latestGrantRequestByGrantMock(latestRequestVars, "processing")],
|
|
147
|
+
};
|
|
148
|
+
const { findByRole } = render(
|
|
149
|
+
<GrantRemovalWorkflow
|
|
150
|
+
grant={{ ...grant, pending_removal: true }}
|
|
151
|
+
actions={{}}
|
|
152
|
+
/>,
|
|
153
|
+
renderOpts
|
|
154
|
+
);
|
|
155
|
+
expect(await findByRole("button")).toHaveClass("grey");
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { Suspense } from "react";
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
3
|
import { GrantRequest } from "../GrantRequest";
|
|
4
|
+
import en from "../../messages/en";
|
|
4
5
|
|
|
5
6
|
describe("<GrantRequest />", () => {
|
|
6
7
|
const grantRequest = {
|
|
@@ -67,6 +68,7 @@ describe("<GrantRequest />", () => {
|
|
|
67
68
|
"grantRequest.summary.emptyApprovals": "empty",
|
|
68
69
|
"grantRequestApproval.header": "approval header",
|
|
69
70
|
"grantRequests.header": "grant requests",
|
|
71
|
+
"request.grantAccess": "Structure access",
|
|
70
72
|
"ruleImplementation.summary.field": "field",
|
|
71
73
|
"ruleImplementation.summary.operator": "operator",
|
|
72
74
|
"ruleImplementation.summary.values": "values",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import React, { Suspense } from "react";
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
3
|
import { GrantRequestHeader } from "../GrantRequestHeader";
|
|
4
|
+
import en from "../../messages/en";
|
|
4
5
|
|
|
5
6
|
describe("<GrantRequestHeader />", () => {
|
|
6
7
|
const renderOpts = {
|
|
7
8
|
messages: {
|
|
8
|
-
en
|
|
9
|
-
"grantRequest.header": "header",
|
|
10
|
-
"grantRequest.actions.approve": "approve",
|
|
11
|
-
"grantRequest.actions.reject": "reject",
|
|
12
|
-
},
|
|
9
|
+
en,
|
|
13
10
|
},
|
|
14
11
|
};
|
|
15
12
|
|
|
@@ -98,21 +98,6 @@ describe("<StructureGrantDropdown />", () => {
|
|
|
98
98
|
expect(container).toMatchSnapshot();
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
it("matches the latest snapshot for pendingRemovalGrant state", () => {
|
|
102
|
-
const grantRequest = null;
|
|
103
|
-
const props = {
|
|
104
|
-
...propsBuilder({ pending_removal: true }),
|
|
105
|
-
grantRequest,
|
|
106
|
-
grantRequestStatus: null,
|
|
107
|
-
};
|
|
108
|
-
const { container } = render(
|
|
109
|
-
<StructureGrantDropdown {...props} />,
|
|
110
|
-
renderOpts
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
expect(container).toMatchSnapshot();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
101
|
it("matches the latest snapshot for activeGrant state", () => {
|
|
117
102
|
const grantRequest = null;
|
|
118
103
|
const props = {
|
|
@@ -177,7 +162,7 @@ describe("<StructureGrantDropdown />", () => {
|
|
|
177
162
|
);
|
|
178
163
|
|
|
179
164
|
userEvent.click(
|
|
180
|
-
await findByText(en["grant.actions.
|
|
165
|
+
await findByText(en["grant.actions.viewRequest.confirmation.header"])
|
|
181
166
|
);
|
|
182
167
|
|
|
183
168
|
expect(mockHistory.push).toHaveBeenCalledWith("/grantRequests/8");
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { waitFor } from "@testing-library/react";
|
|
3
3
|
import { render } from "@truedat/test/render";
|
|
4
|
-
import {
|
|
4
|
+
import { LATEST_GRANT_REQUEST_BY_DS_QUERY } from "../../api/queries";
|
|
5
5
|
import StructureGrantSummaryButton from "../StructureGrantSummaryButton";
|
|
6
6
|
import en from "../../messages/en";
|
|
7
7
|
|
|
8
8
|
const latestGrantMockBuilder = (status) => ({
|
|
9
|
-
request: { query:
|
|
9
|
+
request: { query: LATEST_GRANT_REQUEST_BY_DS_QUERY },
|
|
10
10
|
result: {
|
|
11
11
|
data: {
|
|
12
12
|
latestGrantRequest: status
|
|
13
13
|
? {
|
|
14
14
|
id: 1,
|
|
15
|
+
requestType: "ACCESS",
|
|
15
16
|
group: {
|
|
16
17
|
grant: {
|
|
17
18
|
id: 1,
|
|
@@ -47,18 +47,22 @@ describe("<StructureGrants />", () => {
|
|
|
47
47
|
user: { id: 1, full_name: "foo user" },
|
|
48
48
|
data_structure: structure,
|
|
49
49
|
end_date: "2021/08/02",
|
|
50
|
+
pending_removal: false,
|
|
50
51
|
},
|
|
51
52
|
{
|
|
52
53
|
id: 2,
|
|
53
54
|
user: { id: 2, full_name: "bar user" },
|
|
54
55
|
data_structure: { name: "bar structure" },
|
|
55
56
|
end_date: "2021/09/02",
|
|
57
|
+
pending_removal: false,
|
|
56
58
|
},
|
|
57
59
|
];
|
|
58
60
|
|
|
59
61
|
const userPermissions = { update_grant_removal: {} };
|
|
60
62
|
|
|
61
|
-
const
|
|
63
|
+
const grantsActions = { manage_grant_removal: {} };
|
|
64
|
+
|
|
65
|
+
const props = { grants, columns, structure, userPermissions, grantsActions };
|
|
62
66
|
|
|
63
67
|
it("matches the latest snapshot", () => {
|
|
64
68
|
const { container } = render(<StructureGrants {...props} />);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { render } from "@truedat/test/render";
|
|
5
|
+
import StructureNoteSuggestions from "../StructureNoteSuggestions";
|
|
6
|
+
|
|
7
|
+
const mockSuggestions = {
|
|
8
|
+
editable_field: "editable_field_value",
|
|
9
|
+
non_editable_field: "non_editable_field_value",
|
|
10
|
+
unselect_field: "unselect_field_value",
|
|
11
|
+
};
|
|
12
|
+
jest.mock("@truedat/core/services/api", () => ({
|
|
13
|
+
apiJson: (url) => ({
|
|
14
|
+
then: (callback) =>
|
|
15
|
+
callback({
|
|
16
|
+
data: {
|
|
17
|
+
data: url.startsWith("suggestions")
|
|
18
|
+
? mockSuggestions
|
|
19
|
+
: url.startsWith("error_message")
|
|
20
|
+
? ["error", { error: { message: "ERROR MESSAGE" } }]
|
|
21
|
+
: ["error", "ERROR TEXT"],
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const messages = {
|
|
28
|
+
en: {
|
|
29
|
+
"actions.cancel": "cancel",
|
|
30
|
+
"actions.save": "save",
|
|
31
|
+
"structure_note.ai_suggestion.header": "header",
|
|
32
|
+
"actions.apply_ai_suggestion": "actions.apply_ai_suggestion",
|
|
33
|
+
"actions.ai_suggestion": "actions.ai_suggestion",
|
|
34
|
+
"structure_note.ai_suggestion.error": "error",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe("<StructureNoteSuggestions />", () => {
|
|
39
|
+
it("matches the latest snapshot", () => {
|
|
40
|
+
const props = {
|
|
41
|
+
template: {},
|
|
42
|
+
};
|
|
43
|
+
const { container } = render(
|
|
44
|
+
<Suspense fallback={null}>
|
|
45
|
+
<StructureNoteSuggestions {...props} />
|
|
46
|
+
</Suspense>,
|
|
47
|
+
{ messages }
|
|
48
|
+
);
|
|
49
|
+
expect(container).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("component lifecycle", async () => {
|
|
53
|
+
const applySuggestions = jest.fn();
|
|
54
|
+
const props = {
|
|
55
|
+
aiSuggestionsAction: { href: "suggestions" },
|
|
56
|
+
applySuggestions,
|
|
57
|
+
template: {
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
fields: [
|
|
61
|
+
{
|
|
62
|
+
name: "editable_field",
|
|
63
|
+
label: "EditableField",
|
|
64
|
+
editable: true,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "Group2",
|
|
70
|
+
fields: [
|
|
71
|
+
{
|
|
72
|
+
name: "non_editable_field",
|
|
73
|
+
label: "NonEditableField",
|
|
74
|
+
editable: false,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "unselect_field",
|
|
78
|
+
label: "UnselectedField",
|
|
79
|
+
editable: true,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
isModification: true,
|
|
86
|
+
};
|
|
87
|
+
const { container, findByText, queryByText } = render(
|
|
88
|
+
<Suspense fallback={null}>
|
|
89
|
+
<StructureNoteSuggestions {...props} />
|
|
90
|
+
</Suspense>,
|
|
91
|
+
{ messages }
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
userEvent.click(await findByText(/actions.ai_suggestion/i));
|
|
95
|
+
await waitFor(() =>
|
|
96
|
+
expect(queryByText(/actions.ai_suggestion/i)).not.toBeInTheDocument()
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(container).toMatchSnapshot();
|
|
100
|
+
|
|
101
|
+
userEvent.click(await findByText(/UnselectedField/i));
|
|
102
|
+
userEvent.click(await findByText(/UnselectedField/i));
|
|
103
|
+
userEvent.click(await findByText(/UnselectedField/i));
|
|
104
|
+
|
|
105
|
+
userEvent.click(await findByText(/actions.apply_ai_suggestion/i));
|
|
106
|
+
await waitFor(() =>
|
|
107
|
+
expect(
|
|
108
|
+
queryByText(/actions.apply_ai_suggestion/i)
|
|
109
|
+
).not.toBeInTheDocument()
|
|
110
|
+
);
|
|
111
|
+
expect(applySuggestions).toHaveBeenCalledWith(
|
|
112
|
+
expect.objectContaining({ editable_field: "editable_field_value" })
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
expect(container).toMatchSnapshot();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("renders error with message", async () => {
|
|
119
|
+
const props = {
|
|
120
|
+
aiSuggestionsAction: { href: "error_message" },
|
|
121
|
+
};
|
|
122
|
+
const { container, findByText, queryByText } = render(
|
|
123
|
+
<Suspense fallback={null}>
|
|
124
|
+
<StructureNoteSuggestions {...props} />
|
|
125
|
+
</Suspense>,
|
|
126
|
+
{ messages }
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
userEvent.click(await findByText(/actions.ai_suggestion/i));
|
|
130
|
+
await waitFor(() =>
|
|
131
|
+
expect(queryByText(/error message/i)).toBeInTheDocument()
|
|
132
|
+
);
|
|
133
|
+
expect(container).toMatchSnapshot();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("renders error with message", async () => {
|
|
137
|
+
const props = {
|
|
138
|
+
aiSuggestionsAction: { href: "error_text" },
|
|
139
|
+
};
|
|
140
|
+
const { container, findByText, queryByText } = render(
|
|
141
|
+
<Suspense fallback={null}>
|
|
142
|
+
<StructureNoteSuggestions {...props} />
|
|
143
|
+
</Suspense>,
|
|
144
|
+
{ messages }
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
userEvent.click(await findByText(/actions.ai_suggestion/i));
|
|
148
|
+
await waitFor(() => expect(queryByText(/error text/i)).toBeInTheDocument());
|
|
149
|
+
expect(container).toMatchSnapshot();
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -28,6 +28,40 @@ describe("<StructureNotesEdit />", () => {
|
|
|
28
28
|
expect(container).toMatchSnapshot();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
it("matches the latest snapshot with ai suggestion action", () => {
|
|
32
|
+
const props = {
|
|
33
|
+
structure: { id: 1 },
|
|
34
|
+
template: { id: 2 },
|
|
35
|
+
doStructureNoteAction: () => {},
|
|
36
|
+
selectTemplate: () => {},
|
|
37
|
+
selectDomain: () => {},
|
|
38
|
+
structureNotes: {
|
|
39
|
+
_actions: {
|
|
40
|
+
ai_suggestions: { href: "suggestion" },
|
|
41
|
+
},
|
|
42
|
+
structureNotes: [],
|
|
43
|
+
},
|
|
44
|
+
latestDfContent: { foo: "bar" },
|
|
45
|
+
applyTemplate: applyTemplate({ id: 2 }),
|
|
46
|
+
selectDomains: jest.fn(),
|
|
47
|
+
};
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<Suspense fallback={null}>
|
|
50
|
+
<StructureNotesEdit {...props} />
|
|
51
|
+
</Suspense>,
|
|
52
|
+
{
|
|
53
|
+
messages: {
|
|
54
|
+
en: {
|
|
55
|
+
"actions.cancel": "cancel",
|
|
56
|
+
"actions.save": "save",
|
|
57
|
+
"structure_note.ai_suggestion.header": "header",
|
|
58
|
+
"actions.ai_suggestion": "ai_suggestion",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
expect(container).toMatchSnapshot();
|
|
64
|
+
});
|
|
31
65
|
it("calls doStructureNoteAction when submit is clicked", async () => {
|
|
32
66
|
const doStructureNoteAction = jest.fn();
|
|
33
67
|
const template = {
|
|
@@ -223,7 +223,7 @@ exports[`<Grant /> matches the latest snapshot 1`] = `
|
|
|
223
223
|
</div>
|
|
224
224
|
`;
|
|
225
225
|
|
|
226
|
-
exports[`<Grant /> matches the latest snapshot with
|
|
226
|
+
exports[`<Grant /> matches the latest snapshot with manage_grant_removal action 1`] = `
|
|
227
227
|
<div>
|
|
228
228
|
<div
|
|
229
229
|
class="ui breadcrumb"
|
|
@@ -552,15 +552,16 @@ exports[`<Grant /> matches the latest snapshot with update action 1`] = `
|
|
|
552
552
|
Grants -> foo
|
|
553
553
|
</div>
|
|
554
554
|
</h2>
|
|
555
|
+
</div>
|
|
556
|
+
<div
|
|
557
|
+
class="right aligned four wide column"
|
|
558
|
+
>
|
|
555
559
|
<button
|
|
556
560
|
class="ui button button icon group-actions"
|
|
557
561
|
>
|
|
558
562
|
Request grant change
|
|
559
563
|
</button>
|
|
560
564
|
</div>
|
|
561
|
-
<div
|
|
562
|
-
class="right aligned four wide column"
|
|
563
|
-
/>
|
|
564
565
|
</div>
|
|
565
566
|
</div>
|
|
566
567
|
<div
|
|
@@ -47,7 +47,7 @@ exports[`<GrantRequest /> matches the latest snapshot 1`] = `
|
|
|
47
47
|
<div
|
|
48
48
|
class="content"
|
|
49
49
|
>
|
|
50
|
-
|
|
50
|
+
Structure access
|
|
51
51
|
</div>
|
|
52
52
|
</h2>
|
|
53
53
|
</div>
|
|
@@ -198,7 +198,7 @@ exports[`<GrantRequest /> matches the latest snapshot with approve actions 1`] =
|
|
|
198
198
|
<div
|
|
199
199
|
class="content"
|
|
200
200
|
>
|
|
201
|
-
|
|
201
|
+
Structure access
|
|
202
202
|
</div>
|
|
203
203
|
</h2>
|
|
204
204
|
</div>
|
|
@@ -465,7 +465,7 @@ exports[`<GrantRequest /> matches the latest snapshot with failed status 1`] = `
|
|
|
465
465
|
<div
|
|
466
466
|
class="content"
|
|
467
467
|
>
|
|
468
|
-
|
|
468
|
+
Structure access
|
|
469
469
|
</div>
|
|
470
470
|
</h2>
|
|
471
471
|
</div>
|
|
@@ -18,7 +18,7 @@ exports[`<GrantRequestHeader /> matches the latest snapshot (pending) 1`] = `
|
|
|
18
18
|
<div
|
|
19
19
|
class="content"
|
|
20
20
|
>
|
|
21
|
-
|
|
21
|
+
Structure access request
|
|
22
22
|
</div>
|
|
23
23
|
</h2>
|
|
24
24
|
</div>
|
|
@@ -28,12 +28,12 @@ exports[`<GrantRequestHeader /> matches the latest snapshot (pending) 1`] = `
|
|
|
28
28
|
<button
|
|
29
29
|
class="ui primary button button icon group-actions"
|
|
30
30
|
>
|
|
31
|
-
|
|
31
|
+
Approve
|
|
32
32
|
</button>
|
|
33
33
|
<button
|
|
34
34
|
class="ui secondary button button icon group-actions"
|
|
35
35
|
>
|
|
36
|
-
|
|
36
|
+
Reject
|
|
37
37
|
</button>
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
@@ -58,7 +58,7 @@ exports[`<GrantRequestHeader /> matches the latest snapshot 1`] = `
|
|
|
58
58
|
<div
|
|
59
59
|
class="content"
|
|
60
60
|
>
|
|
61
|
-
|
|
61
|
+
Structure access request
|
|
62
62
|
</div>
|
|
63
63
|
</h2>
|
|
64
64
|
</div>
|
|
@@ -33,58 +33,6 @@ exports[`<StructureGrantDropdown /> matches the latest snapshot for activeGrant
|
|
|
33
33
|
Request grant change
|
|
34
34
|
</span>
|
|
35
35
|
</div>
|
|
36
|
-
<div
|
|
37
|
-
class="item"
|
|
38
|
-
role="option"
|
|
39
|
-
>
|
|
40
|
-
<i
|
|
41
|
-
aria-hidden="true"
|
|
42
|
-
class="delete icon"
|
|
43
|
-
/>
|
|
44
|
-
<span
|
|
45
|
-
class="text"
|
|
46
|
-
>
|
|
47
|
-
Request grant removal
|
|
48
|
-
</span>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
exports[`<StructureGrantDropdown /> matches the latest snapshot for pendingRemovalGrant state 1`] = `
|
|
56
|
-
<div>
|
|
57
|
-
<div
|
|
58
|
-
aria-expanded="false"
|
|
59
|
-
class="ui floating dropdown"
|
|
60
|
-
role="listbox"
|
|
61
|
-
tabindex="0"
|
|
62
|
-
>
|
|
63
|
-
<button
|
|
64
|
-
class="ui red icon button button basic icon group-actions"
|
|
65
|
-
>
|
|
66
|
-
<i
|
|
67
|
-
aria-hidden="true"
|
|
68
|
-
class="shield icon"
|
|
69
|
-
/>
|
|
70
|
-
</button>
|
|
71
|
-
<div
|
|
72
|
-
class="menu transition left"
|
|
73
|
-
>
|
|
74
|
-
<div
|
|
75
|
-
class="item"
|
|
76
|
-
role="option"
|
|
77
|
-
>
|
|
78
|
-
<i
|
|
79
|
-
aria-hidden="true"
|
|
80
|
-
class="delete icon"
|
|
81
|
-
/>
|
|
82
|
-
<span
|
|
83
|
-
class="text"
|
|
84
|
-
>
|
|
85
|
-
Cancel grant removal
|
|
86
|
-
</span>
|
|
87
|
-
</div>
|
|
88
36
|
</div>
|
|
89
37
|
</div>
|
|
90
38
|
</div>
|
|
@@ -73,20 +73,6 @@ exports[`<StructureGrantListButton /> matches the latest snapshot with grant 1`]
|
|
|
73
73
|
Request grant change
|
|
74
74
|
</span>
|
|
75
75
|
</div>
|
|
76
|
-
<div
|
|
77
|
-
class="item"
|
|
78
|
-
role="option"
|
|
79
|
-
>
|
|
80
|
-
<i
|
|
81
|
-
aria-hidden="true"
|
|
82
|
-
class="delete icon"
|
|
83
|
-
/>
|
|
84
|
-
<span
|
|
85
|
-
class="text"
|
|
86
|
-
>
|
|
87
|
-
Request grant removal
|
|
88
|
-
</span>
|
|
89
|
-
</div>
|
|
90
76
|
</div>
|
|
91
77
|
</div>
|
|
92
78
|
</div>
|
|
@@ -85,20 +85,6 @@ exports[`<StructureGrantSummaryButton /> matches snapshot for active grant and i
|
|
|
85
85
|
Request grant change
|
|
86
86
|
</span>
|
|
87
87
|
</div>
|
|
88
|
-
<div
|
|
89
|
-
class="item"
|
|
90
|
-
role="option"
|
|
91
|
-
>
|
|
92
|
-
<i
|
|
93
|
-
aria-hidden="true"
|
|
94
|
-
class="delete icon"
|
|
95
|
-
/>
|
|
96
|
-
<span
|
|
97
|
-
class="text"
|
|
98
|
-
>
|
|
99
|
-
Request grant removal
|
|
100
|
-
</span>
|
|
101
|
-
</div>
|
|
102
88
|
</div>
|
|
103
89
|
</div>
|
|
104
90
|
</div>
|