@jmruthers/pace-core 0.5.191 → 0.5.193

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 (293) hide show
  1. package/dist/{AuthService-CbP_utw2.d.ts → AuthService-DjnJHDtC.d.ts} +1 -0
  2. package/dist/{DataTable-WKRZD47S.js → DataTable-5FU7IESH.js} +7 -6
  3. package/dist/{PublicPageProvider-ULXC_u6U.d.ts → PublicPageProvider-C0Sm_e5k.d.ts} +3 -1
  4. package/dist/{UnifiedAuthProvider-BYA9qB-o.d.ts → UnifiedAuthProvider-185Ih4dj.d.ts} +2 -0
  5. package/dist/{UnifiedAuthProvider-FTSG5XH7.js → UnifiedAuthProvider-RGJTDE2C.js} +3 -3
  6. package/dist/{api-IHKALJZD.js → api-N774RPUA.js} +2 -2
  7. package/dist/chunk-6C4YBBJM 5.js +628 -0
  8. package/dist/chunk-7D4SUZUM.js 2.map +1 -0
  9. package/dist/{chunk-LOMZXPSN.js → chunk-7EQTDTTJ.js} +47 -74
  10. package/dist/chunk-7EQTDTTJ.js 2.map +1 -0
  11. package/dist/chunk-7EQTDTTJ.js.map +1 -0
  12. package/dist/{chunk-6LTQQAT6.js → chunk-7FLMSG37.js} +336 -137
  13. package/dist/chunk-7FLMSG37.js 2.map +1 -0
  14. package/dist/chunk-7FLMSG37.js.map +1 -0
  15. package/dist/{chunk-XNYQOL3Z.js → chunk-BC4IJKSL.js} +9 -18
  16. package/dist/chunk-BC4IJKSL.js.map +1 -0
  17. package/dist/{chunk-ULHIJK66.js → chunk-E3SPN4VZ 5.js } +146 -36
  18. package/dist/chunk-E3SPN4VZ.js +12917 -0
  19. package/dist/{chunk-ULHIJK66.js.map → chunk-E3SPN4VZ.js.map} +1 -1
  20. package/dist/chunk-E66EQZE6 5.js +37 -0
  21. package/dist/chunk-E66EQZE6.js 2.map +1 -0
  22. package/dist/{chunk-6TQDD426.js → chunk-HWIIPPNI.js} +40 -221
  23. package/dist/chunk-HWIIPPNI.js.map +1 -0
  24. package/dist/chunk-I7PSE6JW 5.js +191 -0
  25. package/dist/chunk-I7PSE6JW.js 2.map +1 -0
  26. package/dist/{chunk-OETXORNB.js → chunk-IIELH4DL.js} +211 -136
  27. package/dist/chunk-IIELH4DL.js.map +1 -0
  28. package/dist/{chunk-ROXMHMY2.js → chunk-KNC55RTG.js} +13 -3
  29. package/dist/{chunk-ROXMHMY2.js.map → chunk-KNC55RTG.js 5.map } +1 -1
  30. package/dist/chunk-KNC55RTG.js.map +1 -0
  31. package/dist/chunk-KQCRWDSA.js 5.map +1 -0
  32. package/dist/{chunk-XYXSXPUK.js → chunk-LFNCN2SP.js} +7 -6
  33. package/dist/chunk-LFNCN2SP.js 2.map +1 -0
  34. package/dist/chunk-LFNCN2SP.js.map +1 -0
  35. package/dist/chunk-LMC26NLJ 2.js +84 -0
  36. package/dist/{chunk-VKB2CO4Z.js → chunk-NOAYCWCX 5.js } +84 -87
  37. package/dist/chunk-NOAYCWCX.js +4993 -0
  38. package/dist/chunk-NOAYCWCX.js.map +1 -0
  39. package/dist/chunk-QWWZ5CAQ.js 3.map +1 -0
  40. package/dist/chunk-QXHPKYJV 3.js +113 -0
  41. package/dist/chunk-R77UEZ4E 3.js +68 -0
  42. package/dist/chunk-VBXEHIUJ.js 6.map +1 -0
  43. package/dist/{chunk-VRGWKHDB.js → chunk-XNXXZ43G.js} +77 -33
  44. package/dist/chunk-XNXXZ43G.js.map +1 -0
  45. package/dist/chunk-ZSAAAMVR 6.js +25 -0
  46. package/dist/components.d.ts +2 -2
  47. package/dist/components.js +7 -7
  48. package/dist/components.js 5.map +1 -0
  49. package/dist/hooks.js +8 -8
  50. package/dist/index.d.ts +5 -5
  51. package/dist/index.js +12 -14
  52. package/dist/index.js.map +1 -1
  53. package/dist/providers.d.ts +3 -3
  54. package/dist/providers.js +2 -2
  55. package/dist/rbac/index.d.ts +1 -19
  56. package/dist/rbac/index.js +7 -9
  57. package/dist/styles/index 2.js +12 -0
  58. package/dist/styles/index.js 5.map +1 -0
  59. package/dist/theming/runtime 5.js +19 -0
  60. package/dist/theming/runtime.js 5.map +1 -0
  61. package/dist/utils.js +1 -1
  62. package/docs/api/classes/ColumnFactory.md +1 -1
  63. package/docs/api/classes/ErrorBoundary.md +1 -1
  64. package/docs/api/classes/InvalidScopeError.md +1 -1
  65. package/docs/api/classes/Logger.md +1 -1
  66. package/docs/api/classes/MissingUserContextError.md +1 -1
  67. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  68. package/docs/api/classes/PermissionDeniedError.md +2 -2
  69. package/docs/api/classes/RBACAuditManager.md +2 -2
  70. package/docs/api/classes/RBACCache.md +1 -1
  71. package/docs/api/classes/RBACEngine.md +2 -2
  72. package/docs/api/classes/RBACError.md +1 -1
  73. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  74. package/docs/api/classes/SecureSupabaseClient.md +10 -10
  75. package/docs/api/classes/StorageUtils.md +1 -1
  76. package/docs/api/enums/FileCategory.md +1 -1
  77. package/docs/api/enums/LogLevel.md +1 -1
  78. package/docs/api/enums/RBACErrorCode.md +1 -1
  79. package/docs/api/enums/RPCFunction.md +1 -1
  80. package/docs/api/interfaces/AddressFieldProps.md +1 -1
  81. package/docs/api/interfaces/AddressFieldRef.md +1 -1
  82. package/docs/api/interfaces/AggregateConfig.md +1 -1
  83. package/docs/api/interfaces/AutocompleteOptions.md +1 -1
  84. package/docs/api/interfaces/AvatarProps.md +1 -1
  85. package/docs/api/interfaces/BadgeProps.md +1 -1
  86. package/docs/api/interfaces/ButtonProps.md +1 -1
  87. package/docs/api/interfaces/CalendarProps.md +1 -1
  88. package/docs/api/interfaces/CardProps.md +1 -1
  89. package/docs/api/interfaces/ColorPalette.md +1 -1
  90. package/docs/api/interfaces/ColorShade.md +1 -1
  91. package/docs/api/interfaces/ComplianceResult.md +1 -1
  92. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  93. package/docs/api/interfaces/DataRecord.md +1 -1
  94. package/docs/api/interfaces/DataTableAction.md +1 -1
  95. package/docs/api/interfaces/DataTableColumn.md +1 -1
  96. package/docs/api/interfaces/DataTableProps.md +1 -1
  97. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  98. package/docs/api/interfaces/DatabaseComplianceResult.md +1 -1
  99. package/docs/api/interfaces/DatabaseIssue.md +1 -1
  100. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  101. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  102. package/docs/api/interfaces/EventAppRoleData.md +1 -1
  103. package/docs/api/interfaces/ExportColumn.md +1 -1
  104. package/docs/api/interfaces/ExportOptions.md +1 -1
  105. package/docs/api/interfaces/FileDisplayProps.md +24 -11
  106. package/docs/api/interfaces/FileMetadata.md +1 -1
  107. package/docs/api/interfaces/FileReference.md +1 -1
  108. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  109. package/docs/api/interfaces/FileUploadOptions.md +1 -1
  110. package/docs/api/interfaces/FileUploadProps.md +1 -1
  111. package/docs/api/interfaces/FooterProps.md +1 -1
  112. package/docs/api/interfaces/FormFieldProps.md +1 -1
  113. package/docs/api/interfaces/FormProps.md +1 -1
  114. package/docs/api/interfaces/GrantEventAppRoleParams.md +1 -1
  115. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  116. package/docs/api/interfaces/InputProps.md +1 -1
  117. package/docs/api/interfaces/LabelProps.md +1 -1
  118. package/docs/api/interfaces/LoggerConfig.md +1 -1
  119. package/docs/api/interfaces/LoginFormProps.md +1 -1
  120. package/docs/api/interfaces/NavigationAccessRecord.md +2 -2
  121. package/docs/api/interfaces/NavigationContextType.md +1 -1
  122. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  123. package/docs/api/interfaces/NavigationItem.md +1 -1
  124. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  125. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  126. package/docs/api/interfaces/Organisation.md +1 -1
  127. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  128. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  129. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  130. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  131. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  132. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  133. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  134. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  135. package/docs/api/interfaces/PagePermissionGuardProps.md +2 -2
  136. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  137. package/docs/api/interfaces/PaletteData.md +1 -1
  138. package/docs/api/interfaces/ParsedAddress.md +1 -1
  139. package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
  140. package/docs/api/interfaces/ProgressProps.md +1 -1
  141. package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
  142. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  143. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  144. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  145. package/docs/api/interfaces/QuickFix.md +1 -1
  146. package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
  147. package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
  148. package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
  149. package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
  150. package/docs/api/interfaces/RBACConfig.md +2 -2
  151. package/docs/api/interfaces/RBACContext.md +1 -1
  152. package/docs/api/interfaces/RBACLogger.md +1 -1
  153. package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
  154. package/docs/api/interfaces/RBACPerformanceMetrics.md +1 -1
  155. package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
  156. package/docs/api/interfaces/RBACPermissionCheckResult.md +2 -2
  157. package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
  158. package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
  159. package/docs/api/interfaces/RBACResult.md +1 -1
  160. package/docs/api/interfaces/RBACRoleGrantParams.md +2 -2
  161. package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
  162. package/docs/api/interfaces/RBACRoleRevokeParams.md +2 -2
  163. package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
  164. package/docs/api/interfaces/RBACRoleValidateParams.md +2 -2
  165. package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
  166. package/docs/api/interfaces/RBACRolesListParams.md +1 -1
  167. package/docs/api/interfaces/RBACRolesListResult.md +2 -2
  168. package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
  169. package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
  170. package/docs/api/interfaces/ResourcePermissions.md +1 -1
  171. package/docs/api/interfaces/RevokeEventAppRoleParams.md +1 -1
  172. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  173. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  174. package/docs/api/interfaces/RoleManagementResult.md +1 -1
  175. package/docs/api/interfaces/RouteAccessRecord.md +2 -2
  176. package/docs/api/interfaces/RouteConfig.md +2 -2
  177. package/docs/api/interfaces/RuntimeComplianceResult.md +1 -1
  178. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  179. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  180. package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
  181. package/docs/api/interfaces/SetupIssue.md +1 -1
  182. package/docs/api/interfaces/StorageConfig.md +1 -1
  183. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  184. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  185. package/docs/api/interfaces/StorageListOptions.md +1 -1
  186. package/docs/api/interfaces/StorageListResult.md +1 -1
  187. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  188. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  189. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  190. package/docs/api/interfaces/StyleImport.md +1 -1
  191. package/docs/api/interfaces/SwitchProps.md +1 -1
  192. package/docs/api/interfaces/TabsContentProps.md +1 -1
  193. package/docs/api/interfaces/TabsListProps.md +1 -1
  194. package/docs/api/interfaces/TabsProps.md +1 -1
  195. package/docs/api/interfaces/TabsTriggerProps.md +1 -1
  196. package/docs/api/interfaces/TextareaProps.md +1 -1
  197. package/docs/api/interfaces/ToastActionElement.md +1 -1
  198. package/docs/api/interfaces/ToastProps.md +1 -1
  199. package/docs/api/interfaces/UnifiedAuthContextType.md +60 -38
  200. package/docs/api/interfaces/UnifiedAuthProviderProps.md +13 -13
  201. package/docs/api/interfaces/UseFormDialogOptions.md +1 -1
  202. package/docs/api/interfaces/UseFormDialogReturn.md +1 -1
  203. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  204. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  205. package/docs/api/interfaces/UsePublicEventLogoOptions.md +2 -2
  206. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  207. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  208. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  209. package/docs/api/interfaces/UsePublicFileDisplayOptions.md +2 -2
  210. package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
  211. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  212. package/docs/api/interfaces/UseResolvedScopeOptions.md +2 -2
  213. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  214. package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
  215. package/docs/api/interfaces/UserEventAccess.md +1 -1
  216. package/docs/api/interfaces/UserMenuProps.md +1 -1
  217. package/docs/api/interfaces/UserProfile.md +1 -1
  218. package/docs/api/modules.md +194 -209
  219. package/docs/migration/database-changes-december-2025.md +2 -1
  220. package/docs/rbac/event-based-apps.md +124 -6
  221. package/package.json +1 -1
  222. package/scripts/check-pace-core-compliance.cjs +292 -57
  223. package/src/__tests__/rls-policies.test.ts +3 -1
  224. package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +172 -45
  225. package/src/components/DataTable/__tests__/DataTable.grouping-aggregation.test.tsx +121 -28
  226. package/src/components/DataTable/__tests__/DataTableCore.test-setup.ts +9 -8
  227. package/src/components/DataTable/__tests__/DataTableCore.test.tsx +20 -52
  228. package/src/components/DataTable/__tests__/a11y.basic.test.tsx +170 -34
  229. package/src/components/DataTable/__tests__/keyboard.test.tsx +75 -12
  230. package/src/components/DataTable/__tests__/pagination.modes.test.tsx +75 -11
  231. package/src/components/DataTable/components/UnifiedTableBody.tsx +85 -14
  232. package/src/components/DataTable/hooks/useDataTablePermissions.ts +75 -10
  233. package/src/components/FileDisplay/FileDisplay.test.tsx +2 -1
  234. package/src/components/FileDisplay/FileDisplay.tsx +16 -4
  235. package/src/components/NavigationMenu/NavigationMenu.test.tsx +6 -4
  236. package/src/components/NavigationMenu/NavigationMenu.tsx +1 -10
  237. package/src/components/OrganisationSelector/OrganisationSelector.tsx +0 -1
  238. package/src/components/PaceAppLayout/PaceAppLayout.test.tsx +25 -2
  239. package/src/components/PaceAppLayout/PaceAppLayout.tsx +97 -68
  240. package/src/components/PaceLoginPage/PaceLoginPage.tsx +0 -7
  241. package/src/components/ProtectedRoute/ProtectedRoute.test.tsx +5 -9
  242. package/src/components/ProtectedRoute/ProtectedRoute.tsx +0 -1
  243. package/src/components/PublicLayout/PublicPageProvider.tsx +0 -1
  244. package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +14 -7
  245. package/src/hooks/services/useAuthService.ts +21 -3
  246. package/src/hooks/services/useEventService.ts +21 -3
  247. package/src/hooks/services/useInactivityService.ts +21 -3
  248. package/src/hooks/services/useOrganisationService.ts +21 -3
  249. package/src/hooks/useFileDisplay.ts +10 -17
  250. package/src/hooks/useSecureDataAccess.test.ts +16 -9
  251. package/src/hooks/useSecureDataAccess.ts +3 -2
  252. package/src/providers/services/EventServiceProvider.tsx +0 -8
  253. package/src/providers/services/UnifiedAuthProvider.tsx +174 -24
  254. package/src/rbac/__tests__/adapters.comprehensive.test.tsx +10 -16
  255. package/src/rbac/__tests__/isSuperAdmin.real.test.ts +82 -0
  256. package/src/rbac/adapters.tsx +3 -22
  257. package/src/rbac/api.test.ts +2 -2
  258. package/src/rbac/api.ts +7 -1
  259. package/src/rbac/components/EnhancedNavigationMenu.tsx +2 -15
  260. package/src/rbac/components/NavigationGuard.tsx +1 -10
  261. package/src/rbac/components/NavigationProvider.tsx +0 -1
  262. package/src/rbac/components/PermissionEnforcer.tsx +45 -12
  263. package/src/rbac/components/SecureDataProvider.tsx +0 -1
  264. package/src/rbac/components/__tests__/EnhancedNavigationMenu.test.tsx +7 -43
  265. package/src/rbac/components/__tests__/NavigationGuard.test.tsx +4 -11
  266. package/src/rbac/components/__tests__/NavigationProvider.test.tsx +3 -3
  267. package/src/rbac/components/__tests__/SecureDataProvider.fixed.test.tsx +1 -1
  268. package/src/rbac/components/__tests__/SecureDataProvider.test.tsx +1 -1
  269. package/src/rbac/engine.ts +14 -2
  270. package/src/rbac/hooks/index.ts +0 -3
  271. package/src/rbac/hooks/usePermissions.ts +51 -11
  272. package/src/rbac/hooks/useRBAC.ts +3 -13
  273. package/src/rbac/hooks/useResolvedScope.test.ts +75 -54
  274. package/src/rbac/hooks/useResolvedScope.ts +58 -33
  275. package/src/rbac/hooks/useSecureSupabase.ts +4 -9
  276. package/src/rbac/secureClient.ts +31 -0
  277. package/src/services/EventService.ts +4 -57
  278. package/src/services/InactivityService.ts +127 -34
  279. package/src/services/OrganisationService.ts +68 -10
  280. package/dist/chunk-6LTQQAT6.js.map +0 -1
  281. package/dist/chunk-6TQDD426.js.map +0 -1
  282. package/dist/chunk-LOMZXPSN.js.map +0 -1
  283. package/dist/chunk-OETXORNB.js.map +0 -1
  284. package/dist/chunk-VKB2CO4Z.js.map +0 -1
  285. package/dist/chunk-VRGWKHDB.js.map +0 -1
  286. package/dist/chunk-XNYQOL3Z.js.map +0 -1
  287. package/dist/chunk-XYXSXPUK.js.map +0 -1
  288. package/scripts/check-pace-core-compliance.js +0 -512
  289. package/src/rbac/hooks/useSuperAdminBypass.ts +0 -126
  290. package/src/utils/context/superAdminOverride.ts +0 -58
  291. /package/dist/{DataTable-WKRZD47S.js.map → DataTable-5FU7IESH.js.map} +0 -0
  292. /package/dist/{UnifiedAuthProvider-FTSG5XH7.js.map → UnifiedAuthProvider-RGJTDE2C.js.map} +0 -0
  293. /package/dist/{api-IHKALJZD.js.map → api-N774RPUA.js.map} +0 -0
@@ -15,16 +15,49 @@ import { vi } from 'vitest';
15
15
 
16
16
  // Mock the RBAC hooks
17
17
  vi.mock('../../../rbac/hooks', () => ({
18
- useCan: vi.fn(() => ({ can: true, isLoading: false })),
18
+ useCan: vi.fn(() => ({ can: true, isLoading: false, error: null })),
19
19
  useResolvedScope: vi.fn(() => ({
20
20
  resolvedScope: {
21
21
  organisationId: 'test-org-id',
22
22
  eventId: 'test-event-id',
23
23
  appId: 'test-app-id'
24
- }
24
+ },
25
+ isLoading: false
25
26
  }))
26
27
  }));
27
28
 
29
+ // Mock useDataTablePermissions to return non-loading permissions
30
+ const mockUseDataTablePermissions = vi.hoisted(() => vi.fn(() => ({
31
+ permissions: {
32
+ canRead: { can: true, isLoading: false, error: null },
33
+ canCreate: { can: true, isLoading: false, error: null },
34
+ canUpdate: { can: true, isLoading: false, error: null },
35
+ canDelete: { can: true, isLoading: false, error: null },
36
+ canExport: { can: true, isLoading: false, error: null },
37
+ canImport: { can: true, isLoading: false, error: null },
38
+ },
39
+ secureFeatures: {
40
+ search: true,
41
+ sorting: true,
42
+ pagination: true,
43
+ selection: true,
44
+ creation: true,
45
+ editing: true,
46
+ deletion: true,
47
+ deleteSelected: true,
48
+ export: true,
49
+ import: true,
50
+ columnVisibility: true,
51
+ filtering: true,
52
+ grouping: true,
53
+ },
54
+ effectivePageId: 'test-page',
55
+ })));
56
+
57
+ vi.mock('../hooks/useDataTablePermissions', () => ({
58
+ useDataTablePermissions: mockUseDataTablePermissions
59
+ }));
60
+
28
61
  const mockUseUnifiedAuthFn = vi.fn(() => ({
29
62
  user: {
30
63
  id: 'test-user',
@@ -67,7 +100,7 @@ const defaultRBAC = {
67
100
 
68
101
  describe('DataTable Grouping Aggregation', () => {
69
102
  describe('Basic Aggregation Functions', () => {
70
- it('should display sum aggregation in grouped rows', () => {
103
+ it('should display sum aggregation in grouped rows', async () => {
71
104
  const columns: DataTableColumn<DinerData>[] = [
72
105
  {
73
106
  accessorKey: 'diet',
@@ -102,14 +135,19 @@ describe('DataTable Grouping Aggregation', () => {
102
135
  />
103
136
  );
104
137
 
138
+ // Wait for table to render
139
+ await waitFor(() => {
140
+ expect(screen.getByRole('table')).toBeInTheDocument();
141
+ });
142
+
105
143
  // Check that grouped rows show aggregated values
106
144
  // Standard group: 10 + 15 + 20 = 45 youth, 5 + 8 + 10 = 23 adults
107
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
145
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
108
146
  // The aggregated values should be visible in the grouped row
109
147
  // Note: We need to check for the actual rendered values
110
148
  });
111
149
 
112
- it('should display average aggregation in grouped rows', () => {
150
+ it('should display average aggregation in grouped rows', async () => {
113
151
  const columns: DataTableColumn<DinerData>[] = [
114
152
  {
115
153
  accessorKey: 'diet',
@@ -139,10 +177,15 @@ describe('DataTable Grouping Aggregation', () => {
139
177
  />
140
178
  );
141
179
 
142
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
180
+ // Wait for table to render
181
+ await waitFor(() => {
182
+ expect(screen.getByRole('table')).toBeInTheDocument();
183
+ });
184
+
185
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
143
186
  });
144
187
 
145
- it('should display count aggregation in grouped rows', () => {
188
+ it('should display count aggregation in grouped rows', async () => {
146
189
  const columns: DataTableColumn<DinerData>[] = [
147
190
  {
148
191
  accessorKey: 'diet',
@@ -172,10 +215,15 @@ describe('DataTable Grouping Aggregation', () => {
172
215
  />
173
216
  );
174
217
 
175
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
218
+ // Wait for table to render
219
+ await waitFor(() => {
220
+ expect(screen.getByRole('table')).toBeInTheDocument();
221
+ });
222
+
223
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
176
224
  });
177
225
 
178
- it('should display min aggregation in grouped rows', () => {
226
+ it('should display min aggregation in grouped rows', async () => {
179
227
  const columns: DataTableColumn<DinerData>[] = [
180
228
  {
181
229
  accessorKey: 'diet',
@@ -205,10 +253,15 @@ describe('DataTable Grouping Aggregation', () => {
205
253
  />
206
254
  );
207
255
 
208
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
256
+ // Wait for table to render
257
+ await waitFor(() => {
258
+ expect(screen.getByRole('table')).toBeInTheDocument();
259
+ });
260
+
261
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
209
262
  });
210
263
 
211
- it('should display max aggregation in grouped rows', () => {
264
+ it('should display max aggregation in grouped rows', async () => {
212
265
  const columns: DataTableColumn<DinerData>[] = [
213
266
  {
214
267
  accessorKey: 'diet',
@@ -238,12 +291,17 @@ describe('DataTable Grouping Aggregation', () => {
238
291
  />
239
292
  );
240
293
 
241
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
294
+ // Wait for table to render
295
+ await waitFor(() => {
296
+ expect(screen.getByRole('table')).toBeInTheDocument();
297
+ });
298
+
299
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
242
300
  });
243
301
  });
244
302
 
245
303
  describe('Custom Aggregation Functions', () => {
246
- it('should use custom aggregation function', () => {
304
+ it('should use custom aggregation function', async () => {
247
305
  const customAggregate = (rows: DinerData[]) => {
248
306
  return rows.reduce((total, row) => total + row.youth + row.adults, 0);
249
307
  };
@@ -277,12 +335,17 @@ describe('DataTable Grouping Aggregation', () => {
277
335
  />
278
336
  );
279
337
 
280
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
338
+ // Wait for table to render
339
+ await waitFor(() => {
340
+ expect(screen.getByRole('table')).toBeInTheDocument();
341
+ });
342
+
343
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
281
344
  });
282
345
  });
283
346
 
284
347
  describe('Custom Aggregate Cell Renderer', () => {
285
- it('should use custom aggregateCell renderer', () => {
348
+ it('should use custom aggregateCell renderer', async () => {
286
349
  const columns: DataTableColumn<DinerData>[] = [
287
350
  {
288
351
  accessorKey: 'diet',
@@ -313,12 +376,17 @@ describe('DataTable Grouping Aggregation', () => {
313
376
  />
314
377
  );
315
378
 
316
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
379
+ // Wait for table to render
380
+ await waitFor(() => {
381
+ expect(screen.getByRole('table')).toBeInTheDocument();
382
+ });
383
+
384
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
317
385
  });
318
386
  });
319
387
 
320
388
  describe('Edge Cases', () => {
321
- it('should handle empty groups gracefully', () => {
389
+ it('should handle empty groups gracefully', async () => {
322
390
  const emptyData: DinerData[] = [];
323
391
 
324
392
  const columns: DataTableColumn<DinerData>[] = [
@@ -354,7 +422,7 @@ describe('DataTable Grouping Aggregation', () => {
354
422
  expect(screen.queryByText(/items/)).not.toBeInTheDocument();
355
423
  });
356
424
 
357
- it('should handle null/undefined values in aggregation', () => {
425
+ it('should handle null/undefined values in aggregation', async () => {
358
426
  const dataWithNulls: DinerData[] = [
359
427
  { id: '1', diet: 'Standard', youth: 10, adults: 5, cost: 100 },
360
428
  { id: '2', diet: 'Standard', youth: null as any, adults: 8, cost: 150 },
@@ -395,10 +463,15 @@ describe('DataTable Grouping Aggregation', () => {
395
463
  />
396
464
  );
397
465
 
398
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
466
+ // Wait for table to render
467
+ await waitFor(() => {
468
+ expect(screen.getByRole('table')).toBeInTheDocument();
469
+ });
470
+
471
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
399
472
  });
400
473
 
401
- it('should show empty cells for columns without aggregateFn', () => {
474
+ it('should show empty cells for columns without aggregateFn', async () => {
402
475
  const columns: DataTableColumn<DinerData>[] = [
403
476
  {
404
477
  accessorKey: 'diet',
@@ -433,12 +506,17 @@ describe('DataTable Grouping Aggregation', () => {
433
506
  />
434
507
  );
435
508
 
436
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
509
+ // Wait for table to render
510
+ await waitFor(() => {
511
+ expect(screen.getByRole('table')).toBeInTheDocument();
512
+ });
513
+
514
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
437
515
  });
438
516
  });
439
517
 
440
518
  describe('Multiple Aggregations', () => {
441
- it('should display multiple columns with different aggregation functions', () => {
519
+ it('should display multiple columns with different aggregation functions', async () => {
442
520
  const columns: DataTableColumn<DinerData>[] = [
443
521
  {
444
522
  accessorKey: 'diet',
@@ -488,13 +566,18 @@ describe('DataTable Grouping Aggregation', () => {
488
566
  />
489
567
  );
490
568
 
491
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
492
- expect(screen.getByText('Gluten Free (2 items)')).toBeInTheDocument();
569
+ // Wait for table to render
570
+ await waitFor(() => {
571
+ expect(screen.getByRole('table')).toBeInTheDocument();
572
+ });
573
+
574
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
575
+ expect(await screen.findByText('Gluten Free (2 items)')).toBeInTheDocument();
493
576
  });
494
577
  });
495
578
 
496
579
  describe('Integration with Existing Features', () => {
497
- it('should work with sorting', () => {
580
+ it('should work with sorting', async () => {
498
581
  const columns: DataTableColumn<DinerData>[] = [
499
582
  {
500
583
  accessorKey: 'diet',
@@ -524,10 +607,15 @@ describe('DataTable Grouping Aggregation', () => {
524
607
  />
525
608
  );
526
609
 
527
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
610
+ // Wait for table to render
611
+ await waitFor(() => {
612
+ expect(screen.getByRole('table')).toBeInTheDocument();
613
+ });
614
+
615
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
528
616
  });
529
617
 
530
- it('should work with filtering', () => {
618
+ it('should work with filtering', async () => {
531
619
  const columns: DataTableColumn<DinerData>[] = [
532
620
  {
533
621
  accessorKey: 'diet',
@@ -558,7 +646,12 @@ describe('DataTable Grouping Aggregation', () => {
558
646
  />
559
647
  );
560
648
 
561
- expect(screen.getByText('Standard (3 items)')).toBeInTheDocument();
649
+ // Wait for table to render
650
+ await waitFor(() => {
651
+ expect(screen.getByRole('table')).toBeInTheDocument();
652
+ });
653
+
654
+ expect(await screen.findByText('Standard (3 items)')).toBeInTheDocument();
562
655
  });
563
656
  });
564
657
  });
@@ -13,13 +13,14 @@ import React from 'react';
13
13
 
14
14
  // Mock the RBAC hooks
15
15
  vi.mock('../../../rbac/hooks', () => ({
16
- useCan: vi.fn(),
16
+ useCan: vi.fn(() => ({ can: true, isLoading: false, error: null })),
17
17
  useResolvedScope: vi.fn(() => ({
18
18
  resolvedScope: {
19
19
  organisationId: 'test-org-id',
20
20
  eventId: 'test-event-id',
21
21
  appId: 'test-app-id'
22
- }
22
+ },
23
+ isLoading: false
23
24
  }))
24
25
  }));
25
26
 
@@ -153,12 +154,12 @@ vi.mock('../utils/hierarchicalSorting', () => ({
153
154
  // Create a mock implementation that can be overridden
154
155
  const mockUseDataTablePermissions = vi.hoisted(() => vi.fn(() => ({
155
156
  permissions: {
156
- canRead: { can: true },
157
- canCreate: { can: true },
158
- canUpdate: { can: true },
159
- canDelete: { can: true },
160
- canExport: { can: true },
161
- canImport: { can: true },
157
+ canRead: { can: true, isLoading: false, error: null },
158
+ canCreate: { can: true, isLoading: false, error: null },
159
+ canUpdate: { can: true, isLoading: false, error: null },
160
+ canDelete: { can: true, isLoading: false, error: null },
161
+ canExport: { can: true, isLoading: false, error: null },
162
+ canImport: { can: true, isLoading: false, error: null },
162
163
  },
163
164
  secureFeatures: {
164
165
  search: true,
@@ -20,13 +20,14 @@ import { renderWithProviders } from '../../../__tests__/helpers/test-utils';
20
20
 
21
21
  // Mock the RBAC hooks
22
22
  vi.mock('../../../rbac/hooks', () => ({
23
- useCan: vi.fn(),
23
+ useCan: vi.fn(() => ({ can: true, isLoading: false, error: null })),
24
24
  useResolvedScope: vi.fn(() => ({
25
25
  resolvedScope: {
26
26
  organisationId: 'test-org-id',
27
27
  eventId: 'test-event-id',
28
28
  appId: 'test-app-id'
29
- }
29
+ },
30
+ isLoading: false
30
31
  }))
31
32
  }));
32
33
 
@@ -171,12 +172,12 @@ const mockPermissions = {
171
172
  // Create a mock implementation that can be overridden
172
173
  const mockUseDataTablePermissions = vi.hoisted(() => vi.fn(() => ({
173
174
  permissions: {
174
- canRead: { can: true },
175
- canCreate: { can: true },
176
- canUpdate: { can: true },
177
- canDelete: { can: true },
178
- canExport: { can: true },
179
- canImport: { can: true },
175
+ canRead: { can: true, isLoading: false, error: null },
176
+ canCreate: { can: true, isLoading: false, error: null },
177
+ canUpdate: { can: true, isLoading: false, error: null },
178
+ canDelete: { can: true, isLoading: false, error: null },
179
+ canExport: { can: true, isLoading: false, error: null },
180
+ canImport: { can: true, isLoading: false, error: null },
180
181
  },
181
182
  secureFeatures: {
182
183
  search: true,
@@ -805,51 +806,10 @@ describe('DataTableCore Component', () => {
805
806
 
806
807
  describe('Event Handlers', () => {
807
808
  it('calls onEditRow when row is edited', async () => {
808
- const user = userEvent.setup();
809
809
  const onEditRow = vi.fn();
810
810
  const features = createDefaultFeatures();
811
811
  features.editing = true;
812
812
 
813
- const { useDataTableState } = await import('../hooks/useDataTableState');
814
- vi.mocked(useDataTableState).mockReturnValueOnce({
815
- state: {
816
- sorting: [],
817
- columnFilters: [],
818
- columnVisibility: {},
819
- grouping: [],
820
- expanded: {},
821
- pagination: { pageIndex: 0, pageSize: 10 },
822
- columnOrder: [],
823
- rowSelection: {},
824
- isCreating: false,
825
- creationData: {},
826
- editingRowId: 'user-1',
827
- editingData: { name: 'Edited Name' },
828
- showImportModal: false,
829
- showFilterRow: false,
830
- searchQuery: '',
831
- },
832
- actions: {
833
- setSorting: vi.fn(),
834
- setColumnFilters: vi.fn(),
835
- setColumnVisibility: vi.fn(),
836
- setGrouping: vi.fn(),
837
- setExpanded: vi.fn(),
838
- setPagination: vi.fn(),
839
- setColumnOrder: vi.fn(),
840
- setRowSelection: vi.fn(),
841
- setCreating: vi.fn(),
842
- setCreationData: vi.fn(),
843
- clearCreationData: vi.fn(),
844
- setEditingRow: vi.fn(),
845
- clearEditing: vi.fn(),
846
- setImportModal: vi.fn(),
847
- setFilterRow: vi.fn(),
848
- setSearchQuery: vi.fn(),
849
- resetState: vi.fn(),
850
- },
851
- });
852
-
853
813
  render(
854
814
  <DataTableCore
855
815
  data={mockData}
@@ -861,9 +821,17 @@ describe('DataTableCore Component', () => {
861
821
  />
862
822
  );
863
823
 
864
- // Simulate save editing
865
- // Note: This would require interacting with the EditableRow component
866
- expect(screen.getByText('User 1')).toBeInTheDocument();
824
+ // Wait for table to render
825
+ await waitFor(() => {
826
+ expect(screen.getByRole('table')).toBeInTheDocument();
827
+ });
828
+
829
+ // Verify table rendered with data
830
+ expect(await screen.findByText('User 1')).toBeInTheDocument();
831
+
832
+ // Note: Testing actual editing interaction would require clicking edit button
833
+ // and interacting with EditableRow component, which is complex to mock.
834
+ // This test verifies the component renders correctly with editing enabled.
867
835
  });
868
836
 
869
837
  it('calls onDeleteRow when row is deleted', async () => {