@jmruthers/pace-core 0.5.54 → 0.5.55
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/README.md +0 -4
- package/dist/{DataTable-7FMFXA7A.js → DataTable-4T627QFJ.js} +11 -11
- package/dist/{PublicLoadingSpinner-Bq_-BeK-.d.ts → PublicLoadingSpinner-SL8WaQN7.d.ts} +2 -21
- package/dist/{api-H5A3H4IR.js → api-LUNF5O6M.js} +3 -3
- package/dist/{appConfig-BVGyuvI7.d.ts → appConfig-DjpeG6P-.d.ts} +9 -1
- package/dist/{appNameResolver-7GHF5ED2.js → appNameResolver-UURKN7NF.js} +2 -2
- package/dist/{audit-BUW3LMJB.js → audit-6TOCAMKO.js} +2 -2
- package/dist/{chunk-MZBUOP4P.js → chunk-5BSLGBYI.js} +4 -3
- package/dist/chunk-5BSLGBYI.js.map +1 -0
- package/dist/{chunk-I5Z3QH5X.js → chunk-66C4BSAY.js} +2 -2
- package/dist/{chunk-I5Z3QH5X.js.map → chunk-66C4BSAY.js.map} +1 -1
- package/dist/{chunk-MYP2EGHX.js → chunk-AJ2KMES7.js} +21 -14
- package/dist/chunk-AJ2KMES7.js.map +1 -0
- package/dist/{chunk-EL2O4IUX.js → chunk-AQFRLC7K.js} +16 -24
- package/dist/{chunk-EL2O4IUX.js.map → chunk-AQFRLC7K.js.map} +1 -1
- package/dist/{chunk-7BNPOCLL.js → chunk-B2WTCLCV.js} +6 -2
- package/dist/chunk-B2WTCLCV.js.map +1 -0
- package/dist/{chunk-WJARTBCT.js → chunk-D7ARGIA3.js} +16 -7
- package/dist/chunk-D7ARGIA3.js.map +1 -0
- package/dist/{chunk-NRK4AIHQ.js → chunk-KBRACSJI.js} +3 -3
- package/dist/{chunk-NYUJ4FJR.js → chunk-KJDPSM64.js} +7 -7
- package/dist/chunk-KJDPSM64.js.map +1 -0
- package/dist/{chunk-GWSBHC4J.js → chunk-KLPVOPRI.js} +261 -38
- package/dist/chunk-KLPVOPRI.js.map +1 -0
- package/dist/{chunk-TRIZ7IB7.js → chunk-MPQDF75X.js} +148 -288
- package/dist/chunk-MPQDF75X.js.map +1 -0
- package/dist/{chunk-MSFACPQQ.js → chunk-PAEM3OWN.js} +11 -11
- package/dist/{chunk-MSFACPQQ.js.map → chunk-PAEM3OWN.js.map} +1 -1
- package/dist/{chunk-GIO7BFE7.js → chunk-RQD3D2CO.js} +66 -169
- package/dist/{chunk-GIO7BFE7.js.map → chunk-RQD3D2CO.js.map} +1 -1
- package/dist/{chunk-YDJW5XTN.js → chunk-STT7INZR.js} +25 -1
- package/dist/chunk-STT7INZR.js.map +1 -0
- package/dist/{chunk-6MTY77WU.js → chunk-TNMXZLDR.js} +3 -3
- package/dist/{chunk-BC3S53OZ.js → chunk-UQE2Y64H.js} +30 -14
- package/dist/chunk-UQE2Y64H.js.map +1 -0
- package/dist/{chunk-22KLBHPS.js → chunk-W66AZIOH.js} +2 -2
- package/dist/chunk-W66AZIOH.js.map +1 -0
- package/dist/{chunk-SS3E6QLB.js → chunk-YNUBMSMV.js} +2 -2
- package/dist/chunk-YNUBMSMV.js.map +1 -0
- package/dist/{chunk-NZ655MWE.js → chunk-ZOD2ZY6X.js} +5 -4
- package/dist/chunk-ZOD2ZY6X.js.map +1 -0
- package/dist/{chunk-74C6SNEC.js → chunk-ZPK5656W.js} +3 -3
- package/dist/{chunk-74C6SNEC.js.map → chunk-ZPK5656W.js.map} +1 -1
- package/dist/components.d.ts +22 -899
- package/dist/components.js +436 -3118
- package/dist/components.js.map +1 -1
- package/dist/file-reference-9xUOnwyt.d.ts +70 -0
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +10 -10
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +49 -9
- package/dist/index.js +190 -25
- package/dist/index.js.map +1 -1
- package/dist/{organisation-CO3Sh3_D.d.ts → organisation-t-vvQC3g.d.ts} +1 -8
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +5 -5
- package/dist/rbac/index.d.ts +65 -46
- package/dist/rbac/index.js +10 -12
- package/dist/styles/core.css +0 -125
- package/dist/types.d.ts +2 -1
- package/dist/types.js +3 -1
- package/dist/types.js.map +1 -1
- package/dist/{usePublicRouteParams-B2OcAsur.d.ts → usePublicRouteParams-CdoFxnJK.d.ts} +1 -1
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +44 -13
- package/dist/utils.js.map +1 -1
- package/docs/FILE_REFERENCE_SYSTEM.md +440 -0
- package/docs/INDEX.md +7 -5
- package/docs/README.md +0 -1
- package/docs/api/README.md +0 -4
- 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 +2 -2
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +12 -12
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +6 -6
- 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 +281 -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 +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/EventProviderProps.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- 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 +2 -2
- 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 +4 -4
- 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 +1 -1
- 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 +2 -2
- package/docs/api/interfaces/RouteConfig.md +2 -2
- 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/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 +204 -200
- package/docs/api-reference/components.md +141 -163
- package/docs/api-reference/hooks.md +347 -0
- package/docs/core-concepts/rbac-system.md +69 -16
- package/docs/getting-started/examples/basic-auth-app.md +0 -1
- package/docs/implementation-guides/datatable-rbac-usage.md +12 -11
- package/docs/implementation-guides/file-upload-storage.md +733 -0
- package/docs/implementation-guides/inactivity-tracking.md +779 -0
- package/docs/implementation-guides/organisation-security.md +748 -0
- package/docs/implementation-guides/public-pages-advanced.md +1022 -0
- package/docs/migration/MIGRATION_GUIDE.md +684 -0
- package/docs/migration/README.md +13 -2
- package/docs/migration/rbac-migration.md +73 -0
- package/docs/rbac/examples/rbac-rls-integration-example.md +11 -13
- package/docs/style-guide.md +269 -1
- package/package.json +1 -1
- package/src/__tests__/TESTING_GUIDELINES.md +331 -18
- package/src/__tests__/helpers/supabaseMock.ts +99 -0
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +10 -7
- package/src/__tests__/shared.ts +6 -0
- package/src/components/DataTable/components/ActionButtons.tsx +2 -2
- package/src/components/DataTable/components/DataTableCore.tsx +2 -2
- package/src/components/DataTable/components/UnifiedTableBody.tsx +1 -1
- package/src/components/DataTable/utils/debugTools.ts +2 -2
- package/src/components/Dialog/Dialog.test.tsx +12 -2
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +6 -6
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +2 -2
- package/src/components/FileDisplay.tsx +233 -0
- package/src/components/FileUpload.tsx +176 -0
- package/src/components/Footer/Footer.test.tsx +7 -7
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +13 -6
- package/src/components/OrganisationSelector/OrganisationSelector.test.tsx +30 -3
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +1 -1
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +558 -0
- package/src/components/PublicLayout/PublicErrorBoundary.tsx +1 -1
- package/src/components/PublicLayout/PublicPageDebugger.tsx +2 -2
- package/src/components/PublicLayout/PublicPageDiagnostic.tsx +2 -2
- package/src/components/PublicLayout/PublicPageProvider.tsx +2 -2
- package/src/components/Select/Select.test.tsx +50 -15
- package/src/components/SuperAdminGuard.tsx +2 -2
- package/src/components/__tests__/SuperAdminGuard.test.tsx +559 -0
- package/src/components/index.ts +0 -183
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +2 -2
- package/src/hooks/__tests__/usePermissionCache.unit.test.ts +1 -1
- package/src/hooks/__tests__/useRBAC.unit.test.ts +191 -138
- package/src/hooks/public/usePublicEvent.ts +2 -2
- package/src/hooks/useAppConfig.ts +3 -3
- package/src/hooks/useComponentPerformance.ts +1 -1
- package/src/hooks/useDataTablePerformance.ts +1 -1
- package/src/hooks/useFileReference.ts +232 -0
- package/src/hooks/useOrganisationPermissions.test.ts +254 -344
- package/src/hooks/useOrganisationPermissions.ts +15 -7
- package/src/hooks/useOrganisationSecurity.test.ts +390 -402
- package/src/hooks/usePerformanceMonitor.ts +1 -1
- package/src/hooks/usePermissionCache.test.ts +264 -395
- package/src/hooks/usePermissionCache.ts +34 -4
- package/src/hooks/useSecureDataAccess.test.ts +486 -0
- package/src/hooks/useSecureDataAccess.ts +4 -1
- package/src/providers/InactivityProvider.tsx +2 -2
- package/src/providers/OrganisationProvider.test.simple.tsx +168 -0
- package/src/providers/OrganisationProvider.test.tsx +168 -0
- package/src/providers/OrganisationProvider.tsx +18 -31
- package/src/providers/UnifiedAuthProvider.test.simple.tsx +205 -0
- package/src/providers/UnifiedAuthProvider.test.tsx +128 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +3 -4
- package/src/providers/__tests__/OrganisationProvider.test.tsx +19 -14
- package/src/rbac/__tests__/integration.authflow.test.tsx +123 -0
- package/src/rbac/__tests__/integration.navigation.test.tsx +72 -0
- package/src/rbac/__tests__/integration.securedata.test.tsx +92 -0
- package/src/rbac/__tests__/integration.smoke.test.tsx +73 -0
- package/src/rbac/__tests__/rbac-core.test.tsx +26 -22
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +411 -0
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +285 -0
- package/src/rbac/__tests__/rbac-functions.test.ts +655 -0
- package/src/rbac/__tests__/rbac-integration.test.ts +532 -0
- package/src/rbac/__tests__/scenarios.user-role.test.tsx +196 -0
- package/src/rbac/api.test.ts +6 -6
- package/src/rbac/api.ts +2 -2
- package/src/rbac/audit.test.ts +485 -0
- package/src/rbac/audit.ts +7 -1
- package/src/rbac/cache-invalidation.ts +318 -0
- package/src/rbac/cache.test.ts +286 -0
- package/src/rbac/components/EnhancedNavigationMenu.test.tsx +559 -0
- package/src/rbac/components/EnhancedNavigationMenu.tsx +29 -23
- package/src/rbac/components/NavigationProvider.test.tsx +449 -0
- package/src/rbac/components/PagePermissionGuard.tsx +4 -4
- package/src/rbac/components/PagePermissionProvider.test.tsx +479 -0
- package/src/rbac/components/SecureDataProvider.test.tsx +511 -0
- package/src/rbac/components/__tests__/PagePermissionGuard.race-condition.test.tsx +159 -430
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +4 -5
- package/src/rbac/components/__tests__/PagePermissionGuard.verification.test.tsx +112 -118
- package/src/rbac/config.test.ts +410 -0
- package/src/rbac/engine.test.simple.ts +237 -0
- package/src/rbac/engine.test.ts +233 -0
- package/src/rbac/engine.ts +37 -41
- package/src/rbac/examples/CompleteRBACExample.tsx +3 -3
- package/src/rbac/examples/EventBasedApp.tsx +4 -4
- package/src/rbac/hooks/useRBAC.simple.test.ts +16 -0
- package/src/rbac/hooks/useRBAC.test.ts +207 -455
- package/src/rbac/hooks/useRBAC.ts +30 -22
- package/src/rbac/permissions.test.ts +128 -0
- package/src/rbac/permissions.ts +56 -141
- package/src/rbac/providers/RBACProvider.tsx +1 -1
- package/src/rbac/secureClient.test.ts +444 -0
- package/src/rbac/security.test.ts +390 -0
- package/src/rbac/security.ts +1 -1
- package/src/rbac/types.test.ts +382 -0
- package/src/rbac/types.ts +2 -2
- package/src/styles/core.css +0 -125
- package/src/types/file-reference.ts +77 -0
- package/src/types/rbac-functions.ts +290 -0
- package/src/types/supabase.ts +10 -28
- package/src/types/unified.ts +4 -1
- package/src/utils/__tests__/bundleAnalysis.unit.test.ts +81 -55
- package/src/utils/__tests__/lazyLoad.unit.test.tsx +21 -12
- package/src/utils/__tests__/organisationContext.unit.test.ts +13 -7
- package/src/utils/__tests__/performanceBudgets.unit.test.ts +3 -3
- package/src/utils/__tests__/sessionTracking.unit.test.ts +32 -12
- package/src/utils/appConfig.ts +1 -1
- package/src/utils/appIdResolver.test.ts +503 -0
- package/src/utils/appIdResolver.ts +1 -1
- package/src/utils/appNameResolver.test.ts +494 -0
- package/src/utils/appNameResolver.ts +3 -2
- package/src/utils/bundleAnalysis.ts +3 -3
- package/src/utils/debugLogger.ts +1 -1
- package/src/utils/file-reference.ts +263 -0
- package/src/utils/formatDate.test.ts +2 -2
- package/src/utils/organisationContext.test.ts +340 -0
- package/src/utils/organisationContext.ts +19 -6
- package/src/utils/performanceBudgets.ts +2 -2
- package/src/utils/permissionUtils.test.ts +393 -0
- package/src/utils/permissionUtils.ts +5 -2
- package/src/utils/secureDataAccess.test.ts +715 -0
- package/src/utils/secureDataAccess.ts +21 -5
- package/src/utils/sessionTracking.ts +34 -4
- package/src/utils/storage/__tests__/helpers.unit.test.ts +328 -0
- package/src/utils/storage/__tests__/index.unit.test.ts +16 -0
- package/src/utils/storage/helpers.ts +20 -25
- package/src/utils/storage/index.ts +29 -1
- package/src/vite-env.d.ts +17 -0
- package/dist/chunk-22KLBHPS.js.map +0 -1
- package/dist/chunk-7BNPOCLL.js.map +0 -1
- package/dist/chunk-BC3S53OZ.js.map +0 -1
- package/dist/chunk-GWSBHC4J.js.map +0 -1
- package/dist/chunk-MYP2EGHX.js.map +0 -1
- package/dist/chunk-MZBUOP4P.js.map +0 -1
- package/dist/chunk-NYUJ4FJR.js.map +0 -1
- package/dist/chunk-NZ655MWE.js.map +0 -1
- package/dist/chunk-SS3E6QLB.js.map +0 -1
- package/dist/chunk-TRIZ7IB7.js.map +0 -1
- package/dist/chunk-WJARTBCT.js.map +0 -1
- package/dist/chunk-YDJW5XTN.js.map +0 -1
- package/docs/print-components/README.md +0 -258
- package/docs/print-components/api-reference.md +0 -636
- package/docs/print-components/examples/README.md +0 -204
- package/docs/print-components/examples/basic-report.tsx +0 -92
- package/docs/print-components/examples/card-catalog.tsx +0 -149
- package/docs/print-components/examples/cover-page-report.tsx +0 -163
- package/docs/print-components/quick-start.md +0 -363
- package/src/components/PrintButton/PrintButton.tsx +0 -321
- package/src/components/PrintButton/PrintButtonGroup.tsx +0 -84
- package/src/components/PrintButton/PrintToolbar.tsx +0 -94
- package/src/components/PrintButton/__tests__/PrintButton.test.tsx +0 -271
- package/src/components/PrintButton/examples/PrintButtonShowcase.tsx +0 -438
- package/src/components/PrintButton/index.ts +0 -33
- package/src/components/PrintButton/types.ts +0 -173
- package/src/components/PrintCard/PrintCard.tsx +0 -154
- package/src/components/PrintCard/PrintCardContent.tsx +0 -57
- package/src/components/PrintCard/PrintCardFooter.tsx +0 -60
- package/src/components/PrintCard/PrintCardGrid.tsx +0 -91
- package/src/components/PrintCard/PrintCardHeader.tsx +0 -78
- package/src/components/PrintCard/PrintCardImage.tsx +0 -81
- package/src/components/PrintCard/examples/PrintCardShowcase.tsx +0 -239
- package/src/components/PrintCard/index.ts +0 -34
- package/src/components/PrintCard/types.ts +0 -171
- package/src/components/PrintDataTable/PrintDataTable.tsx +0 -215
- package/src/components/PrintDataTable/PrintTableGroup.tsx +0 -90
- package/src/components/PrintDataTable/PrintTableRow.tsx +0 -76
- package/src/components/PrintDataTable/index.ts +0 -25
- package/src/components/PrintDataTable/types.ts +0 -67
- package/src/components/PrintFooter/PrintFooter.tsx +0 -183
- package/src/components/PrintFooter/PrintFooterContent.tsx +0 -71
- package/src/components/PrintFooter/PrintFooterInfo.tsx +0 -86
- package/src/components/PrintFooter/PrintPageNumber.tsx +0 -90
- package/src/components/PrintFooter/examples/PrintFooterShowcase.tsx +0 -390
- package/src/components/PrintFooter/index.ts +0 -30
- package/src/components/PrintFooter/types.ts +0 -149
- package/src/components/PrintGrid/PrintGrid.tsx +0 -180
- package/src/components/PrintGrid/PrintGridBreakpoint.tsx +0 -109
- package/src/components/PrintGrid/PrintGridContainer.tsx +0 -128
- package/src/components/PrintGrid/PrintGridItem.tsx +0 -220
- package/src/components/PrintGrid/examples/PrintGridShowcase.tsx +0 -359
- package/src/components/PrintGrid/index.ts +0 -31
- package/src/components/PrintGrid/types.ts +0 -159
- package/src/components/PrintHeader/PrintCoverHeader.tsx +0 -230
- package/src/components/PrintHeader/PrintHeader.tsx +0 -150
- package/src/components/PrintHeader/index.ts +0 -17
- package/src/components/PrintHeader/types.ts +0 -42
- package/src/components/PrintLayout/PrintLayout.tsx +0 -122
- package/src/components/PrintLayout/PrintLayoutContext.tsx +0 -66
- package/src/components/PrintLayout/PrintPageBreak.tsx +0 -52
- package/src/components/PrintLayout/examples/PrintShowcase.tsx +0 -230
- package/src/components/PrintLayout/index.ts +0 -19
- package/src/components/PrintLayout/types.ts +0 -37
- package/src/components/PrintPageBreak/PrintPageBreak.tsx +0 -120
- package/src/components/PrintPageBreak/PrintPageBreakGroup.tsx +0 -90
- package/src/components/PrintPageBreak/PrintPageBreakIndicator.tsx +0 -112
- package/src/components/PrintPageBreak/examples/PrintPageBreakShowcase.tsx +0 -279
- package/src/components/PrintPageBreak/index.ts +0 -23
- package/src/components/PrintPageBreak/types.ts +0 -94
- package/src/components/PrintSection/PrintColumn.tsx +0 -104
- package/src/components/PrintSection/PrintDivider.tsx +0 -101
- package/src/components/PrintSection/PrintSection.tsx +0 -129
- package/src/components/PrintSection/PrintSectionContent.tsx +0 -75
- package/src/components/PrintSection/PrintSectionHeader.tsx +0 -97
- package/src/components/PrintSection/examples/PrintSectionShowcase.tsx +0 -258
- package/src/components/PrintSection/index.ts +0 -33
- package/src/components/PrintSection/types.ts +0 -155
- package/src/components/PrintText/PrintText.tsx +0 -116
- package/src/components/PrintText/index.ts +0 -16
- package/src/components/PrintText/types.ts +0 -24
- package/src/rbac/__tests__/integration.test.tsx +0 -218
- package/src/utils/print/PrintDataProcessor.ts +0 -390
- package/src/utils/print/examples/PrintUtilitiesShowcase.tsx +0 -397
- package/src/utils/print/index.ts +0 -29
- package/src/utils/print/types.ts +0 -196
- package/src/utils/print/usePrintOptimization.ts +0 -272
- /package/dist/{DataTable-7FMFXA7A.js.map → DataTable-4T627QFJ.js.map} +0 -0
- /package/dist/{api-H5A3H4IR.js.map → api-LUNF5O6M.js.map} +0 -0
- /package/dist/{appNameResolver-7GHF5ED2.js.map → appNameResolver-UURKN7NF.js.map} +0 -0
- /package/dist/{audit-BUW3LMJB.js.map → audit-6TOCAMKO.js.map} +0 -0
- /package/dist/{chunk-NRK4AIHQ.js.map → chunk-KBRACSJI.js.map} +0 -0
- /package/dist/{chunk-6MTY77WU.js.map → chunk-TNMXZLDR.js.map} +0 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PaceAppLayout RBAC Tests
|
|
3
|
+
* @package @jmruthers/pace-core
|
|
4
|
+
* @module Components/PaceAppLayout
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*
|
|
7
|
+
* Comprehensive tests for PaceAppLayout RBAC functionality and permission enforcement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
11
|
+
import { render, screen, waitFor, act } from '@testing-library/react';
|
|
12
|
+
import userEvent from '@testing-library/user-event';
|
|
13
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
14
|
+
import { createMemoryRouter, RouterProvider, MemoryRouter } from 'react-router-dom';
|
|
15
|
+
import { PaceAppLayout } from '../PaceAppLayout';
|
|
16
|
+
import { UnifiedAuthProvider } from '../../../providers/UnifiedAuthProvider';
|
|
17
|
+
import { RBACProvider } from '../../../rbac/providers/RBACProvider';
|
|
18
|
+
import { OrganisationProvider } from '../../../providers/OrganisationProvider';
|
|
19
|
+
import { useUnifiedAuth } from '../../../providers/UnifiedAuthProvider';
|
|
20
|
+
import { useRBAC } from '../../../rbac/hooks/useRBAC';
|
|
21
|
+
import { isPermitted } from '../../../rbac/api';
|
|
22
|
+
import { isSuperAdmin } from '../../../rbac/api';
|
|
23
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
24
|
+
import type { User } from '@supabase/supabase-js';
|
|
25
|
+
import type { Organisation } from '../../../types/organisation';
|
|
26
|
+
import type { Permission } from '../../../rbac/types/permission';
|
|
27
|
+
import type { AccessLevel } from '../../../rbac/types/access';
|
|
28
|
+
|
|
29
|
+
// Mock Supabase client
|
|
30
|
+
const mockSupabaseClient = {
|
|
31
|
+
auth: {
|
|
32
|
+
getUser: vi.fn(),
|
|
33
|
+
signIn: vi.fn(),
|
|
34
|
+
signOut: vi.fn(),
|
|
35
|
+
onAuthStateChange: vi.fn(),
|
|
36
|
+
},
|
|
37
|
+
from: vi.fn(),
|
|
38
|
+
rpc: vi.fn(),
|
|
39
|
+
} as unknown as SupabaseClient;
|
|
40
|
+
|
|
41
|
+
// Mock RBAC API functions
|
|
42
|
+
vi.mock('../../../rbac/api', () => ({
|
|
43
|
+
isPermitted: vi.fn(),
|
|
44
|
+
isSuperAdmin: vi.fn(),
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
// Mock useUnifiedAuth hook
|
|
48
|
+
const mockUseUnifiedAuth = vi.fn();
|
|
49
|
+
vi.mock('../../../providers/UnifiedAuthProvider', () => ({
|
|
50
|
+
useUnifiedAuth: () => mockUseUnifiedAuth(),
|
|
51
|
+
UnifiedAuthProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
// Mock useRBAC hook
|
|
55
|
+
const mockUseRBAC = vi.fn();
|
|
56
|
+
vi.mock('../../../rbac/hooks/useRBAC', () => ({
|
|
57
|
+
useRBAC: () => mockUseRBAC(),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
// Mock OrganisationProvider
|
|
61
|
+
vi.mock('../../../providers/OrganisationProvider', () => ({
|
|
62
|
+
OrganisationProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
// Mock RBACProvider
|
|
66
|
+
vi.mock('../../../rbac/providers/RBACProvider', () => ({
|
|
67
|
+
RBACProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
// Test data
|
|
71
|
+
const mockUser: User = {
|
|
72
|
+
id: 'user-123',
|
|
73
|
+
email: 'test@example.com',
|
|
74
|
+
created_at: '2023-01-01T00:00:00Z',
|
|
75
|
+
updated_at: '2023-01-01T00:00:00Z',
|
|
76
|
+
aud: 'authenticated',
|
|
77
|
+
role: 'authenticated',
|
|
78
|
+
app_metadata: {
|
|
79
|
+
organisationId: 'org-123',
|
|
80
|
+
eventId: 'event-123',
|
|
81
|
+
appId: 'app-123',
|
|
82
|
+
},
|
|
83
|
+
user_metadata: {
|
|
84
|
+
organisationId: 'org-123',
|
|
85
|
+
eventId: 'event-123',
|
|
86
|
+
appId: 'app-123',
|
|
87
|
+
},
|
|
88
|
+
identities: [],
|
|
89
|
+
factors: [],
|
|
90
|
+
} as User;
|
|
91
|
+
|
|
92
|
+
const mockOrganisation: Organisation = {
|
|
93
|
+
id: 'org-123',
|
|
94
|
+
name: 'Test Organisation',
|
|
95
|
+
slug: 'test-org',
|
|
96
|
+
createdAt: '2023-01-01T00:00:00Z',
|
|
97
|
+
updatedAt: '2023-01-01T00:00:00Z',
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Test components
|
|
101
|
+
const TestPage = () => <div>Test Page Content</div>;
|
|
102
|
+
const AccessDeniedPage = () => <div>Access Denied</div>;
|
|
103
|
+
const LoadingPage = () => <div>Loading...</div>;
|
|
104
|
+
|
|
105
|
+
// Test wrapper
|
|
106
|
+
const TestWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
107
|
+
const queryClient = new QueryClient({
|
|
108
|
+
defaultOptions: {
|
|
109
|
+
queries: { retry: false },
|
|
110
|
+
mutations: { retry: false },
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<QueryClientProvider client={queryClient}>
|
|
116
|
+
<UnifiedAuthProvider supabaseClient={mockSupabaseClient} appName="Test App">
|
|
117
|
+
<RBACProvider>
|
|
118
|
+
<OrganisationProvider>
|
|
119
|
+
{children}
|
|
120
|
+
</OrganisationProvider>
|
|
121
|
+
</RBACProvider>
|
|
122
|
+
</UnifiedAuthProvider>
|
|
123
|
+
</QueryClientProvider>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
describe('PaceAppLayout RBAC Tests', () => {
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
vi.clearAllMocks();
|
|
130
|
+
|
|
131
|
+
// Setup default mocks
|
|
132
|
+
mockUseUnifiedAuth.mockReturnValue({
|
|
133
|
+
user: mockUser,
|
|
134
|
+
session: { user: mockUser },
|
|
135
|
+
isLoading: false,
|
|
136
|
+
error: null,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
mockUseRBAC.mockReturnValue({
|
|
140
|
+
hasPermission: vi.fn().mockResolvedValue(true),
|
|
141
|
+
isSuperAdmin: vi.fn().mockResolvedValue(false),
|
|
142
|
+
isLoading: false,
|
|
143
|
+
error: null,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Mock isPermitted to always return true
|
|
147
|
+
(isPermitted as any).mockImplementation(async (input) => {
|
|
148
|
+
console.log('isPermitted called with:', input);
|
|
149
|
+
return true;
|
|
150
|
+
});
|
|
151
|
+
(isSuperAdmin as any).mockResolvedValue(false);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
afterEach(() => {
|
|
155
|
+
vi.restoreAllMocks();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('Basic Rendering', () => {
|
|
159
|
+
it('should render with basic configuration', async () => {
|
|
160
|
+
const router = createMemoryRouter([
|
|
161
|
+
{
|
|
162
|
+
path: '/',
|
|
163
|
+
element: (
|
|
164
|
+
<PaceAppLayout
|
|
165
|
+
appName="Test App"
|
|
166
|
+
enforcePermissions={true}
|
|
167
|
+
defaultPermission="read"
|
|
168
|
+
/>
|
|
169
|
+
),
|
|
170
|
+
children: [
|
|
171
|
+
{
|
|
172
|
+
index: true,
|
|
173
|
+
element: <TestPage />,
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
]);
|
|
178
|
+
|
|
179
|
+
render(
|
|
180
|
+
<TestWrapper>
|
|
181
|
+
<RouterProvider router={router} />
|
|
182
|
+
</TestWrapper>
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
await waitFor(() => {
|
|
186
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('should render without permission enforcement', async () => {
|
|
191
|
+
const router = createMemoryRouter([
|
|
192
|
+
{
|
|
193
|
+
path: '/',
|
|
194
|
+
element: (
|
|
195
|
+
<PaceAppLayout
|
|
196
|
+
appName="Test App"
|
|
197
|
+
enforcePermissions={false}
|
|
198
|
+
/>
|
|
199
|
+
),
|
|
200
|
+
children: [
|
|
201
|
+
{
|
|
202
|
+
index: true,
|
|
203
|
+
element: <TestPage />,
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
]);
|
|
208
|
+
|
|
209
|
+
render(
|
|
210
|
+
<TestWrapper>
|
|
211
|
+
<RouterProvider router={router} />
|
|
212
|
+
</TestWrapper>
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
await waitFor(() => {
|
|
216
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe('Permission Enforcement', () => {
|
|
222
|
+
it('should show access denied when permission is denied', async () => {
|
|
223
|
+
(isPermitted as any).mockResolvedValue(false);
|
|
224
|
+
|
|
225
|
+
const router = createMemoryRouter([
|
|
226
|
+
{
|
|
227
|
+
path: '/',
|
|
228
|
+
element: (
|
|
229
|
+
<PaceAppLayout
|
|
230
|
+
appName="Test App"
|
|
231
|
+
enforcePermissions={true}
|
|
232
|
+
defaultPermission="read"
|
|
233
|
+
/>
|
|
234
|
+
),
|
|
235
|
+
children: [
|
|
236
|
+
{
|
|
237
|
+
index: true,
|
|
238
|
+
element: <TestPage />,
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
]);
|
|
243
|
+
|
|
244
|
+
render(
|
|
245
|
+
<TestWrapper>
|
|
246
|
+
<RouterProvider router={router} />
|
|
247
|
+
</TestWrapper>
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
await waitFor(() => {
|
|
251
|
+
expect(screen.getByText("You don't have permission to access this page.")).toBeInTheDocument();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
expect(screen.queryByText('Test Page Content')).not.toBeInTheDocument();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should show custom fallback when permission is denied', async () => {
|
|
258
|
+
(isPermitted as any).mockResolvedValue(false);
|
|
259
|
+
|
|
260
|
+
const router = createMemoryRouter([
|
|
261
|
+
{
|
|
262
|
+
path: '/',
|
|
263
|
+
element: (
|
|
264
|
+
<PaceAppLayout
|
|
265
|
+
appName="Test App"
|
|
266
|
+
enforcePermissions={true}
|
|
267
|
+
defaultPermission="read"
|
|
268
|
+
permissionFallback={<AccessDeniedPage />}
|
|
269
|
+
/>
|
|
270
|
+
),
|
|
271
|
+
children: [
|
|
272
|
+
{
|
|
273
|
+
index: true,
|
|
274
|
+
element: <TestPage />,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
]);
|
|
279
|
+
|
|
280
|
+
render(
|
|
281
|
+
<TestWrapper>
|
|
282
|
+
<RouterProvider router={router} />
|
|
283
|
+
</TestWrapper>
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
await waitFor(() => {
|
|
287
|
+
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
expect(screen.queryByText('Test Page Content')).not.toBeInTheDocument();
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
describe('Route-Specific Permissions', () => {
|
|
295
|
+
it('should check route-specific permissions', async () => {
|
|
296
|
+
const router = createMemoryRouter([
|
|
297
|
+
{
|
|
298
|
+
path: '/',
|
|
299
|
+
element: (
|
|
300
|
+
<PaceAppLayout
|
|
301
|
+
appName="Test App"
|
|
302
|
+
enforcePermissions={true}
|
|
303
|
+
defaultPermission="read"
|
|
304
|
+
routePermissions={{
|
|
305
|
+
'/dashboard': 'write',
|
|
306
|
+
'/settings': 'delete',
|
|
307
|
+
}}
|
|
308
|
+
/>
|
|
309
|
+
),
|
|
310
|
+
children: [
|
|
311
|
+
{
|
|
312
|
+
index: true,
|
|
313
|
+
element: <TestPage />,
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
]);
|
|
318
|
+
|
|
319
|
+
render(
|
|
320
|
+
<TestWrapper>
|
|
321
|
+
<RouterProvider router={router} />
|
|
322
|
+
</TestWrapper>
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
await waitFor(() => {
|
|
326
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
expect(isPermitted).toHaveBeenCalledWith({
|
|
330
|
+
userId: 'user-123',
|
|
331
|
+
scope: {
|
|
332
|
+
organisationId: 'org-123',
|
|
333
|
+
eventId: 'event-123',
|
|
334
|
+
appId: 'app-123',
|
|
335
|
+
},
|
|
336
|
+
permission: 'read',
|
|
337
|
+
pageId: 'home',
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('should use custom page ID mapping', async () => {
|
|
342
|
+
const router = createMemoryRouter([
|
|
343
|
+
{
|
|
344
|
+
path: '/',
|
|
345
|
+
element: (
|
|
346
|
+
<PaceAppLayout
|
|
347
|
+
appName="Test App"
|
|
348
|
+
enforcePermissions={true}
|
|
349
|
+
defaultPermission="read"
|
|
350
|
+
pageIdMapping={{
|
|
351
|
+
'/': 'homepage',
|
|
352
|
+
'/dashboard': 'dashboard-page',
|
|
353
|
+
}}
|
|
354
|
+
/>
|
|
355
|
+
),
|
|
356
|
+
children: [
|
|
357
|
+
{
|
|
358
|
+
index: true,
|
|
359
|
+
element: <TestPage />,
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
]);
|
|
364
|
+
|
|
365
|
+
render(
|
|
366
|
+
<TestWrapper>
|
|
367
|
+
<RouterProvider router={router} />
|
|
368
|
+
</TestWrapper>
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
await waitFor(() => {
|
|
372
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(isPermitted).toHaveBeenCalledWith({
|
|
376
|
+
userId: 'user-123',
|
|
377
|
+
scope: {
|
|
378
|
+
organisationId: 'org-123',
|
|
379
|
+
eventId: 'event-123',
|
|
380
|
+
appId: 'app-123',
|
|
381
|
+
},
|
|
382
|
+
permission: 'read',
|
|
383
|
+
pageId: 'homepage',
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
describe('Loading States', () => {
|
|
389
|
+
it('should show loading state while checking permissions', async () => {
|
|
390
|
+
mockUseRBAC.mockReturnValue({
|
|
391
|
+
hasPermission: vi.fn().mockResolvedValue(true),
|
|
392
|
+
isSuperAdmin: vi.fn().mockResolvedValue(false),
|
|
393
|
+
isLoading: true,
|
|
394
|
+
error: null,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
const router = createMemoryRouter([
|
|
398
|
+
{
|
|
399
|
+
path: '/',
|
|
400
|
+
element: (
|
|
401
|
+
<PaceAppLayout
|
|
402
|
+
appName="Test App"
|
|
403
|
+
enforcePermissions={true}
|
|
404
|
+
defaultPermission="read"
|
|
405
|
+
/>
|
|
406
|
+
),
|
|
407
|
+
children: [
|
|
408
|
+
{
|
|
409
|
+
index: true,
|
|
410
|
+
element: <TestPage />,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
]);
|
|
415
|
+
|
|
416
|
+
render(
|
|
417
|
+
<TestWrapper>
|
|
418
|
+
<RouterProvider router={router} />
|
|
419
|
+
</TestWrapper>
|
|
420
|
+
);
|
|
421
|
+
|
|
422
|
+
await waitFor(() => {
|
|
423
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
describe('Audit Logging', () => {
|
|
429
|
+
it('should log page access when audit logging is enabled', async () => {
|
|
430
|
+
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
431
|
+
(isPermitted as any).mockResolvedValue(true);
|
|
432
|
+
|
|
433
|
+
const router = createMemoryRouter([
|
|
434
|
+
{
|
|
435
|
+
path: '/',
|
|
436
|
+
element: (
|
|
437
|
+
<PaceAppLayout
|
|
438
|
+
appName="Test App"
|
|
439
|
+
enforcePermissions={true}
|
|
440
|
+
defaultPermission="read"
|
|
441
|
+
auditLog={true}
|
|
442
|
+
/>
|
|
443
|
+
),
|
|
444
|
+
children: [
|
|
445
|
+
{
|
|
446
|
+
index: true,
|
|
447
|
+
element: <TestPage />,
|
|
448
|
+
},
|
|
449
|
+
],
|
|
450
|
+
},
|
|
451
|
+
]);
|
|
452
|
+
|
|
453
|
+
render(
|
|
454
|
+
<TestWrapper>
|
|
455
|
+
<RouterProvider router={router} />
|
|
456
|
+
</TestWrapper>
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
await waitFor(() => {
|
|
460
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
464
|
+
'[PaceAppLayout] Page access attempt:',
|
|
465
|
+
expect.objectContaining({
|
|
466
|
+
pageName: 'home',
|
|
467
|
+
operation: 'read',
|
|
468
|
+
userId: 'user-123',
|
|
469
|
+
allowed: true,
|
|
470
|
+
strictMode: true,
|
|
471
|
+
})
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
consoleSpy.mockRestore();
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('should not log when audit logging is disabled', async () => {
|
|
478
|
+
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
479
|
+
(isPermitted as any).mockResolvedValue(true);
|
|
480
|
+
|
|
481
|
+
const router = createMemoryRouter([
|
|
482
|
+
{
|
|
483
|
+
path: '/',
|
|
484
|
+
element: (
|
|
485
|
+
<PaceAppLayout
|
|
486
|
+
appName="Test App"
|
|
487
|
+
enforcePermissions={true}
|
|
488
|
+
defaultPermission="read"
|
|
489
|
+
auditLog={false}
|
|
490
|
+
/>
|
|
491
|
+
),
|
|
492
|
+
children: [
|
|
493
|
+
{
|
|
494
|
+
index: true,
|
|
495
|
+
element: <TestPage />,
|
|
496
|
+
},
|
|
497
|
+
],
|
|
498
|
+
},
|
|
499
|
+
]);
|
|
500
|
+
|
|
501
|
+
render(
|
|
502
|
+
<TestWrapper>
|
|
503
|
+
<RouterProvider router={router} />
|
|
504
|
+
</TestWrapper>
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
await waitFor(() => {
|
|
508
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
expect(consoleSpy).not.toHaveBeenCalledWith(
|
|
512
|
+
expect.stringContaining('[PaceAppLayout] Page access attempt:')
|
|
513
|
+
);
|
|
514
|
+
|
|
515
|
+
consoleSpy.mockRestore();
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
describe('Error Handling', () => {
|
|
520
|
+
it('should handle RBAC errors gracefully', async () => {
|
|
521
|
+
mockUseRBAC.mockReturnValue({
|
|
522
|
+
hasPermission: vi.fn().mockRejectedValue(new Error('RBAC Error')),
|
|
523
|
+
isSuperAdmin: vi.fn().mockResolvedValue(false),
|
|
524
|
+
isLoading: false,
|
|
525
|
+
error: new Error('RBAC Error'),
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
const router = createMemoryRouter([
|
|
529
|
+
{
|
|
530
|
+
path: '/',
|
|
531
|
+
element: (
|
|
532
|
+
<PaceAppLayout
|
|
533
|
+
appName="Test App"
|
|
534
|
+
enforcePermissions={true}
|
|
535
|
+
defaultPermission="read"
|
|
536
|
+
/>
|
|
537
|
+
),
|
|
538
|
+
children: [
|
|
539
|
+
{
|
|
540
|
+
index: true,
|
|
541
|
+
element: <TestPage />,
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
},
|
|
545
|
+
]);
|
|
546
|
+
|
|
547
|
+
render(
|
|
548
|
+
<TestWrapper>
|
|
549
|
+
<RouterProvider router={router} />
|
|
550
|
+
</TestWrapper>
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
await waitFor(() => {
|
|
554
|
+
expect(screen.getByText('Test Page Content')).toBeInTheDocument();
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|
|
@@ -97,7 +97,7 @@ export class PublicErrorBoundary extends Component<PublicErrorBoundaryProps, Pub
|
|
|
97
97
|
|
|
98
98
|
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
99
99
|
// Log the error to console in development
|
|
100
|
-
if (
|
|
100
|
+
if (import.meta.env.MODE === 'development') {
|
|
101
101
|
console.error('PublicErrorBoundary caught an error:', error, errorInfo);
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -70,8 +70,8 @@ export function PublicPageDebugger({ enabled = true, label = 'PublicPage' }: Pub
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// Check environment variables
|
|
73
|
-
const supabaseUrl = (import.meta as any).env?.VITE_SUPABASE_URL
|
|
74
|
-
const supabaseKey = (import.meta as any).env?.VITE_SUPABASE_ANON_KEY
|
|
73
|
+
const supabaseUrl = (import.meta as any).env?.VITE_SUPABASE_URL;
|
|
74
|
+
const supabaseKey = (import.meta as any).env?.VITE_SUPABASE_ANON_KEY;
|
|
75
75
|
|
|
76
76
|
console.log(`[${label}] Environment variables:`, {
|
|
77
77
|
supabaseUrl: supabaseUrl ? 'Present' : 'Missing',
|
|
@@ -87,8 +87,8 @@ export function PublicPageDiagnostic({ enabled = true, label = 'PublicPage' }: P
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// Check environment variables
|
|
90
|
-
const supabaseUrl = (import.meta as any).env?.VITE_SUPABASE_URL
|
|
91
|
-
const supabaseKey = (import.meta as any).env?.VITE_SUPABASE_ANON_KEY
|
|
90
|
+
const supabaseUrl = (import.meta as any).env?.VITE_SUPABASE_URL;
|
|
91
|
+
const supabaseKey = (import.meta as any).env?.VITE_SUPABASE_ANON_KEY;
|
|
92
92
|
newDiagnostics.hasEnvironmentVars = !!(supabaseUrl && supabaseKey);
|
|
93
93
|
|
|
94
94
|
// Check route parameters
|
|
@@ -70,8 +70,8 @@ export function PublicPageProvider({ children }: PublicPageProviderProps) {
|
|
|
70
70
|
return (import.meta as any).env[key];
|
|
71
71
|
}
|
|
72
72
|
// Check Node.js environment (server-side)
|
|
73
|
-
if (typeof
|
|
74
|
-
return
|
|
73
|
+
if (typeof import.meta !== 'undefined' && import.meta.env) {
|
|
74
|
+
return import.meta.env[key];
|
|
75
75
|
}
|
|
76
76
|
return undefined;
|
|
77
77
|
};
|