@micha.bigler/ui-core-micha 3.14.4 → 4.0.0

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 (341) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +7 -0
  3. package/dist/chat/kitSxRegistry.js +9 -0
  4. package/dist/components/charts/kitSxRegistry.js +6 -0
  5. package/dist/entries/charts.js +6 -0
  6. package/dist/entries/chat.js +8 -0
  7. package/dist/entries/markdown.js +1 -0
  8. package/dist/index.js +0 -14
  9. package/dist/pages/AccountPage.js +1 -2
  10. package/dist/pages/LoginPage.js +1 -2
  11. package/dist/pages/PasswordChangePage.js +1 -2
  12. package/dist/pages/PasswordInvitePage.js +1 -2
  13. package/dist/pages/PasswordResetRequestPage.js +1 -2
  14. package/dist/pages/SignUpPage.js +1 -2
  15. package/dist/pages/SignupConfirmPage.js +1 -2
  16. package/dist/theme/kitSxEntry.js +11 -0
  17. package/dist/theme/kitSxRegistry.js +2 -15
  18. package/package.json +32 -7
  19. package/.github/workflows/ci.yml +0 -35
  20. package/.github/workflows/publish.yml +0 -126
  21. package/DESIGN.md +0 -60
  22. package/WORK_ORDERS.md +0 -150
  23. package/dev/entries.jsx +0 -721
  24. package/dev/fixtures.js +0 -26
  25. package/dev/main.jsx +0 -75
  26. package/dev/mockTransport.jsx +0 -128
  27. package/docs/CHART-LAYOUT.md +0 -157
  28. package/docs/DARK-TOKENS.md +0 -140
  29. package/docs/TYPE-SCALE.md +0 -111
  30. package/docs/messaging-deviations.md +0 -118
  31. package/index.html +0 -12
  32. package/renovate.json +0 -10
  33. package/scripts/chart-api-census.mjs +0 -415
  34. package/src/auth/AuthContext.jsx +0 -158
  35. package/src/auth/ReauthModal.jsx +0 -82
  36. package/src/auth/UserMenu.jsx +0 -121
  37. package/src/auth/apiClient.jsx +0 -232
  38. package/src/auth/authApi.jsx +0 -539
  39. package/src/auth/authConfig.jsx +0 -34
  40. package/src/auth/reauth.js +0 -47
  41. package/src/chat/ChatComposer.jsx +0 -36
  42. package/src/chat/ChatList.jsx +0 -87
  43. package/src/chat/ChatThread.jsx +0 -128
  44. package/src/chat/ChatWorkspace.jsx +0 -244
  45. package/src/chat/MarkdownReply.jsx +0 -22
  46. package/src/chat/ModelPicker.jsx +0 -85
  47. package/src/chat/api.js +0 -18
  48. package/src/chat/useChatSocket.js +0 -32
  49. package/src/chat/wire.js +0 -7
  50. package/src/components/AccessCodeManager.jsx +0 -288
  51. package/src/components/AccessCodeSingleUseToggle.jsx +0 -92
  52. package/src/components/AllowedEmailDomainsManager.jsx +0 -92
  53. package/src/components/AuthFactorRequirementCard.jsx +0 -95
  54. package/src/components/BulkInviteCsvTab.jsx +0 -198
  55. package/src/components/EmptyState.jsx +0 -38
  56. package/src/components/LoginForm.jsx +0 -159
  57. package/src/components/MFAComponent.jsx +0 -350
  58. package/src/components/MfaLoginComponent.jsx +0 -252
  59. package/src/components/MobileBottomNav.jsx +0 -82
  60. package/src/components/PasskeysComponent.jsx +0 -252
  61. package/src/components/PasswordChangeForm.jsx +0 -87
  62. package/src/components/PasswordResetRequestForm.jsx +0 -43
  63. package/src/components/PasswordSetForm.jsx +0 -97
  64. package/src/components/ProfileComponent.jsx +0 -348
  65. package/src/components/QrSignupManager.jsx +0 -404
  66. package/src/components/QrSignupValidityManager.jsx +0 -106
  67. package/src/components/RegistrationMethodsManager.jsx +0 -150
  68. package/src/components/SecurityComponent.jsx +0 -141
  69. package/src/components/SocialLoginButtons.jsx +0 -83
  70. package/src/components/SoftChip.jsx +0 -93
  71. package/src/components/StatTile.jsx +0 -39
  72. package/src/components/SupportRecoveryRequestsTab.jsx +0 -482
  73. package/src/components/TurnstileWidget.jsx +0 -99
  74. package/src/components/UserInviteComponent.jsx +0 -76
  75. package/src/components/UserListComponent.jsx +0 -618
  76. package/src/components/charts/BarChart.jsx +0 -102
  77. package/src/components/charts/ChartFrame.jsx +0 -214
  78. package/src/components/charts/LineChart.jsx +0 -126
  79. package/src/components/charts/ScatterChart.jsx +0 -299
  80. package/src/components/charts/TimeSeriesChart.jsx +0 -300
  81. package/src/components/charts/chartDefaults.js +0 -644
  82. package/src/components/charts/chartLabels.js +0 -36
  83. package/src/components/charts/exportChart.js +0 -258
  84. package/src/components/charts/formatters.js +0 -39
  85. package/src/components/charts/palette.js +0 -33
  86. package/src/components/charts/yearTickInterval.js +0 -7
  87. package/src/i18n/authTranslations.ts +0 -2651
  88. package/src/i18n/chartsTranslations.ts +0 -91
  89. package/src/i18n/chatTranslations.ts +0 -55
  90. package/src/i18n/messagingTranslations.ts +0 -120
  91. package/src/i18n/notificationsTranslations.ts +0 -32
  92. package/src/i18n/onboardingTranslations.ts +0 -29
  93. package/src/i18n/sectionNavTranslations.ts +0 -20
  94. package/src/i18n/uiCoreTranslations.js +0 -29
  95. package/src/i18n/userMenuTranslations.ts +0 -5
  96. package/src/index.js +0 -158
  97. package/src/layout/PageLayout.jsx +0 -36
  98. package/src/layout/SectionNav.jsx +0 -320
  99. package/src/messaging/AttachmentList.jsx +0 -145
  100. package/src/messaging/Composer.jsx +0 -197
  101. package/src/messaging/ConversationLaunchers.jsx +0 -51
  102. package/src/messaging/ConversationList.jsx +0 -109
  103. package/src/messaging/DirectMessageLauncher.jsx +0 -112
  104. package/src/messaging/MessageBubble.jsx +0 -183
  105. package/src/messaging/MessagingProvider.jsx +0 -0
  106. package/src/messaging/MessagingScopeConfig.jsx +0 -24
  107. package/src/messaging/PollCard.jsx +0 -163
  108. package/src/messaging/ReactionBar.jsx +0 -43
  109. package/src/messaging/ReadTicks.jsx +0 -82
  110. package/src/messaging/Thread.jsx +0 -195
  111. package/src/messaging/api.js +0 -48
  112. package/src/messaging/composerImageCompression.js +0 -35
  113. package/src/messaging/linkifyText.jsx +0 -37
  114. package/src/notifications/NotificationBell.jsx +0 -84
  115. package/src/notifications/NotificationSettings.jsx +0 -330
  116. package/src/notifications/NotificationsProvider.jsx +0 -224
  117. package/src/notifications/PopupSurface.jsx +0 -105
  118. package/src/notifications/api.js +0 -55
  119. package/src/notifications/feedApi.js +0 -18
  120. package/src/notifications/realtime.jsx +0 -138
  121. package/src/notifications/serviceWorker/sw.js +0 -50
  122. package/src/onboarding/OnboardingProvider.jsx +0 -326
  123. package/src/onboarding/OnboardingWizard.jsx +0 -61
  124. package/src/onboarding/WizardDialogShell.jsx +0 -51
  125. package/src/onboarding/api.js +0 -13
  126. package/src/onboarding/stepSelection.js +0 -16
  127. package/src/onboarding/steps/BrowserPushStep.jsx +0 -121
  128. package/src/onboarding/steps/CompleteNameStep.jsx +0 -46
  129. package/src/onboarding/steps/CookieConsentStep.jsx +0 -133
  130. package/src/onboarding/steps/PwaInstallStep.jsx +0 -47
  131. package/src/pages/AccountPage.jsx +0 -394
  132. package/src/pages/LoginPage.jsx +0 -343
  133. package/src/pages/PasswordChangePage.jsx +0 -62
  134. package/src/pages/PasswordInvitePage.jsx +0 -177
  135. package/src/pages/PasswordResetRequestPage.jsx +0 -68
  136. package/src/pages/SignUpPage.jsx +0 -268
  137. package/src/pages/SignupConfirmPage.jsx +0 -155
  138. package/src/testing/checkKitIntegration.js +0 -233
  139. package/src/theme/createAppTheme.js +0 -423
  140. package/src/theme/fonts.js +0 -3
  141. package/src/theme/index.js +0 -21
  142. package/src/theme/kitSxRegistry.js +0 -285
  143. package/src/theme/themeCompleteness.js +0 -1045
  144. package/src/theme/tokens.js +0 -478
  145. package/src/utils/auth-errors.js +0 -76
  146. package/src/utils/authService.js +0 -223
  147. package/src/utils/resolveErrorText.js +0 -28
  148. package/src/utils/webauthn.js +0 -51
  149. package/tests/AccountPage.profileStatements.test.jsx +0 -162
  150. package/tests/AccountPage.test.jsx +0 -200
  151. package/tests/AuthContext.test.jsx +0 -129
  152. package/tests/BarChart.test.jsx +0 -112
  153. package/tests/BrowserPushStep.test.jsx +0 -110
  154. package/tests/ChartFrame.test.jsx +0 -336
  155. package/tests/ConversationList.test.jsx +0 -144
  156. package/tests/CookieConsentStep.test.jsx +0 -69
  157. package/tests/EmptyState.test.jsx +0 -62
  158. package/tests/LineChart.test.jsx +0 -80
  159. package/tests/MessagingProvider.test.jsx +0 -50
  160. package/tests/MobileBottomNav.test.jsx +0 -319
  161. package/tests/NotificationBell.test.jsx +0 -60
  162. package/tests/NotificationSettings.test.jsx +0 -276
  163. package/tests/NotificationsProvider.test.jsx +0 -240
  164. package/tests/OnboardingProvider.test.jsx +0 -294
  165. package/tests/OnboardingWizard.test.jsx +0 -143
  166. package/tests/PasswordChangeForm.test.jsx +0 -70
  167. package/tests/PasswordInvitePage.test.jsx +0 -142
  168. package/tests/PasswordSetForm.test.jsx +0 -70
  169. package/tests/PopupSurface.test.jsx +0 -142
  170. package/tests/ProfileComponent.refresh.test.jsx +0 -194
  171. package/tests/QrSignupManager.registrationContext.test.jsx +0 -106
  172. package/tests/QrSignupManagerInfoBox.test.jsx +0 -49
  173. package/tests/ScatterChart.test.jsx +0 -270
  174. package/tests/SectionNav.test.jsx +0 -363
  175. package/tests/SignUpPage.test.jsx +0 -208
  176. package/tests/SoftChip.test.jsx +0 -105
  177. package/tests/StatTile.test.jsx +0 -57
  178. package/tests/Thread.test.jsx +0 -151
  179. package/tests/TimeSeriesChart.test.jsx +0 -367
  180. package/tests/UserListComponent.test.jsx +0 -192
  181. package/tests/UserMenu.test.jsx +0 -171
  182. package/tests/apiClientLanguage.test.js +0 -33
  183. package/tests/apiClientPublicPaths.test.js +0 -178
  184. package/tests/authApiLogin.test.js +0 -42
  185. package/tests/authApiRegistration.test.js +0 -31
  186. package/tests/authErrorCodeRendering.test.jsx +0 -77
  187. package/tests/authErrors.test.js +0 -74
  188. package/tests/authTranslations.test.js +0 -74
  189. package/tests/chart-api-census.test.js +0 -366
  190. package/tests/chartAxisTickBand.test.jsx +0 -95
  191. package/tests/chartDefaults.test.js +0 -902
  192. package/tests/chartLabels.test.js +0 -50
  193. package/tests/chartsPalette.test.js +0 -99
  194. package/tests/chatApi.test.js +0 -48
  195. package/tests/chatDriverNames.test.jsx +0 -71
  196. package/tests/chatExports.test.js +0 -3
  197. package/tests/chatList.test.jsx +0 -84
  198. package/tests/chatPicker.test.jsx +0 -82
  199. package/tests/chatSocket.test.jsx +0 -26
  200. package/tests/chatThread.test.jsx +0 -116
  201. package/tests/chatTranslations.test.js +0 -47
  202. package/tests/chatWorkspace.test.jsx +0 -234
  203. package/tests/checkKitIntegration.test.jsx +0 -219
  204. package/tests/createAppTheme.test.js +0 -132
  205. package/tests/createAppThemeDark.test.js +0 -127
  206. package/tests/createAppThemeLightGuard.test.js +0 -40
  207. package/tests/createAppThemePageContrast.test.js +0 -108
  208. package/tests/createAppThemeTypography.test.js +0 -53
  209. package/tests/errorCallSiteGuard.test.js +0 -32
  210. package/tests/exportChart.test.js +0 -313
  211. package/tests/feedApi.test.js +0 -46
  212. package/tests/fixtures/light-theme-baseline.json +0 -2234
  213. package/tests/i18nAggregate.test.js +0 -120
  214. package/tests/i18nGermanVariant.test.js +0 -65
  215. package/tests/loginPageErrorResolution.test.jsx +0 -102
  216. package/tests/messagingApi.test.js +0 -32
  217. package/tests/messagingChunk6.test.jsx +0 -116
  218. package/tests/messagingCompactBubble.test.jsx +0 -64
  219. package/tests/messagingComposer.test.jsx +0 -136
  220. package/tests/messagingComposerChunk5.test.jsx +0 -113
  221. package/tests/messagingContractConformance.test.js +0 -69
  222. package/tests/messagingDirectMessageLauncher.test.jsx +0 -151
  223. package/tests/messagingExports.test.js +0 -21
  224. package/tests/messagingInteractions.test.jsx +0 -136
  225. package/tests/messagingLastMessagePreview.test.jsx +0 -93
  226. package/tests/messagingLinkify.test.jsx +0 -51
  227. package/tests/messagingMessageActions.test.jsx +0 -163
  228. package/tests/messagingMsg6.test.jsx +0 -105
  229. package/tests/messagingMsg6f.test.jsx +0 -155
  230. package/tests/messagingMsg6g.test.jsx +0 -166
  231. package/tests/messagingMsg6h.test.jsx +0 -136
  232. package/tests/messagingMsg6i.test.jsx +0 -129
  233. package/tests/messagingPollRendering.test.jsx +0 -142
  234. package/tests/messagingReactionMerge.test.jsx +0 -77
  235. package/tests/messagingReadTicksTooltip.test.jsx +0 -36
  236. package/tests/messagingThreadReceipts.test.jsx +0 -178
  237. package/tests/messagingThreadingQuoting.test.jsx +0 -87
  238. package/tests/messagingUnreadLifecycle.test.jsx +0 -78
  239. package/tests/notificationsApi.test.js +0 -41
  240. package/tests/notificationsExports.test.js +0 -34
  241. package/tests/onboardingDescriptors.test.js +0 -132
  242. package/tests/packageTreeShaking.test.js +0 -126
  243. package/tests/realtime.test.jsx +0 -219
  244. package/tests/resolveErrorText.test.js +0 -72
  245. package/tests/stepSelection.test.js +0 -53
  246. package/tests/themeCompleteness.test.js +0 -626
  247. package/tests/timeSeriesLegend.test.js +0 -99
  248. package/tests/userScreenTranslations.test.jsx +0 -218
  249. package/tsconfig.build.json +0 -18
  250. package/vite.config.mjs +0 -6
  251. package/work-orders/AUTH-1.md +0 -74
  252. package/work-orders/AUTH-2.md +0 -74
  253. package/work-orders/AUTH-4.md +0 -183
  254. package/work-orders/AUTH-5.md +0 -154
  255. package/work-orders/AUTH-7.md +0 -181
  256. package/work-orders/AUTH-8.md +0 -184
  257. package/work-orders/CHART-1.md +0 -285
  258. package/work-orders/CHART-2.md +0 -222
  259. package/work-orders/CHART-3.md +0 -163
  260. package/work-orders/CHART-4.md +0 -203
  261. package/work-orders/CHART-5.md +0 -226
  262. package/work-orders/CHART-6.md +0 -428
  263. package/work-orders/CHART-7.md +0 -175
  264. package/work-orders/DX-1.md +0 -169
  265. package/work-orders/DX-2.md +0 -188
  266. package/work-orders/DX-3.md +0 -195
  267. package/work-orders/I18N-1.md +0 -254
  268. package/work-orders/I18N-3.md +0 -207
  269. package/work-orders/MSG-3.md +0 -375
  270. package/work-orders/MSG-3b.md +0 -1002
  271. package/work-orders/MSG-3c.md +0 -378
  272. package/work-orders/MSG-3d.md +0 -268
  273. package/work-orders/MSG-3e.md +0 -164
  274. package/work-orders/MSG-3f.md +0 -391
  275. package/work-orders/MSG-6e.md +0 -308
  276. package/work-orders/MSG-6f.md +0 -214
  277. package/work-orders/MSG-6g.md +0 -244
  278. package/work-orders/MSG-6h.md +0 -238
  279. package/work-orders/MSG-6i.md +0 -271
  280. package/work-orders/MSG-6j.md +0 -117
  281. package/work-orders/NOTIF-12.md +0 -214
  282. package/work-orders/NOTIF-13.md +0 -142
  283. package/work-orders/NOTIF-14.md +0 -151
  284. package/work-orders/PRIM-1.md +0 -177
  285. package/work-orders/SHELL-1.md +0 -255
  286. package/work-orders/SHELL-2.md +0 -197
  287. package/work-orders/SHELL-3.md +0 -359
  288. package/work-orders/SHELL-4.md +0 -351
  289. package/work-orders/SHELL-5.md +0 -345
  290. package/work-orders/SHELL-6.md +0 -210
  291. package/work-orders/THEME-1.md +0 -587
  292. package/work-orders/THEME-10.md +0 -303
  293. package/work-orders/THEME-11.md +0 -208
  294. package/work-orders/THEME-2.md +0 -339
  295. package/work-orders/THEME-3.md +0 -210
  296. package/work-orders/THEME-4.md +0 -271
  297. package/work-orders/THEME-5.md +0 -341
  298. package/work-orders/THEME-6.md +0 -247
  299. package/work-orders/THEME-7.md +0 -82
  300. package/work-orders/THEME-8.md +0 -211
  301. package/work-orders/THEME-9.md +0 -194
  302. package/work-orders/UCM-AUTH-10.md +0 -490
  303. package/work-orders/UCM-AUTH-11.md +0 -185
  304. package/work-orders/UCM-AUTH-12.md +0 -98
  305. package/work-orders/UCM-AUTH-13.md +0 -47
  306. package/work-orders/UCM-AUTH-9.md +0 -207
  307. package/work-orders/UCM-CHART-10.md +0 -150
  308. package/work-orders/UCM-CHART-11.md +0 -132
  309. package/work-orders/UCM-CHART-12.md +0 -348
  310. package/work-orders/UCM-CHART-13.md +0 -122
  311. package/work-orders/UCM-CHART-14.md +0 -198
  312. package/work-orders/UCM-CHART-15.md +0 -187
  313. package/work-orders/UCM-CHART-16.md +0 -169
  314. package/work-orders/UCM-CHART-17.md +0 -195
  315. package/work-orders/UCM-CHART-18.md +0 -200
  316. package/work-orders/UCM-CHART-8.md +0 -147
  317. package/work-orders/UCM-CHART-9.md +0 -265
  318. package/work-orders/UCM-CHAT-1.md +0 -190
  319. package/work-orders/UCM-CHAT-2.md +0 -75
  320. package/work-orders/UCM-CI-1.md +0 -65
  321. package/work-orders/UCM-DEP-1.md +0 -63
  322. package/work-orders/UCM-I18N-4.md +0 -226
  323. package/work-orders/UCM-I18N-5.md +0 -211
  324. package/work-orders/UCM-MSG-20.md +0 -192
  325. package/work-orders/UCM-PRIM-2.md +0 -114
  326. package/work-orders/UCM-SHELL-7.md +0 -134
  327. package/work-orders/UCM-SHELL-8.md +0 -125
  328. package/work-orders/UCM-TEST-1.md +0 -304
  329. package/work-orders/UCM-THEME-13.md +0 -69
  330. package/work-orders/UCM-THEME-14.md +0 -312
  331. package/work-orders/UCM-THEME-15.md +0 -356
  332. package/work-orders/UCM-THEME-16.md +0 -80
  333. package/work-orders/UCM-THEME-17.md +0 -111
  334. package/work-orders/UCM-THEME-18.md +0 -184
  335. package/work-orders/assets/AUTH-4-user-list-card.html +0 -407
  336. package/work-orders/assets/PRIM-1-dashboard-primitives.html +0 -624
  337. package/work-orders/assets/SHELL-2-account-navigation.html +0 -1159
  338. package/work-orders/assets/THEME-1-baseline-reference-sheet.html +0 -1352
  339. package/work-orders/assets/UCM-CHAT-1-ai-chat.html +0 -447
  340. package/work-orders/assets/UCM-THEME-13-dark-prototype.html +0 -390
  341. package/work-orders/assets/UCM-THEME-17-type-scale.html +0 -391
@@ -1,120 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
-
4
- import { describe, expect, it, vi } from 'vitest';
5
-
6
- vi.mock('@mui/icons-material', () => ({
7
- Archive: () => null,
8
- Campaign: () => null,
9
- Groups: () => null,
10
- MoreVert: () => null,
11
- NotificationsOff: () => null,
12
- Person: () => null,
13
- }));
14
-
15
- import {
16
- authTranslations as publicAuthTranslations,
17
- chartsTranslations as publicChartsTranslations,
18
- chatTranslations as publicChatTranslations,
19
- messagingTranslations as publicMessagingTranslations,
20
- notificationsTranslations as publicNotificationsTranslations,
21
- onboardingTranslations as publicOnboardingTranslations,
22
- sectionNavTranslations as publicSectionNavTranslations,
23
- uiCoreTranslations,
24
- userMenuTranslations as publicUserMenuTranslations,
25
- } from '../src/index';
26
-
27
- const I18N_DIRECTORY = path.resolve('src/i18n');
28
- const REQUIRED_LOCALES = ['de', 'en', 'fr', 'sw'];
29
- const bundleImporters = import.meta.glob('../src/i18n/*.ts');
30
- const PUBLIC_BUNDLES = {
31
- authTranslations: publicAuthTranslations,
32
- chartsTranslations: publicChartsTranslations,
33
- chatTranslations: publicChatTranslations,
34
- messagingTranslations: publicMessagingTranslations,
35
- notificationsTranslations: publicNotificationsTranslations,
36
- onboardingTranslations: publicOnboardingTranslations,
37
- sectionNavTranslations: publicSectionNavTranslations,
38
- userMenuTranslations: publicUserMenuTranslations,
39
- };
40
-
41
- function bundleFileNames() {
42
- return fs.readdirSync(I18N_DIRECTORY, { withFileTypes: true })
43
- .filter((entry) => entry.isFile() && entry.name.endsWith('.ts'))
44
- .map((entry) => entry.name)
45
- .sort();
46
- }
47
-
48
- async function loadBundles() {
49
- return Promise.all(bundleFileNames().map(async (fileName) => {
50
- const modulePath = `../src/i18n/${fileName}`;
51
- const importBundle = bundleImporters[modulePath];
52
- if (!importBundle) {
53
- throw new Error(`${fileName} was enumerated from src/i18n but has no module importer`);
54
- }
55
-
56
- const bundleModule = await importBundle();
57
- const translationExports = Object.entries(bundleModule)
58
- .filter(([exportName]) => exportName.endsWith('Translations'));
59
-
60
- if (Object.keys(bundleModule).length !== 1 || translationExports.length !== 1) {
61
- throw new Error(`${fileName} must export exactly one *Translations bundle`);
62
- }
63
-
64
- const [[exportName, translations]] = translationExports;
65
- return { exportName, fileName, translations };
66
- }));
67
- }
68
-
69
- describe('uiCoreTranslations', () => {
70
- it('contains every directory-enumerated bundle key with its original value', async () => {
71
- const bundles = await loadBundles();
72
- const sourceKeys = [];
73
-
74
- for (const { fileName, translations } of bundles) {
75
- for (const [key, value] of Object.entries(translations)) {
76
- sourceKeys.push(key);
77
- expect(
78
- Object.hasOwn(uiCoreTranslations, key),
79
- `${key} from ${fileName} is missing from the public aggregate`,
80
- ).toBe(true);
81
- expect(uiCoreTranslations[key]).toEqual(value);
82
- }
83
- }
84
-
85
- expect(Object.keys(uiCoreTranslations).sort()).toEqual(sourceKeys.sort());
86
- });
87
-
88
- it('does not allow duplicate keys across source bundles', async () => {
89
- const owners = new Map();
90
- const collisions = [];
91
-
92
- for (const { fileName, translations } of await loadBundles()) {
93
- for (const key of Object.keys(translations)) {
94
- if (owners.has(key)) {
95
- collisions.push(`${key}: ${owners.get(key)} and ${fileName}`);
96
- } else {
97
- owners.set(key, fileName);
98
- }
99
- }
100
- }
101
-
102
- expect(collisions, `Translation key collisions:\n${collisions.join('\n')}`).toEqual([]);
103
- });
104
-
105
- it('preserves at least the required locale shape for every aggregate value', () => {
106
- for (const [key, value] of Object.entries(uiCoreTranslations)) {
107
- for (const locale of REQUIRED_LOCALES) {
108
- expect(typeof value[locale], `${key}.${locale} must be a string`).toBe('string');
109
- expect(value[locale].trim(), `${key}.${locale} must not be empty`).not.toBe('');
110
- }
111
- }
112
- });
113
-
114
- it('keeps every per-feature bundle available unchanged from the package root', async () => {
115
- for (const { exportName, translations } of await loadBundles()) {
116
- expect(PUBLIC_BUNDLES[exportName], `${exportName} must remain a public export`)
117
- .toBe(translations);
118
- }
119
- });
120
- });
@@ -1,65 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { authTranslations } from '../src/i18n/authTranslations';
4
- import {
5
- createUiCoreTranslations,
6
- uiCoreTranslations,
7
- } from '../src/i18n/uiCoreTranslations';
8
-
9
- const SIE_FORM = /\b(Sie|Ihr|Ihre|Ihrem|Ihren|Ihrer|Ihres)\b/;
10
- const REQUIRED_LOCALES = ['de', 'en', 'fr', 'sw'];
11
-
12
- describe('German translation variants', () => {
13
- it('keeps formal German by default and switches representative auth copy to du', () => {
14
- const key = 'Auth.PAGE_INVITE_SUBTITLE';
15
- const formal = createUiCoreTranslations();
16
- const informal = createUiCoreTranslations({ germanVariant: 'informal' });
17
-
18
- expect(formal[key].de).toBe(uiCoreTranslations[key].de);
19
- expect(formal[key]).not.toHaveProperty('de_informal');
20
- expect(informal[key].de).toBe('Bitte wähle ein Passwort, um auf dein Konto zuzugreifen.');
21
- expect(informal[key].de).not.toMatch(SIE_FORM);
22
- expect(informal['Auth.EMAIL_LABEL'].de).toBe(formal['Auth.EMAIL_LABEL'].de);
23
- });
24
-
25
- it('switches EVERY Sie-form key to its own rewritten de_informal, not one hardcoded example', () => {
26
- // Not just one representative key -- a factory hardcoded to a single
27
- // (key, value) pair would pass the test above but fail here the moment a
28
- // second Sie-form key is checked against ITS OWN de_informal value.
29
- const formalKeys = Object.entries(authTranslations)
30
- .filter(([, value]) => SIE_FORM.test(value.de))
31
- .map(([key]) => key);
32
- expect(formalKeys.length).toBeGreaterThan(1);
33
-
34
- const informal = createUiCoreTranslations({ germanVariant: 'informal' });
35
- const formal = createUiCoreTranslations();
36
- for (const key of formalKeys) {
37
- expect(informal[key].de, `${key} should switch to its own de_informal`).toBe(authTranslations[key].de_informal);
38
- expect(informal[key].de).not.toMatch(SIE_FORM);
39
- expect(formal[key].de, `${key} default must stay formal`).toBe(authTranslations[key].de);
40
- }
41
- });
42
-
43
- it('requires every Sie-form auth string to have a rewritten informal variant', () => {
44
- const formalKeys = Object.entries(authTranslations)
45
- .filter(([, value]) => SIE_FORM.test(value.de))
46
- .map(([key]) => key);
47
-
48
- expect(formalKeys.length).toBeGreaterThan(0);
49
- for (const key of formalKeys) {
50
- const informal = authTranslations[key].de_informal;
51
- expect(informal, `${key} needs de_informal`).toEqual(expect.any(String));
52
- expect(informal.trim(), `${key}.de_informal must not be empty`).not.toBe('');
53
- expect(informal, `${key}.de_informal must not retain Sie-form`).not.toMatch(SIE_FORM);
54
- }
55
- });
56
-
57
- it('preserves the four-locale shape for the aggregate after adding screen keys', () => {
58
- for (const [key, value] of Object.entries(uiCoreTranslations)) {
59
- for (const locale of REQUIRED_LOCALES) {
60
- expect(typeof value[locale], `${key}.${locale} must be a string`).toBe('string');
61
- expect(value[locale].trim(), `${key}.${locale} must not be empty`).not.toBe('');
62
- }
63
- }
64
- });
65
- });
@@ -1,102 +0,0 @@
1
- // @vitest-environment jsdom
2
- import React from 'react';
3
- import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
4
- import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
5
- import { I18nextProvider } from 'react-i18next';
6
- import i18next from 'i18next';
7
- import { MemoryRouter } from 'react-router-dom';
8
-
9
- const authApi = vi.hoisted(() => ({
10
- fetchRecoverySessionToken: vi.fn(),
11
- loginWithPassword: vi.fn(),
12
- loginWithRecoveryPassword: vi.fn(),
13
- }));
14
-
15
- vi.mock('../src/auth/authApi', () => authApi);
16
- vi.mock('../src/utils/authService', () => ({
17
- loginWithPasskey: vi.fn(),
18
- startSocialLogin: vi.fn(),
19
- }));
20
- vi.mock('react-helmet', () => ({ Helmet: ({ children }) => <>{children}</> }));
21
-
22
- import { authTranslations } from '../src/i18n/authTranslations';
23
- import { AuthContext } from '../src/auth/AuthContext';
24
- import { LoginPage } from '../src/pages/LoginPage';
25
-
26
- const translations = Object.fromEntries(
27
- Object.entries(authTranslations).map(([key, value]) => [key, value.en]),
28
- );
29
- const i18n = i18next.createInstance();
30
-
31
- beforeAll(async () => {
32
- await i18n.init({
33
- lng: 'en',
34
- fallbackLng: 'en',
35
- resources: { en: { translation: translations } },
36
- keySeparator: false,
37
- nsSeparator: false,
38
- interpolation: { escapeValue: false },
39
- });
40
- });
41
-
42
- beforeEach(() => {
43
- authApi.loginWithPassword.mockRejectedValue({
44
- response: {
45
- data: {
46
- errors: [{
47
- message: 'Gib eine gültige E-Mail Adresse an.',
48
- code: 'invalid',
49
- param: 'email',
50
- }],
51
- },
52
- },
53
- });
54
- });
55
-
56
- afterEach(() => {
57
- cleanup();
58
- vi.clearAllMocks();
59
- });
60
-
61
- function renderLoginPage() {
62
- return render(
63
- <I18nextProvider i18n={i18n}>
64
- <MemoryRouter initialEntries={['/login']}>
65
- <AuthContext.Provider value={{
66
- user: null,
67
- loading: false,
68
- login: vi.fn(),
69
- authMethods: {
70
- password_login: true,
71
- password_reset: false,
72
- signup: false,
73
- signup_modes: [],
74
- social_login: false,
75
- passkey_login: false,
76
- },
77
- }}>
78
- <LoginPage />
79
- </AuthContext.Provider>
80
- </MemoryRouter>
81
- </I18nextProvider>,
82
- );
83
- }
84
-
85
- describe('LoginPage error resolution', () => {
86
- it('shows the email field translation for the exact allauth invalid-email response', async () => {
87
- renderLoginPage();
88
-
89
- fireEvent.change(screen.getByRole('textbox', { name: new RegExp(authTranslations['Auth.EMAIL_LABEL'].en) }), {
90
- target: { value: 'not-an-email@example.com' },
91
- });
92
- fireEvent.change(screen.getByLabelText(new RegExp(authTranslations['Auth.LOGIN_PASSWORD_LABEL'].en)), {
93
- target: { value: 'password' },
94
- });
95
- fireEvent.click(screen.getByRole('button', { name: authTranslations['Auth.PAGE_LOGIN_TITLE'].en }));
96
-
97
- await waitFor(() => {
98
- expect(screen.getByText(authTranslations['Auth.field.email.invalid'].en)).toBeTruthy();
99
- });
100
- expect(screen.queryByText('invalid')).toBeNull();
101
- });
102
- });
@@ -1,32 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
-
3
- const client = vi.hoisted(() => ({ get: vi.fn(), post: vi.fn(), patch: vi.fn(), delete: vi.fn() }));
4
- vi.mock('../src/auth/apiClient', () => ({ default: client }));
5
-
6
- import * as api from '../src/messaging/api';
7
-
8
- const response = { data: { ok: true } };
9
- beforeEach(() => { vi.clearAllMocks(); Object.values(client).forEach((method) => method.mockResolvedValue(response)); });
10
-
11
- describe('messaging API contract', () => {
12
- it('uses the published conversations and message routes', async () => {
13
- await api.listConversations({ scope_kind: 'container', cursor: 'opaque' });
14
- await api.createDirectConversation({ target_user_id: 8 });
15
- await api.createGroupConversation({ title: 'Group' }); await api.createBroadcastConversation({}); await api.createManagedConversation({}); await api.createObjectThreadConversation({});
16
- await api.getConversationConfig(1); await api.patchConversationConfig(1, {}); await api.archiveConversation(1, true); await api.patchConversationPreferences(1, {});
17
- await api.listMessages(1, { cursor: 'opaque' }); await api.createMessage(1, { body: 'x' }, { idempotencyKey: 'key' }); await api.uploadAttachments(1, new FormData()); await api.createPoll(1, {});
18
- expect(client.get).toHaveBeenCalledWith('/api/messaging/conversations/', { params: { scope_kind: 'container', cursor: 'opaque' } });
19
- expect(client.post).toHaveBeenCalledWith('/api/messaging/conversations/direct/', { target_user_id: 8 });
20
- expect(client.post).toHaveBeenCalledWith('/api/messaging/conversations/1/messages/', { body: 'x' }, { headers: { 'Idempotency-Key': 'key' } });
21
- expect(client.get).toHaveBeenCalledWith('/api/messaging/conversations/1/messages/', { params: { cursor: 'opaque' } });
22
- });
23
-
24
- it('uses the published detail, receipt, poll and attachment routes', async () => {
25
- await api.getMessage(2); await api.patchMessage(2, {}); await api.deleteMessage(2); await api.addReaction(2, '👍'); await api.removeReaction(2, '👍');
26
- await api.listThread(2, { cursor: 'opaque' }); await api.markThreadRead(2); await api.markConversationRead(3); await api.getReadStatus(2); await api.votePoll(4, [5]); await api.closePoll(4); await api.getAttachment(6); await api.getAttachmentThumbnail(6); await api.getUnreadCount();
27
- expect(client.delete).toHaveBeenCalledWith('/api/messaging/messages/2/reactions/%F0%9F%91%8D/');
28
- expect(client.get).toHaveBeenCalledWith('/api/messaging/messages/2/thread/', { params: { cursor: 'opaque' } });
29
- expect(client.post).toHaveBeenCalledWith('/api/messaging/conversations/3/read/', {});
30
- expect(client.get).toHaveBeenCalledWith('/api/messaging/unread-count/');
31
- });
32
- });
@@ -1,116 +0,0 @@
1
- // @vitest-environment jsdom
2
- import React from 'react';
3
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
- import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
5
-
6
- // Thread.jsx (MSG-6f scope C) now subscribes to the messaging envelope
7
- // independently of MessagingProvider's own subscription -- a Set of handlers,
8
- // not a single captured variable, so frameHandler(...) still reaches every
9
- // current subscriber, matching the real registry's multi-handler support.
10
- let frameHandlers;
11
- function frameHandler(frame) { frameHandlers.forEach((handler) => handler(frame)); }
12
- vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key, options) => options?.count != null ? `${key}:${options.count}` : key, i18n: { language: 'en' } }) }));
13
- vi.mock('../src/notifications/realtime', () => ({ useRealtime: () => ({ subscribe: (_envelope, handler) => { frameHandlers.add(handler); return () => frameHandlers.delete(handler); }, onReconnect: () => () => {} }) }));
14
-
15
- import { Composer } from '../src/messaging/Composer';
16
- import { ConversationList } from '../src/messaging/ConversationList';
17
- import { MessageBubble } from '../src/messaging/MessageBubble';
18
- import { MessagingProvider } from '../src/messaging/MessagingProvider';
19
- import { ReadTicks } from '../src/messaging/ReadTicks';
20
- import { Thread } from '../src/messaging/Thread';
21
-
22
- function makeApi(overrides = {}) {
23
- return {
24
- listConversations: vi.fn().mockResolvedValue({ results: [] }),
25
- listMessages: vi.fn().mockResolvedValue({ results: [] }),
26
- listThread: vi.fn().mockResolvedValue({ results: [] }),
27
- getUnreadCount: vi.fn().mockResolvedValue({ unread_count: 0, by_conversation: {} }),
28
- getReadStatus: vi.fn().mockResolvedValue({ all_read: false }),
29
- markConversationRead: vi.fn().mockResolvedValue({}), markThreadRead: vi.fn().mockResolvedValue({}),
30
- createPoll: vi.fn().mockResolvedValue({}),
31
- ...overrides,
32
- };
33
- }
34
-
35
- beforeEach(() => { frameHandlers = new Set(); });
36
- afterEach(() => { cleanup(); vi.useRealTimers(); vi.restoreAllMocks(); frameHandlers = new Set(); });
37
-
38
- describe('MSG-3b chunk 6', () => {
39
- it('renders localized relative list timestamps for now, minutes, hours, and days', async () => {
40
- vi.spyOn(Date, 'now').mockReturnValue(new Date('2026-07-31T12:00:00Z').getTime());
41
- const api = makeApi({ listConversations: vi.fn().mockResolvedValue({ results: [
42
- { id: 1, title: 'Now', last_message_at: '2026-07-31T11:59:50Z' },
43
- { id: 2, title: 'Minutes', last_message_at: '2026-07-31T11:55:00Z' },
44
- { id: 3, title: 'Hours', last_message_at: '2026-07-31T09:00:00Z' },
45
- { id: 4, title: 'Days', last_message_at: '2026-07-29T12:00:00Z' },
46
- ] }) });
47
- render(<MessagingProvider api={api}><ConversationList /></MessagingProvider>);
48
- await screen.findByText('Now');
49
- expect(screen.getByText('now')).toBeTruthy();
50
- expect(screen.getByText(/5m/)).toBeTruthy();
51
- expect(screen.getByText(/3h/)).toBeTruthy();
52
- expect(screen.getByText(/2d/)).toBeTruthy();
53
- });
54
-
55
- it('auto-scrolls only for active-conversation messages when the reader was near the bottom', async () => {
56
- const api = makeApi({ listConversations: vi.fn().mockResolvedValue({ results: [{ id: 1, kind: 'group' }] }), listMessages: vi.fn().mockResolvedValue({ results: [{ id: 1, conversation_id: 1, body: 'First' }] }) });
57
- render(<MessagingProvider api={api} activeConversationId={1}><Thread conversationId={1} /></MessagingProvider>);
58
- const timeline = await screen.findByLabelText('MessagingThread.TIMELINE');
59
- Object.defineProperties(timeline, { scrollHeight: { configurable: true, value: 1000 }, clientHeight: { configurable: true, value: 300 }, scrollTop: { configurable: true, writable: true, value: 690 } });
60
- timeline.scrollTo = vi.fn();
61
- fireEvent.scroll(timeline);
62
- frameHandler({ type: 'message', conversation_id: 1, message: { id: 2, body: 'Near bottom' } });
63
- await waitFor(() => expect(timeline.scrollTo).toHaveBeenCalledTimes(1));
64
- timeline.scrollTo.mockClear(); timeline.scrollTop = 100;
65
- fireEvent.scroll(timeline);
66
- frameHandler({ type: 'message', conversation_id: 1, message: { id: 3, body: 'Reading history' } });
67
- await screen.findByText('Reading history');
68
- expect(timeline.scrollTo).not.toHaveBeenCalled();
69
- });
70
-
71
- it('renders announcement deep links only with a host handler and supplies its exact target', () => {
72
- const onAnnouncementLink = vi.fn();
73
- const message = { id: 3, kind: 'announcement', title: 'Notice', body: 'Read this', link_target: '/events/7' };
74
- const bubble = (props) => <MessagingProvider api={makeApi()} active={false}><MessageBubble {...props} /></MessagingProvider>;
75
- const view = render(bubble({ message, onAnnouncementLink }));
76
- fireEvent.click(screen.getByRole('button', { name: 'MessagingAnnouncement.OPEN_LINK' }));
77
- expect(onAnnouncementLink).toHaveBeenCalledWith('/events/7');
78
- view.rerender(bubble({ message }));
79
- expect(screen.queryByRole('button', { name: 'MessagingAnnouncement.OPEN_LINK' })).toBeNull();
80
- view.rerender(bubble({ message: { ...message, link_target: null }, onAnnouncementLink }));
81
- expect(screen.queryByRole('button', { name: 'MessagingAnnouncement.OPEN_LINK' })).toBeNull();
82
- });
83
-
84
- it('shows senders for group messages and suppresses them for direct messages', () => {
85
- const message = { id: 4, body: 'Hi', sender: { display_name: 'Ava' } };
86
- const bubble = (conversation) => <MessagingProvider api={makeApi()} active={false}><MessageBubble message={message} conversation={conversation} /></MessagingProvider>;
87
- const view = render(bubble({ kind: 'group' }));
88
- expect(screen.getByText('Ava')).toBeTruthy();
89
- view.rerender(bubble({ kind: 'direct' }));
90
- expect(screen.queryByText('Ava')).toBeNull();
91
- });
92
-
93
- it('opens receipt recipients by click for non-direct conversations with counts, and never exposes direct details', async () => {
94
- const api = makeApi({ getReadStatus: vi.fn().mockResolvedValue({ all_read: false, read_count: 1, recipient_count: 2, recipient_detail: [{ display_name: 'Ava' }] }) });
95
- const view = render(<MessagingProvider api={api} active={false}><ReadTicks messageId={7} conversation={{ kind: 'group' }} /></MessagingProvider>);
96
- const detail = await screen.findByRole('button', { name: 'MessagingReadTicks.READ_RATIO' });
97
- fireEvent.click(detail);
98
- expect(await screen.findByText('Ava')).toBeTruthy();
99
- view.unmount();
100
- api.getReadStatus.mockResolvedValue({ all_read: false, recipient_detail: [{ display_name: 'Ava' }] });
101
- render(<MessagingProvider api={api} active={false}><ReadTicks messageId={7} conversation={{ kind: 'direct' }} /></MessagingProvider>);
102
- await screen.findByLabelText('MessagingReadTicks.SENT');
103
- expect(screen.queryByRole('button', { name: 'MessagingReadTicks.READ_RATIO' })).toBeNull();
104
- expect(screen.queryByText('Ava')).toBeNull();
105
- });
106
-
107
- it('caps poll composer options at ten without changing the existing two-option start', () => {
108
- render(<MessagingProvider api={makeApi()} active={false}><Composer conversationId={1} /></MessagingProvider>);
109
- fireEvent.click(screen.getByRole('button', { name: 'MessagingPoll.CREATE' }));
110
- const addOption = screen.getByRole('button', { name: 'MessagingPoll.ADD_OPTION' });
111
- expect(screen.getAllByLabelText(/MessagingPoll.OPTION/)).toHaveLength(2);
112
- for (let count = 0; count < 8; count += 1) fireEvent.click(addOption);
113
- expect(screen.getAllByLabelText(/MessagingPoll.OPTION/)).toHaveLength(10);
114
- expect(addOption.disabled).toBe(true);
115
- });
116
- });
@@ -1,64 +0,0 @@
1
- // @vitest-environment jsdom
2
- import React from 'react';
3
- import { afterEach, describe, expect, it, vi } from 'vitest';
4
- import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
5
-
6
- vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key, options) => options?.count != null ? `${key}:${options.count}` : options?.sender ? `${key}:${options.sender}` : key }) }));
7
- vi.mock('../src/notifications/realtime', () => ({ useRealtime: () => ({ subscribe: () => () => {}, onReconnect: () => () => {} }) }));
8
-
9
- import { AuthContext } from '../src/auth/AuthContext';
10
- import { MessageBubble } from '../src/messaging/MessageBubble';
11
- import { MessagingProvider } from '../src/messaging/MessagingProvider';
12
- import { ReadTicks } from '../src/messaging/ReadTicks';
13
-
14
- const api = () => ({
15
- getReadStatus: vi.fn().mockResolvedValue({ all_read: false }),
16
- getAttachment: vi.fn(), getAttachmentThumbnail: vi.fn(), addReaction: vi.fn(), removeReaction: vi.fn(),
17
- votePoll: vi.fn(), closePoll: vi.fn(),
18
- });
19
- function renderBubble(message, { conversation = { kind: 'group' }, replyTo, onJumpToMessage, child, ownId = 1 } = {}) {
20
- return render(<AuthContext.Provider value={{ user: { id: ownId } }}><MessagingProvider api={api()} active={false}><MessageBubble message={message} conversation={conversation} replyTo={replyTo} onJumpToMessage={onJumpToMessage}>{child}</MessageBubble></MessagingProvider></AuthContext.Provider>);
21
- }
22
-
23
- afterEach(cleanup);
24
-
25
- describe('compact message bubbles', () => {
26
- it('keeps the timestamp and own-message status icon inside the bubble and has no standalone plain-message controls', async () => {
27
- const { container } = renderBubble({ id: 1, body: 'Hallo', sender: { id: 1, display_name: 'Me' }, created_at: '2026-08-02T10:00:00Z' }, { child: <ReadTicks messageId={1} conversation={{ kind: 'direct' }} /> });
28
- const tick = await screen.findByLabelText('MessagingReadTicks.SENT');
29
- const paper = container.querySelector('[data-message-id="1"] .MuiPaper-root');
30
- expect(paper.contains(tick)).toBe(true);
31
- expect(paper.querySelector('[data-testid="message-meta"]')).toBeTruthy();
32
- expect(screen.queryByText('MessagingThread.REPLY')).toBeNull();
33
- expect(screen.queryByLabelText('MessagingReactions.LABEL')).toBeNull();
34
- });
35
-
36
- it('marks own and incoming bubbles differently and only shows a sender in non-direct conversations', () => {
37
- const { container, rerender } = renderBubble({ id: 2, body: 'Mine', sender: { id: 1, display_name: 'Me' } });
38
- expect(container.querySelector('[data-message-id="2"]').getAttribute('data-message-side')).toBe('own');
39
- expect(screen.getByText('Me')).toBeTruthy();
40
- rerender(<AuthContext.Provider value={{ user: { id: 1 } }}><MessagingProvider api={api()} active={false}><MessageBubble message={{ id: 3, body: 'Theirs', sender: { id: 9, display_name: 'Ava' } }} conversation={{ kind: 'direct' }} /></MessagingProvider></AuthContext.Provider>);
41
- expect(container.querySelector('[data-message-id="3"]').getAttribute('data-message-side')).toBe('incoming');
42
- expect(screen.queryByText('Ava')).toBeNull();
43
- });
44
-
45
- it('keeps a reply quote clickable inside the bubble', () => {
46
- const onJumpToMessage = vi.fn();
47
- const { container } = renderBubble({ id: 5, body: 'Reply', sender: { id: 1 } }, { replyTo: { id: 4, body: 'Quoted words', sender: { display_name: 'Ava' } }, onJumpToMessage });
48
- fireEvent.click(screen.getByText('Quoted words'));
49
- expect(onJumpToMessage).toHaveBeenCalledWith(4);
50
- expect(container.querySelector('[data-message-id="5"] .MuiPaper-root').contains(screen.getByText('Quoted words'))).toBe(true);
51
- });
52
-
53
- it('continues to render announcement, poll and attachment content inside the bubble', async () => {
54
- const { container, rerender } = renderBubble({ id: 6, kind: 'announcement', title: 'Notice', body: 'Update', sender: { id: 1 } });
55
- expect(container.querySelector('.MuiPaper-root').contains(screen.getByText('Notice'))).toBe(true);
56
- rerender(<AuthContext.Provider value={{ user: { id: 1 } }}><MessagingProvider api={api()} active={false}><MessageBubble message={{ id: 7, kind: 'poll', body: 'Poll', sender: { id: 1 }, poll: { id: 1, question: 'Where?', options: [], allow_multiple: false } }} conversation={{ kind: 'group' }} /></MessagingProvider></AuthContext.Provider>);
57
- expect(container.querySelector('.MuiPaper-root').contains(screen.getByText('Where?'))).toBe(true);
58
- rerender(<AuthContext.Provider value={{ user: { id: 1 } }}><MessagingProvider api={api()} active={false}><MessageBubble message={{ id: 8, body: 'File', sender: { id: 1 }, attachments: [{ id: 1, filename: 'notes.pdf', content_type: 'application/pdf' }] }} conversation={{ kind: 'group' }} /></MessagingProvider></AuthContext.Provider>);
59
- // MSG-6h: a non-image attachment's visible content is now its filename +
60
- // a file icon (the download semantics live in the accessible name).
61
- await waitFor(() => expect(screen.getByText('notes.pdf')).toBeTruthy());
62
- expect(container.querySelector('.MuiPaper-root').contains(screen.getByText('notes.pdf'))).toBe(true);
63
- });
64
- });
@@ -1,136 +0,0 @@
1
- // @vitest-environment jsdom
2
- import React from 'react';
3
- import { afterEach, describe, expect, it, vi } from 'vitest';
4
- import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
5
-
6
- vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key, options) => options?.message ? `${key}:${options.message}` : (options?.sender ? `${key}:${options.sender}` : key) }) }));
7
-
8
- const realtimeSubscribers = new Map();
9
- vi.mock('../src/notifications/realtime', () => ({
10
- useRealtime: () => ({
11
- subscribe: (envelope, handler) => { realtimeSubscribers.set(envelope, handler); return () => realtimeSubscribers.delete(envelope); },
12
- onReconnect: () => () => {},
13
- }),
14
- }));
15
- function dispatchMessagingFrame(frame) { realtimeSubscribers.get('messaging')?.(frame); }
16
-
17
- import { AuthContext } from '../src/auth/AuthContext';
18
- import { AttachmentList } from '../src/messaging/AttachmentList';
19
- import { Composer } from '../src/messaging/Composer';
20
- import { messagingReducer, MessagingProvider, useMessaging } from '../src/messaging/MessagingProvider';
21
-
22
- function State() { const { cache } = useMessaging(); return <output data-testid="cache">{JSON.stringify(cache)}</output>; }
23
- function makeApi() {
24
- return {
25
- listConversations: vi.fn().mockResolvedValue({ results: [] }), listMessages: vi.fn().mockResolvedValue({ results: [] }), getUnreadCount: vi.fn().mockResolvedValue({ unread_count: 0, by_conversation: {} }),
26
- createMessage: vi.fn(), uploadAttachments: vi.fn(), getAttachment: vi.fn().mockResolvedValue(new Blob(['file'])), getAttachmentThumbnail: vi.fn().mockResolvedValue(new Blob(['image'], { type: 'image/png' })),
27
- };
28
- }
29
- function renderComposer(api, { userId } = {}) {
30
- const tree = <MessagingProvider api={api} active={false}><Composer conversationId={7} /><State /></MessagingProvider>;
31
- return render(userId ? <AuthContext.Provider value={{ user: { id: userId, username: 'me' } }}>{tree}</AuthContext.Provider> : tree);
32
- }
33
- function typeAndSend(text = 'hello') { fireEvent.change(screen.getByLabelText('MessagingComposer.MESSAGE'), { target: { value: text } }); fireEvent.click(screen.getByRole('button', { name: 'MessagingComposer.SEND' })); }
34
- const state = () => JSON.parse(screen.getByTestId('cache').textContent);
35
-
36
- afterEach(() => { cleanup(); realtimeSubscribers.clear(); });
37
-
38
- describe('Composer optimistic send and attachments', () => {
39
- it('reconciles REST then websocket confirmation into exactly one row', () => {
40
- const pending = { id: 'local-r1', conversation_id: 7, client_request_id: 'r1', status: 'pending' };
41
- const rest = { id: 88, conversation_id: 7, body: 'hello', client_request_id: 'r1' };
42
- let next = messagingReducer({ conversations: {}, messages: {}, cursors: { conversations: null, messages: {}, threads: {} } }, { type: 'messageOptimistic', message: pending });
43
- next = messagingReducer(next, { type: 'messageReconciled', message: rest });
44
- next = messagingReducer(next, { type: 'frame', frame: { type: 'message', conversation_id: 7, message: rest } });
45
- expect(Object.values(next.messages)).toHaveLength(1);
46
- expect(next.messages[88].client_request_id).toBe('r1');
47
- });
48
-
49
- it('reconciles websocket then REST confirmation into exactly one row', () => {
50
- const pending = { id: 'local-r2', conversation_id: 7, client_request_id: 'r2', status: 'pending' };
51
- const websocket = { id: 89, conversation_id: 7, body: 'hello', client_request_id: 'r2' };
52
- let next = messagingReducer({ conversations: {}, messages: {}, cursors: { conversations: null, messages: {}, threads: {} } }, { type: 'messageOptimistic', message: pending });
53
- next = messagingReducer(next, { type: 'frame', frame: { type: 'message', conversation_id: 7, message: websocket } });
54
- next = messagingReducer(next, { type: 'messageReconciled', message: websocket });
55
- expect(Object.values(next.messages)).toHaveLength(1);
56
- expect(next.messages[89].client_request_id).toBe('r2');
57
- });
58
-
59
- it('retries a failed send with the same idempotency key and optimistic row', async () => {
60
- const api = makeApi(); api.createMessage.mockRejectedValueOnce(new Error('offline')).mockResolvedValueOnce({ id: 90, conversation_id: 7, body: 'hello' });
61
- renderComposer(api); typeAndSend(); await screen.findByRole('alert'); const first = api.createMessage.mock.calls[0][1].client_request_id;
62
- fireEvent.click(screen.getByRole('button', { name: 'MessagingComposer.RETRY' }));
63
- await waitFor(() => expect(api.createMessage).toHaveBeenCalledTimes(2));
64
- expect(api.createMessage.mock.calls[1][1].client_request_id).toBe(first);
65
- await waitFor(() => expect(Object.keys(state().messages)).toEqual(['90']));
66
- });
67
-
68
- it('shows the server validation message for a rejected attachment upload', async () => {
69
- // dcm's ConversationAttachmentView translates a rejected upload into a
70
- // field-keyed {"files": [...]} body (the MSG-2 chunk-4 fix), not {detail}.
71
- const api = makeApi(); api.uploadAttachments.mockRejectedValue({ response: { data: { files: ['File type application/octet-stream is not allowed.'] } } });
72
- renderComposer(api); const input = document.querySelector('input[type=file]'); const file = new File(['x'], 'bad.exe', { type: 'application/octet-stream' });
73
- fireEvent.change(input, { target: { files: [file] } }); fireEvent.click(screen.getByRole('button', { name: 'MessagingComposer.SEND' }));
74
- await screen.findByText('MessagingComposer.UPLOAD_ERROR:File type application/octet-stream is not allowed.');
75
- });
76
-
77
- it('shows the server validation message when it arrives as {detail} (the text-message error shape)', async () => {
78
- const api = makeApi(); api.createMessage.mockRejectedValue({ response: { data: { detail: 'Posting is not permitted.' } } });
79
- renderComposer(api); typeAndSend('hello');
80
- await screen.findByText('MessagingComposer.SEND_ERROR:Posting is not permitted.');
81
- });
82
-
83
- it('populates the optimistic row with the current user as sender, not "unknown sender"', async () => {
84
- let resolveCreate; const api = makeApi(); api.createMessage.mockReturnValue(new Promise((resolve) => { resolveCreate = resolve; }));
85
- renderComposer(api, { userId: 9 }); typeAndSend('hello');
86
- await waitFor(() => expect(Object.keys(state().messages)).toHaveLength(1));
87
- const [optimistic] = Object.values(state().messages);
88
- expect(optimistic.status).toBe('pending');
89
- expect(optimistic.sender).toEqual({ id: 9, display_name: 'me' });
90
- resolveCreate({ id: 91, conversation_id: 7, body: 'hello' });
91
- });
92
-
93
- it('end-to-end: a real in-flight send reconciled by a WS frame arriving before the REST response settles produces exactly one row', async () => {
94
- let resolveCreate; const api = makeApi(); api.createMessage.mockReturnValue(new Promise((resolve) => { resolveCreate = resolve; }));
95
- renderComposer(api); typeAndSend('hello');
96
- await waitFor(() => expect(Object.keys(state().messages)).toHaveLength(1));
97
- const requestId = api.createMessage.mock.calls[0][1].client_request_id;
98
- // The WS frame for this message's creation arrives while the REST POST is still in flight.
99
- act(() => dispatchMessagingFrame({ envelope: 'messaging', type: 'message', conversation_id: 7, message: { id: 91, conversation_id: 7, body: 'hello', client_request_id: requestId } }));
100
- expect(Object.keys(state().messages)).toEqual(['91']);
101
- // The REST response for the same send resolves afterward and must not create a second row.
102
- await act(async () => resolveCreate({ id: 91, conversation_id: 7, body: 'hello', client_request_id: requestId }));
103
- expect(Object.keys(state().messages)).toEqual(['91']);
104
- });
105
-
106
- it('mounts Composer and AttachmentList independently', async () => {
107
- const api = makeApi(); const { unmount } = renderComposer(api); expect(screen.getByLabelText('MessagingComposer.LABEL')).toBeTruthy(); unmount();
108
- render(<MessagingProvider api={api} active={false}><AttachmentList attachments={[{ id: 1, filename: 'note.pdf', content_type: 'application/pdf' }]} /></MessagingProvider>);
109
- expect(screen.getByLabelText('MessagingAttachments.LABEL')).toBeTruthy();
110
- });
111
-
112
- it('keeps the message field and send button usable beside all enabled actions', () => {
113
- render(<MessagingProvider api={makeApi()} active={false}><Composer conversationId={7} conversation={{ kind: 'group' }} allowAnnouncement /></MessagingProvider>);
114
- const messageField = screen.getByLabelText('MessagingComposer.MESSAGE');
115
- const messageFieldRoot = messageField.closest('.MuiFormControl-root');
116
- expect(messageFieldRoot).toBeTruthy();
117
- expect(window.getComputedStyle(messageFieldRoot).minWidth).toBe('120px');
118
- const sendButton = screen.getByRole('button', { name: 'MessagingComposer.SEND' });
119
- expect(window.getComputedStyle(sendButton).flexShrink).toBe('0');
120
- expect(screen.getByRole('button', { name: 'MessagingComposer.ADD_ATTACHMENT' }).disabled).toBe(false);
121
- expect(screen.getByRole('button', { name: 'MessagingComposer.ADD_EMOJI' }).disabled).toBe(false);
122
- expect(screen.getByRole('button', { name: 'MessagingPoll.CREATE' }).disabled).toBe(false);
123
- expect(screen.getByRole('button', { name: 'MessagingAnnouncement.CREATE' }).disabled).toBe(false);
124
-
125
- // Structural proof, not just a CSS-value check: the action icons and the
126
- // message field/send button must sit in DIFFERENT Stack rows, not merely
127
- // carry different sx values while still being flex siblings in one row
128
- // (a same-row layout with only the sx tweaks would still pass every
129
- // assertion above without actually fixing the 375px overflow).
130
- const attachButton = screen.getByRole('button', { name: 'MessagingComposer.ADD_ATTACHMENT' });
131
- const actionsRow = attachButton.closest('.MuiStack-root');
132
- expect(actionsRow).toBeTruthy();
133
- expect(actionsRow.contains(messageField)).toBe(false);
134
- expect(actionsRow.contains(sendButton)).toBe(false);
135
- });
136
- });