@truedat/dd 7.6.0 → 7.6.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/package.json +3 -3
- package/src/components/StructureGrantCartCheckout.js +1 -0
- package/src/components/StructureGrantCartInformation.js +0 -1
- package/src/components/__tests__/StructureGrantCartCheckout.spec.js +57 -0
- package/src/components/__tests__/__snapshots__/StructureGrantCartCheckout.spec.js.snap +106 -0
- package/src/reducers/__tests__/grantRequestsCart.spec.js +1 -1
- package/src/reducers/grantRequestsCart.js +12 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.2",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.6.
|
|
51
|
+
"@truedat/test": "7.6.2",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"svg-pan-zoom": "^3.6.2",
|
|
84
84
|
"swr": "^2.3.3"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "413392c768bdc4e352be8863a70b031483b9ca88"
|
|
87
87
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
3
|
+
import { StructureGrantCartCheckout } from "../StructureGrantCartCheckout";
|
|
4
|
+
|
|
5
|
+
const grantRequestsCart = {
|
|
6
|
+
template: null,
|
|
7
|
+
templateContent: {},
|
|
8
|
+
modificationGrant: {
|
|
9
|
+
__typename: "Grant",
|
|
10
|
+
data_structure: {
|
|
11
|
+
__typename: "DataStructure",
|
|
12
|
+
external_id: "postgres://postgres/td_auth/public/roles_permissions",
|
|
13
|
+
id: "4570121",
|
|
14
|
+
system_id: 7,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
detail: {},
|
|
18
|
+
id: "73399",
|
|
19
|
+
inserted_at: "2025-01-03T11:47:30.447054Z",
|
|
20
|
+
pending_removal: false,
|
|
21
|
+
source_user_name: "grantuser",
|
|
22
|
+
start_date: "2024-12-12",
|
|
23
|
+
user: {
|
|
24
|
+
full_name: "grantuser",
|
|
25
|
+
user_name: "grantuser",
|
|
26
|
+
},
|
|
27
|
+
user_id: "10",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe("StructureGrantCartCheckout", () => {
|
|
32
|
+
const mockCheckoutGrantRequest = jest.fn();
|
|
33
|
+
|
|
34
|
+
const defaultProps = {
|
|
35
|
+
grantRequestsCart,
|
|
36
|
+
checkoutGrantRequest: mockCheckoutGrantRequest,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
jest.clearAllMocks();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const variables = { scope: "gr" };
|
|
44
|
+
|
|
45
|
+
const renderOpts = {
|
|
46
|
+
mocks: [singleTemplateMock(variables)],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
it("matches the latest snapshot", async () => {
|
|
50
|
+
const rendered = render(
|
|
51
|
+
<StructureGrantCartCheckout {...defaultProps} />,
|
|
52
|
+
renderOpts
|
|
53
|
+
);
|
|
54
|
+
await waitForLoad(rendered);
|
|
55
|
+
expect(rendered.container).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StructureGrantCartCheckout matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="ui segment structures"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="ui grid"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
class="row"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
class="eight wide column"
|
|
16
|
+
>
|
|
17
|
+
<h2
|
|
18
|
+
class="ui header"
|
|
19
|
+
>
|
|
20
|
+
<div
|
|
21
|
+
class="content"
|
|
22
|
+
>
|
|
23
|
+
grantRequest.header.update
|
|
24
|
+
</div>
|
|
25
|
+
</h2>
|
|
26
|
+
</div>
|
|
27
|
+
<div
|
|
28
|
+
class="right aligned eight wide column"
|
|
29
|
+
>
|
|
30
|
+
<a
|
|
31
|
+
class="ui secondary button"
|
|
32
|
+
data-discover="true"
|
|
33
|
+
href="/"
|
|
34
|
+
role="button"
|
|
35
|
+
>
|
|
36
|
+
actions.cancel
|
|
37
|
+
</a>
|
|
38
|
+
<button
|
|
39
|
+
class="ui primary disabled button"
|
|
40
|
+
disabled=""
|
|
41
|
+
tabindex="-1"
|
|
42
|
+
>
|
|
43
|
+
actions.save
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<div
|
|
48
|
+
class="row"
|
|
49
|
+
>
|
|
50
|
+
<div
|
|
51
|
+
class="five wide column"
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
class="ui segment"
|
|
55
|
+
>
|
|
56
|
+
<form
|
|
57
|
+
class="ui form"
|
|
58
|
+
>
|
|
59
|
+
<div
|
|
60
|
+
class="ui header"
|
|
61
|
+
title="structure.grant.cart.template"
|
|
62
|
+
>
|
|
63
|
+
structure.grant.cart.template
|
|
64
|
+
</div>
|
|
65
|
+
<div
|
|
66
|
+
class="ui segment"
|
|
67
|
+
>
|
|
68
|
+
<h4
|
|
69
|
+
class="ui header"
|
|
70
|
+
>
|
|
71
|
+
g1
|
|
72
|
+
</h4>
|
|
73
|
+
<div
|
|
74
|
+
class="field"
|
|
75
|
+
data-testid="form-field"
|
|
76
|
+
>
|
|
77
|
+
<label>
|
|
78
|
+
field1
|
|
79
|
+
</label>
|
|
80
|
+
<div
|
|
81
|
+
class="field"
|
|
82
|
+
>
|
|
83
|
+
<div
|
|
84
|
+
class="ui input"
|
|
85
|
+
>
|
|
86
|
+
<input
|
|
87
|
+
name="field1"
|
|
88
|
+
placeholder="field1"
|
|
89
|
+
type="text"
|
|
90
|
+
value=""
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</form>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
<div
|
|
100
|
+
class="eleven wide column"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
@@ -225,7 +225,7 @@ describe("reducers: structureVersion", () => {
|
|
|
225
225
|
const expectedState = {
|
|
226
226
|
...initialState,
|
|
227
227
|
modificationGrant: grant,
|
|
228
|
-
templateContent:
|
|
228
|
+
templateContent: { foo: { origin: "user", value: "bar" } },
|
|
229
229
|
structures: [structure],
|
|
230
230
|
};
|
|
231
231
|
expect(
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
updateGrantRequestTemplateContent,
|
|
11
11
|
updateGrantRequestUser,
|
|
12
12
|
} from "../routines";
|
|
13
|
+
import { formatLegacyContent } from "@truedat/df/utils";
|
|
13
14
|
|
|
14
15
|
const initialState = {
|
|
15
16
|
structures: [],
|
|
@@ -32,6 +33,8 @@ const setRowValue = ({ index, value, population }) => {
|
|
|
32
33
|
} else return dropAt(index)(population);
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
const modificationGrantContent = (modificationGrant) => _.isEmpty(modificationGrant) ? {} : formatLegacyContent(modificationGrant.detail)
|
|
37
|
+
|
|
35
38
|
const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
36
39
|
switch (type) {
|
|
37
40
|
case addGrantRequestToCart.TRIGGER:
|
|
@@ -56,6 +59,7 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
56
59
|
return {
|
|
57
60
|
...state,
|
|
58
61
|
template: payload,
|
|
62
|
+
templateContent: modificationGrantContent(state.modificationGrant)
|
|
59
63
|
};
|
|
60
64
|
case updateGrantRequestTemplateContent.TRIGGER:
|
|
61
65
|
const { content, valid } = payload;
|
|
@@ -76,7 +80,7 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
76
80
|
const { structure, grant } = payload;
|
|
77
81
|
return {
|
|
78
82
|
...initialState,
|
|
79
|
-
templateContent:
|
|
83
|
+
templateContent: formatLegacyContent(grant.detail),
|
|
80
84
|
modificationGrant: grant,
|
|
81
85
|
structures: [mapPayload(structure)],
|
|
82
86
|
};
|
|
@@ -87,13 +91,13 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
87
91
|
structures: _.map((s) =>
|
|
88
92
|
s.id === structureId
|
|
89
93
|
? {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
...s,
|
|
95
|
+
filters: setRowValue({
|
|
96
|
+
index,
|
|
97
|
+
value,
|
|
98
|
+
population: _.pathOr([], "filters")(s),
|
|
99
|
+
}),
|
|
100
|
+
}
|
|
97
101
|
: s
|
|
98
102
|
)(state.structures),
|
|
99
103
|
};
|