-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathGroupUiSchemaSettings.test.ts
122 lines (121 loc) · 4.07 KB
/
GroupUiSchemaSettings.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { UiSchemaRuleEffects } from "../../../src";
import { buildUiSchema } from "../../../src/groups/_internal/GroupUiSchemaSettings";
import { MOCK_CONTEXT } from "../../mocks/mock-auth";
describe("buildUiSchema: group settings", () => {
it("returns the full group settings uiSchema", async () => {
const uiSchema = await buildUiSchema(
"some.scope",
{ isSharedUpdate: true } as any,
MOCK_CONTEXT
);
expect(uiSchema).toEqual({
type: "Layout",
elements: [
{
type: "Section",
labelKey: "some.scope.sections.membershipAccess.label",
elements: [
{
scope: "/properties/isSharedUpdate",
type: "Control",
rule: {
effect: UiSchemaRuleEffects.HIDE,
condition: {
scope: "/properties/isSharedUpdate",
schema: { const: false },
},
},
},
{
labelKey: "some.scope.fields.membershipAccess.label",
scope: "/properties/membershipAccess",
type: "Control",
options: {
control: "hub-field-input-tile-select",
labels: [
"{{some.scope.fields.membershipAccess.org.description:translate}}",
"{{some.scope.fields.membershipAccess.collab.description:translate}}",
"{{some.scope.fields.membershipAccess.any.description:translate}}",
],
rules: [
[
{
effect: UiSchemaRuleEffects.NONE,
},
],
[
{
effect: UiSchemaRuleEffects.DISABLE,
conditions: [
{
scope: "/properties/leavingDisallowed",
schema: { const: true },
},
],
},
],
[
{
effect: UiSchemaRuleEffects.DISABLE,
conditions: [
{
scope: "/properties/leavingDisallowed",
schema: { const: true },
},
],
},
{
effect: UiSchemaRuleEffects.DISABLE,
conditions: [
{
scope: "/properties/isSharedUpdate",
schema: { const: true },
},
],
},
],
],
},
rules: [
{
effect: UiSchemaRuleEffects.RESET,
conditions: [
{
scope: "/properties/leavingDisallowed",
schema: { const: true },
},
],
},
{
effect: UiSchemaRuleEffects.RESET,
conditions: [
{
scope: "/properties/isSharedUpdate",
schema: { const: true },
},
{
scope: "/properties/membershipAccess",
schema: { const: "anyone" },
},
],
},
],
},
{
labelKey: "some.scope.fields.contributeContent.label",
scope: "/properties/isViewOnly",
type: "Control",
options: {
control: "hub-field-input-tile-select",
labels: [
"{{some.scope.fields.contributeContent.members.description:translate}}",
"{{some.scope.fields.contributeContent.admins.description:translate}}",
],
},
},
],
},
],
});
});
});