@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.
Files changed (375) hide show
  1. package/dist/{DataTable-4IUY7BXB.js → DataTable-MPBSXUC6.js} +5 -6
  2. package/dist/{PublicLoadingSpinner-DdKXTkCZ.d.ts → PublicLoadingSpinner-BOdyU3u-.d.ts} +1 -1
  3. package/dist/{chunk-PXWEDX7Y.js → chunk-2ARQW6VX.js} +3 -3
  4. package/dist/{chunk-MOJXHWDE.js → chunk-6JILXFEA.js} +335 -5
  5. package/dist/chunk-6JILXFEA.js.map +1 -0
  6. package/dist/{chunk-D7ARGIA3.js → chunk-6RBH67W7.js} +23 -6
  7. package/dist/chunk-6RBH67W7.js.map +1 -0
  8. package/dist/{chunk-ZMS23NS5.js → chunk-FJTAWPAQ.js} +3 -5
  9. package/dist/{chunk-ZMS23NS5.js.map → chunk-FJTAWPAQ.js.map} +1 -1
  10. package/dist/{chunk-OPCWH3A4.js → chunk-NO5QHMDX.js} +7 -6
  11. package/dist/chunk-NO5QHMDX.js.map +1 -0
  12. package/dist/{chunk-ZPK5656W.js → chunk-O3NWNXDY.js} +4 -5
  13. package/dist/chunk-O3NWNXDY.js.map +1 -0
  14. package/dist/{chunk-UYA6U6H7.js → chunk-Q2UP3ZWQ.js} +4 -4
  15. package/dist/{chunk-KRCRNXPD.js → chunk-RVYGJPOD.js} +79 -18
  16. package/dist/chunk-RVYGJPOD.js.map +1 -0
  17. package/dist/{chunk-NN45OBIS.js → chunk-UCMHBF7Y.js} +3 -5
  18. package/dist/{chunk-NN45OBIS.js.map → chunk-UCMHBF7Y.js.map} +1 -1
  19. package/dist/{chunk-ZPG4XPV5.js → chunk-V3QO3LL7.js} +5 -7
  20. package/dist/chunk-V3QO3LL7.js.map +1 -0
  21. package/dist/{chunk-U6GPOF6J.js → chunk-ZXJGZLLO.js} +17 -17
  22. package/dist/{chunk-U6GPOF6J.js.map → chunk-ZXJGZLLO.js.map} +1 -1
  23. package/dist/components.d.ts +1 -1
  24. package/dist/components.js +8 -9
  25. package/dist/components.js.map +1 -1
  26. package/dist/hooks.d.ts +1 -1
  27. package/dist/hooks.js +9 -6
  28. package/dist/hooks.js.map +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +16 -16
  31. package/dist/index.js.map +1 -1
  32. package/dist/providers.js +5 -7
  33. package/dist/rbac/index.js +5 -6
  34. package/dist/{usePublicRouteParams-CdoFxnJK.d.ts → usePublicRouteParams-Ua1Vz-HG.d.ts} +35 -1
  35. package/dist/utils.d.ts +4 -1
  36. package/dist/utils.js +3 -3
  37. package/docs/DOCUMENTATION_CHECKLIST.md +281 -0
  38. package/docs/README.md +22 -10
  39. package/docs/api/classes/ColumnFactory.md +1 -1
  40. package/docs/api/classes/ErrorBoundary.md +1 -1
  41. package/docs/api/classes/InvalidScopeError.md +1 -1
  42. package/docs/api/classes/MissingUserContextError.md +1 -1
  43. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  44. package/docs/api/classes/PermissionDeniedError.md +1 -1
  45. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  46. package/docs/api/classes/RBACAuditManager.md +1 -1
  47. package/docs/api/classes/RBACCache.md +1 -1
  48. package/docs/api/classes/RBACEngine.md +1 -1
  49. package/docs/api/classes/RBACError.md +1 -1
  50. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  51. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  52. package/docs/api/classes/StorageUtils.md +1 -1
  53. package/docs/api/interfaces/AggregateConfig.md +1 -1
  54. package/docs/api/interfaces/ButtonProps.md +1 -1
  55. package/docs/api/interfaces/CardProps.md +1 -1
  56. package/docs/api/interfaces/ColorPalette.md +1 -1
  57. package/docs/api/interfaces/ColorShade.md +1 -1
  58. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  59. package/docs/api/interfaces/DataTableAction.md +1 -1
  60. package/docs/api/interfaces/DataTableColumn.md +1 -1
  61. package/docs/api/interfaces/DataTableProps.md +1 -1
  62. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  63. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  64. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  65. package/docs/api/interfaces/EventContextType.md +1 -1
  66. package/docs/api/interfaces/EventLogoProps.md +1 -1
  67. package/docs/api/interfaces/EventProviderProps.md +1 -1
  68. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  69. package/docs/api/interfaces/FileUploadProps.md +1 -1
  70. package/docs/api/interfaces/FooterProps.md +1 -1
  71. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  72. package/docs/api/interfaces/InputProps.md +1 -1
  73. package/docs/api/interfaces/LabelProps.md +1 -1
  74. package/docs/api/interfaces/LoginFormProps.md +1 -1
  75. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  76. package/docs/api/interfaces/NavigationContextType.md +1 -1
  77. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  78. package/docs/api/interfaces/NavigationItem.md +1 -1
  79. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  80. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  81. package/docs/api/interfaces/Organisation.md +1 -1
  82. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  83. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  84. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  85. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  86. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  87. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  88. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  89. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  90. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  91. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  92. package/docs/api/interfaces/PaletteData.md +1 -1
  93. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  94. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  95. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  96. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  97. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  98. package/docs/api/interfaces/PublicPageHeaderProps.md +2 -2
  99. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  100. package/docs/api/interfaces/RBACConfig.md +1 -1
  101. package/docs/api/interfaces/RBACContextType.md +1 -1
  102. package/docs/api/interfaces/RBACLogger.md +1 -1
  103. package/docs/api/interfaces/RBACProviderProps.md +1 -1
  104. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  105. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  106. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  107. package/docs/api/interfaces/RouteConfig.md +1 -1
  108. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  109. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  110. package/docs/api/interfaces/StorageConfig.md +1 -1
  111. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  112. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  113. package/docs/api/interfaces/StorageListOptions.md +1 -1
  114. package/docs/api/interfaces/StorageListResult.md +1 -1
  115. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  116. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  117. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  118. package/docs/api/interfaces/StyleImport.md +1 -1
  119. package/docs/api/interfaces/SwitchProps.md +1 -1
  120. package/docs/api/interfaces/ToastActionElement.md +1 -1
  121. package/docs/api/interfaces/ToastProps.md +1 -1
  122. package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
  123. package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
  124. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  125. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  126. package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
  127. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  128. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  129. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  130. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  131. package/docs/api/interfaces/UserEventAccess.md +1 -1
  132. package/docs/api/interfaces/UserMenuProps.md +1 -1
  133. package/docs/api/interfaces/UserProfile.md +1 -1
  134. package/docs/api/modules.md +39 -14
  135. package/docs/architecture/services.md +374 -0
  136. package/docs/best-practices/README.md +1 -1
  137. package/docs/best-practices/testing.md +1 -1
  138. package/docs/breaking-changes.md +182 -0
  139. package/docs/common-patterns.md +445 -0
  140. package/docs/core-concepts/authentication.md +26 -11
  141. package/docs/core-concepts/events.md +2 -0
  142. package/docs/core-concepts/organisations.md +2 -0
  143. package/docs/core-concepts/permissions.md +2 -0
  144. package/docs/{INDEX.md → documentation-index.md} +26 -38
  145. package/docs/faq.md +286 -0
  146. package/docs/{FILE_REFERENCE_SYSTEM.md → file-reference-system.md} +1 -1
  147. package/docs/getting-started/installation-guide.md +284 -0
  148. package/docs/getting-started/quick-start.md +8 -1
  149. package/docs/implementation-guides/app-layout.md +3 -1
  150. package/docs/implementation-guides/data-tables.md +2 -0
  151. package/docs/implementation-guides/dynamic-colors.md +47 -2
  152. package/docs/implementation-guides/event-theming-summary.md +220 -0
  153. package/docs/implementation-guides/forms.md +9 -7
  154. package/docs/implementation-guides/navigation.md +2 -0
  155. package/docs/migration/service-architecture.md +351 -0
  156. package/docs/rbac/README-rbac-rls-integration.md +2 -2
  157. package/docs/rbac/README.md +1 -1
  158. package/docs/rbac/examples/rbac-rls-integration-example.md +3 -3
  159. package/docs/rbac/quick-start.md +2 -0
  160. package/docs/rbac/rbac-rls-integration.md +2 -2
  161. package/docs/style-guide.md +136 -1
  162. package/docs/testing/README.md +1 -1
  163. package/docs/troubleshooting/authentication-issues.md +334 -0
  164. package/docs/troubleshooting/common-issues.md +2 -0
  165. package/docs/troubleshooting/styling-issues.md +199 -144
  166. package/docs/usage.md +23 -2
  167. package/package.json +1 -1
  168. package/src/__tests__/{TESTING_GUIDELINES.md → TEST_GUIDE_CURSOR.md} +20 -0
  169. package/src/__tests__/TEST_GUIDE_HUMAN.md +103 -0
  170. package/src/__tests__/fixtures/test-data.ts +90 -0
  171. package/src/__tests__/helpers/__tests__/component-test-utils.test.tsx +260 -0
  172. package/src/__tests__/helpers/__tests__/optimized-test-setup.test.ts +224 -0
  173. package/src/__tests__/helpers/__tests__/supabaseMock.test.ts +273 -0
  174. package/src/__tests__/helpers/__tests__/test-providers.test.tsx +98 -0
  175. package/src/__tests__/helpers/__tests__/test-utils.test.tsx +436 -0
  176. package/src/__tests__/helpers/__tests__/timer-utils.test.ts +371 -0
  177. package/src/__tests__/helpers/component-test-utils.tsx +14 -4
  178. package/src/__tests__/helpers/optimized-test-setup.ts +68 -0
  179. package/src/__tests__/helpers/test-providers.tsx +329 -0
  180. package/src/__tests__/helpers/test-utils.tsx +91 -45
  181. package/src/__tests__/helpers/timer-utils.ts +71 -0
  182. package/src/__tests__/hooks/usePermissions.test.ts +1 -5
  183. package/src/__tests__/integration/UserProfile.test.tsx +1 -5
  184. package/src/__tests__/rbac/PagePermissionGuard.test.tsx +42 -12
  185. package/src/__tests__/setup.ts +34 -28
  186. package/src/components/Alert/Alert.test.tsx +1 -5
  187. package/src/components/Avatar/Avatar.test.tsx +1 -5
  188. package/src/components/Button/Button.test.tsx +4 -20
  189. package/src/components/Card/Card.test.tsx +1 -5
  190. package/src/components/Checkbox/Checkbox.test.tsx +1 -5
  191. package/src/components/DataTable/__tests__/DataTable.comprehensive.test.tsx +1 -5
  192. package/src/components/DataTable/__tests__/DataTable.test.tsx +45 -49
  193. package/src/components/DataTable/__tests__/DataTableCore.test.tsx +1 -5
  194. package/src/components/DataTable/__tests__/styles.test.ts +382 -0
  195. package/src/components/DataTable/context/__tests__/DataTableContext.test.tsx +409 -0
  196. package/src/components/DataTable/core/__tests__/ActionManager.test.ts +634 -0
  197. package/src/components/DataTable/core/__tests__/DataManager.test.ts +519 -0
  198. package/src/components/DataTable/core/__tests__/StateManager.test.ts +714 -0
  199. package/src/components/DataTable/hooks/__tests__/useDataTableState.test.ts +592 -0
  200. package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +354 -0
  201. package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +539 -0
  202. package/src/components/Dialog/examples/__tests__/SmartDialogExample.unit.test.tsx +1 -5
  203. package/src/components/Dialog/utils/__tests__/safeHtml.unit.test.ts +1 -8
  204. package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +34 -38
  205. package/src/components/Footer/Footer.test.tsx +1 -5
  206. package/src/components/Form/Form.test.tsx +22 -35
  207. package/src/components/Header/Header.test.tsx +1 -9
  208. package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +1 -5
  209. package/src/components/Input/Input.test.tsx +2 -10
  210. package/src/components/LoginForm/LoginForm.test.tsx +1 -5
  211. package/src/components/NavigationMenu/NavigationMenu.test.tsx +24 -24
  212. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.accessibility.test.tsx +1 -6
  213. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.integration.test.tsx +6 -16
  214. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.performance.test.tsx +1 -5
  215. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +1 -5
  216. package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +1 -7
  217. package/src/components/PasswordReset/PasswordChangeForm.test.tsx +1 -9
  218. package/src/components/PasswordReset/PasswordResetForm.test.tsx +1 -9
  219. package/src/components/PublicLayout/PublicErrorBoundary.tsx +4 -5
  220. package/src/components/PublicLayout/PublicPageHeader.tsx +13 -9
  221. package/src/components/PublicLayout/__tests__/EventLogo.test.tsx +666 -0
  222. package/src/components/PublicLayout/__tests__/PublicErrorBoundary.test.tsx +457 -0
  223. package/src/components/PublicLayout/__tests__/PublicLoadingSpinner.test.tsx +393 -0
  224. package/src/components/PublicLayout/__tests__/PublicPageFooter.test.tsx +351 -0
  225. package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +374 -0
  226. package/src/components/PublicLayout/__tests__/PublicPageLayout.test.tsx +388 -0
  227. package/src/components/Select/Select.bug-test.tsx +69 -0
  228. package/src/components/Select/Select.refactored.tsx +497 -0
  229. package/src/components/Select/Select.test.tsx +42 -49
  230. package/src/components/Select/Select.tsx +5 -2
  231. package/src/components/Select/hooks.ts +254 -0
  232. package/src/components/Switch/Switch.test.tsx +1 -5
  233. package/src/components/Table/__tests__/Table.test.tsx +775 -0
  234. package/src/components/Toast/Toast.test.tsx +15 -8
  235. package/src/components/Tooltip/Tooltip.test.tsx +1 -5
  236. package/src/components/UserMenu/UserMenu.test.tsx +3 -15
  237. package/src/components/__tests__/FileDisplay.test.tsx +575 -0
  238. package/src/components/__tests__/FileUpload.test.tsx +446 -0
  239. package/src/components/__tests__/SuperAdminGuard.test.tsx +422 -354
  240. package/src/hooks/__tests__/ServiceHooks.test.tsx +613 -0
  241. package/src/hooks/__tests__/hooks.integration.test.tsx +1 -10
  242. package/src/hooks/__tests__/useApiFetch.unit.test.ts +10 -14
  243. package/src/hooks/__tests__/useAppConfig.unit.test.ts +307 -0
  244. package/src/hooks/__tests__/useComponentPerformance.unit.test.tsx +1 -6
  245. package/src/hooks/__tests__/useFocusTrap.unit.test.tsx +1 -5
  246. package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +6 -9
  247. package/src/hooks/__tests__/usePublicEvent.simple.test.ts +321 -0
  248. package/src/hooks/__tests__/usePublicEvent.unit.test.ts +583 -0
  249. package/src/hooks/__tests__/usePublicEventLogo.unit.test.ts +640 -0
  250. package/src/hooks/__tests__/usePublicRouteParams.unit.test.ts +435 -0
  251. package/src/hooks/__tests__/useRBAC.unit.test.ts +10 -10
  252. package/src/hooks/__tests__/useStorage.unit.test.ts +751 -0
  253. package/src/hooks/index.ts +3 -0
  254. package/src/hooks/public/usePublicEvent.ts +30 -9
  255. package/src/hooks/public/usePublicRouteParams.ts +13 -3
  256. package/src/hooks/services/useAuth.ts +50 -0
  257. package/src/hooks/services/useAuthService.ts +30 -0
  258. package/src/hooks/services/useCurrentEvent.ts +36 -0
  259. package/src/hooks/services/useCurrentOrganisation.ts +52 -0
  260. package/src/hooks/services/useEventService.ts +30 -0
  261. package/src/hooks/services/useInactivityService.ts +30 -0
  262. package/src/hooks/services/useOrganisationService.ts +30 -0
  263. package/src/hooks/services/usePermissions.ts +70 -0
  264. package/src/hooks/services/useRBACService.ts +30 -0
  265. package/src/hooks/useCounter.test.ts +1 -5
  266. package/src/hooks/useEventTheme.ts +86 -0
  267. package/src/hooks/useOrganisationPermissions.test.ts +2 -5
  268. package/src/hooks/useOrganisationSecurity.test.ts +1 -5
  269. package/src/hooks/usePermissionCache.test.ts +1 -5
  270. package/src/hooks/usePermissionCheck.ts +150 -0
  271. package/src/hooks/useSecureDataAccess.test.ts +1 -5
  272. package/src/index.ts +1 -0
  273. package/src/providers/OrganisationProvider.test.tsx +1 -5
  274. package/src/providers/OrganisationProvider.tsx +56 -4
  275. package/src/providers/UnifiedAuthProvider.test.tsx +1 -5
  276. package/src/providers/__tests__/AuthProvider.test.tsx +105 -439
  277. package/src/providers/__tests__/AuthProvider.test.tsx.backup +771 -0
  278. package/src/providers/__tests__/EventProvider.test.tsx +211 -110
  279. package/src/providers/__tests__/EventProvider.test.tsx.backup +824 -0
  280. package/src/providers/__tests__/InactivityProvider.test.tsx +1 -5
  281. package/src/providers/__tests__/OrganisationProvider.test.tsx +97 -261
  282. package/src/providers/__tests__/OrganisationProvider.test.tsx.backup +820 -0
  283. package/src/providers/__tests__/ServiceProviders.test.tsx +477 -0
  284. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +72 -504
  285. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup +911 -0
  286. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup2 +166 -0
  287. package/src/providers/services/AuthServiceProvider.tsx +65 -0
  288. package/src/providers/services/EventServiceProvider.tsx +83 -0
  289. package/src/providers/services/InactivityServiceProvider.tsx +83 -0
  290. package/src/providers/services/OrganisationServiceProvider.tsx +77 -0
  291. package/src/providers/services/RBACServiceProvider.tsx +79 -0
  292. package/src/providers/services/UnifiedAuthProvider.tsx +368 -0
  293. package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +210 -0
  294. package/src/providers/services/__tests__/UnifiedAuthProvider.integration.test.tsx +269 -0
  295. package/src/rbac/__tests__/adapters.comprehensive.test.tsx +892 -0
  296. package/src/rbac/__tests__/engine.comprehensive.test.ts +954 -0
  297. package/src/rbac/__tests__/integration.authflow.test.tsx +1 -5
  298. package/src/rbac/__tests__/integration.navigation.test.tsx +1 -4
  299. package/src/rbac/__tests__/rbac-core.test.tsx +2 -7
  300. package/src/rbac/__tests__/rbac-functions.test.ts +1 -9
  301. package/src/rbac/__tests__/rbac-integration.test.ts +1 -9
  302. package/src/rbac/api.test.ts +1 -9
  303. package/src/rbac/cache.test.ts +10 -8
  304. package/src/rbac/cli/__tests__/policy-manager.test.ts +339 -0
  305. package/src/rbac/components/EnhancedNavigationMenu.test.tsx +1 -5
  306. package/src/rbac/components/NavigationProvider.test.tsx +1 -5
  307. package/src/rbac/components/PagePermissionProvider.test.tsx +1 -5
  308. package/src/rbac/components/SecureDataProvider.test.tsx +1 -5
  309. package/src/rbac/components/__tests__/NavigationGuard.test.tsx +25 -29
  310. package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +27 -30
  311. package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +23 -27
  312. package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +18 -22
  313. package/src/rbac/config.test.ts +1 -5
  314. package/src/rbac/hooks/useCan.test.ts +262 -9
  315. package/src/rbac/hooks/usePermissions.test.ts +246 -6
  316. package/src/rbac/hooks/useRBAC.simple.test.ts +1 -5
  317. package/src/rbac/hooks/useRBAC.test.ts +472 -198
  318. package/src/rbac/providers/__tests__/RBACProvider.test.tsx +1 -9
  319. package/src/services/AuthService.ts +416 -0
  320. package/src/services/EventService.ts +366 -0
  321. package/src/services/InactivityService.ts +388 -0
  322. package/src/services/OrganisationService.ts +592 -0
  323. package/src/services/RBACService.ts +522 -0
  324. package/src/services/__tests__/AuthService.test.ts +356 -0
  325. package/src/services/__tests__/BaseService.test.ts +314 -0
  326. package/src/services/__tests__/EventService.test.ts +489 -0
  327. package/src/services/__tests__/InactivityService.test.ts +403 -0
  328. package/src/services/__tests__/OrganisationService.test.ts +660 -0
  329. package/src/services/__tests__/RBACService.test.ts +492 -0
  330. package/src/services/base/BaseService.ts +87 -0
  331. package/src/services/interfaces/IAuthService.ts +39 -0
  332. package/src/services/interfaces/IEventService.ts +30 -0
  333. package/src/services/interfaces/IInactivityService.ts +31 -0
  334. package/src/services/interfaces/IOrganisationService.ts +41 -0
  335. package/src/services/interfaces/IRBACService.ts +62 -0
  336. package/src/theming/__tests__/runtime.test.ts +540 -0
  337. package/src/types/__tests__/file-reference.test.ts +447 -0
  338. package/src/types/__tests__/organisation.test.ts +1133 -0
  339. package/src/types/__tests__/theme.test.ts +830 -0
  340. package/src/types/__tests__/type-validation.test.ts +527 -0
  341. package/src/utils/__tests__/bundleAnalysis.unit.test.ts +1 -5
  342. package/src/utils/__tests__/debugLogger.test.ts +417 -0
  343. package/src/utils/__tests__/deviceFingerprint.unit.test.ts +1 -6
  344. package/src/utils/__tests__/dynamicUtils.unit.test.ts +1 -5
  345. package/src/utils/__tests__/lazyLoad.unit.test.tsx +35 -35
  346. package/src/utils/__tests__/organisationContext.unit.test.ts +1 -5
  347. package/src/utils/__tests__/performanceBudgets.unit.test.ts +5 -11
  348. package/src/utils/__tests__/secureErrors.unit.test.ts +1 -6
  349. package/src/utils/__tests__/secureStorage.unit.test.ts +1 -5
  350. package/src/utils/__tests__/securityMonitor.unit.test.ts +1 -5
  351. package/src/utils/__tests__/sessionTracking.unit.test.ts +1 -5
  352. package/src/utils/appIdResolver.test.ts +6 -10
  353. package/src/utils/appNameResolver.simple.test.ts +142 -0
  354. package/src/utils/appNameResolver.test.ts +31 -458
  355. package/src/utils/appNameResolver.test.ts.backup +494 -0
  356. package/src/utils/debugLogger.ts +26 -5
  357. package/src/utils/formatDate.test.ts +1 -5
  358. package/src/utils/organisationContext.test.ts +1 -5
  359. package/src/utils/performanceBudgets.ts +3 -4
  360. package/src/utils/secureDataAccess.test.ts +1 -5
  361. package/src/utils/storage/__tests__/helpers.unit.test.ts +1 -5
  362. package/src/validation/__tests__/sqlInjectionProtection.unit.test.ts +1 -5
  363. package/dist/chunk-D7ARGIA3.js.map +0 -1
  364. package/dist/chunk-IPCH4YPT.js +0 -315
  365. package/dist/chunk-IPCH4YPT.js.map +0 -1
  366. package/dist/chunk-KRCRNXPD.js.map +0 -1
  367. package/dist/chunk-MOJXHWDE.js.map +0 -1
  368. package/dist/chunk-OPCWH3A4.js.map +0 -1
  369. package/dist/chunk-ZPG4XPV5.js.map +0 -1
  370. package/dist/chunk-ZPK5656W.js.map +0 -1
  371. package/docs/getting-started/installation.md +0 -269
  372. package/src/__tests__/REBUILD_PLAN.md +0 -223
  373. /package/dist/{DataTable-4IUY7BXB.js.map → DataTable-MPBSXUC6.js.map} +0 -0
  374. /package/dist/{chunk-PXWEDX7Y.js.map → chunk-2ARQW6VX.js.map} +0 -0
  375. /package/dist/{chunk-UYA6U6H7.js.map → chunk-Q2UP3ZWQ.js.map} +0 -0
@@ -1,32 +1,81 @@
1
- # Styling Issues Troubleshooting
1
+ # Troubleshooting Styling Issues
2
2
 
3
- This guide helps you diagnose and fix common styling issues when using pace-core components.
3
+ > **🎨 Styling Problems?** | [← Back to Troubleshooting](../README.md) | [Troubleshooting Overview](./common-issues.md)
4
4
 
5
- ## 🚨 Most Common Issue: Unstyled Components
5
+ Quick fixes and solutions for common styling issues with PACE Core components.
6
6
 
7
- ### Symptoms
8
- - Components render but appear unstyled (no colors, spacing, or typography)
9
- - Buttons look like plain HTML buttons
10
- - Cards appear as plain divs
11
- - Colors like `text-main-900`, `bg-sec-500` don't work
7
+ ## 🚨 Most Common Issues
12
8
 
13
- ### Root Cause
14
- **Pace-core components are not being scanned for Tailwind classes during the build process.**
9
+ ### Components Appear Unstyled
15
10
 
16
- ### Solution
17
- Update your `vite.config.ts` to include pace-core in content scanning:
11
+ **Symptoms:**
12
+ - Components render without styles
13
+ - Default browser styling appears
14
+ - No colors, spacing, or fonts
15
+
16
+ **Immediate Fix:**
17
+ ```tsx
18
+ // ✅ In your entry point (main.tsx or App.tsx)
19
+ import '@jmruthers/pace-core/src/styles/core.css'; // MUST be first
20
+ import './app.css'; // Your app's color palette
21
+ ```
22
+
23
+ **Checklist:**
24
+ - [ ] CSS files imported in correct order (core.css first, then app.css)
25
+ - [ ] Tailwind v4 installed (`npm list tailwindcss`)
26
+ - [ ] Vite configured with pace-core content scanning
27
+ - [ ] Dev server restarted after config changes
28
+
29
+ ### Colors Don't Work
30
+
31
+ **Symptoms:**
32
+ - `bg-main-600` shows as gray or doesn't work
33
+ - Tailwind utilities return default colors
34
+ - Theme colors not applied
35
+
36
+ **Fix:**
37
+ ```css
38
+ /* src/app.css - MUST contain color palettes */
39
+ @import "tailwindcss";
40
+
41
+ /* Source directives */
42
+ @source "./src/**/*.{js,ts,jsx,tsx}";
43
+ @source "./node_modules/@jmruthers/pace-core/src/**/*.{js,ts,jsx,tsx}";
44
+
45
+ /* Color palettes - REQUIRED */
46
+ @theme static {
47
+ --color-main-50: oklch(0.98 0.003 300);
48
+ --color-main-100: oklch(0.96 0.014 300);
49
+ /* ... continue through 950 for main, sec, acc */
50
+ }
51
+ ```
52
+
53
+ ### Tailwind v4 Not Working
54
+
55
+ **Symptoms:**
56
+ - Build errors about Tailwind configuration
57
+ - Styles not generated
58
+ - "Cannot find module '@tailwindcss/vite'"
59
+
60
+ **Fix:**
61
+ ```bash
62
+ # Install Tailwind v4 (correct version)
63
+ npm uninstall tailwindcss@^3.0.0
64
+ npm install -D @tailwindcss/vite tailwindcss@^4.0.0
65
+
66
+ # Verify installation
67
+ npm list tailwindcss
68
+ # Should show: tailwindcss@^4.0.0
69
+ ```
18
70
 
19
71
  ```ts
20
- // vite.config.ts
21
- import { defineConfig } from 'vite'
22
- import react from '@vitejs/plugin-react'
72
+ // vite.config.ts - Required configuration
23
73
  import tailwindcss from '@tailwindcss/vite'
24
74
 
25
75
  export default defineConfig({
26
76
  plugins: [
27
77
  react(),
28
78
  tailwindcss({
29
- // CRITICAL: Include pace-core components for scanning
30
79
  content: [
31
80
  './src/**/*.{js,ts,jsx,tsx}',
32
81
  './node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}'
@@ -36,184 +85,190 @@ export default defineConfig({
36
85
  })
37
86
  ```
38
87
 
39
- ### Verification Steps
40
- 1. **Check your Vite config** - Ensure pace-core is included in content array
41
- 2. **Restart dev server** - Configuration changes require a restart
42
- 3. **Test with a simple component**:
43
- ```tsx
44
- import { Button } from '@jmruthers/pace-core';
45
-
46
- function Test() {
47
- return <Button variant="primary">Test</Button>;
48
- }
49
- ```
50
- 4. **Check browser dev tools** - Look for missing CSS classes in the computed styles
88
+ ### Fonts Not Loading
51
89
 
52
- ## 🔍 Other Common Issues
90
+ **Symptoms:**
91
+ - Text appears in system default font
92
+ - Font files not found in network tab
53
93
 
54
- ### Issue: CSS file not imported
55
-
56
- **Symptoms**: No styles at all, components look completely unstyled
57
-
58
- **Solution**: Import the CSS file in your main entry point:
94
+ **Fix:**
59
95
  ```tsx
60
- // src/main.tsx or src/index.tsx
96
+ // Fonts are included in core.css
97
+ import '@jmruthers/pace-core/src/styles/core.css';
98
+
99
+ // Verify fonts are loading
61
100
  import '@jmruthers/pace-core/src/styles/core.css';
101
+ // Check browser DevTools > Network > Font for Georama, Open Sans, Reddit Mono
62
102
  ```
63
103
 
64
- ### Issue: Colors not working
104
+ ### CSS Conflicts with Existing Styles
65
105
 
66
- **Symptoms**: Components render but colors like `text-main-900`, `bg-sec-500` don't apply
106
+ **Symptoms:**
107
+ - PACE Core styles override your custom styles
108
+ - Unexpected styling conflicts
109
+ - Specificity issues
67
110
 
68
- **Possible Causes**:
69
- 1. CSS file not imported
70
- 2. Pace-core not included in content scanning
71
- 3. Tailwind v3 instead of v4
111
+ **Fix:**
112
+ ```css
113
+ /* Use CSS layers to control specificity */
114
+ @layer pace-core, your-app;
72
115
 
73
- **Solution**:
74
- 1. Ensure CSS file is imported
75
- 2. Check Vite configuration includes pace-core
76
- 3. Verify you're using Tailwind v4: `npm list tailwindcss`
116
+ /* Your app styles will take precedence when needed */
117
+ @layer your-app {
118
+ .my-custom-button {
119
+ /* Your styles here */
120
+ }
121
+ }
122
+ ```
77
123
 
78
- ### Issue: Styles work in dev but not production
124
+ ## 🔧 Detailed Solutions
79
125
 
80
- **Symptoms**: Components look good in development but unstyled in production build
126
+ ### Vite Configuration Issues
81
127
 
82
- **Solution**: Ensure your build configuration also includes content scanning:
128
+ **Problem:** Tailwind not scanning pace-core source files
129
+
130
+ **Solution:**
83
131
  ```ts
84
- // vite.config.ts
132
+ // vite.config.ts - REQUIRED
133
+ import { defineConfig } from 'vite'
134
+ import react from '@vitejs/plugin-react'
135
+ import tailwindcss from '@tailwindcss/vite'
136
+
85
137
  export default defineConfig({
86
138
  plugins: [
87
139
  react(),
88
140
  tailwindcss({
141
+ // CRITICAL: Must include pace-core source files
89
142
  content: [
90
143
  './src/**/*.{js,ts,jsx,tsx}',
91
- './node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}'
144
+ './node_modules/@jmruthers/pace-core/src/**/*.{js,ts,jsx,tsx}',
145
+ './node_modules/@jmruthers/pace-core/src/components/**/*.{js,ts,jsx,tsx}',
146
+ './node_modules/@jmruthers/pace-core/src/providers/**/*.{js,ts,jsx,tsx}'
92
147
  ]
93
148
  })
94
149
  ],
95
- build: {
96
- // Your build config
97
- }
98
150
  })
99
151
  ```
100
152
 
101
- ### Issue: Build errors about missing classes
153
+ ### Import Order Issues
102
154
 
103
- **Symptoms**: Build fails with errors about missing Tailwind classes
155
+ **Problem:** Styles not applied due to import order
104
156
 
105
- **Solution**: Check that your content paths are correct and include both source files and pace-core:
106
- ```ts
107
- content: [
108
- './src/**/*.{js,ts,jsx,tsx}',
109
- './node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}'
110
- ]
111
- ```
157
+ **Solution:**
158
+ ```tsx
159
+ // ✅ CORRECT ORDER
160
+ // 1. Import core.css first
161
+ import '@jmruthers/pace-core/src/styles/core.css';
112
162
 
113
- ### Issue: Some components work, others don't
163
+ // 2. Import your app.css second
164
+ import './app.css';
114
165
 
115
- **Symptoms**: Some pace-core components are styled, others are not
166
+ // 3. Import your other styles
167
+ import './index.css';
116
168
 
117
- **Possible Causes**:
118
- 1. Partial content scanning
119
- 2. Different import paths
120
- 3. Component-specific issues
169
+ // ❌ WRONG ORDER
170
+ import './app.css';
171
+ import '@jmruthers/pace-core/src/styles/core.css'; // Too late!
172
+ ```
121
173
 
122
- **Solution**:
123
- 1. Check that all pace-core paths are included in content scanning
124
- 2. Try the alternative configuration:
125
- ```ts
126
- tailwindcss({
127
- content: {
128
- files: [
129
- './src/**/*.{js,ts,jsx,tsx}',
130
- './node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}',
131
- './node_modules/@jmruthers/pace-core/dist/**/*.{js,ts,jsx,tsx}'
132
- ]
133
- }
134
- })
135
- ```
174
+ ### Missing Color Palette
175
+
176
+ **Problem:** Error or gray colors because color palette not defined
177
+
178
+ **Complete app.css Template:**
179
+ ```css
180
+ /* src/app.css */
181
+ @import "tailwindcss";
182
+
183
+ /* Source directives for scanning */
184
+ @source "./src/**/*.{js,ts,jsx,tsx}";
185
+ @source "./node_modules/@jmruthers/pace-core/src/**/*.{js,ts,jsx,tsx}";
186
+
187
+ /* Main palette - Primary brand color */
188
+ @theme static {
189
+ --color-main-50: oklch(0.98 0.003 300);
190
+ --color-main-100: oklch(0.96 0.014 300);
191
+ --color-main-200: oklch(0.927 0.033 300);
192
+ --color-main-300: oklch(0.881 0.059 300);
193
+ --color-main-400: oklch(0.822 0.093 300);
194
+ --color-main-500: oklch(0.75 0.133 300);
195
+ --color-main-600: oklch(0.665 0.182 300);
196
+ --color-main-700: oklch(0.58 0.23 300);
197
+ --color-main-800: oklch(0.456 0.158 300);
198
+ --color-main-900: oklch(0.332 0.099 300);
199
+ --color-main-950: oklch(0.195 0.047 300);
200
+
201
+ /* Secondary palette */
202
+ --color-sec-50: oklch(0.98 0.003 244.75);
203
+ /* ... continue through 950 */
204
+
205
+ /* Accent palette */
206
+ --color-acc-50: oklch(0.98 0.003 7.385);
207
+ /* ... continue through 950 */
208
+ }
209
+ ```
136
210
 
137
- ## 🔧 Advanced Troubleshooting
211
+ ## 🧪 Verification Steps
138
212
 
139
- ### Check if Tailwind is scanning pace-core
213
+ ### 1. Check Imports
140
214
 
141
- 1. **Enable Tailwind debug mode**:
142
- ```ts
143
- // vite.config.ts
144
- tailwindcss({
145
- content: [
146
- './src/**/*.{js,ts,jsx,tsx}',
147
- './node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}'
148
- ],
149
- debug: true // Add this for debugging
150
- })
151
- ```
215
+ ```tsx
216
+ // Add to your entry file to verify
217
+ console.log('✅ CSS imports working');
218
+ ```
152
219
 
153
- 2. **Check the generated CSS** - Look for pace-core specific classes in your build output
220
+ ### 2. Inspect Generated CSS
154
221
 
155
- 3. **Use browser dev tools** - Inspect elements to see which classes are missing
222
+ Open browser DevTools > Elements > Styles tab
223
+ - Should see Tailwind utility classes
224
+ - Colors should show oklch() values
225
+ - Component styles should be present
156
226
 
157
- ### Verify Tailwind v4 installation
227
+ ### 3. Test Basic Component
158
228
 
159
- ```bash
160
- # Check Tailwind version
161
- npm list tailwindcss
229
+ ```tsx
230
+ import { Button } from '@jmruthers/pace-core';
231
+
232
+ function Test() {
233
+ return <Button>Test Button</Button>;
234
+ }
162
235
 
163
- # Should show version 4.x.x, not 3.x.x
236
+ // Should render with proper PACE Core styling
237
+ // Not unstyled or default browser styling
164
238
  ```
165
239
 
166
- ### Check file paths
240
+ ## 🐛 Debug Commands
167
241
 
168
- Ensure your content paths are correct:
169
- - `./src/**/*.{js,ts,jsx,tsx}` - Your source files
170
- - `./node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}` - Pace-core components
242
+ ```bash
243
+ # Check Tailwind version
244
+ npm list tailwindcss
171
245
 
172
- ### Alternative content configuration
246
+ # Check if pace-core installed
247
+ npm list @jmruthers/pace-core
173
248
 
174
- If the standard configuration doesn't work, try this more explicit approach:
249
+ # Verify Vite configuration
250
+ npx vite --config vite.config.ts --debug
175
251
 
176
- ```ts
177
- // vite.config.ts
178
- export default defineConfig({
179
- plugins: [
180
- react(),
181
- tailwindcss({
182
- content: {
183
- files: [
184
- './src/**/*.{js,ts,jsx,tsx}',
185
- './node_modules/@jmruthers/pace-core/**/*.{js,ts,jsx,tsx}',
186
- './node_modules/@jmruthers/pace-core/dist/**/*.{js,ts,jsx,tsx}'
187
- ]
188
- }
189
- })
190
- ],
191
- })
252
+ # Build and check for errors
253
+ npm run build
192
254
  ```
193
255
 
194
- ## Quick Checklist
195
-
196
- Before asking for help, verify:
256
+ ## 📚 Related Documentation
197
257
 
198
- - [ ] CSS file is imported: `import '@jmruthers/pace-core/src/styles/core.css'`
199
- - [ ] Vite config includes pace-core in content scanning
200
- - [ ] Using Tailwind v4 (not v3)
201
- - [ ] Dev server restarted after config changes
202
- - [ ] All required peer dependencies installed
203
- - [ ] Test component renders with proper styling
258
+ - [Styling Overview](../styles/README.md) - Complete styling guide
259
+ - [Installation Guide](../getting-started/installation-guide.md) - Setup instructions
260
+ - [Vite Configuration](../consuming-app-vite-config.md) - Critical setup
261
+ - [Common Issues](./common-issues.md) - Other troubleshooting
204
262
 
205
- ## 🆘 Still Having Issues?
263
+ ## 🆘 Still Not Working?
206
264
 
207
- If you've tried all the above and still have problems:
265
+ If you've tried everything above and still have issues:
208
266
 
209
- 1. **Check the console** for any error messages
210
- 2. **Verify your setup** matches the [installation guide](../getting-started/installation.md)
211
- 3. **Test with a minimal example** to isolate the issue
212
- 4. **Check your package versions** for compatibility issues
267
+ 1. **Create a minimal test case** showing the problem
268
+ 2. **Gather debug info** using the commands above
269
+ 3. **Check browser console** for error messages
270
+ 4. **File an issue** with your findings
213
271
 
214
- ## 📚 Related Documentation
272
+ ---
215
273
 
216
- - [Installation Guide](../getting-started/installation.md) - Complete setup instructions
217
- - [Vite Configuration](../consuming-app-vite-config.md) - Detailed Vite setup
218
- - [Quick Start Guide](../getting-started/quick-start.md) - Step-by-step tutorial
219
- - [Styles Guide](../styles/README.md) - Understanding the styling system
274
+ **Last Updated:** 2025-01-XX | **Version:** v0.5.65+
package/docs/usage.md CHANGED
@@ -73,9 +73,30 @@ function MyComponent() {
73
73
 
74
74
  ## Dynamic Theming
75
75
 
76
- ### Organisation/Event Colors
76
+ ### Automatic Event Theming (Recommended)
77
77
 
78
- Apply dynamic colors from your database:
78
+ If your app uses the `EventProvider`, simply call `useEventTheme()`:
79
+
80
+ ```tsx
81
+ import { useEventTheme } from '@jmruthers/pace-core';
82
+
83
+ function MyApp() {
84
+ // Automatically applies event colors when an event is selected
85
+ useEventTheme();
86
+
87
+ return <div>Your app</div>;
88
+ }
89
+ ```
90
+
91
+ This hook automatically:
92
+ - Applies event colors when an event is selected
93
+ - Clears theming when no event is selected
94
+ - Handles cleanup and error cases
95
+ - Works consistently across all apps
96
+
97
+ ### Manual Organisation/Event Colors
98
+
99
+ For custom logic or organisation-based theming:
79
100
 
80
101
  ```tsx
81
102
  import { applyPalette, clearPalette } from '@jmruthers/pace-core/theming/runtime';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmruthers/pace-core",
3
- "version": "0.5.68",
3
+ "version": "0.5.69",
4
4
  "description": "Clean, modern React component library with Tailwind v4 styling and native utilities",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -293,6 +293,26 @@ screen.getByLabelText('Email address');
293
293
  - ❌ Configuration files
294
294
  - ❌ Type definitions
295
295
 
296
+ ## 🧩 Test Expansion Workflow
297
+
298
+ When expanding test coverage:
299
+
300
+ 1. **Start with the coverage report** (`npm test -- --coverage`)
301
+ 2. Identify high-priority or under-tested modules
302
+ 3. Choose the appropriate test type (unit, component, integration)
303
+ 4. Use our standard structure and semantic queries
304
+ 5. Assert observable behaviour (not internal state or styles)
305
+ 6. Use test tags (`[unit]`, `[integration]`, etc.) for discoverability
306
+
307
+ ## ✅ Pre-Merge Test Checklist
308
+
309
+ - [ ] Are all tests passing (no `it.only` or `test.skip`)?
310
+ - [ ] Are coverage thresholds still met?
311
+ - [ ] Are tests colocated with the source?
312
+ - [ ] Are semantic queries used (no test IDs)?
313
+ - [ ] Is global state cleaned up properly?
314
+ - [ ] Are new utilities or hooks covered with tests?
315
+
296
316
  ## 🚀 Running Tests
297
317
 
298
318
  ### Commands
@@ -0,0 +1,103 @@
1
+
2
+ # 🎯 Cursor-Friendly Testing Guide (pace-core)
3
+
4
+ This is a simplified version of our full `TESTING_GUIDELINES.md`, designed for use by Cursor or other automated tools.
5
+
6
+ ---
7
+
8
+ ## ✅ Testing Principles (Keep It Simple)
9
+
10
+ - Test observable behaviour, not internal state or styling
11
+ - Prefer unit/component tests; use integration tests only where needed
12
+ - Avoid brittle selectors and over-mocking
13
+
14
+ ---
15
+
16
+ ## 🧪 Preferred Patterns
17
+
18
+ ### Semantic Queries
19
+ Use these in place of test IDs or class names:
20
+ ```ts
21
+ getByRole, getByText, getByLabelText, findByText
22
+ ```
23
+
24
+ ### Hook Testing
25
+ ```ts
26
+ const { result } = renderHook(() => useCustomHook());
27
+ expect(result.current.value).toBe('expected');
28
+ ```
29
+
30
+ ### Component Testing
31
+ ```ts
32
+ describe('MyComponent', () => {
33
+ it('renders correctly', () => {
34
+ render(<MyComponent />);
35
+ expect(screen.getByRole('heading')).toHaveTextContent('Title');
36
+ });
37
+ });
38
+ ```
39
+
40
+ ### Async Behaviour
41
+ ```ts
42
+ const button = await screen.findByRole('button');
43
+ await user.click(button);
44
+ expect(await screen.findByText('Submitted')).toBeInTheDocument();
45
+ ```
46
+
47
+ ---
48
+
49
+ ## ♻️ Structure & Naming
50
+
51
+ - Test files should be colocated: `MyComponent.test.tsx`, `useThing.test.ts`
52
+ - Use structured `describe` blocks for clarity:
53
+ ```ts
54
+ describe('ComponentName', () => {
55
+ describe('Rendering', () => {});
56
+ describe('User Interactions', () => {});
57
+ describe('Error Handling', () => {});
58
+ });
59
+ ```
60
+
61
+ ---
62
+
63
+ ## 🔧 Mocking & Cleanup
64
+
65
+ ### Mocks
66
+ ```ts
67
+ vi.mock('module', () => ({
68
+ myFn: vi.fn(),
69
+ }));
70
+ ```
71
+
72
+ ### Cleanup
73
+ ```ts
74
+ afterEach(() => {
75
+ cleanup();
76
+ vi.clearAllMocks();
77
+ vi.useRealTimers();
78
+ });
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 📊 Coverage Targets
84
+
85
+ - Utils/Hooks: ≥ 95%
86
+ - UI Components: ≥ 90%
87
+ - Feature Modules: ≥ 85%
88
+ - Overall Project: ≥ 82%
89
+
90
+ ---
91
+
92
+ ## 🚫 Avoid
93
+
94
+ - `getByTestId`, `getByClassName`, DOM structure assertions
95
+ - Snapshot tests (unless explicitly stable)
96
+ - Global state leaks (unreset between tests)
97
+ - Asserting internal state or props
98
+
99
+ ---
100
+
101
+ ## 🧠 Remember
102
+
103
+ Tests should be readable, behavioural, isolated, and maintainable.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @file Test Data Fixtures
3
+ * @description Shared test data to reduce generation overhead
4
+ */
5
+
6
+ import { vi } from 'vitest';
7
+
8
+ // Pre-generated test data to avoid repeated object creation
9
+ export const TEST_FIXTURES = {
10
+ users: {
11
+ basic: {
12
+ id: 'test-user-id',
13
+ email: 'test@example.com',
14
+ name: 'Test User',
15
+ created_at: '2023-01-01T00:00:00Z',
16
+ },
17
+ admin: {
18
+ id: 'admin-user-id',
19
+ email: 'admin@example.com',
20
+ name: 'Admin User',
21
+ role: 'admin',
22
+ created_at: '2023-01-01T00:00:00Z',
23
+ },
24
+ superAdmin: {
25
+ id: 'super-admin-id',
26
+ email: 'superadmin@example.com',
27
+ name: 'Super Admin',
28
+ role: 'super_admin',
29
+ created_at: '2023-01-01T00:00:00Z',
30
+ },
31
+ },
32
+
33
+ organisations: {
34
+ basic: {
35
+ id: 'org-123',
36
+ name: 'Test Organisation',
37
+ slug: 'test-org',
38
+ created_at: '2023-01-01T00:00:00Z',
39
+ },
40
+ },
41
+
42
+ events: {
43
+ basic: {
44
+ id: 'event-123',
45
+ name: 'Test Event',
46
+ code: 'TEST123',
47
+ organisation_id: 'org-123',
48
+ created_at: '2023-01-01T00:00:00Z',
49
+ },
50
+ },
51
+
52
+ permissions: {
53
+ read: 'read:users',
54
+ write: 'write:users',
55
+ delete: 'delete:users',
56
+ admin: 'admin:organisation',
57
+ },
58
+
59
+ mockFunctions: {
60
+ onClick: vi.fn(),
61
+ onSubmit: vi.fn(),
62
+ onError: vi.fn(),
63
+ onSuccess: vi.fn(),
64
+ },
65
+ } as const;
66
+
67
+ // Helper to create variations of fixtures
68
+ export const createFixture = <T extends Record<string, any>>(
69
+ base: T,
70
+ overrides: Partial<T> = {}
71
+ ): T => ({ ...base, ...overrides });
72
+
73
+ // Pre-generated arrays for bulk testing
74
+ export const BULK_FIXTURES = {
75
+ users: Array.from({ length: 10 }, (_, i) => ({
76
+ ...TEST_FIXTURES.users.basic,
77
+ id: `user-${i}`,
78
+ email: `user${i}@example.com`,
79
+ name: `User ${i}`,
80
+ })),
81
+
82
+ permissions: [
83
+ 'read:users',
84
+ 'write:users',
85
+ 'delete:users',
86
+ 'read:events',
87
+ 'write:events',
88
+ 'admin:organisation',
89
+ ],
90
+ } as const;