@griddo/ax 11.15.9 → 11.16.0-rc.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.
Files changed (95) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/components/RestrictionsModal/CurrentAccessList/CurrentAccessList.test.tsx +173 -0
  3. package/src/__tests__/components/RestrictionsModal/OptionsStep/OptionsStep.test.tsx +160 -0
  4. package/src/__tests__/components/RestrictionsModal/RestrictionsModal.test.tsx +134 -0
  5. package/src/__tests__/components/RestrictionsModal/RolesList/RolesList.test.tsx +234 -0
  6. package/src/__tests__/components/RestrictionsModal/UsersList/UsersList.test.tsx +288 -0
  7. package/src/__tests__/hooks/users.test.tsx +382 -0
  8. package/src/api/pages.tsx +24 -1
  9. package/src/api/sites.tsx +14 -14
  10. package/src/api/structuredData.tsx +17 -7
  11. package/src/components/Browser/index.tsx +12 -0
  12. package/src/components/Browser/style.tsx +5 -1
  13. package/src/components/ConfigPanel/Form/index.tsx +11 -10
  14. package/src/components/ContentItem/index.tsx +31 -0
  15. package/src/components/ContentItem/style.tsx +43 -0
  16. package/src/components/Fields/ImageField/index.tsx +2 -1
  17. package/src/components/Fields/RadioField/index.tsx +3 -3
  18. package/src/components/Fields/RadioField/style.tsx +1 -1
  19. package/src/components/FloatingNote/index.tsx +12 -1
  20. package/src/components/FloatingNote/style.tsx +2 -1
  21. package/src/components/Modal/style.tsx +11 -0
  22. package/src/components/PageFinder/SelectionListItem/index.tsx +27 -17
  23. package/src/components/PageFinder/index.tsx +65 -28
  24. package/src/components/PageFinder/style.tsx +0 -1
  25. package/src/components/RestrictionsModal/CurrentAccessList/index.tsx +74 -0
  26. package/src/components/RestrictionsModal/CurrentAccessList/style.tsx +155 -0
  27. package/src/components/RestrictionsModal/OptionsStep/index.tsx +55 -0
  28. package/src/components/RestrictionsModal/OptionsStep/style.tsx +29 -0
  29. package/src/components/RestrictionsModal/RolesList/RoleItem/index.tsx +54 -0
  30. package/src/components/RestrictionsModal/RolesList/RoleItem/style.tsx +34 -0
  31. package/src/components/RestrictionsModal/RolesList/index.tsx +107 -0
  32. package/src/components/RestrictionsModal/RolesList/style.tsx +76 -0
  33. package/src/components/RestrictionsModal/UsersList/UserItem/index.tsx +78 -0
  34. package/src/components/RestrictionsModal/UsersList/UserItem/style.tsx +73 -0
  35. package/src/components/RestrictionsModal/UsersList/index.tsx +151 -0
  36. package/src/components/RestrictionsModal/UsersList/style.tsx +55 -0
  37. package/src/components/RestrictionsModal/index.tsx +181 -0
  38. package/src/components/RestrictionsModal/style.tsx +31 -0
  39. package/src/components/RestrictionsModal/utils.tsx +24 -0
  40. package/src/components/ScheduleModal/index.tsx +32 -8
  41. package/src/components/SelectionComponent/index.tsx +65 -0
  42. package/src/components/SelectionComponent/style.tsx +69 -0
  43. package/src/components/TableFilters/RoleFilter/index.tsx +3 -3
  44. package/src/components/TableList/TableItem/style.tsx +7 -13
  45. package/src/components/Tabs/index.tsx +2 -1
  46. package/src/components/UserRolesAndSites/index.tsx +2 -2
  47. package/src/components/index.tsx +6 -0
  48. package/src/containers/PageEditor/actions.tsx +43 -0
  49. package/src/containers/PageEditor/constants.tsx +1 -0
  50. package/src/containers/PageEditor/interfaces.tsx +26 -19
  51. package/src/containers/PageEditor/reducer.tsx +32 -19
  52. package/src/containers/Users/reducer.tsx +1 -0
  53. package/src/helpers/forms.tsx +3 -1
  54. package/src/hooks/index.tsx +2 -1
  55. package/src/hooks/users.tsx +154 -14
  56. package/src/modules/ActivityLog/LogFilters/UserFilter/index.tsx +11 -12
  57. package/src/modules/Content/PageItem/index.tsx +17 -10
  58. package/src/modules/Content/index.tsx +1 -3
  59. package/src/modules/GlobalEditor/Editor/index.tsx +6 -0
  60. package/src/modules/GlobalEditor/PageBrowser/index.tsx +6 -0
  61. package/src/modules/GlobalEditor/Preview/index.tsx +4 -2
  62. package/src/modules/GlobalEditor/index.tsx +72 -45
  63. package/src/modules/Navigation/Menus/List/Table/ConfigPanel/Form/index.tsx +3 -5
  64. package/src/modules/Navigation/Menus/List/Table/ConfigPanel/index.tsx +4 -4
  65. package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/ConnectedField/index.tsx +2 -3
  66. package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +3 -4
  67. package/src/modules/Navigation/Menus/List/Table/SidePanel/index.tsx +5 -6
  68. package/src/modules/PageEditor/Editor/index.tsx +6 -0
  69. package/src/modules/PageEditor/PageBrowser/index.tsx +6 -0
  70. package/src/modules/PageEditor/Preview/index.tsx +9 -2
  71. package/src/modules/PageEditor/atoms.tsx +110 -3
  72. package/src/modules/PageEditor/index.tsx +76 -95
  73. package/src/modules/Settings/Integrations/IntegrationForm/index.tsx +1 -3
  74. package/src/modules/Sites/SitesList/GridView/GridSiteItem/style.tsx +19 -2
  75. package/src/modules/Sites/SitesList/WelcomeModal/FinalStep/index.tsx +2 -2
  76. package/src/modules/Sites/SitesList/WelcomeModal/utils.ts +2 -2
  77. package/src/modules/StructuredData/Form/ConnectedField/index.tsx +2 -2
  78. package/src/modules/StructuredData/Form/index.tsx +120 -75
  79. package/src/modules/StructuredData/Form/style.tsx +7 -1
  80. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +15 -8
  81. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +15 -9
  82. package/src/modules/StructuredData/{StructuredDataList/StructuredDataItem/utils.tsx → utils.tsx} +16 -2
  83. package/src/modules/Users/Profile/atoms.tsx +62 -4
  84. package/src/modules/Users/Profile/index.tsx +83 -4
  85. package/src/modules/Users/Profile/style.tsx +60 -0
  86. package/src/modules/Users/UserCreate/SiteItem/RolesModal/RoleItem/index.tsx +3 -5
  87. package/src/modules/Users/UserCreate/SiteItem/index.tsx +2 -2
  88. package/src/modules/Users/UserCreate/atoms.tsx +69 -0
  89. package/src/modules/Users/UserCreate/index.tsx +149 -70
  90. package/src/modules/Users/UserCreate/style.tsx +24 -1
  91. package/src/modules/Users/UserForm/index.tsx +260 -146
  92. package/src/modules/Users/UserForm/style.tsx +13 -1
  93. package/src/modules/Users/UserList/UserItem/index.tsx +3 -3
  94. package/src/types/index.tsx +19 -6
  95. package/src/types/logs.tsx +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "11.15.9",
4
+ "version": "11.16.0-rc.1",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -219,5 +219,5 @@
219
219
  "publishConfig": {
220
220
  "access": "public"
221
221
  },
222
- "gitHead": "190d5b241da3aeb5585b3c39ff11221f4e8f7d3e"
222
+ "gitHead": "637014e49d261e8866cb4268059007e7e50b3e51"
223
223
  }
@@ -0,0 +1,173 @@
1
+ import { ThemeProvider } from "styled-components";
2
+ import { render, cleanup, screen, fireEvent } from "@testing-library/react";
3
+ import { parseTheme } from "@ax/helpers";
4
+ import "@testing-library/jest-dom";
5
+
6
+ import CurrentAccessList from "@ax/components/RestrictionsModal/CurrentAccessList";
7
+ import type { IUser } from "@ax/types";
8
+ import globalTheme from "@ax/themes/theme.json";
9
+
10
+ jest.mock("react-redux", () => ({
11
+ ...jest.requireActual("react-redux"),
12
+ useSelector: jest.fn((selector) => {
13
+ const mockState = {
14
+ users: {
15
+ roles: [
16
+ { id: 1, name: "Admin" },
17
+ { id: 2, name: "Editor" },
18
+ ],
19
+ },
20
+ };
21
+ return selector(mockState);
22
+ }),
23
+ }));
24
+
25
+ afterEach(cleanup);
26
+
27
+ const defaultProps: {
28
+ restrictionType: "users" | "roles";
29
+ currentAccessGrants: { users: number[]; roles: number[] };
30
+ onEdit: jest.Mock;
31
+ users: IUser[];
32
+ canSetPermissions: boolean;
33
+ } = {
34
+ restrictionType: "users",
35
+ currentAccessGrants: {
36
+ users: [1, 2],
37
+ roles: [],
38
+ },
39
+ onEdit: jest.fn(),
40
+ users: [
41
+ {
42
+ id: 1,
43
+ username: "john",
44
+ name: "John Doe",
45
+ email: "john@example.com",
46
+ failed: 0,
47
+ roles: [],
48
+ isSuperAdmin: false,
49
+ pagePermissions: [],
50
+ },
51
+ {
52
+ id: 2,
53
+ username: "jane",
54
+ name: "Jane Smith",
55
+ email: "jane@example.com",
56
+ failed: 0,
57
+ roles: [],
58
+ isSuperAdmin: false,
59
+ pagePermissions: [],
60
+ },
61
+ ],
62
+ canSetPermissions: true,
63
+ };
64
+
65
+ const renderComponent = (props = defaultProps) =>
66
+ render(
67
+ <ThemeProvider theme={parseTheme(globalTheme)}>
68
+ <CurrentAccessList {...props} />
69
+ </ThemeProvider>,
70
+ );
71
+
72
+ describe("CurrentAccessList component rendering", () => {
73
+ it("should render the component with users message by default", () => {
74
+ renderComponent();
75
+
76
+ expect(screen.getByText(/Only these users/)).toBeTruthy();
77
+ expect(screen.getByText("can edit")).toBeTruthy();
78
+ });
79
+
80
+ it("should show roles message when restrictionType is roles", () => {
81
+ renderComponent({
82
+ ...defaultProps,
83
+ restrictionType: "roles",
84
+ currentAccessGrants: {
85
+ users: [],
86
+ roles: [1],
87
+ },
88
+ });
89
+
90
+ expect(screen.getByText(/Only these roles/)).toBeTruthy();
91
+ });
92
+
93
+ it("should render the Manage User Access button when canSetPermissions is true", () => {
94
+ renderComponent({ ...defaultProps, canSetPermissions: true });
95
+
96
+ expect(screen.getByText("MANAGE USER ACCESS")).toBeTruthy();
97
+ });
98
+
99
+ it("should not render the Manage User Access button when canSetPermissions is false", () => {
100
+ renderComponent({ ...defaultProps, canSetPermissions: false });
101
+
102
+ expect(screen.queryByText("MANAGE USER ACCESS")).toBeNull();
103
+ });
104
+
105
+ it("should filter to show only selected users when restrictionType is users", () => {
106
+ const allUsers = [
107
+ { id: 1, username: "john", name: "John Doe", email: "john@example.com", failed: 0, roles: [], isSuperAdmin: false, pagePermissions: [] },
108
+ { id: 2, username: "jane", name: "Jane Smith", email: "jane@example.com", failed: 0, roles: [], isSuperAdmin: false, pagePermissions: [] },
109
+ { id: 3, username: "bob", name: "Bob Wilson", email: "bob@example.com", failed: 0, roles: [], isSuperAdmin: false, pagePermissions: [] },
110
+ ];
111
+
112
+ renderComponent({
113
+ ...defaultProps,
114
+ users: allUsers,
115
+ currentAccessGrants: {
116
+ users: [1, 2],
117
+ roles: [],
118
+ },
119
+ });
120
+
121
+ expect(screen.getByText(/Only these users/)).toBeTruthy();
122
+ });
123
+ });
124
+
125
+ describe("CurrentAccessList component events", () => {
126
+ it("should call onEdit when Manage User Access button is clicked", () => {
127
+ const onEditMock = jest.fn();
128
+
129
+ renderComponent({
130
+ ...defaultProps,
131
+ canSetPermissions: true,
132
+ onEdit: onEditMock,
133
+ });
134
+
135
+ const manageButton = screen.getByText("MANAGE USER ACCESS");
136
+ fireEvent.click(manageButton);
137
+
138
+ expect(onEditMock).toBeCalled();
139
+ });
140
+
141
+ it("should handle empty users list", () => {
142
+ renderComponent({
143
+ ...defaultProps,
144
+ users: [],
145
+ currentAccessGrants: {
146
+ users: [],
147
+ roles: [],
148
+ },
149
+ });
150
+
151
+ expect(screen.getByText(/Only these users/)).toBeTruthy();
152
+ });
153
+
154
+ it("should handle multiple users correctly", () => {
155
+ const allUsers = [
156
+ { id: 1, username: "john", name: "John Doe", email: "john@example.com", failed: 0, roles: [], isSuperAdmin: false, pagePermissions: [] },
157
+ { id: 2, username: "jane", name: "Jane Smith", email: "jane@example.com", failed: 0, roles: [], isSuperAdmin: false, pagePermissions: [] },
158
+ { id: 3, username: "bob", name: "Bob Wilson", email: "bob@example.com", failed: 0, roles: [], isSuperAdmin: false, pagePermissions: [] },
159
+ ];
160
+
161
+ renderComponent({
162
+ ...defaultProps,
163
+ users: allUsers,
164
+ currentAccessGrants: {
165
+ users: [1, 2],
166
+ roles: [],
167
+ },
168
+ });
169
+
170
+ // Should render the component with the filtered users
171
+ expect(screen.getByText(/Only these users/)).toBeTruthy();
172
+ });
173
+ });
@@ -0,0 +1,160 @@
1
+ import React from "react";
2
+
3
+ import { ThemeProvider } from "styled-components";
4
+ import { render, cleanup, screen, fireEvent } from "@testing-library/react";
5
+ import { parseTheme } from "@ax/helpers";
6
+ import "@testing-library/jest-dom";
7
+
8
+ import OptionsStep from "@ax/components/RestrictionsModal/OptionsStep";
9
+ import globalTheme from "@ax/themes/theme.json";
10
+
11
+ afterEach(cleanup);
12
+
13
+ const defaultProps: {
14
+ restrictionType: "users" | "roles";
15
+ onRestrictionTypeChange: jest.Mock;
16
+ onCancel: jest.Mock;
17
+ onNext: jest.Mock;
18
+ } = {
19
+ restrictionType: "users",
20
+ onRestrictionTypeChange: jest.fn(),
21
+ onCancel: jest.fn(),
22
+ onNext: jest.fn(),
23
+ };
24
+
25
+ const renderComponent = (props = defaultProps) =>
26
+ render(
27
+ <ThemeProvider theme={parseTheme(globalTheme)}>
28
+ <OptionsStep {...props} />
29
+ </ThemeProvider>,
30
+ );
31
+
32
+ describe("OptionsStep component rendering", () => {
33
+ it("should render the component with description text", () => {
34
+ renderComponent();
35
+
36
+ expect(screen.getByText(/By default/)).toBeTruthy();
37
+ });
38
+
39
+ it("should render both selection options", () => {
40
+ renderComponent();
41
+
42
+ expect(screen.getByText("By users")).toBeTruthy();
43
+ expect(screen.getByText("By roles")).toBeTruthy();
44
+ });
45
+
46
+ it("should render the user option description", () => {
47
+ renderComponent();
48
+
49
+ expect(screen.getByText("Only the selected users can edit the page.")).toBeTruthy();
50
+ });
51
+
52
+ it("should render the roles option description", () => {
53
+ renderComponent();
54
+
55
+ expect(screen.getByText("Only users with a specific roles can edit the page.")).toBeTruthy();
56
+ });
57
+
58
+ it("should render Cancel and Next buttons", () => {
59
+ renderComponent();
60
+
61
+ expect(screen.getByText("Cancel")).toBeTruthy();
62
+ expect(screen.getByText("Manage users access")).toBeTruthy();
63
+ });
64
+
65
+ it("should highlight users option when restrictionType is users", () => {
66
+ renderComponent({ ...defaultProps, restrictionType: "users" });
67
+
68
+ const radioInputs = screen.getAllByTestId("radio-field-input");
69
+ const usersInput = radioInputs.find((input) => (input as HTMLInputElement).value === "users");
70
+ expect((usersInput as HTMLInputElement).checked).toBe(true);
71
+ });
72
+
73
+ it("should highlight roles option when restrictionType is roles", () => {
74
+ renderComponent({ ...defaultProps, restrictionType: "roles" });
75
+
76
+ const radioInputs = screen.getAllByTestId("radio-field-input");
77
+ const rolesInput = radioInputs.find((input) => (input as HTMLInputElement).value === "roles");
78
+ expect((rolesInput as HTMLInputElement).checked).toBe(true);
79
+ });
80
+ });
81
+
82
+ describe("OptionsStep component events", () => {
83
+ it("should call onRestrictionTypeChange when users option is clicked", () => {
84
+ const onRestrictionTypeChangeMock = jest.fn();
85
+
86
+ renderComponent({
87
+ ...defaultProps,
88
+ restrictionType: "roles",
89
+ onRestrictionTypeChange: onRestrictionTypeChangeMock,
90
+ });
91
+
92
+ const radioInputs = screen.getAllByTestId("radio-field-input");
93
+ const usersInput = radioInputs.find((input) => (input as HTMLInputElement).value === "users");
94
+ fireEvent.click(usersInput!);
95
+
96
+ expect(onRestrictionTypeChangeMock).toBeCalledWith("users");
97
+ });
98
+
99
+ it("should call onRestrictionTypeChange when roles option is clicked", () => {
100
+ const onRestrictionTypeChangeMock = jest.fn();
101
+
102
+ renderComponent({
103
+ ...defaultProps,
104
+ restrictionType: "users",
105
+ onRestrictionTypeChange: onRestrictionTypeChangeMock,
106
+ });
107
+
108
+ const radioInputs = screen.getAllByTestId("radio-field-input");
109
+ const rolesInput = radioInputs.find((input) => (input as HTMLInputElement).value === "roles");
110
+ fireEvent.click(rolesInput!);
111
+
112
+ expect(onRestrictionTypeChangeMock).toBeCalledWith("roles");
113
+ });
114
+
115
+ it("should call onCancel when Cancel button is clicked", () => {
116
+ const onCancelMock = jest.fn();
117
+
118
+ renderComponent({
119
+ ...defaultProps,
120
+ onCancel: onCancelMock,
121
+ });
122
+
123
+ const cancelButton = screen.getByText("Cancel");
124
+ fireEvent.click(cancelButton);
125
+
126
+ expect(onCancelMock).toBeCalled();
127
+ });
128
+
129
+ it("should call onNext when Next button is clicked", () => {
130
+ const onNextMock = jest.fn();
131
+
132
+ renderComponent({
133
+ ...defaultProps,
134
+ onNext: onNextMock,
135
+ });
136
+
137
+ const nextButton = screen.getByText("Manage users access");
138
+ fireEvent.click(nextButton);
139
+
140
+ expect(onNextMock).toBeCalled();
141
+ });
142
+
143
+ it("should toggle between users and roles selections", () => {
144
+ const onRestrictionTypeChangeMock = jest.fn();
145
+
146
+ renderComponent({
147
+ ...defaultProps,
148
+ restrictionType: "users",
149
+ onRestrictionTypeChange: onRestrictionTypeChangeMock,
150
+ });
151
+
152
+ // Switch to roles
153
+ const radioInputs = screen.getAllByTestId("radio-field-input");
154
+ const rolesInput = radioInputs.find((input) => (input as HTMLInputElement).value === "roles");
155
+ fireEvent.click(rolesInput!);
156
+
157
+ expect(onRestrictionTypeChangeMock).toHaveBeenCalledWith("roles");
158
+ expect(onRestrictionTypeChangeMock).toHaveBeenCalledTimes(1);
159
+ });
160
+ });
@@ -0,0 +1,134 @@
1
+ import { act } from "@testing-library/react";
2
+ import { ThemeProvider } from "styled-components";
3
+ import { render, cleanup, screen, fireEvent } from "@testing-library/react";
4
+ import "@testing-library/jest-dom";
5
+
6
+ import RestrictionsModal from "@ax/components/RestrictionsModal";
7
+ import { parseTheme } from "@ax/helpers";
8
+ import globalTheme from "@ax/themes/theme.json";
9
+
10
+ jest.mock("@ax/components/RestrictionsModal/utils", () => ({
11
+ fetchUsers: jest.fn().mockResolvedValue([]),
12
+ }));
13
+
14
+ jest.mock("react-redux", () => ({
15
+ ...jest.requireActual("react-redux"),
16
+ useSelector: jest.fn((selector) => {
17
+ const mockState = {
18
+ sites: {
19
+ currentSiteInfo: { id: 1 },
20
+ },
21
+ users: {
22
+ roles: [
23
+ { id: 1, name: "Admin" },
24
+ { id: 2, name: "Editor" },
25
+ ],
26
+ currentUser: { id: 1 },
27
+ },
28
+ };
29
+ return selector(mockState);
30
+ }),
31
+ }));
32
+
33
+ afterEach(cleanup);
34
+
35
+ const defaultProps = {
36
+ isOpen: false,
37
+ toggleModal: jest.fn(),
38
+ currentAccessGrants: undefined,
39
+ onUpdateAccessGrants: jest.fn().mockResolvedValue(undefined),
40
+ isSaving: false,
41
+ canSetPermissions: true,
42
+ };
43
+
44
+ const renderComponent = (props = defaultProps) =>
45
+ render(
46
+ <ThemeProvider theme={parseTheme(globalTheme)}>
47
+ <RestrictionsModal {...props} />
48
+ </ThemeProvider>,
49
+ );
50
+
51
+ describe("RestrictionsModal component rendering", () => {
52
+ it("should not render the modal content when closed", () => {
53
+ renderComponent();
54
+
55
+ expect(screen.queryByText("By default")).toBeNull();
56
+ });
57
+
58
+ it("should render the modal with OptionsStep when open", () => {
59
+ renderComponent({ ...defaultProps, isOpen: true });
60
+
61
+ expect(screen.getByText(/By default/)).toBeTruthy();
62
+ });
63
+
64
+ it("should render CurrentAccessList when modal opens with current access grants", () => {
65
+ const currentAccessGrants = {
66
+ users: [1],
67
+ roles: [],
68
+ };
69
+
70
+ renderComponent({
71
+ ...defaultProps,
72
+ isOpen: true,
73
+ currentAccessGrants,
74
+ });
75
+
76
+ // Should show "current" step instead of "options"
77
+ expect(screen.queryByText(/By default/)).toBeNull();
78
+ });
79
+
80
+ it("should render the modal title", () => {
81
+ renderComponent({ ...defaultProps, isOpen: true });
82
+
83
+ const titles = screen.getAllByText("Page restrictions");
84
+ expect(titles.length).toBeGreaterThan(0);
85
+ });
86
+ });
87
+
88
+ describe("RestrictionsModal component navigation", () => {
89
+ it("should navigate to options step when OptionsStep Next button is clicked", () => {
90
+ renderComponent({ ...defaultProps, isOpen: true });
91
+
92
+ const nextButton = screen.getByText("Manage users access");
93
+ fireEvent.click(nextButton);
94
+
95
+ // Should navigate to list step
96
+ expect(screen.queryByText(/Select the/)).toBeTruthy();
97
+ });
98
+
99
+ it("should close modal when Cancel button is clicked", () => {
100
+ const toggleModalMock = jest.fn();
101
+
102
+ renderComponent({
103
+ ...defaultProps,
104
+ isOpen: true,
105
+ toggleModal: toggleModalMock,
106
+ });
107
+
108
+ const cancelButton = screen.getByText("Cancel");
109
+ fireEvent.click(cancelButton);
110
+
111
+ expect(toggleModalMock).toBeCalled();
112
+ });
113
+ });
114
+
115
+ describe("RestrictionsModal restriction type selection", () => {
116
+ it("should toggle restriction type when selection changes", () => {
117
+ renderComponent({ ...defaultProps, isOpen: true });
118
+
119
+ const radioInputs = screen.getAllByTestId("radio-field-input");
120
+ const rolesInput = radioInputs.find((input) => (input as HTMLInputElement).value === "roles");
121
+ fireEvent.click(rolesInput!);
122
+
123
+ // Should show the roles description
124
+ expect(screen.getByText(/Only users with a specific roles/)).toBeTruthy();
125
+ });
126
+
127
+ it("should start with users restriction type by default", () => {
128
+ renderComponent({ ...defaultProps, isOpen: true });
129
+
130
+ const radioInputs = screen.getAllByTestId("radio-field-input");
131
+ const usersInput = radioInputs.find((input) => (input as HTMLInputElement).value === "users");
132
+ expect((usersInput as HTMLInputElement).checked).toBe(true);
133
+ });
134
+ });