@jmruthers/pace-core 0.5.68 → 0.5.70
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/dist/{DataTable-4IUY7BXB.js → DataTable-OSELOGMA.js} +6 -6
- package/dist/{PublicLoadingSpinner-DdKXTkCZ.d.ts → PublicLoadingSpinner-DLpF5bbs.d.ts} +78 -2
- package/dist/{chunk-OPCWH3A4.js → chunk-4YMVZ76F.js} +7 -6
- package/dist/chunk-4YMVZ76F.js.map +1 -0
- package/dist/{chunk-NN45OBIS.js → chunk-5G7JA3L5.js} +3 -5
- package/dist/{chunk-NN45OBIS.js.map → chunk-5G7JA3L5.js.map} +1 -1
- package/dist/{chunk-U6GPOF6J.js → chunk-5NV76BYF.js} +666 -110
- package/dist/chunk-5NV76BYF.js.map +1 -0
- package/dist/{chunk-D7ARGIA3.js → chunk-6RBH67W7.js} +23 -6
- package/dist/chunk-6RBH67W7.js.map +1 -0
- package/dist/{chunk-ZPG4XPV5.js → chunk-BHBMXMLT.js} +5 -7
- package/dist/chunk-BHBMXMLT.js.map +1 -0
- package/dist/{chunk-ZMS23NS5.js → chunk-FOT3WUV6.js} +3 -5
- package/dist/{chunk-ZMS23NS5.js.map → chunk-FOT3WUV6.js.map} +1 -1
- package/dist/{chunk-MOJXHWDE.js → chunk-GCUIIBLB.js} +382 -5
- package/dist/chunk-GCUIIBLB.js.map +1 -0
- package/dist/{chunk-PXWEDX7Y.js → chunk-KWQH4VO3.js} +3 -3
- package/dist/{chunk-ZPK5656W.js → chunk-O3NWNXDY.js} +4 -5
- package/dist/chunk-O3NWNXDY.js.map +1 -0
- package/dist/{chunk-KRCRNXPD.js → chunk-OTJUAYBG.js} +81 -18
- package/dist/chunk-OTJUAYBG.js.map +1 -0
- package/dist/chunk-SMJZMKYN.js +141 -0
- package/dist/chunk-SMJZMKYN.js.map +1 -0
- package/dist/{chunk-UYA6U6H7.js → chunk-V2TE7LOF.js} +4 -4
- package/dist/{chunk-L3RV2ALE.js → chunk-VKOCWWVY.js} +6 -1
- package/dist/{chunk-L3RV2ALE.js.map → chunk-VKOCWWVY.js.map} +1 -1
- package/dist/components.d.ts +4 -79
- package/dist/components.js +23 -581
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +9 -6
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +32 -19
- package/dist/index.js.map +1 -1
- package/dist/providers.js +6 -7
- package/dist/rbac/index.js +6 -6
- package/dist/styles/index.js +2 -2
- package/dist/theming/runtime.d.ts +4 -3
- package/dist/theming/runtime.js +3 -1
- package/dist/{usePublicRouteParams-CdoFxnJK.d.ts → usePublicRouteParams-Ua1Vz-HG.d.ts} +35 -1
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +3 -3
- package/docs/DOCUMENTATION_CHECKLIST.md +281 -0
- package/docs/README.md +22 -10
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +1 -1
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +1 -1
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +129 -0
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventContextType.md +7 -7
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/EventProviderProps.md +2 -2
- package/docs/api/interfaces/FileDisplayProps.md +107 -0
- package/docs/api/interfaces/FileMetadata.md +129 -0
- package/docs/api/interfaces/FileReference.md +118 -0
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +85 -0
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +2 -2
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACContextType.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACProviderProps.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +228 -23
- package/docs/architecture/services.md +374 -0
- package/docs/best-practices/README.md +1 -1
- package/docs/best-practices/testing.md +1 -1
- package/docs/breaking-changes.md +182 -0
- package/docs/common-patterns.md +445 -0
- package/docs/core-concepts/authentication.md +26 -11
- package/docs/core-concepts/events.md +2 -0
- package/docs/core-concepts/organisations.md +2 -0
- package/docs/core-concepts/permissions.md +2 -0
- package/docs/{INDEX.md → documentation-index.md} +26 -38
- package/docs/faq.md +286 -0
- package/docs/{FILE_REFERENCE_SYSTEM.md → file-reference-system.md} +1 -1
- package/docs/getting-started/installation-guide.md +284 -0
- package/docs/getting-started/quick-start.md +8 -1
- package/docs/implementation-guides/app-layout.md +3 -1
- package/docs/implementation-guides/data-tables.md +2 -0
- package/docs/implementation-guides/dynamic-colors.md +47 -2
- package/docs/implementation-guides/event-theming-summary.md +220 -0
- package/docs/implementation-guides/forms.md +9 -7
- package/docs/implementation-guides/navigation.md +2 -0
- package/docs/migration/service-architecture.md +351 -0
- package/docs/rbac/README-rbac-rls-integration.md +2 -2
- package/docs/rbac/README.md +1 -1
- package/docs/rbac/examples/rbac-rls-integration-example.md +3 -3
- package/docs/rbac/quick-start.md +2 -0
- package/docs/rbac/rbac-rls-integration.md +2 -2
- package/docs/style-guide.md +136 -1
- package/docs/testing/README.md +1 -1
- package/docs/troubleshooting/authentication-issues.md +334 -0
- package/docs/troubleshooting/common-issues.md +2 -0
- package/docs/troubleshooting/styling-issues.md +199 -144
- package/docs/usage.md +23 -2
- package/package.json +3 -2
- package/src/__tests__/{TESTING_GUIDELINES.md → TEST_GUIDE_CURSOR.md} +20 -0
- package/src/__tests__/TEST_GUIDE_HUMAN.md +103 -0
- package/src/__tests__/fixtures/test-data.ts +90 -0
- package/src/__tests__/helpers/__tests__/component-test-utils.test.tsx +260 -0
- package/src/__tests__/helpers/__tests__/optimized-test-setup.test.ts +224 -0
- package/src/__tests__/helpers/__tests__/supabaseMock.test.ts +273 -0
- package/src/__tests__/helpers/__tests__/test-providers.test.tsx +98 -0
- package/src/__tests__/helpers/__tests__/test-utils.test.tsx +436 -0
- package/src/__tests__/helpers/__tests__/timer-utils.test.ts +371 -0
- package/src/__tests__/helpers/component-test-utils.tsx +14 -4
- package/src/__tests__/helpers/optimized-test-setup.ts +68 -0
- package/src/__tests__/helpers/test-providers.tsx +329 -0
- package/src/__tests__/helpers/test-utils.tsx +91 -45
- package/src/__tests__/helpers/timer-utils.ts +71 -0
- package/src/__tests__/hooks/usePermissions.test.ts +1 -5
- package/src/__tests__/integration/UserProfile.test.tsx +1 -5
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +42 -12
- package/src/__tests__/setup.ts +34 -28
- package/src/components/Alert/Alert.test.tsx +1 -5
- package/src/components/Avatar/Avatar.test.tsx +1 -5
- package/src/components/Button/Button.test.tsx +4 -20
- package/src/components/Card/Card.test.tsx +1 -5
- package/src/components/Checkbox/Checkbox.test.tsx +1 -5
- package/src/components/DataTable/__tests__/DataTable.comprehensive.test.tsx +1 -5
- package/src/components/DataTable/__tests__/DataTable.test.tsx +45 -49
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +1 -5
- package/src/components/DataTable/__tests__/styles.test.ts +382 -0
- package/src/components/DataTable/context/__tests__/DataTableContext.test.tsx +409 -0
- package/src/components/DataTable/core/__tests__/ActionManager.test.ts +634 -0
- package/src/components/DataTable/core/__tests__/DataManager.test.ts +519 -0
- package/src/components/DataTable/core/__tests__/StateManager.test.ts +714 -0
- package/src/components/DataTable/hooks/__tests__/useDataTableState.test.ts +592 -0
- package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +354 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +539 -0
- package/src/components/Dialog/examples/__tests__/SmartDialogExample.unit.test.tsx +1 -5
- package/src/components/Dialog/utils/__tests__/safeHtml.unit.test.ts +1 -8
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +34 -38
- package/src/components/Footer/Footer.test.tsx +1 -5
- package/src/components/Form/Form.test.tsx +22 -35
- package/src/components/Header/Header.test.tsx +1 -9
- package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +1 -5
- package/src/components/Input/Input.test.tsx +2 -10
- package/src/components/LoginForm/LoginForm.test.tsx +1 -5
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +24 -24
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.accessibility.test.tsx +1 -6
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.integration.test.tsx +6 -16
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.performance.test.tsx +1 -4
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +1 -5
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +1 -7
- package/src/components/PasswordReset/PasswordChangeForm.test.tsx +1 -9
- package/src/components/PasswordReset/PasswordResetForm.test.tsx +1 -9
- package/src/components/PublicLayout/PublicErrorBoundary.tsx +4 -5
- package/src/components/PublicLayout/PublicPageHeader.tsx +13 -9
- package/src/components/PublicLayout/__tests__/EventLogo.test.tsx +666 -0
- package/src/components/PublicLayout/__tests__/PublicErrorBoundary.test.tsx +457 -0
- package/src/components/PublicLayout/__tests__/PublicLoadingSpinner.test.tsx +393 -0
- package/src/components/PublicLayout/__tests__/PublicPageFooter.test.tsx +351 -0
- package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +374 -0
- package/src/components/PublicLayout/__tests__/PublicPageLayout.test.tsx +388 -0
- package/src/components/Select/Select.bug-test.tsx +69 -0
- package/src/components/Select/Select.refactored.tsx +497 -0
- package/src/components/Select/Select.test.tsx +42 -49
- package/src/components/Select/Select.tsx +5 -2
- package/src/components/Select/hooks.ts +254 -0
- package/src/components/Switch/Switch.test.tsx +1 -5
- package/src/components/Table/__tests__/Table.test.tsx +775 -0
- package/src/components/Toast/Toast.test.tsx +15 -8
- package/src/components/Tooltip/Tooltip.test.tsx +1 -5
- package/src/components/UserMenu/UserMenu.test.tsx +3 -15
- package/src/components/__tests__/FileDisplay.test.tsx +575 -0
- package/src/components/__tests__/FileUpload.test.tsx +446 -0
- package/src/components/__tests__/SuperAdminGuard.test.tsx +422 -354
- package/src/hooks/__tests__/ServiceHooks.test.tsx +613 -0
- package/src/hooks/__tests__/hooks.integration.test.tsx +1 -10
- package/src/hooks/__tests__/useApiFetch.unit.test.ts +10 -14
- package/src/hooks/__tests__/useAppConfig.unit.test.ts +307 -0
- package/src/hooks/__tests__/useComponentPerformance.unit.test.tsx +1 -6
- package/src/hooks/__tests__/useFocusTrap.unit.test.tsx +1 -5
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +6 -9
- package/src/hooks/__tests__/usePublicEvent.simple.test.ts +321 -0
- package/src/hooks/__tests__/usePublicEvent.unit.test.ts +583 -0
- package/src/hooks/__tests__/usePublicEventLogo.unit.test.ts +640 -0
- package/src/hooks/__tests__/usePublicRouteParams.unit.test.ts +435 -0
- package/src/hooks/__tests__/useRBAC.unit.test.ts +10 -10
- package/src/hooks/__tests__/useStorage.unit.test.ts +751 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/public/usePublicEvent.ts +30 -9
- package/src/hooks/public/usePublicRouteParams.ts +13 -3
- package/src/hooks/services/useAuth.ts +50 -0
- package/src/hooks/services/useAuthService.ts +30 -0
- package/src/hooks/services/useCurrentEvent.ts +36 -0
- package/src/hooks/services/useCurrentOrganisation.ts +52 -0
- package/src/hooks/services/useEventService.ts +30 -0
- package/src/hooks/services/useInactivityService.ts +30 -0
- package/src/hooks/services/useOrganisationService.ts +30 -0
- package/src/hooks/services/usePermissions.ts +70 -0
- package/src/hooks/services/useRBACService.ts +30 -0
- package/src/hooks/useCounter.test.ts +1 -5
- package/src/hooks/useEventTheme.ts +86 -0
- package/src/hooks/useOrganisationPermissions.test.ts +2 -5
- package/src/hooks/useOrganisationSecurity.test.ts +1 -5
- package/src/hooks/usePermissionCache.test.ts +1 -5
- package/src/hooks/usePermissionCheck.ts +150 -0
- package/src/hooks/useSecureDataAccess.test.ts +1 -5
- package/src/index.ts +7 -0
- package/src/providers/EventProvider.tsx +58 -2
- package/src/providers/OrganisationProvider.test.tsx +1 -5
- package/src/providers/OrganisationProvider.tsx +56 -4
- package/src/providers/UnifiedAuthProvider.test.tsx +1 -5
- package/src/providers/__tests__/AuthProvider.test.tsx +105 -439
- package/src/providers/__tests__/AuthProvider.test.tsx.backup +771 -0
- package/src/providers/__tests__/EventProvider.test.tsx +211 -110
- package/src/providers/__tests__/EventProvider.test.tsx.backup +824 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +1 -5
- package/src/providers/__tests__/OrganisationProvider.test.tsx +97 -261
- package/src/providers/__tests__/OrganisationProvider.test.tsx.backup +820 -0
- package/src/providers/__tests__/ServiceProviders.test.tsx +477 -0
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +72 -504
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup +911 -0
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup2 +166 -0
- package/src/providers/services/AuthServiceProvider.tsx +65 -0
- package/src/providers/services/EventServiceProvider.tsx +83 -0
- package/src/providers/services/InactivityServiceProvider.tsx +83 -0
- package/src/providers/services/OrganisationServiceProvider.tsx +77 -0
- package/src/providers/services/RBACServiceProvider.tsx +79 -0
- package/src/providers/services/UnifiedAuthProvider.tsx +368 -0
- package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +210 -0
- package/src/providers/services/__tests__/UnifiedAuthProvider.integration.test.tsx +269 -0
- package/src/rbac/__tests__/adapters.comprehensive.test.tsx +892 -0
- package/src/rbac/__tests__/engine.comprehensive.test.ts +954 -0
- package/src/rbac/__tests__/integration.authflow.test.tsx +1 -5
- package/src/rbac/__tests__/integration.navigation.test.tsx +1 -4
- package/src/rbac/__tests__/rbac-core.test.tsx +2 -7
- package/src/rbac/__tests__/rbac-functions.test.ts +1 -9
- package/src/rbac/__tests__/rbac-integration.test.ts +1 -9
- package/src/rbac/api.test.ts +1 -9
- package/src/rbac/cache.test.ts +10 -8
- package/src/rbac/cli/__tests__/policy-manager.test.ts +339 -0
- package/src/rbac/components/EnhancedNavigationMenu.test.tsx +1 -5
- package/src/rbac/components/NavigationProvider.test.tsx +1 -5
- package/src/rbac/components/PagePermissionProvider.test.tsx +1 -5
- package/src/rbac/components/SecureDataProvider.test.tsx +1 -5
- package/src/rbac/components/__tests__/NavigationGuard.test.tsx +25 -29
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +27 -30
- package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +23 -27
- package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +18 -22
- package/src/rbac/config.test.ts +1 -5
- package/src/rbac/hooks/useCan.test.ts +262 -9
- package/src/rbac/hooks/usePermissions.test.ts +246 -6
- package/src/rbac/hooks/useRBAC.simple.test.ts +1 -5
- package/src/rbac/hooks/useRBAC.test.ts +472 -198
- package/src/rbac/providers/__tests__/RBACProvider.test.tsx +1 -9
- package/src/services/AuthService.ts +416 -0
- package/src/services/EventService.ts +366 -0
- package/src/services/InactivityService.ts +388 -0
- package/src/services/OrganisationService.ts +592 -0
- package/src/services/RBACService.ts +522 -0
- package/src/services/__tests__/AuthService.test.ts +356 -0
- package/src/services/__tests__/BaseService.test.ts +314 -0
- package/src/services/__tests__/EventService.test.ts +489 -0
- package/src/services/__tests__/InactivityService.test.ts +403 -0
- package/src/services/__tests__/OrganisationService.test.ts +660 -0
- package/src/services/__tests__/RBACService.test.ts +492 -0
- package/src/services/base/BaseService.ts +87 -0
- package/src/services/interfaces/IAuthService.ts +39 -0
- package/src/services/interfaces/IEventService.ts +30 -0
- package/src/services/interfaces/IInactivityService.ts +31 -0
- package/src/services/interfaces/IOrganisationService.ts +41 -0
- package/src/services/interfaces/IRBACService.ts +62 -0
- package/src/theming/__tests__/runtime.test.ts +560 -0
- package/src/theming/runtime.ts +71 -28
- package/src/types/__tests__/file-reference.test.ts +447 -0
- package/src/types/__tests__/organisation.test.ts +1133 -0
- package/src/types/__tests__/theme.test.ts +830 -0
- package/src/types/__tests__/type-validation.test.ts +527 -0
- package/src/utils/__tests__/bundleAnalysis.unit.test.ts +1 -5
- package/src/utils/__tests__/debugLogger.test.ts +417 -0
- package/src/utils/__tests__/deviceFingerprint.unit.test.ts +1 -6
- package/src/utils/__tests__/dynamicUtils.unit.test.ts +1 -5
- package/src/utils/__tests__/lazyLoad.unit.test.tsx +35 -35
- package/src/utils/__tests__/organisationContext.unit.test.ts +1 -5
- package/src/utils/__tests__/performanceBudgets.unit.test.ts +5 -11
- package/src/utils/__tests__/secureErrors.unit.test.ts +1 -6
- package/src/utils/__tests__/secureStorage.unit.test.ts +1 -5
- package/src/utils/__tests__/securityMonitor.unit.test.ts +1 -5
- package/src/utils/__tests__/sessionTracking.unit.test.ts +1 -5
- package/src/utils/appIdResolver.test.ts +6 -10
- package/src/utils/appNameResolver.simple.test.ts +142 -0
- package/src/utils/appNameResolver.test.ts +31 -458
- package/src/utils/appNameResolver.test.ts.backup +494 -0
- package/src/utils/debugLogger.ts +26 -5
- package/src/utils/formatDate.test.ts +1 -5
- package/src/utils/organisationContext.test.ts +1 -5
- package/src/utils/performanceBudgets.ts +3 -4
- package/src/utils/secureDataAccess.test.ts +1 -5
- package/src/utils/storage/__tests__/helpers.unit.test.ts +1 -5
- package/src/validation/__tests__/sqlInjectionProtection.unit.test.ts +1 -5
- package/dist/chunk-D7ARGIA3.js.map +0 -1
- package/dist/chunk-IPCH4YPT.js +0 -315
- package/dist/chunk-IPCH4YPT.js.map +0 -1
- package/dist/chunk-KRCRNXPD.js.map +0 -1
- package/dist/chunk-MOJXHWDE.js.map +0 -1
- package/dist/chunk-N2EUGZRW.js +0 -98
- package/dist/chunk-N2EUGZRW.js.map +0 -1
- package/dist/chunk-OPCWH3A4.js.map +0 -1
- package/dist/chunk-U6GPOF6J.js.map +0 -1
- package/dist/chunk-ZPG4XPV5.js.map +0 -1
- package/dist/chunk-ZPK5656W.js.map +0 -1
- package/docs/getting-started/installation.md +0 -269
- package/src/__tests__/REBUILD_PLAN.md +0 -223
- package/src/styles/base.css +0 -208
- package/src/styles/semantic.css +0 -24
- /package/dist/{DataTable-4IUY7BXB.js.map → DataTable-OSELOGMA.js.map} +0 -0
- /package/dist/{chunk-PXWEDX7Y.js.map → chunk-KWQH4VO3.js.map} +0 -0
- /package/dist/{chunk-UYA6U6H7.js.map → chunk-V2TE7LOF.js.map} +0 -0
|
@@ -120,11 +120,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
vi.restoreAllMocks();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('Rendering', () => {
|
|
123
|
+
describe('Rendering', () => {
|
|
128
124
|
it('renders children when user has permission', async () => {
|
|
129
125
|
mockUseCan.mockReturnValue({
|
|
130
126
|
can: true,
|
|
@@ -143,7 +139,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
143
139
|
await waitFor(() => {
|
|
144
140
|
expect(screen.getByTestId('test-component')).toBeInTheDocument();
|
|
145
141
|
expect(screen.getByText('App Content')).toBeInTheDocument();
|
|
146
|
-
});
|
|
142
|
+
}, { interval: 10 });
|
|
147
143
|
});
|
|
148
144
|
|
|
149
145
|
it('renders unauthorized component when user lacks permission', async () => {
|
|
@@ -167,7 +163,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
167
163
|
await waitFor(() => {
|
|
168
164
|
expect(screen.getByTestId('test-unauthorized')).toBeInTheDocument();
|
|
169
165
|
expect(screen.getByText('Unauthorized: /dashboard - Insufficient permissions')).toBeInTheDocument();
|
|
170
|
-
});
|
|
166
|
+
}, { interval: 10 });
|
|
171
167
|
});
|
|
172
168
|
|
|
173
169
|
it('shows loading state while checking permissions', () => {
|
|
@@ -207,7 +203,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
207
203
|
await waitFor(() => {
|
|
208
204
|
expect(screen.getByTestId('test-component')).toBeInTheDocument();
|
|
209
205
|
expect(screen.getByText('App Content')).toBeInTheDocument();
|
|
210
|
-
});
|
|
206
|
+
}, { interval: 10 });
|
|
211
207
|
});
|
|
212
208
|
});
|
|
213
209
|
|
|
@@ -229,7 +225,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
229
225
|
|
|
230
226
|
await waitFor(() => {
|
|
231
227
|
expect(screen.getByTestId('test-component')).toBeInTheDocument();
|
|
232
|
-
});
|
|
228
|
+
}, { interval: 10 });
|
|
233
229
|
|
|
234
230
|
expect(mockUseCan).toHaveBeenCalledWith(
|
|
235
231
|
'user-123',
|
|
@@ -261,7 +257,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
261
257
|
await waitFor(() => {
|
|
262
258
|
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
263
259
|
expect(screen.getByText('You don\'t have permission to access')).toBeInTheDocument();
|
|
264
|
-
});
|
|
260
|
+
}, { interval: 10 });
|
|
265
261
|
});
|
|
266
262
|
|
|
267
263
|
it('handles routes not found in configuration', async () => {
|
|
@@ -353,7 +349,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
353
349
|
expect(screen.getByTestId('context-consumer')).toBeInTheDocument();
|
|
354
350
|
expect(screen.getByTestId('strict-mode')).toHaveTextContent('true');
|
|
355
351
|
expect(screen.getByTestId('audit-log')).toHaveTextContent('false');
|
|
356
|
-
});
|
|
352
|
+
}, { interval: 10 });
|
|
357
353
|
});
|
|
358
354
|
|
|
359
355
|
it('throws error when useRoleBasedRouter is used outside provider', () => {
|
|
@@ -392,7 +388,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
392
388
|
|
|
393
389
|
await waitFor(() => {
|
|
394
390
|
expect(screen.getByTestId('test-component')).toBeInTheDocument();
|
|
395
|
-
});
|
|
391
|
+
}, { interval: 10 });
|
|
396
392
|
|
|
397
393
|
expect(onRouteAccessSpy).toHaveBeenCalledWith(
|
|
398
394
|
'/dashboard',
|
|
@@ -465,7 +461,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
465
461
|
|
|
466
462
|
await waitFor(() => {
|
|
467
463
|
expect(screen.getByTestId('history-length')).toHaveTextContent('1');
|
|
468
|
-
});
|
|
464
|
+
}, { interval: 10 });
|
|
469
465
|
});
|
|
470
466
|
|
|
471
467
|
it('provides accessible routes', async () => {
|
|
@@ -493,7 +489,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
493
489
|
|
|
494
490
|
await waitFor(() => {
|
|
495
491
|
expect(screen.getByTestId('accessible-routes')).toHaveTextContent('3');
|
|
496
|
-
});
|
|
492
|
+
}, { interval: 10 });
|
|
497
493
|
});
|
|
498
494
|
|
|
499
495
|
it('provides route configuration', async () => {
|
|
@@ -521,7 +517,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
521
517
|
|
|
522
518
|
await waitFor(() => {
|
|
523
519
|
expect(screen.getByTestId('route-config')).toHaveTextContent('/dashboard');
|
|
524
|
-
});
|
|
520
|
+
}, { interval: 10 });
|
|
525
521
|
});
|
|
526
522
|
});
|
|
527
523
|
|
|
@@ -545,7 +541,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
545
541
|
|
|
546
542
|
await waitFor(() => {
|
|
547
543
|
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
548
|
-
});
|
|
544
|
+
}, { interval: 10 });
|
|
549
545
|
|
|
550
546
|
expect(consoleSpy).not.toHaveBeenCalledWith(
|
|
551
547
|
expect.stringContaining('STRICT MODE VIOLATION')
|
|
@@ -577,7 +573,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
577
573
|
|
|
578
574
|
await waitFor(() => {
|
|
579
575
|
expect(screen.getByTestId('test-component')).toBeInTheDocument();
|
|
580
|
-
});
|
|
576
|
+
}, { interval: 10 });
|
|
581
577
|
|
|
582
578
|
expect(onRouteAccessSpy).not.toHaveBeenCalled();
|
|
583
579
|
});
|
|
@@ -607,7 +603,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
607
603
|
|
|
608
604
|
await waitFor(() => {
|
|
609
605
|
expect(screen.getByTestId('history-length')).toHaveTextContent('1');
|
|
610
|
-
});
|
|
606
|
+
}, { interval: 10 });
|
|
611
607
|
});
|
|
612
608
|
});
|
|
613
609
|
|
|
@@ -635,7 +631,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
635
631
|
|
|
636
632
|
await waitFor(() => {
|
|
637
633
|
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
638
|
-
});
|
|
634
|
+
}, { interval: 10 });
|
|
639
635
|
|
|
640
636
|
expect(mockUseCan).toHaveBeenCalledWith(
|
|
641
637
|
'',
|
|
@@ -672,7 +668,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
672
668
|
|
|
673
669
|
await waitFor(() => {
|
|
674
670
|
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
675
|
-
});
|
|
671
|
+
}, { interval: 10 });
|
|
676
672
|
});
|
|
677
673
|
|
|
678
674
|
it('handles permission check errors', async () => {
|
|
@@ -693,7 +689,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
693
689
|
|
|
694
690
|
await waitFor(() => {
|
|
695
691
|
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
696
|
-
});
|
|
692
|
+
}, { interval: 10 });
|
|
697
693
|
});
|
|
698
694
|
});
|
|
699
695
|
|
|
@@ -735,7 +731,7 @@ describe('RoleBasedRouter Component', () => {
|
|
|
735
731
|
'admin:system',
|
|
736
732
|
'admin'
|
|
737
733
|
);
|
|
738
|
-
});
|
|
734
|
+
}, { interval: 10 });
|
|
739
735
|
});
|
|
740
736
|
});
|
|
741
737
|
});
|
package/src/rbac/config.test.ts
CHANGED
|
@@ -32,11 +32,7 @@ describe('RBAC Configuration', () => {
|
|
|
32
32
|
vi.clearAllMocks();
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
vi.restoreAllMocks();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('Configuration Creation', () => {
|
|
35
|
+
describe('Configuration Creation', () => {
|
|
40
36
|
it('creates configuration with required fields', () => {
|
|
41
37
|
const config: RBACConfig = {
|
|
42
38
|
supabase: mockSupabase as any,
|
|
@@ -32,15 +32,7 @@ describe('useCan Hook', () => {
|
|
|
32
32
|
const mockIsPermitted = vi.mocked(isPermitted);
|
|
33
33
|
const mockIsPermittedCached = vi.mocked(isPermittedCached);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
vi.clearAllMocks();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
afterEach(() => {
|
|
40
|
-
vi.restoreAllMocks();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('Permission Checking', () => {
|
|
35
|
+
describe('Permission Checking', () => {
|
|
44
36
|
it('returns true for allowed permissions', async () => {
|
|
45
37
|
mockIsPermitted.mockResolvedValue(true);
|
|
46
38
|
|
|
@@ -353,6 +345,215 @@ describe('useCan Hook', () => {
|
|
|
353
345
|
});
|
|
354
346
|
});
|
|
355
347
|
|
|
348
|
+
describe('Role-Based Permission Scenarios', () => {
|
|
349
|
+
it('allows super admin permissions', async () => {
|
|
350
|
+
mockIsPermitted.mockResolvedValue(true);
|
|
351
|
+
|
|
352
|
+
const { result } = renderHook(() =>
|
|
353
|
+
useCan(mockUserId, mockScope, 'manage:organisations', undefined, false)
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
await waitFor(() => {
|
|
357
|
+
expect(result.current.isLoading).toBe(false);
|
|
358
|
+
expect(result.current.can).toBe(true);
|
|
359
|
+
expect(result.current.error).toBeNull();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
expect(mockIsPermitted).toHaveBeenCalledWith({
|
|
363
|
+
userId: mockUserId,
|
|
364
|
+
scope: mockScope,
|
|
365
|
+
permission: 'manage:organisations',
|
|
366
|
+
pageId: undefined
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('denies super admin permissions for regular users', async () => {
|
|
371
|
+
mockIsPermitted.mockResolvedValue(false);
|
|
372
|
+
|
|
373
|
+
const { result } = renderHook(() =>
|
|
374
|
+
useCan(mockUserId, mockScope, 'super_admin', undefined, false)
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
await waitFor(() => {
|
|
378
|
+
expect(result.current.isLoading).toBe(false);
|
|
379
|
+
expect(result.current.can).toBe(false);
|
|
380
|
+
expect(result.current.error).toBeNull();
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('allows organisation admin permissions', async () => {
|
|
385
|
+
mockIsPermitted.mockResolvedValue(true);
|
|
386
|
+
|
|
387
|
+
const { result } = renderHook(() =>
|
|
388
|
+
useCan(mockUserId, mockScope, 'org_admin', undefined, false)
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
await waitFor(() => {
|
|
392
|
+
expect(result.current.isLoading).toBe(false);
|
|
393
|
+
expect(result.current.can).toBe(true);
|
|
394
|
+
expect(result.current.error).toBeNull();
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('denies organisation admin permissions for members', async () => {
|
|
399
|
+
mockIsPermitted.mockResolvedValue(false);
|
|
400
|
+
|
|
401
|
+
const { result } = renderHook(() =>
|
|
402
|
+
useCan(mockUserId, mockScope, 'org_admin', undefined, false)
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
await waitFor(() => {
|
|
406
|
+
expect(result.current.isLoading).toBe(false);
|
|
407
|
+
expect(result.current.can).toBe(false);
|
|
408
|
+
expect(result.current.error).toBeNull();
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it('allows event admin permissions', async () => {
|
|
413
|
+
mockIsPermitted.mockResolvedValue(true);
|
|
414
|
+
|
|
415
|
+
const { result } = renderHook(() =>
|
|
416
|
+
useCan(mockUserId, mockScope, 'event_admin', undefined, false)
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
await waitFor(() => {
|
|
420
|
+
expect(result.current.isLoading).toBe(false);
|
|
421
|
+
expect(result.current.can).toBe(true);
|
|
422
|
+
expect(result.current.error).toBeNull();
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it('denies event admin permissions for participants', async () => {
|
|
427
|
+
mockIsPermitted.mockResolvedValue(false);
|
|
428
|
+
|
|
429
|
+
const { result } = renderHook(() =>
|
|
430
|
+
useCan(mockUserId, mockScope, 'event_admin', undefined, false)
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
await waitFor(() => {
|
|
434
|
+
expect(result.current.isLoading).toBe(false);
|
|
435
|
+
expect(result.current.can).toBe(false);
|
|
436
|
+
expect(result.current.error).toBeNull();
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it('allows member permissions', async () => {
|
|
441
|
+
mockIsPermitted.mockResolvedValue(true);
|
|
442
|
+
|
|
443
|
+
const { result } = renderHook(() =>
|
|
444
|
+
useCan(mockUserId, mockScope, 'read:users', undefined, false)
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
await waitFor(() => {
|
|
448
|
+
expect(result.current.isLoading).toBe(false);
|
|
449
|
+
expect(result.current.can).toBe(true);
|
|
450
|
+
expect(result.current.error).toBeNull();
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('denies member permissions for participants', async () => {
|
|
455
|
+
mockIsPermitted.mockResolvedValue(false);
|
|
456
|
+
|
|
457
|
+
const { result } = renderHook(() =>
|
|
458
|
+
useCan(mockUserId, mockScope, 'read:users', undefined, false)
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
await waitFor(() => {
|
|
462
|
+
expect(result.current.isLoading).toBe(false);
|
|
463
|
+
expect(result.current.can).toBe(false);
|
|
464
|
+
expect(result.current.error).toBeNull();
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('handles participant-only permissions', async () => {
|
|
469
|
+
mockIsPermitted.mockResolvedValue(true);
|
|
470
|
+
|
|
471
|
+
const { result } = renderHook(() =>
|
|
472
|
+
useCan(mockUserId, mockScope, 'participant', undefined, false)
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
await waitFor(() => {
|
|
476
|
+
expect(result.current.isLoading).toBe(false);
|
|
477
|
+
expect(result.current.can).toBe(true);
|
|
478
|
+
expect(result.current.error).toBeNull();
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
describe('Fallback Scenarios', () => {
|
|
484
|
+
it('falls back to cached permissions when API fails', async () => {
|
|
485
|
+
mockIsPermitted.mockRejectedValue(new Error('API Error'));
|
|
486
|
+
mockIsPermittedCached.mockResolvedValue(true);
|
|
487
|
+
|
|
488
|
+
const { result } = renderHook(() =>
|
|
489
|
+
useCan(mockUserId, mockScope, mockPermission, mockPageId, true)
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
await waitFor(() => {
|
|
493
|
+
expect(result.current.isLoading).toBe(false);
|
|
494
|
+
expect(result.current.can).toBe(true);
|
|
495
|
+
expect(result.current.error).toBeNull();
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
expect(mockIsPermittedCached).toHaveBeenCalledWith({
|
|
499
|
+
userId: mockUserId,
|
|
500
|
+
scope: mockScope,
|
|
501
|
+
permission: mockPermission,
|
|
502
|
+
pageId: mockPageId
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
it('handles permission denied with fallback to false', async () => {
|
|
507
|
+
mockIsPermitted.mockResolvedValue(false);
|
|
508
|
+
mockIsPermittedCached.mockResolvedValue(false);
|
|
509
|
+
|
|
510
|
+
const { result } = renderHook(() =>
|
|
511
|
+
useCan(mockUserId, mockScope, mockPermission, mockPageId, true)
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
await waitFor(() => {
|
|
515
|
+
expect(result.current.isLoading).toBe(false);
|
|
516
|
+
expect(result.current.can).toBe(false);
|
|
517
|
+
expect(result.current.error).toBeNull();
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it('handles permission check timeout gracefully', async () => {
|
|
522
|
+
// Mock a slow API response
|
|
523
|
+
mockIsPermitted.mockImplementation(() =>
|
|
524
|
+
new Promise((resolve) => setTimeout(() => resolve(false), 1000))
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
const { result } = renderHook(() =>
|
|
528
|
+
useCan(mockUserId, mockScope, mockPermission, undefined, false)
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
// Should show loading initially
|
|
532
|
+
expect(result.current.isLoading).toBe(true);
|
|
533
|
+
expect(result.current.can).toBe(false);
|
|
534
|
+
|
|
535
|
+
await waitFor(() => {
|
|
536
|
+
expect(result.current.isLoading).toBe(false);
|
|
537
|
+
expect(result.current.can).toBe(false);
|
|
538
|
+
}, { timeout: 2000 });
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
it('handles network error with graceful degradation', async () => {
|
|
542
|
+
const networkError = new Error('Network error');
|
|
543
|
+
mockIsPermitted.mockRejectedValue(networkError);
|
|
544
|
+
|
|
545
|
+
const { result } = renderHook(() =>
|
|
546
|
+
useCan(mockUserId, mockScope, mockPermission, undefined, false)
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
await waitFor(() => {
|
|
550
|
+
expect(result.current.isLoading).toBe(false);
|
|
551
|
+
expect(result.current.can).toBe(false);
|
|
552
|
+
expect(result.current.error).toEqual(networkError);
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
|
|
356
557
|
describe('Edge Cases', () => {
|
|
357
558
|
it('handles empty userId', async () => {
|
|
358
559
|
mockIsPermitted.mockResolvedValue(false);
|
|
@@ -399,6 +600,58 @@ describe('useCan Hook', () => {
|
|
|
399
600
|
expect(mockIsPermitted).not.toHaveBeenCalled();
|
|
400
601
|
}, { timeout: 20000 });
|
|
401
602
|
});
|
|
603
|
+
|
|
604
|
+
it('handles null userId', async () => {
|
|
605
|
+
const { result } = renderHook(() =>
|
|
606
|
+
useCan(null as any, mockScope, mockPermission, undefined, false)
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
await waitFor(() => {
|
|
610
|
+
expect(result.current.isLoading).toBe(false);
|
|
611
|
+
expect(result.current.can).toBe(false);
|
|
612
|
+
expect(mockIsPermitted).not.toHaveBeenCalled();
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
it('handles undefined userId', async () => {
|
|
617
|
+
const { result } = renderHook(() =>
|
|
618
|
+
useCan(undefined as any, mockScope, mockPermission, undefined, false)
|
|
619
|
+
);
|
|
620
|
+
|
|
621
|
+
await waitFor(() => {
|
|
622
|
+
expect(result.current.isLoading).toBe(false);
|
|
623
|
+
expect(result.current.can).toBe(false);
|
|
624
|
+
expect(mockIsPermitted).not.toHaveBeenCalled();
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
it('handles scope with empty organisationId', async () => {
|
|
629
|
+
const invalidScope = { organisationId: '', eventId: 'event-123' };
|
|
630
|
+
|
|
631
|
+
const { result } = renderHook(() =>
|
|
632
|
+
useCan(mockUserId, invalidScope, mockPermission, undefined, false)
|
|
633
|
+
);
|
|
634
|
+
|
|
635
|
+
await waitFor(() => {
|
|
636
|
+
expect(result.current.isLoading).toBe(true);
|
|
637
|
+
expect(result.current.can).toBe(false);
|
|
638
|
+
expect(mockIsPermitted).not.toHaveBeenCalled();
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
it('handles scope with whitespace-only organisationId', async () => {
|
|
643
|
+
const invalidScope = { organisationId: ' ', eventId: 'event-123' };
|
|
644
|
+
|
|
645
|
+
const { result } = renderHook(() =>
|
|
646
|
+
useCan(mockUserId, invalidScope, mockPermission, undefined, false)
|
|
647
|
+
);
|
|
648
|
+
|
|
649
|
+
await waitFor(() => {
|
|
650
|
+
expect(result.current.isLoading).toBe(true);
|
|
651
|
+
expect(result.current.can).toBe(false);
|
|
652
|
+
expect(mockIsPermitted).not.toHaveBeenCalled();
|
|
653
|
+
});
|
|
654
|
+
});
|
|
402
655
|
});
|
|
403
656
|
|
|
404
657
|
describe('Performance', () => {
|