@jmruthers/pace-core 0.5.68 → 0.5.69
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-MPBSXUC6.js} +5 -6
- package/dist/{PublicLoadingSpinner-DdKXTkCZ.d.ts → PublicLoadingSpinner-BOdyU3u-.d.ts} +1 -1
- package/dist/{chunk-PXWEDX7Y.js → chunk-2ARQW6VX.js} +3 -3
- package/dist/{chunk-MOJXHWDE.js → chunk-6JILXFEA.js} +335 -5
- package/dist/chunk-6JILXFEA.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-ZMS23NS5.js → chunk-FJTAWPAQ.js} +3 -5
- package/dist/{chunk-ZMS23NS5.js.map → chunk-FJTAWPAQ.js.map} +1 -1
- package/dist/{chunk-OPCWH3A4.js → chunk-NO5QHMDX.js} +7 -6
- package/dist/chunk-NO5QHMDX.js.map +1 -0
- package/dist/{chunk-ZPK5656W.js → chunk-O3NWNXDY.js} +4 -5
- package/dist/chunk-O3NWNXDY.js.map +1 -0
- package/dist/{chunk-UYA6U6H7.js → chunk-Q2UP3ZWQ.js} +4 -4
- package/dist/{chunk-KRCRNXPD.js → chunk-RVYGJPOD.js} +79 -18
- package/dist/chunk-RVYGJPOD.js.map +1 -0
- package/dist/{chunk-NN45OBIS.js → chunk-UCMHBF7Y.js} +3 -5
- package/dist/{chunk-NN45OBIS.js.map → chunk-UCMHBF7Y.js.map} +1 -1
- package/dist/{chunk-ZPG4XPV5.js → chunk-V3QO3LL7.js} +5 -7
- package/dist/chunk-V3QO3LL7.js.map +1 -0
- package/dist/{chunk-U6GPOF6J.js → chunk-ZXJGZLLO.js} +17 -17
- package/dist/{chunk-U6GPOF6J.js.map → chunk-ZXJGZLLO.js.map} +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +8 -9
- 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 +3 -3
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/providers.js +5 -7
- package/dist/rbac/index.js +5 -6
- 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/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 +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 +39 -14
- 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 +1 -1
- 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 -5
- 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 +1 -0
- 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 +540 -0
- 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-OPCWH3A4.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/dist/{DataTable-4IUY7BXB.js.map → DataTable-MPBSXUC6.js.map} +0 -0
- /package/dist/{chunk-PXWEDX7Y.js.map → chunk-2ARQW6VX.js.map} +0 -0
- /package/dist/{chunk-UYA6U6H7.js.map → chunk-Q2UP3ZWQ.js.map} +0 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Debug Logger Tests
|
|
3
|
+
* @package @jmruthers/pace-core
|
|
4
|
+
* @module Utils/DebugLogger/Tests
|
|
5
|
+
* @since 0.4.76
|
|
6
|
+
*
|
|
7
|
+
* Comprehensive test suite for the DebugLogger utility covering:
|
|
8
|
+
* - Environment-based logging behavior
|
|
9
|
+
* - Console method calls
|
|
10
|
+
* - Message formatting
|
|
11
|
+
* - Error handling
|
|
12
|
+
* - Performance considerations
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
16
|
+
import { DebugLogger } from '../debugLogger';
|
|
17
|
+
|
|
18
|
+
describe('[unit] DebugLogger Tests', () => {
|
|
19
|
+
let originalConsoleLog: typeof console.log;
|
|
20
|
+
let originalConsoleError: typeof console.error;
|
|
21
|
+
let originalConsoleWarn: typeof console.warn;
|
|
22
|
+
let originalConsoleInfo: typeof console.info;
|
|
23
|
+
let originalEnvMode: string;
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
// Store original console methods
|
|
27
|
+
originalConsoleLog = console.log;
|
|
28
|
+
originalConsoleError = console.error;
|
|
29
|
+
originalConsoleWarn = console.warn;
|
|
30
|
+
originalConsoleInfo = console.info;
|
|
31
|
+
|
|
32
|
+
// Store original environment mode
|
|
33
|
+
originalEnvMode = import.meta.env.MODE;
|
|
34
|
+
|
|
35
|
+
// Mock console methods
|
|
36
|
+
console.log = vi.fn();
|
|
37
|
+
console.error = vi.fn();
|
|
38
|
+
console.warn = vi.fn();
|
|
39
|
+
console.info = vi.fn();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
// Restore original console methods
|
|
44
|
+
console.log = originalConsoleLog;
|
|
45
|
+
console.error = originalConsoleError;
|
|
46
|
+
console.warn = originalConsoleWarn;
|
|
47
|
+
console.info = originalConsoleInfo;
|
|
48
|
+
|
|
49
|
+
// Restore original environment mode
|
|
50
|
+
import.meta.env.MODE = originalEnvMode;
|
|
51
|
+
|
|
52
|
+
vi.clearAllMocks();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('Development Mode Logging', () => {
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
import.meta.env.MODE = 'development';
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should log debug messages in development mode', () => {
|
|
61
|
+
const component = 'TestComponent';
|
|
62
|
+
const message = 'Test debug message';
|
|
63
|
+
const args = ['arg1', 'arg2'];
|
|
64
|
+
|
|
65
|
+
DebugLogger.log(component, message, ...args);
|
|
66
|
+
|
|
67
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
68
|
+
`[${component}] ${message}`,
|
|
69
|
+
...args
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should log info messages in development mode', () => {
|
|
74
|
+
const component = 'TestComponent';
|
|
75
|
+
const message = 'Test info message';
|
|
76
|
+
const args = ['arg1', 'arg2'];
|
|
77
|
+
|
|
78
|
+
DebugLogger.info(component, message, ...args);
|
|
79
|
+
|
|
80
|
+
expect(console.info).toHaveBeenCalledWith(
|
|
81
|
+
`[${component}] ${message}`,
|
|
82
|
+
...args
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should always log error messages regardless of environment', () => {
|
|
87
|
+
const component = 'TestComponent';
|
|
88
|
+
const message = 'Test error message';
|
|
89
|
+
const args = ['arg1', 'arg2'];
|
|
90
|
+
|
|
91
|
+
DebugLogger.error(component, message, ...args);
|
|
92
|
+
|
|
93
|
+
expect(console.error).toHaveBeenCalledWith(
|
|
94
|
+
`[${component}] ${message}`,
|
|
95
|
+
...args
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should always log warning messages regardless of environment', () => {
|
|
100
|
+
const component = 'TestComponent';
|
|
101
|
+
const message = 'Test warning message';
|
|
102
|
+
const args = ['arg1', 'arg2'];
|
|
103
|
+
|
|
104
|
+
DebugLogger.warn(component, message, ...args);
|
|
105
|
+
|
|
106
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
107
|
+
`[${component}] ${message}`,
|
|
108
|
+
...args
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('Production Mode Logging', () => {
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
import.meta.env.MODE = 'production';
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should not log debug messages in production mode', () => {
|
|
119
|
+
const component = 'TestComponent';
|
|
120
|
+
const message = 'Test debug message';
|
|
121
|
+
const args = ['arg1', 'arg2'];
|
|
122
|
+
|
|
123
|
+
DebugLogger.log(component, message, ...args);
|
|
124
|
+
|
|
125
|
+
expect(console.log).not.toHaveBeenCalled();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should not log info messages in production mode', () => {
|
|
129
|
+
const component = 'TestComponent';
|
|
130
|
+
const message = 'Test info message';
|
|
131
|
+
const args = ['arg1', 'arg2'];
|
|
132
|
+
|
|
133
|
+
DebugLogger.info(component, message, ...args);
|
|
134
|
+
|
|
135
|
+
expect(console.info).not.toHaveBeenCalled();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should still log error messages in production mode', () => {
|
|
139
|
+
const component = 'TestComponent';
|
|
140
|
+
const message = 'Test error message';
|
|
141
|
+
const args = ['arg1', 'arg2'];
|
|
142
|
+
|
|
143
|
+
DebugLogger.error(component, message, ...args);
|
|
144
|
+
|
|
145
|
+
expect(console.error).toHaveBeenCalledWith(
|
|
146
|
+
`[${component}] ${message}`,
|
|
147
|
+
...args
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should still log warning messages in production mode', () => {
|
|
152
|
+
const component = 'TestComponent';
|
|
153
|
+
const message = 'Test warning message';
|
|
154
|
+
const args = ['arg1', 'arg2'];
|
|
155
|
+
|
|
156
|
+
DebugLogger.warn(component, message, ...args);
|
|
157
|
+
|
|
158
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
159
|
+
`[${component}] ${message}`,
|
|
160
|
+
...args
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('Message Formatting', () => {
|
|
166
|
+
beforeEach(() => {
|
|
167
|
+
import.meta.env.MODE = 'development';
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should format messages with component prefix', () => {
|
|
171
|
+
const component = 'AuthService';
|
|
172
|
+
const message = 'User authenticated successfully';
|
|
173
|
+
|
|
174
|
+
DebugLogger.log(component, message);
|
|
175
|
+
|
|
176
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
177
|
+
`[${component}] ${message}`
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should handle empty messages', () => {
|
|
182
|
+
const component = 'TestComponent';
|
|
183
|
+
const message = '';
|
|
184
|
+
|
|
185
|
+
DebugLogger.log(component, message);
|
|
186
|
+
|
|
187
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
188
|
+
`[${component}] `
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should handle special characters in messages', () => {
|
|
193
|
+
const component = 'TestComponent';
|
|
194
|
+
const message = 'Special chars: !@#$%^&*()_+-=[]{}|;:,.<>?';
|
|
195
|
+
|
|
196
|
+
DebugLogger.log(component, message);
|
|
197
|
+
|
|
198
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
199
|
+
`[${component}] ${message}`
|
|
200
|
+
);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('should handle Unicode characters in messages', () => {
|
|
204
|
+
const component = 'TestComponent';
|
|
205
|
+
const message = 'Unicode: 🚀 测试 日本語';
|
|
206
|
+
|
|
207
|
+
DebugLogger.log(component, message);
|
|
208
|
+
|
|
209
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
210
|
+
`[${component}] ${message}`
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
describe('Argument Handling', () => {
|
|
216
|
+
beforeEach(() => {
|
|
217
|
+
import.meta.env.MODE = 'development';
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should pass through additional arguments', () => {
|
|
221
|
+
const component = 'TestComponent';
|
|
222
|
+
const message = 'Test message';
|
|
223
|
+
const args = ['string', 123, true, { key: 'value' }, [1, 2, 3]];
|
|
224
|
+
|
|
225
|
+
DebugLogger.log(component, message, ...args);
|
|
226
|
+
|
|
227
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
228
|
+
`[${component}] ${message}`,
|
|
229
|
+
...args
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('should handle no additional arguments', () => {
|
|
234
|
+
const component = 'TestComponent';
|
|
235
|
+
const message = 'Test message';
|
|
236
|
+
|
|
237
|
+
DebugLogger.log(component, message);
|
|
238
|
+
|
|
239
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
240
|
+
`[${component}] ${message}`
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should handle undefined and null arguments', () => {
|
|
245
|
+
const component = 'TestComponent';
|
|
246
|
+
const message = 'Test message';
|
|
247
|
+
const args = [undefined, null];
|
|
248
|
+
|
|
249
|
+
DebugLogger.log(component, message, ...args);
|
|
250
|
+
|
|
251
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
252
|
+
`[${component}] ${message}`,
|
|
253
|
+
...args
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should handle circular reference objects', () => {
|
|
258
|
+
const component = 'TestComponent';
|
|
259
|
+
const message = 'Test message';
|
|
260
|
+
const circularObj: any = { name: 'test' };
|
|
261
|
+
circularObj.self = circularObj;
|
|
262
|
+
|
|
263
|
+
DebugLogger.log(component, message, circularObj);
|
|
264
|
+
|
|
265
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
266
|
+
`[${component}] ${message}`,
|
|
267
|
+
circularObj
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('Performance Considerations', () => {
|
|
273
|
+
beforeEach(() => {
|
|
274
|
+
import.meta.env.MODE = 'production';
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should not create unnecessary string concatenations in production', () => {
|
|
278
|
+
const component = 'TestComponent';
|
|
279
|
+
const message = 'Test message';
|
|
280
|
+
const args = ['arg1', 'arg2'];
|
|
281
|
+
|
|
282
|
+
// Mock console.log to track calls
|
|
283
|
+
const logSpy = vi.spyOn(console, 'log');
|
|
284
|
+
|
|
285
|
+
DebugLogger.log(component, message, ...args);
|
|
286
|
+
|
|
287
|
+
// In production, console.log should not be called
|
|
288
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('should handle high-frequency logging without performance issues', () => {
|
|
292
|
+
const component = 'TestComponent';
|
|
293
|
+
const message = 'High frequency message';
|
|
294
|
+
const iterations = 1000;
|
|
295
|
+
|
|
296
|
+
const startTime = Date.now();
|
|
297
|
+
|
|
298
|
+
for (let i = 0; i < iterations; i++) {
|
|
299
|
+
DebugLogger.log(component, `${message} ${i}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const endTime = Date.now();
|
|
303
|
+
const duration = endTime - startTime;
|
|
304
|
+
|
|
305
|
+
// Should complete quickly even with many calls
|
|
306
|
+
expect(duration).toBeLessThan(100); // Less than 100ms for 1000 calls
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
describe('Error Handling', () => {
|
|
311
|
+
beforeEach(() => {
|
|
312
|
+
import.meta.env.MODE = 'development';
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('should handle console method errors gracefully', () => {
|
|
316
|
+
const component = 'TestComponent';
|
|
317
|
+
const message = 'Test message';
|
|
318
|
+
|
|
319
|
+
// Mock console.log to throw an error
|
|
320
|
+
console.log = vi.fn().mockImplementation(() => {
|
|
321
|
+
throw new Error('Console error');
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// Should not throw an error
|
|
325
|
+
expect(() => {
|
|
326
|
+
DebugLogger.log(component, message);
|
|
327
|
+
}).not.toThrow();
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should handle malformed component names', () => {
|
|
331
|
+
const component = null as any;
|
|
332
|
+
const message = 'Test message';
|
|
333
|
+
|
|
334
|
+
expect(() => {
|
|
335
|
+
DebugLogger.log(component, message);
|
|
336
|
+
}).not.toThrow();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('should handle malformed messages', () => {
|
|
340
|
+
const component = 'TestComponent';
|
|
341
|
+
const message = null as any;
|
|
342
|
+
|
|
343
|
+
expect(() => {
|
|
344
|
+
DebugLogger.log(component, message);
|
|
345
|
+
}).not.toThrow();
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
describe('Environment Detection', () => {
|
|
350
|
+
it('should detect test environment correctly', () => {
|
|
351
|
+
import.meta.env.MODE = 'test';
|
|
352
|
+
|
|
353
|
+
const component = 'TestComponent';
|
|
354
|
+
const message = 'Test message';
|
|
355
|
+
|
|
356
|
+
DebugLogger.log(component, message);
|
|
357
|
+
|
|
358
|
+
// In test mode, should not log (treated as production)
|
|
359
|
+
expect(console.log).not.toHaveBeenCalled();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('should handle undefined environment mode', () => {
|
|
363
|
+
import.meta.env.MODE = undefined as any;
|
|
364
|
+
|
|
365
|
+
const component = 'TestComponent';
|
|
366
|
+
const message = 'Test message';
|
|
367
|
+
|
|
368
|
+
DebugLogger.log(component, message);
|
|
369
|
+
|
|
370
|
+
// Should not log when mode is undefined
|
|
371
|
+
expect(console.log).not.toHaveBeenCalled();
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it('should handle empty environment mode', () => {
|
|
375
|
+
import.meta.env.MODE = '';
|
|
376
|
+
|
|
377
|
+
const component = 'TestComponent';
|
|
378
|
+
const message = 'Test message';
|
|
379
|
+
|
|
380
|
+
DebugLogger.log(component, message);
|
|
381
|
+
|
|
382
|
+
// Should not log when mode is empty
|
|
383
|
+
expect(console.log).not.toHaveBeenCalled();
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
describe('Static Method Behavior', () => {
|
|
388
|
+
beforeEach(() => {
|
|
389
|
+
import.meta.env.MODE = 'development';
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it('should work as static methods without instantiation', () => {
|
|
393
|
+
const component = 'TestComponent';
|
|
394
|
+
const message = 'Test message';
|
|
395
|
+
|
|
396
|
+
// Should work without creating an instance
|
|
397
|
+
DebugLogger.log(component, message);
|
|
398
|
+
|
|
399
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
400
|
+
`[${component}] ${message}`
|
|
401
|
+
);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it('should maintain consistent behavior across multiple calls', () => {
|
|
405
|
+
const component = 'TestComponent';
|
|
406
|
+
const message1 = 'First message';
|
|
407
|
+
const message2 = 'Second message';
|
|
408
|
+
|
|
409
|
+
DebugLogger.log(component, message1);
|
|
410
|
+
DebugLogger.log(component, message2);
|
|
411
|
+
|
|
412
|
+
expect(console.log).toHaveBeenCalledTimes(2);
|
|
413
|
+
expect(console.log).toHaveBeenNthCalledWith(1, `[${component}] ${message1}`);
|
|
414
|
+
expect(console.log).toHaveBeenNthCalledWith(2, `[${component}] ${message2}`);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
});
|
|
@@ -96,12 +96,7 @@ describe('Device Fingerprint', () => {
|
|
|
96
96
|
vi.setSystemTime(new Date('2023-01-01T00:00:00.000Z'));
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
vi.useRealTimers();
|
|
101
|
-
vi.restoreAllMocks();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe('generateDeviceFingerprint', () => {
|
|
99
|
+
describe('generateDeviceFingerprint', () => {
|
|
105
100
|
it('should generate a device fingerprint', () => {
|
|
106
101
|
const fingerprint = generateDeviceFingerprint();
|
|
107
102
|
|
|
@@ -62,11 +62,7 @@ describe('dynamicUtils', () => {
|
|
|
62
62
|
vi.clearAllMocks();
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
vi.restoreAllMocks();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('loadLodash', () => {
|
|
65
|
+
describe('loadLodash', () => {
|
|
70
66
|
it('should load lodash utilities', async () => {
|
|
71
67
|
const result = await loadLodash();
|
|
72
68
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
10
|
-
import { screen, waitFor } from '@testing-library/react';
|
|
10
|
+
import { screen, waitFor, act } from '@testing-library/react';
|
|
11
11
|
import '@testing-library/jest-dom';
|
|
12
12
|
import { createLazyComponent, LazyDataTable } from '../lazyLoad';
|
|
13
13
|
import { LoadingSpinner } from '../../components/LoadingSpinner/LoadingSpinner';
|
|
@@ -24,11 +24,7 @@ vi.mock('../../components/LoadingSpinner/LoadingSpinner', () => ({
|
|
|
24
24
|
}));
|
|
25
25
|
|
|
26
26
|
describe('LazyLoad Utility', () => {
|
|
27
|
-
|
|
28
|
-
vi.clearAllMocks();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('createLazyComponent', () => {
|
|
27
|
+
describe('createLazyComponent', () => {
|
|
32
28
|
it('should create a lazy component with default fallback', async () => {
|
|
33
29
|
const mockImportFn = vi.fn().mockResolvedValue({
|
|
34
30
|
default: () => <div data-testid="lazy-component">Lazy Component</div>
|
|
@@ -105,50 +101,54 @@ describe('LazyLoad Utility', () => {
|
|
|
105
101
|
expect(screen.getByTestId('error-boundary')).toBeInTheDocument();
|
|
106
102
|
});
|
|
107
103
|
|
|
108
|
-
it
|
|
104
|
+
it('should handle import errors gracefully', async () => {
|
|
105
|
+
// Test that React.lazy with error boundary properly handles failed imports
|
|
109
106
|
const mockImportFn = vi.fn().mockRejectedValue(new Error('Import failed'));
|
|
110
107
|
|
|
108
|
+
// Create a simple Error Boundary wrapper
|
|
109
|
+
class TestErrorBoundary extends React.Component<
|
|
110
|
+
{ children: React.ReactNode },
|
|
111
|
+
{ hasError: boolean }
|
|
112
|
+
> {
|
|
113
|
+
constructor(props: { children: React.ReactNode }) {
|
|
114
|
+
super(props);
|
|
115
|
+
this.state = { hasError: false };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static getDerivedStateFromError() {
|
|
119
|
+
return { hasError: true };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
render() {
|
|
123
|
+
if (this.state.hasError) {
|
|
124
|
+
return <div data-testid="error-display">Error occurred</div>;
|
|
125
|
+
}
|
|
126
|
+
return this.props.children;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
111
130
|
const LazyTestComponent = createLazyComponent(
|
|
112
131
|
mockImportFn,
|
|
113
|
-
'TestComponent'
|
|
132
|
+
'TestComponent',
|
|
133
|
+
{ errorBoundary: TestErrorBoundary }
|
|
114
134
|
);
|
|
115
135
|
|
|
116
|
-
// Suppress console.error
|
|
136
|
+
// Suppress console.error for this test
|
|
117
137
|
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
118
|
-
|
|
119
|
-
// Only set up process listeners if process is available (Node.js environment)
|
|
120
|
-
let originalUnhandledRejection: any[] = [];
|
|
121
|
-
let unhandledRejectionHandler: ((reason: any) => void) | null = null;
|
|
122
|
-
|
|
123
|
-
if (typeof process !== 'undefined' && process.listeners) {
|
|
124
|
-
originalUnhandledRejection = process.listeners('unhandledRejection');
|
|
125
|
-
|
|
126
|
-
// Add a handler to catch the unhandled rejection
|
|
127
|
-
unhandledRejectionHandler = (reason: any) => {
|
|
128
|
-
if (reason?.message === 'Import failed') {
|
|
129
|
-
// Expected error, ignore it
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
// Re-throw other errors
|
|
133
|
-
throw reason;
|
|
134
|
-
};
|
|
135
|
-
process.on('unhandledRejection', unhandledRejectionHandler);
|
|
136
|
-
}
|
|
137
138
|
|
|
138
139
|
renderWithProviders(<LazyTestComponent />);
|
|
139
140
|
|
|
140
141
|
// Should show loading spinner initially
|
|
141
142
|
expect(screen.getByTestId('loading-spinner')).toBeInTheDocument();
|
|
142
143
|
|
|
143
|
-
// Wait for
|
|
144
|
+
// Wait for error to be caught and displayed
|
|
144
145
|
await waitFor(() => {
|
|
145
|
-
expect(screen.getByTestId('
|
|
146
|
-
}, { timeout:
|
|
146
|
+
expect(screen.getByTestId('error-display')).toBeInTheDocument();
|
|
147
|
+
}, { timeout: 2000 });
|
|
148
|
+
|
|
149
|
+
// The import function should have been called
|
|
150
|
+
expect(mockImportFn).toHaveBeenCalled();
|
|
147
151
|
|
|
148
|
-
// Clean up
|
|
149
|
-
if (typeof process !== 'undefined' && process.removeListener && unhandledRejectionHandler) {
|
|
150
|
-
process.removeListener('unhandledRejection', unhandledRejectionHandler);
|
|
151
|
-
}
|
|
152
152
|
consoleSpy.mockRestore();
|
|
153
153
|
});
|
|
154
154
|
|
|
@@ -23,11 +23,7 @@ describe('organisationContext', () => {
|
|
|
23
23
|
} as unknown as SupabaseClient;
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
vi.restoreAllMocks();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('setOrganisationContext', () => {
|
|
26
|
+
describe('setOrganisationContext', () => {
|
|
31
27
|
it('should set organisation context successfully', async () => {
|
|
32
28
|
const organisationId = 'org-123';
|
|
33
29
|
const mockRpc = vi.fn().mockResolvedValue({ error: null });
|
|
@@ -24,11 +24,7 @@ describe('performanceBudgets', () => {
|
|
|
24
24
|
performanceBudgetMonitor.reset();
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
vi.restoreAllMocks();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('PERFORMANCE_BUDGETS', () => {
|
|
27
|
+
describe('PERFORMANCE_BUDGETS', () => {
|
|
32
28
|
it('should have all required performance budget thresholds', () => {
|
|
33
29
|
expect(PERFORMANCE_BUDGETS).toHaveProperty('COMPONENT_RENDER');
|
|
34
30
|
expect(PERFORMANCE_BUDGETS).toHaveProperty('BUNDLE_SIZE');
|
|
@@ -76,22 +72,20 @@ describe('performanceBudgets', () => {
|
|
|
76
72
|
});
|
|
77
73
|
|
|
78
74
|
it('should log metrics in development mode', () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
// The performance budget monitor checks for 'development' or 'test' mode
|
|
76
|
+
// In the test environment, import.meta.env.MODE should be 'test'
|
|
82
77
|
performanceBudgetMonitor.measure('TEST_METRIC', 25, { component: 'Button' });
|
|
83
78
|
|
|
84
79
|
expect(consoleSpy.log).toHaveBeenCalledWith(
|
|
85
80
|
'📊 Performance Metric: TEST_METRIC = 25',
|
|
86
81
|
{ component: 'Button' }
|
|
87
82
|
);
|
|
88
|
-
|
|
89
|
-
process.env.NODE_ENV = originalEnv;
|
|
90
83
|
});
|
|
91
84
|
|
|
92
85
|
it('should not log metrics in production mode', () => {
|
|
93
|
-
// Mock
|
|
86
|
+
// Mock both MODE and NODE_ENV for production
|
|
94
87
|
vi.stubEnv('MODE', 'production');
|
|
88
|
+
vi.stubEnv('NODE_ENV', 'production');
|
|
95
89
|
|
|
96
90
|
performanceBudgetMonitor.measure('TEST_METRIC', 25);
|
|
97
91
|
|
|
@@ -18,12 +18,7 @@ import {
|
|
|
18
18
|
import { AuthErrorCode } from '../../types/unified';
|
|
19
19
|
|
|
20
20
|
describe('Secure Errors', () => {
|
|
21
|
-
|
|
22
|
-
vi.clearAllMocks();
|
|
23
|
-
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('SecureError', () => {
|
|
21
|
+
describe('SecureError', () => {
|
|
27
22
|
it('should create a SecureError with all properties', () => {
|
|
28
23
|
const error = new SecureError(
|
|
29
24
|
'Test error message',
|
|
@@ -55,11 +55,7 @@ describe('Secure Storage', () => {
|
|
|
55
55
|
mockCrypto.getRandomValues.mockReturnValue(new Uint8Array(12));
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
vi.restoreAllMocks();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('initialization', () => {
|
|
58
|
+
describe('initialization', () => {
|
|
63
59
|
it('should initialize without existing key', async () => {
|
|
64
60
|
mockLocalStorage.getItem.mockReturnValue(null);
|
|
65
61
|
mockCrypto.subtle.generateKey.mockResolvedValue({} as CryptoKey);
|
|
@@ -7,11 +7,7 @@ describe('securityMonitor', () => {
|
|
|
7
7
|
securityMonitor.clearEvents();
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
vi.restoreAllMocks();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
describe('logEvent', () => {
|
|
10
|
+
describe('logEvent', () => {
|
|
15
11
|
it('should log a security event with generated ID and timestamp', () => {
|
|
16
12
|
const event = {
|
|
17
13
|
action: 'login_attempt',
|
|
@@ -27,11 +27,7 @@ describe('sessionTracking', () => {
|
|
|
27
27
|
} as unknown as SupabaseClient;
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
vi.restoreAllMocks();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('trackLogin', () => {
|
|
30
|
+
describe('trackLogin', () => {
|
|
35
31
|
it('should track login successfully', async () => {
|
|
36
32
|
const mockUser = { id: 'user-123', email: 'test@example.com' };
|
|
37
33
|
const mockGetUser = vi.fn().mockResolvedValue({ data: { user: mockUser } });
|