@jmruthers/pace-core 0.5.74 → 0.5.76
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-4GAVPIEG.js +120 -0
- package/dist/{PublicLoadingSpinner-DLpF5bbs.d.ts → PublicLoadingSpinner-BiNER8F5.d.ts} +30 -19
- package/dist/RBACService-C4udt_Zp.d.ts +528 -0
- package/dist/{UnifiedAuthProvider-K4NRGXL4.js → UnifiedAuthProvider-3NKDOSOK.js} +6 -4
- package/dist/UnifiedAuthProvider-Bj6YCf7c.d.ts +113 -0
- package/dist/chunk-5F3NDPJV.js +232 -0
- package/dist/chunk-5F3NDPJV.js.map +1 -0
- package/dist/chunk-A4FUBC7B.js +17 -0
- package/dist/chunk-A4FUBC7B.js.map +1 -0
- package/dist/{chunk-SMJZMKYN.js → chunk-A6HBIY5P.js} +2 -11
- package/dist/{chunk-SMJZMKYN.js.map → chunk-A6HBIY5P.js.map} +1 -1
- package/dist/{chunk-LVQ26TCN.js → chunk-AFGTSUAD.js} +43 -127
- package/dist/chunk-AFGTSUAD.js.map +1 -0
- package/dist/{chunk-BKVGJVUR.js → chunk-K34IM5CT.js} +497 -33
- package/dist/chunk-K34IM5CT.js.map +1 -0
- package/dist/{chunk-UJMCGBLS.js → chunk-KHJS6VIA.js} +203 -41
- package/dist/chunk-KHJS6VIA.js.map +1 -0
- package/dist/{chunk-ORSMVXO2.js → chunk-KK73ZB4E.js} +9 -14
- package/dist/chunk-KK73ZB4E.js.map +1 -0
- package/dist/{chunk-VKOCWWVY.js → chunk-L3RV2ALE.js} +1 -6
- package/dist/{chunk-VKOCWWVY.js.map → chunk-L3RV2ALE.js.map} +1 -1
- package/dist/chunk-LW7MMEAQ.js +59 -0
- package/dist/chunk-LW7MMEAQ.js.map +1 -0
- package/dist/{chunk-IHMMNKNA.js → chunk-M5IWZRBT.js} +5118 -1864
- package/dist/chunk-M5IWZRBT.js.map +1 -0
- package/dist/{chunk-DG5Z55HH.js → chunk-NTNILOBC.js} +7 -9
- package/dist/chunk-NTNILOBC.js.map +1 -0
- package/dist/chunk-PYUXFQJ3.js +11 -0
- package/dist/chunk-PYUXFQJ3.js.map +1 -0
- package/dist/chunk-URUTVZ7N.js +27 -0
- package/dist/chunk-URUTVZ7N.js.map +1 -0
- package/dist/chunk-WN6XJWOS.js +2468 -0
- package/dist/chunk-WN6XJWOS.js.map +1 -0
- package/dist/{chunk-3SP4P7NS.js → chunk-XLZ7U46Z.js} +59 -1
- package/dist/chunk-XLZ7U46Z.js.map +1 -0
- package/dist/{chunk-H2TNUICK.js → chunk-Y6TXWPJO.js} +50 -50
- package/dist/chunk-Y6TXWPJO.js.map +1 -0
- package/dist/{chunk-YNUBMSMV.js → chunk-YCKPEMJA.js} +186 -263
- package/dist/chunk-YCKPEMJA.js.map +1 -0
- package/dist/components.d.ts +4 -5
- package/dist/components.js +35 -41
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +20 -43
- package/dist/hooks.js +13 -12
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +156 -10
- package/dist/index.js +193 -96
- package/dist/index.js.map +1 -1
- package/dist/{organisation-t-vvQC3g.d.ts → organisation-BtshODVF.d.ts} +4 -3
- package/dist/providers.d.ts +27 -38
- package/dist/providers.js +33 -23
- package/dist/rbac/index.d.ts +114 -5
- package/dist/rbac/index.js +15 -15
- package/dist/styles/index.js +2 -2
- package/dist/theming/runtime.js +1 -3
- package/dist/types.d.ts +3 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/{unified-CMPjE_fv.d.ts → unified-CM7T0aTK.d.ts} +1 -1
- package/dist/useInactivityTracker-MRUU55XI.js +10 -0
- package/dist/{usePublicRouteParams-Ua1Vz-HG.d.ts → usePublicRouteParams-B-CumWRc.d.ts} +3 -3
- package/dist/utils.js +7 -9
- package/dist/utils.js.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/docs/TERMINOLOGY.md +231 -0
- 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 +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +3 -3
- package/docs/api/interfaces/CardProps.md +2 -2
- 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/EventLogoProps.md +2 -2
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.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 +2 -2
- 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 +28 -17
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +2 -2
- 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 +2 -2
- 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 +5 -11
- 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 +524 -440
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +14 -14
- 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/UseResolvedScopeOptions.md +47 -0
- package/docs/api/interfaces/UseResolvedScopeReturn.md +47 -0
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +234 -61
- package/docs/api-reference/providers.md +26 -7
- package/docs/architecture/services.md +30 -32
- package/docs/best-practices/README.md +20 -0
- package/docs/best-practices/accessibility.md +566 -0
- package/docs/best-practices/performance-expansion.md +473 -0
- package/docs/breaking-changes.md +2 -5
- package/docs/core-concepts/authentication.md +15 -7
- package/docs/documentation-index.md +1 -1
- package/docs/documentation-templates.md +539 -0
- package/docs/getting-started/quick-start.md +16 -66
- package/docs/implementation-guides/component-styling.md +410 -0
- package/docs/implementation-guides/data-tables.md +1 -1
- package/docs/migration/service-architecture.md +121 -260
- package/docs/rbac/README-rbac-rls-integration.md +48 -38
- package/docs/style-guide.md +39 -0
- package/{src/rbac/examples → examples/RBAC}/CompleteRBACExample.tsx +3 -2
- package/{src/rbac/examples → examples/RBAC}/EventBasedApp.tsx +5 -4
- package/{src/components/examples → examples/RBAC}/PermissionExample.tsx +7 -6
- package/examples/RBAC/__tests__/PermissionExample.test.tsx +150 -0
- package/examples/RBAC/index.ts +13 -0
- package/examples/README.md +37 -0
- package/examples/index.ts +22 -0
- package/{src/examples → examples/public-pages}/CorrectPublicPageImplementation.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicEventPage.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicPageApp.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicPageUsageExample.tsx +1 -1
- package/examples/public-pages/__tests__/PublicPageUsageExample.test.tsx +159 -0
- package/examples/public-pages/index.ts +14 -0
- package/package.json +22 -18
- package/src/__tests__/TEST_GUIDE_CURSOR.md +940 -9
- package/src/__tests__/helpers/README.md +255 -0
- package/src/__tests__/helpers/index.ts +62 -0
- package/src/__tests__/helpers/supabaseMock.ts +75 -5
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +6 -8
- package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +17 -6
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +73 -9
- package/src/components/DataTable/components/DataTableCore.tsx +280 -475
- package/src/components/DataTable/components/UnifiedTableBody.tsx +120 -153
- package/src/components/DataTable/components/__tests__/COVERAGE_NOTE.md +55 -0
- package/src/components/DataTable/components/index.ts +1 -2
- package/src/components/DataTable/context/__tests__/DataTableContext.test.tsx +208 -275
- package/src/components/DataTable/core/__tests__/ColumnFactory.test.ts +254 -0
- package/src/components/DataTable/core/index.ts +1 -8
- package/src/components/DataTable/examples/__tests__/HierarchicalExample.test.tsx +45 -0
- package/src/components/DataTable/examples/__tests__/PerformanceExample.test.tsx +117 -0
- package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.test.ts +525 -0
- package/src/components/DataTable/hooks/__tests__/useColumnReordering.test.ts +570 -0
- package/src/components/DataTable/hooks/__tests__/useHierarchicalState.test.ts +214 -0
- package/src/components/DataTable/hooks/__tests__/useTableColumns.test.ts +224 -0
- package/src/components/DataTable/hooks/index.ts +6 -0
- package/src/components/DataTable/hooks/useColumnReordering.ts +1 -0
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +149 -0
- package/src/components/DataTable/hooks/useDataTableState.ts +12 -6
- package/src/components/DataTable/hooks/useHierarchicalState.ts +26 -8
- package/src/components/DataTable/hooks/useTableColumns.ts +153 -0
- package/src/components/DataTable/index.ts +1 -9
- package/src/components/DataTable/utils/__tests__/COVERAGE_NOTE.md +89 -0
- package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +3 -6
- package/src/components/DataTable/utils/__tests__/flexibleImport.test.ts +462 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalSorting.test.ts +247 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +8 -6
- package/src/components/DataTable/utils/__tests__/performanceUtils.test.ts +466 -0
- package/src/components/DataTable/utils/__tests__/rowUtils.test.ts +265 -0
- package/src/components/DataTable/utils/errorHandling.ts +52 -460
- package/src/components/DataTable/utils/exportUtils.ts +46 -15
- package/src/components/DataTable/utils/hierarchicalSorting.ts +50 -3
- package/src/components/DataTable/utils/hierarchicalUtils.ts +167 -34
- package/src/components/DataTable/utils/index.ts +5 -0
- package/src/components/DataTable/utils/rowUtils.ts +68 -0
- package/src/components/Dialog/examples/__tests__/HtmlDialogExample.test.tsx +71 -0
- package/src/components/Dialog/examples/__tests__/SimpleHtmlTest.test.tsx +122 -0
- package/src/components/EventSelector/EventSelector.test.tsx +672 -0
- package/src/components/EventSelector/EventSelector.tsx +1 -1
- package/src/components/Header/Header.test.tsx +35 -1
- package/src/components/Header/Header.tsx +3 -1
- package/src/components/Label/__tests__/Label.test.tsx +434 -0
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +3 -3
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +24 -4
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +3 -2
- package/src/components/PublicLayout/__tests__/PublicPageContextChecker.test.tsx +190 -0
- package/src/components/PublicLayout/__tests__/PublicPageDebugger.test.tsx +185 -0
- package/src/components/PublicLayout/__tests__/PublicPageProvider.test.tsx +313 -0
- package/src/components/Select/Select.test.tsx +143 -120
- package/src/components/Select/Select.tsx +47 -212
- package/src/components/Select/hooks.ts +36 -1
- package/src/components/Select/index.ts +2 -1
- package/src/hooks/__tests__/useFocusManagement.unit.test.ts +220 -0
- package/src/hooks/__tests__/useIsMobile.unit.test.ts +117 -0
- package/src/hooks/__tests__/useKeyboardShortcuts.unit.test.ts +295 -0
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +29 -19
- package/src/hooks/__tests__/useRBAC.unit.test.ts +7 -3
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +115 -19
- package/src/hooks/services/__tests__/useServiceHooks.test.tsx +137 -0
- package/src/hooks/useEventTheme.test.ts +350 -0
- package/src/hooks/useEventTheme.ts +1 -1
- package/src/hooks/useEvents.ts +61 -0
- package/src/hooks/useOrganisationSecurity.test.ts +4 -4
- package/src/hooks/useOrganisationSecurity.ts +2 -2
- package/src/hooks/useOrganisations.ts +64 -0
- package/src/hooks/useSecureDataAccess.test.ts +37 -30
- package/src/hooks/useSecureDataAccess.ts +2 -2
- package/src/index.ts +18 -3
- package/src/providers/AuthProvider.tsx +8 -292
- package/src/providers/EventProvider.tsx +15 -425
- package/src/providers/InactivityProvider.tsx +8 -231
- package/src/providers/OrganisationProvider.test.simple.tsx +3 -2
- package/src/providers/OrganisationProvider.tsx +11 -890
- package/src/providers/UnifiedAuthProvider.tsx +8 -320
- package/src/providers/__tests__/AuthProvider.test.tsx +18 -17
- package/src/providers/__tests__/EventProvider.test.tsx +253 -2
- package/src/providers/__tests__/InactivityProvider.test-helper.tsx +65 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +46 -114
- package/src/providers/__tests__/OrganisationProvider.test.tsx +313 -3
- package/src/providers/__tests__/ProviderLifecycle.test.tsx +341 -0
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +383 -2
- package/src/providers/index.ts +8 -7
- package/src/providers/services/EventServiceProvider.tsx +3 -0
- package/src/providers/services/UnifiedAuthProvider.tsx +3 -0
- package/src/rbac/hooks/__tests__/usePermissions.integration.test.ts +437 -0
- package/src/rbac/hooks/index.ts +2 -0
- package/src/rbac/hooks/usePermissions.test.ts +296 -0
- package/src/rbac/hooks/useRBAC.test.ts +9 -5
- package/src/rbac/hooks/useRBAC.ts +3 -3
- package/src/rbac/hooks/useResolvedScope.ts +232 -0
- package/src/rbac/providers/__tests__/RBACProvider.integration.test.tsx +688 -0
- package/src/rbac/providers/__tests__/RBACProvider.test.tsx +507 -0
- package/src/services/AuthService.ts +19 -4
- package/src/services/__tests__/AuthService.test.ts +288 -0
- package/src/services/__tests__/InactivityService.lifecycle.test.ts +411 -0
- package/src/services/__tests__/OrganisationService.pagination.test.ts +375 -0
- package/src/styles/core.css +2 -0
- package/src/types/__tests__/README.md +114 -0
- package/src/types/__tests__/guards.test.ts +246 -0
- package/src/types/__tests__/validation.test.ts +731 -0
- package/src/types/guards.ts +1 -0
- package/src/types/organisation.ts +3 -2
- package/src/utils/__tests__/file-reference.test.ts +383 -0
- package/src/utils/__tests__/performanceBenchmark.test.ts +175 -0
- package/src/utils/appNameResolver.test.ts +54 -0
- package/src/validation/__tests__/csrf.unit.test.ts +63 -0
- package/src/validation/__tests__/passwordSchema.unit.test.ts +105 -0
- package/src/validation/__tests__/sanitization.unit.test.ts +250 -0
- package/src/validation/__tests__/schemaUtils.unit.test.ts +451 -0
- package/src/validation/__tests__/user.unit.test.ts +440 -0
- package/dist/DataTable-2QR5TER5.js +0 -102
- package/dist/RBACProvider-BO4ilsQB.d.ts +0 -63
- package/dist/UnifiedAuthProvider-D02AMXgO.d.ts +0 -103
- package/dist/chunk-3SP4P7NS.js.map +0 -1
- package/dist/chunk-B5LK25HV.js +0 -953
- package/dist/chunk-B5LK25HV.js.map +0 -1
- package/dist/chunk-BKVGJVUR.js.map +0 -1
- package/dist/chunk-C5Q5LRU5.js +0 -5691
- package/dist/chunk-C5Q5LRU5.js.map +0 -1
- package/dist/chunk-CDDYJCYU.js +0 -79
- package/dist/chunk-CDDYJCYU.js.map +0 -1
- package/dist/chunk-DG5Z55HH.js.map +0 -1
- package/dist/chunk-H2TNUICK.js.map +0 -1
- package/dist/chunk-IHMMNKNA.js.map +0 -1
- package/dist/chunk-LVQ26TCN.js.map +0 -1
- package/dist/chunk-ORSMVXO2.js.map +0 -1
- package/dist/chunk-TYHR5X4W.js +0 -33
- package/dist/chunk-TYHR5X4W.js.map +0 -1
- package/dist/chunk-UJMCGBLS.js.map +0 -1
- package/dist/chunk-V6BHACCH.js +0 -17
- package/dist/chunk-V6BHACCH.js.map +0 -1
- package/dist/chunk-YNUBMSMV.js.map +0 -1
- package/dist/eventContext-BBA42P6G.js +0 -14
- package/dist/rbac/cli/policy-manager.js +0 -278
- package/dist/rbac/cli/policy-manager.js.map +0 -1
- package/docs/api/interfaces/EventContextType.md +0 -96
- package/docs/api/interfaces/EventProviderProps.md +0 -19
- package/docs/documentation-style-checklist.md +0 -294
- package/src/components/DataTable/components/DataTableBody.tsx +0 -488
- package/src/components/DataTable/components/DraggableColumnHeader.tsx +0 -144
- package/src/components/DataTable/components/VirtualizedDataTable.tsx +0 -515
- package/src/components/DataTable/core/ActionManager.ts +0 -235
- package/src/components/DataTable/core/ColumnManager.ts +0 -205
- package/src/components/DataTable/core/DataManager.ts +0 -188
- package/src/components/DataTable/core/DataTableContext.tsx +0 -181
- package/src/components/DataTable/core/LocalDataAdapter.ts +0 -264
- package/src/components/DataTable/core/PluginRegistry.ts +0 -229
- package/src/components/DataTable/core/StateManager.ts +0 -311
- package/src/components/DataTable/core/__tests__/ActionManager.test.ts +0 -634
- package/src/components/DataTable/core/__tests__/DataManager.test.ts +0 -519
- package/src/components/DataTable/core/__tests__/StateManager.test.ts +0 -714
- package/src/components/DataTable/core/interfaces.ts +0 -338
- package/src/components/DataTable/utils/debugTools.ts +0 -583
- package/src/components/Select/Select.bug-test.tsx +0 -69
- package/src/components/Select/Select.refactored.tsx +0 -497
- package/src/providers/OrganisationProvider.test.tsx +0 -164
- package/src/providers/UnifiedAuthProvider.test.tsx +0 -124
- package/src/providers/__tests__/AuthProvider.test.tsx.backup +0 -771
- package/src/providers/__tests__/EventProvider.test.tsx.backup +0 -824
- package/src/providers/__tests__/OrganisationProvider.test.tsx.backup +0 -820
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup +0 -911
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup2 +0 -166
- package/src/rbac/cli/__tests__/policy-manager.test.ts +0 -339
- package/src/rbac/cli/policy-manager.ts +0 -443
- package/dist/{DataTable-2QR5TER5.js.map → DataTable-4GAVPIEG.js.map} +0 -0
- package/dist/{UnifiedAuthProvider-K4NRGXL4.js.map → UnifiedAuthProvider-3NKDOSOK.js.map} +0 -0
- package/dist/{eventContext-BBA42P6G.js.map → useInactivityTracker-MRUU55XI.js.map} +0 -0
- package/dist/{validation-PM_iOaTI.d.ts → validation-D8VcbTzC.d.ts} +2 -2
- /package/src/utils/{appNameResolver.test.ts.backup → appNameResolver.test 2.ts} +0 -0
|
@@ -1,634 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file ActionManager Unit Tests
|
|
3
|
-
* @package @jmruthers/pace-core
|
|
4
|
-
* @module Components/DataTable/Core/ActionManager
|
|
5
|
-
* @since 0.3.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
|
9
|
-
import { ActionManagerImpl } from '../ActionManager';
|
|
10
|
-
import type { DataTableAction } from '../../types';
|
|
11
|
-
import type { DataRecord } from '../../types';
|
|
12
|
-
|
|
13
|
-
// Test data types
|
|
14
|
-
interface TestDataRecord extends DataRecord {
|
|
15
|
-
id: string;
|
|
16
|
-
name: string;
|
|
17
|
-
email: string;
|
|
18
|
-
role: string;
|
|
19
|
-
isActive: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Test data fixtures
|
|
23
|
-
const createTestData = (overrides: Partial<TestDataRecord> = {}): TestDataRecord => ({
|
|
24
|
-
id: 'test-id-1',
|
|
25
|
-
name: 'Test User',
|
|
26
|
-
email: 'test@example.com',
|
|
27
|
-
role: 'user',
|
|
28
|
-
isActive: true,
|
|
29
|
-
...overrides,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const createTestAction = (overrides: Partial<DataTableAction<TestDataRecord>> = {}): DataTableAction<TestDataRecord> => ({
|
|
33
|
-
label: 'Test Action',
|
|
34
|
-
onClick: vi.fn(),
|
|
35
|
-
variant: 'default',
|
|
36
|
-
testId: 'test-action',
|
|
37
|
-
...overrides,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const createTestActions = (count: number): DataTableAction<TestDataRecord>[] =>
|
|
41
|
-
Array.from({ length: count }, (_, i) => createTestAction({
|
|
42
|
-
label: `Action ${i + 1}`,
|
|
43
|
-
testId: `action-${i + 1}`,
|
|
44
|
-
onClick: vi.fn(),
|
|
45
|
-
}));
|
|
46
|
-
|
|
47
|
-
describe('[unit] ActionManager', () => {
|
|
48
|
-
let actionManager: ActionManagerImpl<TestDataRecord>;
|
|
49
|
-
let testActions: DataTableAction<TestDataRecord>[];
|
|
50
|
-
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
testActions = createTestActions(3);
|
|
53
|
-
actionManager = new ActionManagerImpl(testActions);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
afterEach(() => {
|
|
57
|
-
vi.clearAllMocks();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('Initialization', () => {
|
|
61
|
-
it('should initialize with empty actions array', () => {
|
|
62
|
-
const emptyManager = new ActionManagerImpl();
|
|
63
|
-
expect(emptyManager.getActions()).toEqual([]);
|
|
64
|
-
expect(emptyManager.getActionCount()).toBe(0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should initialize with provided actions', () => {
|
|
68
|
-
expect(actionManager.getActions()).toHaveLength(3);
|
|
69
|
-
expect(actionManager.getActionCount()).toBe(3);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should create action map from initial actions', () => {
|
|
73
|
-
expect(actionManager.hasAction('action-1')).toBe(true);
|
|
74
|
-
expect(actionManager.hasAction('action-2')).toBe(true);
|
|
75
|
-
expect(actionManager.hasAction('action-3')).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('Action Retrieval', () => {
|
|
80
|
-
it('should get all actions', () => {
|
|
81
|
-
const actions = actionManager.getActions();
|
|
82
|
-
expect(actions).toHaveLength(3);
|
|
83
|
-
expect(actions[0].label).toBe('Action 1');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should return copy of actions array', () => {
|
|
87
|
-
const actions1 = actionManager.getActions();
|
|
88
|
-
const actions2 = actionManager.getActions();
|
|
89
|
-
expect(actions1).not.toBe(actions2); // Different array instances
|
|
90
|
-
expect(actions1).toEqual(actions2); // Same content
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should get action by ID', () => {
|
|
94
|
-
const action = actionManager.getAction('action-1');
|
|
95
|
-
expect(action).toBeDefined();
|
|
96
|
-
expect(action?.label).toBe('Action 1');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should return undefined for non-existent action', () => {
|
|
100
|
-
const action = actionManager.getAction('non-existent');
|
|
101
|
-
expect(action).toBeUndefined();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should get action by index', () => {
|
|
105
|
-
const action = actionManager.getActionByIndex(0);
|
|
106
|
-
expect(action).toBeDefined();
|
|
107
|
-
expect(action?.label).toBe('Action 1');
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should return undefined for invalid index', () => {
|
|
111
|
-
const action = actionManager.getActionByIndex(999);
|
|
112
|
-
expect(action).toBeUndefined();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should get action index by ID', () => {
|
|
116
|
-
const index = actionManager.getActionIndex('action-2');
|
|
117
|
-
expect(index).toBe(1);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should return -1 for non-existent action index', () => {
|
|
121
|
-
const index = actionManager.getActionIndex('non-existent');
|
|
122
|
-
expect(index).toBe(-1);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('Action Management', () => {
|
|
127
|
-
describe('Add Action', () => {
|
|
128
|
-
it('should add new action', () => {
|
|
129
|
-
const newAction = createTestAction({
|
|
130
|
-
label: 'New Action',
|
|
131
|
-
testId: 'new-action',
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
actionManager.addAction(newAction);
|
|
135
|
-
|
|
136
|
-
expect(actionManager.getActionCount()).toBe(4);
|
|
137
|
-
expect(actionManager.hasAction('new-action')).toBe(true);
|
|
138
|
-
expect(actionManager.getAction('new-action')).toEqual(newAction);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('should replace existing action with same ID', () => {
|
|
142
|
-
const originalAction = actionManager.getAction('action-1');
|
|
143
|
-
const updatedAction = createTestAction({
|
|
144
|
-
label: 'Updated Action 1',
|
|
145
|
-
testId: 'action-1',
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
actionManager.addAction(updatedAction);
|
|
149
|
-
|
|
150
|
-
expect(actionManager.getActionCount()).toBe(3); // Count should remain same
|
|
151
|
-
expect(actionManager.getAction('action-1')).toEqual(updatedAction);
|
|
152
|
-
expect(actionManager.getAction('action-1')).not.toEqual(originalAction);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('should generate ID from label when testId is not provided', () => {
|
|
156
|
-
const actionWithoutId = createTestAction({
|
|
157
|
-
label: 'Action Without ID',
|
|
158
|
-
testId: undefined,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
actionManager.addAction(actionWithoutId);
|
|
162
|
-
|
|
163
|
-
const generatedId = 'action-without-id';
|
|
164
|
-
expect(actionManager.hasAction(generatedId)).toBe(true);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('should generate random ID when neither testId nor label provided', () => {
|
|
168
|
-
const actionWithoutId = createTestAction({
|
|
169
|
-
label: '',
|
|
170
|
-
testId: undefined,
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
actionManager.addAction(actionWithoutId);
|
|
174
|
-
|
|
175
|
-
// The action should be stored with a generated testId
|
|
176
|
-
const actions = actionManager.getActions();
|
|
177
|
-
const addedAction = actions.find(a => a.label === '');
|
|
178
|
-
expect(addedAction).toBeDefined();
|
|
179
|
-
|
|
180
|
-
// Check that the action has a generated testId
|
|
181
|
-
const generatedId = (actionManager as any).getActionId(addedAction);
|
|
182
|
-
expect(generatedId).toMatch(/^action-[a-z0-9]{9}$/);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe('Remove Action', () => {
|
|
187
|
-
it('should remove existing action', () => {
|
|
188
|
-
actionManager.removeAction('action-1');
|
|
189
|
-
|
|
190
|
-
expect(actionManager.getActionCount()).toBe(2);
|
|
191
|
-
expect(actionManager.hasAction('action-1')).toBe(false);
|
|
192
|
-
expect(actionManager.getAction('action-1')).toBeUndefined();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('should not affect other actions when removing', () => {
|
|
196
|
-
actionManager.removeAction('action-2');
|
|
197
|
-
|
|
198
|
-
expect(actionManager.hasAction('action-1')).toBe(true);
|
|
199
|
-
expect(actionManager.hasAction('action-3')).toBe(true);
|
|
200
|
-
expect(actionManager.getActionCount()).toBe(2);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('should handle removal of non-existent action gracefully', () => {
|
|
204
|
-
const initialCount = actionManager.getActionCount();
|
|
205
|
-
actionManager.removeAction('non-existent');
|
|
206
|
-
expect(actionManager.getActionCount()).toBe(initialCount);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
describe('Update Action', () => {
|
|
211
|
-
it('should update existing action', () => {
|
|
212
|
-
const updates = { label: 'Updated Action 1', variant: 'destructive' as const };
|
|
213
|
-
|
|
214
|
-
actionManager.updateAction('action-1', updates);
|
|
215
|
-
|
|
216
|
-
const updatedAction = actionManager.getAction('action-1');
|
|
217
|
-
expect(updatedAction?.label).toBe('Updated Action 1');
|
|
218
|
-
expect(updatedAction?.variant).toBe('destructive');
|
|
219
|
-
expect(updatedAction?.testId).toBe('action-1'); // Should preserve original testId
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should throw error when updating non-existent action', () => {
|
|
223
|
-
expect(() => {
|
|
224
|
-
actionManager.updateAction('non-existent', { label: 'Updated' });
|
|
225
|
-
}).toThrow('Action with ID "non-existent" not found');
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should update action in both array and map', () => {
|
|
229
|
-
const updates = { label: 'Updated Action 1' };
|
|
230
|
-
|
|
231
|
-
actionManager.updateAction('action-1', updates);
|
|
232
|
-
|
|
233
|
-
const actionFromMap = actionManager.getAction('action-1');
|
|
234
|
-
const actionFromArray = actionManager.getActionByIndex(0);
|
|
235
|
-
|
|
236
|
-
expect(actionFromMap?.label).toBe('Updated Action 1');
|
|
237
|
-
expect(actionFromArray?.label).toBe('Updated Action 1');
|
|
238
|
-
expect(actionFromMap).toBe(actionFromArray); // Same reference
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe('Set Actions', () => {
|
|
243
|
-
it('should replace all actions', () => {
|
|
244
|
-
const newActions = createTestActions(2);
|
|
245
|
-
newActions[0].testId = 'new-action-1';
|
|
246
|
-
newActions[1].testId = 'new-action-2';
|
|
247
|
-
|
|
248
|
-
actionManager.setActions(newActions);
|
|
249
|
-
|
|
250
|
-
expect(actionManager.getActionCount()).toBe(2);
|
|
251
|
-
expect(actionManager.hasAction('action-1')).toBe(false);
|
|
252
|
-
expect(actionManager.hasAction('new-action-1')).toBe(true);
|
|
253
|
-
expect(actionManager.hasAction('new-action-2')).toBe(true);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('should clear action map when setting new actions', () => {
|
|
257
|
-
const newActions = createTestActions(1);
|
|
258
|
-
newActions[0].testId = 'replacement-action';
|
|
259
|
-
|
|
260
|
-
actionManager.setActions(newActions);
|
|
261
|
-
|
|
262
|
-
expect(actionManager.getActionCount()).toBe(1);
|
|
263
|
-
expect(actionManager.hasAction('action-1')).toBe(false);
|
|
264
|
-
expect(actionManager.hasAction('replacement-action')).toBe(true);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('should handle empty actions array', () => {
|
|
268
|
-
actionManager.setActions([]);
|
|
269
|
-
|
|
270
|
-
expect(actionManager.getActionCount()).toBe(0);
|
|
271
|
-
expect(actionManager.getActions()).toEqual([]);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe('Clear Actions', () => {
|
|
276
|
-
it('should clear all actions', () => {
|
|
277
|
-
actionManager.clearActions();
|
|
278
|
-
|
|
279
|
-
expect(actionManager.getActionCount()).toBe(0);
|
|
280
|
-
expect(actionManager.getActions()).toEqual([]);
|
|
281
|
-
expect(actionManager.hasAction('action-1')).toBe(false);
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('Action Filtering', () => {
|
|
287
|
-
beforeEach(() => {
|
|
288
|
-
const actions = [
|
|
289
|
-
createTestAction({ label: 'Enabled Action', testId: 'enabled', disabled: false }),
|
|
290
|
-
createTestAction({ label: 'Disabled Action', testId: 'disabled', disabled: true }),
|
|
291
|
-
createTestAction({
|
|
292
|
-
label: 'Conditional Action',
|
|
293
|
-
testId: 'conditional',
|
|
294
|
-
disabled: (row: TestDataRecord) => !row.isActive
|
|
295
|
-
}),
|
|
296
|
-
createTestAction({ label: 'Another Enabled', testId: 'enabled2', disabled: false }),
|
|
297
|
-
];
|
|
298
|
-
actionManager.setActions(actions);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('should get enabled actions', () => {
|
|
302
|
-
const enabledActions = actionManager.getEnabledActions();
|
|
303
|
-
expect(enabledActions).toHaveLength(2); // 2 explicitly enabled (conditional is disabled with mock row)
|
|
304
|
-
expect(enabledActions.map(a => a.testId)).toContain('enabled');
|
|
305
|
-
expect(enabledActions.map(a => a.testId)).toContain('enabled2');
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('should get actions by variant', () => {
|
|
309
|
-
const actions = [
|
|
310
|
-
createTestAction({ label: 'Default Action', testId: 'default', variant: 'default' }),
|
|
311
|
-
createTestAction({ label: 'Destructive Action', testId: 'destructive', variant: 'destructive' }),
|
|
312
|
-
createTestAction({ label: 'Secondary Action', testId: 'secondary', variant: 'secondary' }),
|
|
313
|
-
createTestAction({ label: 'Another Default', testId: 'default2', variant: 'default' }),
|
|
314
|
-
];
|
|
315
|
-
actionManager.setActions(actions);
|
|
316
|
-
|
|
317
|
-
const defaultActions = actionManager.getActionsByVariant('default');
|
|
318
|
-
expect(defaultActions).toHaveLength(2);
|
|
319
|
-
expect(defaultActions.map(a => a.testId)).toContain('default');
|
|
320
|
-
expect(defaultActions.map(a => a.testId)).toContain('default2');
|
|
321
|
-
|
|
322
|
-
const destructiveActions = actionManager.getActionsByVariant('destructive');
|
|
323
|
-
expect(destructiveActions).toHaveLength(1);
|
|
324
|
-
expect(destructiveActions[0].testId).toBe('destructive');
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
it('should get destructive actions', () => {
|
|
328
|
-
const actions = [
|
|
329
|
-
createTestAction({ label: 'Delete', testId: 'delete', variant: 'destructive' }),
|
|
330
|
-
createTestAction({ label: 'Edit', testId: 'edit', variant: 'default' }),
|
|
331
|
-
createTestAction({ label: 'Remove', testId: 'remove', variant: 'destructive' }),
|
|
332
|
-
];
|
|
333
|
-
actionManager.setActions(actions);
|
|
334
|
-
|
|
335
|
-
const destructiveActions = actionManager.getDestructiveActions();
|
|
336
|
-
expect(destructiveActions).toHaveLength(2);
|
|
337
|
-
expect(destructiveActions.map(a => a.testId)).toContain('delete');
|
|
338
|
-
expect(destructiveActions.map(a => a.testId)).toContain('remove');
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it('should get primary actions', () => {
|
|
342
|
-
const actions = [
|
|
343
|
-
createTestAction({ label: 'Primary', testId: 'primary', variant: 'default' }),
|
|
344
|
-
createTestAction({ label: 'Secondary', testId: 'secondary', variant: 'secondary' }),
|
|
345
|
-
createTestAction({ label: 'Another Primary', testId: 'primary2', variant: 'default' }),
|
|
346
|
-
];
|
|
347
|
-
actionManager.setActions(actions);
|
|
348
|
-
|
|
349
|
-
const primaryActions = actionManager.getPrimaryActions();
|
|
350
|
-
expect(primaryActions).toHaveLength(2);
|
|
351
|
-
expect(primaryActions.map(a => a.testId)).toContain('primary');
|
|
352
|
-
expect(primaryActions.map(a => a.testId)).toContain('primary2');
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('should get secondary actions', () => {
|
|
356
|
-
const actions = [
|
|
357
|
-
createTestAction({ label: 'Primary', testId: 'primary', variant: 'default' }),
|
|
358
|
-
createTestAction({ label: 'Secondary', testId: 'secondary', variant: 'secondary' }),
|
|
359
|
-
createTestAction({ label: 'Another Secondary', testId: 'secondary2', variant: 'secondary' }),
|
|
360
|
-
];
|
|
361
|
-
actionManager.setActions(actions);
|
|
362
|
-
|
|
363
|
-
const secondaryActions = actionManager.getSecondaryActions();
|
|
364
|
-
expect(secondaryActions).toHaveLength(2);
|
|
365
|
-
expect(secondaryActions.map(a => a.testId)).toContain('secondary');
|
|
366
|
-
expect(secondaryActions.map(a => a.testId)).toContain('secondary2');
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
describe('Action Execution', () => {
|
|
371
|
-
it('should execute action successfully', () => {
|
|
372
|
-
const mockOnClick = vi.fn();
|
|
373
|
-
const action = createTestAction({
|
|
374
|
-
label: 'Test Action',
|
|
375
|
-
testId: 'test-action',
|
|
376
|
-
onClick: mockOnClick,
|
|
377
|
-
});
|
|
378
|
-
actionManager.addAction(action);
|
|
379
|
-
|
|
380
|
-
const testRow = createTestData();
|
|
381
|
-
actionManager.executeAction('test-action', testRow);
|
|
382
|
-
|
|
383
|
-
expect(mockOnClick).toHaveBeenCalledWith(testRow);
|
|
384
|
-
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it('should throw error when executing non-existent action', () => {
|
|
388
|
-
const testRow = createTestData();
|
|
389
|
-
|
|
390
|
-
expect(() => {
|
|
391
|
-
actionManager.executeAction('non-existent', testRow);
|
|
392
|
-
}).toThrow('Action with ID "non-existent" not found');
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
it('should throw error when executing disabled action', () => {
|
|
396
|
-
const mockOnClick = vi.fn();
|
|
397
|
-
const action = createTestAction({
|
|
398
|
-
label: 'Disabled Action',
|
|
399
|
-
testId: 'disabled-action',
|
|
400
|
-
onClick: mockOnClick,
|
|
401
|
-
disabled: (row: TestDataRecord) => !row.isActive,
|
|
402
|
-
});
|
|
403
|
-
actionManager.addAction(action);
|
|
404
|
-
|
|
405
|
-
const inactiveRow = createTestData({ isActive: false });
|
|
406
|
-
|
|
407
|
-
expect(() => {
|
|
408
|
-
actionManager.executeAction('disabled-action', inactiveRow);
|
|
409
|
-
}).toThrow('Action "disabled-action" is disabled for this row');
|
|
410
|
-
|
|
411
|
-
expect(mockOnClick).not.toHaveBeenCalled();
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it('should execute action when disabled function returns false', () => {
|
|
415
|
-
const mockOnClick = vi.fn();
|
|
416
|
-
const action = createTestAction({
|
|
417
|
-
label: 'Conditional Action',
|
|
418
|
-
testId: 'conditional-action',
|
|
419
|
-
onClick: mockOnClick,
|
|
420
|
-
disabled: (row: TestDataRecord) => !row.isActive,
|
|
421
|
-
});
|
|
422
|
-
actionManager.addAction(action);
|
|
423
|
-
|
|
424
|
-
const activeRow = createTestData({ isActive: true });
|
|
425
|
-
actionManager.executeAction('conditional-action', activeRow);
|
|
426
|
-
|
|
427
|
-
expect(mockOnClick).toHaveBeenCalledWith(activeRow);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it('should execute action when disabled is false', () => {
|
|
431
|
-
const mockOnClick = vi.fn();
|
|
432
|
-
const action = createTestAction({
|
|
433
|
-
label: 'Enabled Action',
|
|
434
|
-
testId: 'enabled-action',
|
|
435
|
-
onClick: mockOnClick,
|
|
436
|
-
disabled: false,
|
|
437
|
-
});
|
|
438
|
-
actionManager.addAction(action);
|
|
439
|
-
|
|
440
|
-
const testRow = createTestData();
|
|
441
|
-
actionManager.executeAction('enabled-action', testRow);
|
|
442
|
-
|
|
443
|
-
expect(mockOnClick).toHaveBeenCalledWith(testRow);
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
describe('Action State Checking', () => {
|
|
448
|
-
beforeEach(() => {
|
|
449
|
-
const actions = [
|
|
450
|
-
createTestAction({
|
|
451
|
-
label: 'Always Disabled',
|
|
452
|
-
testId: 'always-disabled',
|
|
453
|
-
disabled: true
|
|
454
|
-
}),
|
|
455
|
-
createTestAction({
|
|
456
|
-
label: 'Always Enabled',
|
|
457
|
-
testId: 'always-enabled',
|
|
458
|
-
disabled: false
|
|
459
|
-
}),
|
|
460
|
-
createTestAction({
|
|
461
|
-
label: 'Conditional',
|
|
462
|
-
testId: 'conditional',
|
|
463
|
-
disabled: (row: TestDataRecord) => !row.isActive
|
|
464
|
-
}),
|
|
465
|
-
];
|
|
466
|
-
actionManager.setActions(actions);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
it('should check if action is disabled for specific row', () => {
|
|
470
|
-
const activeRow = createTestData({ isActive: true });
|
|
471
|
-
const inactiveRow = createTestData({ isActive: false });
|
|
472
|
-
|
|
473
|
-
expect(actionManager.isActionDisabled('always-disabled', activeRow)).toBe(true);
|
|
474
|
-
expect(actionManager.isActionDisabled('always-enabled', activeRow)).toBe(false);
|
|
475
|
-
expect(actionManager.isActionDisabled('conditional', activeRow)).toBe(false);
|
|
476
|
-
expect(actionManager.isActionDisabled('conditional', inactiveRow)).toBe(true);
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
it('should return true for non-existent action', () => {
|
|
480
|
-
const testRow = createTestData();
|
|
481
|
-
expect(actionManager.isActionDisabled('non-existent', testRow)).toBe(true);
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
it('should handle function-based disabled state', () => {
|
|
485
|
-
const testRow = createTestData({ isActive: true });
|
|
486
|
-
expect(actionManager.isActionDisabled('conditional', testRow)).toBe(false);
|
|
487
|
-
|
|
488
|
-
const inactiveRow = createTestData({ isActive: false });
|
|
489
|
-
expect(actionManager.isActionDisabled('conditional', inactiveRow)).toBe(true);
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
describe('Action Movement', () => {
|
|
494
|
-
beforeEach(() => {
|
|
495
|
-
const actions = createTestActions(5);
|
|
496
|
-
actionManager.setActions(actions);
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it('should move action to new position', () => {
|
|
500
|
-
actionManager.moveAction('action-2', 0);
|
|
501
|
-
|
|
502
|
-
const actions = actionManager.getActions();
|
|
503
|
-
expect(actions[0].testId).toBe('action-2');
|
|
504
|
-
expect(actions[1].testId).toBe('action-1');
|
|
505
|
-
expect(actions[2].testId).toBe('action-3');
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
it('should move action to last position', () => {
|
|
509
|
-
actionManager.moveAction('action-1', 4);
|
|
510
|
-
|
|
511
|
-
const actions = actionManager.getActions();
|
|
512
|
-
expect(actions[4].testId).toBe('action-1');
|
|
513
|
-
expect(actions[0].testId).toBe('action-2');
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it('should throw error when moving non-existent action', () => {
|
|
517
|
-
expect(() => {
|
|
518
|
-
actionManager.moveAction('non-existent', 0);
|
|
519
|
-
}).toThrow('Action with ID "non-existent" not found');
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
it('should throw error for invalid index', () => {
|
|
523
|
-
expect(() => {
|
|
524
|
-
actionManager.moveAction('action-1', -1);
|
|
525
|
-
}).toThrow('Invalid index: -1');
|
|
526
|
-
|
|
527
|
-
expect(() => {
|
|
528
|
-
actionManager.moveAction('action-1', 10);
|
|
529
|
-
}).toThrow('Invalid index: 10');
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
it('should handle moving to same position', () => {
|
|
533
|
-
const originalActions = actionManager.getActions();
|
|
534
|
-
actionManager.moveAction('action-3', 2);
|
|
535
|
-
|
|
536
|
-
const newActions = actionManager.getActions();
|
|
537
|
-
expect(newActions).toEqual(originalActions);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
describe('Action ID Generation', () => {
|
|
542
|
-
it('should generate ID from testId when available', () => {
|
|
543
|
-
const action = createTestAction({ testId: 'custom-id', label: 'Test' });
|
|
544
|
-
const id = (actionManager as any).getActionId(action);
|
|
545
|
-
expect(id).toBe('custom-id');
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
it('should generate ID from label when testId not available', () => {
|
|
549
|
-
const action = createTestAction({ testId: undefined, label: 'Test Action' });
|
|
550
|
-
const id = (actionManager as any).getActionId(action);
|
|
551
|
-
expect(id).toBe('test-action');
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
it('should handle special characters in label', () => {
|
|
555
|
-
const action = createTestAction({ testId: undefined, label: 'Test Action with Spaces!' });
|
|
556
|
-
const id = (actionManager as any).getActionId(action);
|
|
557
|
-
expect(id).toBe('test-action-with-spaces!');
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
it('should generate random ID when neither testId nor label available', () => {
|
|
561
|
-
const action = createTestAction({ testId: undefined, label: '' });
|
|
562
|
-
const id = (actionManager as any).getActionId(action);
|
|
563
|
-
expect(id).toMatch(/^action-[a-z0-9]{9}$/);
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
describe('Performance and Memory', () => {
|
|
568
|
-
it('should handle large number of actions efficiently', () => {
|
|
569
|
-
const largeActionSet = createTestActions(1000);
|
|
570
|
-
actionManager.setActions(largeActionSet);
|
|
571
|
-
|
|
572
|
-
expect(actionManager.getActionCount()).toBe(1000);
|
|
573
|
-
expect(actionManager.hasAction('action-500')).toBe(true);
|
|
574
|
-
expect(actionManager.getAction('action-500')).toBeDefined();
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
it('should not leak memory with repeated operations', () => {
|
|
578
|
-
// Perform many add/remove operations
|
|
579
|
-
for (let i = 0; i < 100; i++) {
|
|
580
|
-
const action = createTestAction({ testId: `temp-action-${i}` });
|
|
581
|
-
actionManager.addAction(action);
|
|
582
|
-
actionManager.removeAction(`temp-action-${i}`);
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
expect(actionManager.getActionCount()).toBe(3); // Original actions
|
|
586
|
-
expect(actionManager.hasAction('temp-action-99')).toBe(false);
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
it('should handle concurrent operations', () => {
|
|
590
|
-
const actions = createTestActions(10);
|
|
591
|
-
|
|
592
|
-
// Add multiple actions concurrently with unique testIds
|
|
593
|
-
actions.forEach((action, index) => {
|
|
594
|
-
actionManager.addAction({ ...action, testId: `concurrent-action-${index}` });
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
expect(actionManager.getActionCount()).toBe(13); // 3 original + 10 new
|
|
598
|
-
});
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
describe('Edge Cases', () => {
|
|
602
|
-
it('should handle actions with undefined properties', () => {
|
|
603
|
-
const action = {
|
|
604
|
-
label: 'Test Action',
|
|
605
|
-
onClick: vi.fn(),
|
|
606
|
-
} as any;
|
|
607
|
-
|
|
608
|
-
actionManager.addAction(action);
|
|
609
|
-
|
|
610
|
-
expect(actionManager.getActionCount()).toBe(4);
|
|
611
|
-
expect(actionManager.hasAction('test-action')).toBe(true);
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
it('should handle empty string labels', () => {
|
|
615
|
-
const action = createTestAction({ label: '', testId: 'empty-label' });
|
|
616
|
-
actionManager.addAction(action);
|
|
617
|
-
|
|
618
|
-
expect(actionManager.hasAction('empty-label')).toBe(true);
|
|
619
|
-
expect(actionManager.getAction('empty-label')?.label).toBe('');
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
it('should handle actions with same label but different testId', () => {
|
|
623
|
-
const action1 = createTestAction({ label: 'Same Label', testId: 'same-label-1' });
|
|
624
|
-
const action2 = createTestAction({ label: 'Same Label', testId: 'same-label-2' });
|
|
625
|
-
|
|
626
|
-
actionManager.addAction(action1);
|
|
627
|
-
actionManager.addAction(action2);
|
|
628
|
-
|
|
629
|
-
expect(actionManager.getActionCount()).toBe(5); // 3 original + 2 new
|
|
630
|
-
expect(actionManager.hasAction('same-label-1')).toBe(true);
|
|
631
|
-
expect(actionManager.hasAction('same-label-2')).toBe(true);
|
|
632
|
-
});
|
|
633
|
-
});
|
|
634
|
-
});
|