@micha.bigler/ui-core-micha 3.14.4 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +7 -0
- package/dist/chat/kitSxRegistry.js +9 -0
- package/dist/components/charts/kitSxRegistry.js +6 -0
- package/dist/entries/charts.js +6 -0
- package/dist/entries/chat.js +8 -0
- package/dist/entries/markdown.js +1 -0
- package/dist/index.js +0 -14
- package/dist/pages/AccountPage.js +1 -2
- package/dist/pages/LoginPage.js +1 -2
- package/dist/pages/PasswordChangePage.js +1 -2
- package/dist/pages/PasswordInvitePage.js +1 -2
- package/dist/pages/PasswordResetRequestPage.js +1 -2
- package/dist/pages/SignUpPage.js +1 -2
- package/dist/pages/SignupConfirmPage.js +1 -2
- package/dist/theme/kitSxEntry.js +11 -0
- package/dist/theme/kitSxRegistry.js +2 -15
- package/package.json +31 -7
- package/.github/workflows/ci.yml +0 -35
- package/.github/workflows/publish.yml +0 -126
- package/DESIGN.md +0 -60
- package/WORK_ORDERS.md +0 -150
- package/dev/entries.jsx +0 -721
- package/dev/fixtures.js +0 -26
- package/dev/main.jsx +0 -75
- package/dev/mockTransport.jsx +0 -128
- package/docs/CHART-LAYOUT.md +0 -157
- package/docs/DARK-TOKENS.md +0 -140
- package/docs/TYPE-SCALE.md +0 -111
- package/docs/messaging-deviations.md +0 -118
- package/index.html +0 -12
- package/renovate.json +0 -10
- package/scripts/chart-api-census.mjs +0 -415
- package/src/auth/AuthContext.jsx +0 -158
- package/src/auth/ReauthModal.jsx +0 -82
- package/src/auth/UserMenu.jsx +0 -121
- package/src/auth/apiClient.jsx +0 -232
- package/src/auth/authApi.jsx +0 -539
- package/src/auth/authConfig.jsx +0 -34
- package/src/auth/reauth.js +0 -47
- package/src/chat/ChatComposer.jsx +0 -36
- package/src/chat/ChatList.jsx +0 -87
- package/src/chat/ChatThread.jsx +0 -128
- package/src/chat/ChatWorkspace.jsx +0 -244
- package/src/chat/MarkdownReply.jsx +0 -22
- package/src/chat/ModelPicker.jsx +0 -85
- package/src/chat/api.js +0 -18
- package/src/chat/useChatSocket.js +0 -32
- package/src/chat/wire.js +0 -7
- package/src/components/AccessCodeManager.jsx +0 -288
- package/src/components/AccessCodeSingleUseToggle.jsx +0 -92
- package/src/components/AllowedEmailDomainsManager.jsx +0 -92
- package/src/components/AuthFactorRequirementCard.jsx +0 -95
- package/src/components/BulkInviteCsvTab.jsx +0 -198
- package/src/components/EmptyState.jsx +0 -38
- package/src/components/LoginForm.jsx +0 -159
- package/src/components/MFAComponent.jsx +0 -350
- package/src/components/MfaLoginComponent.jsx +0 -252
- package/src/components/MobileBottomNav.jsx +0 -82
- package/src/components/PasskeysComponent.jsx +0 -252
- package/src/components/PasswordChangeForm.jsx +0 -87
- package/src/components/PasswordResetRequestForm.jsx +0 -43
- package/src/components/PasswordSetForm.jsx +0 -97
- package/src/components/ProfileComponent.jsx +0 -348
- package/src/components/QrSignupManager.jsx +0 -404
- package/src/components/QrSignupValidityManager.jsx +0 -106
- package/src/components/RegistrationMethodsManager.jsx +0 -150
- package/src/components/SecurityComponent.jsx +0 -141
- package/src/components/SocialLoginButtons.jsx +0 -83
- package/src/components/SoftChip.jsx +0 -93
- package/src/components/StatTile.jsx +0 -39
- package/src/components/SupportRecoveryRequestsTab.jsx +0 -482
- package/src/components/TurnstileWidget.jsx +0 -99
- package/src/components/UserInviteComponent.jsx +0 -76
- package/src/components/UserListComponent.jsx +0 -618
- package/src/components/charts/BarChart.jsx +0 -102
- package/src/components/charts/ChartFrame.jsx +0 -214
- package/src/components/charts/LineChart.jsx +0 -126
- package/src/components/charts/ScatterChart.jsx +0 -299
- package/src/components/charts/TimeSeriesChart.jsx +0 -300
- package/src/components/charts/chartDefaults.js +0 -644
- package/src/components/charts/chartLabels.js +0 -36
- package/src/components/charts/exportChart.js +0 -258
- package/src/components/charts/formatters.js +0 -39
- package/src/components/charts/palette.js +0 -33
- package/src/components/charts/yearTickInterval.js +0 -7
- package/src/i18n/authTranslations.ts +0 -2651
- package/src/i18n/chartsTranslations.ts +0 -91
- package/src/i18n/chatTranslations.ts +0 -55
- package/src/i18n/messagingTranslations.ts +0 -120
- package/src/i18n/notificationsTranslations.ts +0 -32
- package/src/i18n/onboardingTranslations.ts +0 -29
- package/src/i18n/sectionNavTranslations.ts +0 -20
- package/src/i18n/uiCoreTranslations.js +0 -29
- package/src/i18n/userMenuTranslations.ts +0 -5
- package/src/index.js +0 -158
- package/src/layout/PageLayout.jsx +0 -36
- package/src/layout/SectionNav.jsx +0 -320
- package/src/messaging/AttachmentList.jsx +0 -145
- package/src/messaging/Composer.jsx +0 -197
- package/src/messaging/ConversationLaunchers.jsx +0 -51
- package/src/messaging/ConversationList.jsx +0 -109
- package/src/messaging/DirectMessageLauncher.jsx +0 -112
- package/src/messaging/MessageBubble.jsx +0 -183
- package/src/messaging/MessagingProvider.jsx +0 -0
- package/src/messaging/MessagingScopeConfig.jsx +0 -24
- package/src/messaging/PollCard.jsx +0 -163
- package/src/messaging/ReactionBar.jsx +0 -43
- package/src/messaging/ReadTicks.jsx +0 -82
- package/src/messaging/Thread.jsx +0 -195
- package/src/messaging/api.js +0 -48
- package/src/messaging/composerImageCompression.js +0 -35
- package/src/messaging/linkifyText.jsx +0 -37
- package/src/notifications/NotificationBell.jsx +0 -84
- package/src/notifications/NotificationSettings.jsx +0 -330
- package/src/notifications/NotificationsProvider.jsx +0 -224
- package/src/notifications/PopupSurface.jsx +0 -105
- package/src/notifications/api.js +0 -55
- package/src/notifications/feedApi.js +0 -18
- package/src/notifications/realtime.jsx +0 -138
- package/src/notifications/serviceWorker/sw.js +0 -50
- package/src/onboarding/OnboardingProvider.jsx +0 -326
- package/src/onboarding/OnboardingWizard.jsx +0 -61
- package/src/onboarding/WizardDialogShell.jsx +0 -51
- package/src/onboarding/api.js +0 -13
- package/src/onboarding/stepSelection.js +0 -16
- package/src/onboarding/steps/BrowserPushStep.jsx +0 -121
- package/src/onboarding/steps/CompleteNameStep.jsx +0 -46
- package/src/onboarding/steps/CookieConsentStep.jsx +0 -133
- package/src/onboarding/steps/PwaInstallStep.jsx +0 -47
- package/src/pages/AccountPage.jsx +0 -394
- package/src/pages/LoginPage.jsx +0 -343
- package/src/pages/PasswordChangePage.jsx +0 -62
- package/src/pages/PasswordInvitePage.jsx +0 -177
- package/src/pages/PasswordResetRequestPage.jsx +0 -68
- package/src/pages/SignUpPage.jsx +0 -268
- package/src/pages/SignupConfirmPage.jsx +0 -155
- package/src/testing/checkKitIntegration.js +0 -233
- package/src/theme/createAppTheme.js +0 -423
- package/src/theme/fonts.js +0 -3
- package/src/theme/index.js +0 -21
- package/src/theme/kitSxRegistry.js +0 -285
- package/src/theme/themeCompleteness.js +0 -1045
- package/src/theme/tokens.js +0 -478
- package/src/utils/auth-errors.js +0 -76
- package/src/utils/authService.js +0 -223
- package/src/utils/resolveErrorText.js +0 -28
- package/src/utils/webauthn.js +0 -51
- package/tests/AccountPage.profileStatements.test.jsx +0 -162
- package/tests/AccountPage.test.jsx +0 -200
- package/tests/AuthContext.test.jsx +0 -129
- package/tests/BarChart.test.jsx +0 -112
- package/tests/BrowserPushStep.test.jsx +0 -110
- package/tests/ChartFrame.test.jsx +0 -336
- package/tests/ConversationList.test.jsx +0 -144
- package/tests/CookieConsentStep.test.jsx +0 -69
- package/tests/EmptyState.test.jsx +0 -62
- package/tests/LineChart.test.jsx +0 -80
- package/tests/MessagingProvider.test.jsx +0 -50
- package/tests/MobileBottomNav.test.jsx +0 -319
- package/tests/NotificationBell.test.jsx +0 -60
- package/tests/NotificationSettings.test.jsx +0 -276
- package/tests/NotificationsProvider.test.jsx +0 -240
- package/tests/OnboardingProvider.test.jsx +0 -294
- package/tests/OnboardingWizard.test.jsx +0 -143
- package/tests/PasswordChangeForm.test.jsx +0 -70
- package/tests/PasswordInvitePage.test.jsx +0 -142
- package/tests/PasswordSetForm.test.jsx +0 -70
- package/tests/PopupSurface.test.jsx +0 -142
- package/tests/ProfileComponent.refresh.test.jsx +0 -194
- package/tests/QrSignupManager.registrationContext.test.jsx +0 -106
- package/tests/QrSignupManagerInfoBox.test.jsx +0 -49
- package/tests/ScatterChart.test.jsx +0 -270
- package/tests/SectionNav.test.jsx +0 -363
- package/tests/SignUpPage.test.jsx +0 -208
- package/tests/SoftChip.test.jsx +0 -105
- package/tests/StatTile.test.jsx +0 -57
- package/tests/Thread.test.jsx +0 -151
- package/tests/TimeSeriesChart.test.jsx +0 -367
- package/tests/UserListComponent.test.jsx +0 -192
- package/tests/UserMenu.test.jsx +0 -171
- package/tests/apiClientLanguage.test.js +0 -33
- package/tests/apiClientPublicPaths.test.js +0 -178
- package/tests/authApiLogin.test.js +0 -42
- package/tests/authApiRegistration.test.js +0 -31
- package/tests/authErrorCodeRendering.test.jsx +0 -77
- package/tests/authErrors.test.js +0 -74
- package/tests/authTranslations.test.js +0 -74
- package/tests/chart-api-census.test.js +0 -366
- package/tests/chartAxisTickBand.test.jsx +0 -95
- package/tests/chartDefaults.test.js +0 -902
- package/tests/chartLabels.test.js +0 -50
- package/tests/chartsPalette.test.js +0 -99
- package/tests/chatApi.test.js +0 -48
- package/tests/chatDriverNames.test.jsx +0 -71
- package/tests/chatExports.test.js +0 -3
- package/tests/chatList.test.jsx +0 -84
- package/tests/chatPicker.test.jsx +0 -82
- package/tests/chatSocket.test.jsx +0 -26
- package/tests/chatThread.test.jsx +0 -116
- package/tests/chatTranslations.test.js +0 -47
- package/tests/chatWorkspace.test.jsx +0 -234
- package/tests/checkKitIntegration.test.jsx +0 -219
- package/tests/createAppTheme.test.js +0 -132
- package/tests/createAppThemeDark.test.js +0 -127
- package/tests/createAppThemeLightGuard.test.js +0 -40
- package/tests/createAppThemePageContrast.test.js +0 -108
- package/tests/createAppThemeTypography.test.js +0 -53
- package/tests/errorCallSiteGuard.test.js +0 -32
- package/tests/exportChart.test.js +0 -313
- package/tests/feedApi.test.js +0 -46
- package/tests/fixtures/light-theme-baseline.json +0 -2234
- package/tests/i18nAggregate.test.js +0 -120
- package/tests/i18nGermanVariant.test.js +0 -65
- package/tests/loginPageErrorResolution.test.jsx +0 -102
- package/tests/messagingApi.test.js +0 -32
- package/tests/messagingChunk6.test.jsx +0 -116
- package/tests/messagingCompactBubble.test.jsx +0 -64
- package/tests/messagingComposer.test.jsx +0 -136
- package/tests/messagingComposerChunk5.test.jsx +0 -113
- package/tests/messagingContractConformance.test.js +0 -69
- package/tests/messagingDirectMessageLauncher.test.jsx +0 -151
- package/tests/messagingExports.test.js +0 -21
- package/tests/messagingInteractions.test.jsx +0 -136
- package/tests/messagingLastMessagePreview.test.jsx +0 -93
- package/tests/messagingLinkify.test.jsx +0 -51
- package/tests/messagingMessageActions.test.jsx +0 -163
- package/tests/messagingMsg6.test.jsx +0 -105
- package/tests/messagingMsg6f.test.jsx +0 -155
- package/tests/messagingMsg6g.test.jsx +0 -166
- package/tests/messagingMsg6h.test.jsx +0 -136
- package/tests/messagingMsg6i.test.jsx +0 -129
- package/tests/messagingPollRendering.test.jsx +0 -142
- package/tests/messagingReactionMerge.test.jsx +0 -77
- package/tests/messagingReadTicksTooltip.test.jsx +0 -36
- package/tests/messagingThreadReceipts.test.jsx +0 -178
- package/tests/messagingThreadingQuoting.test.jsx +0 -87
- package/tests/messagingUnreadLifecycle.test.jsx +0 -78
- package/tests/notificationsApi.test.js +0 -41
- package/tests/notificationsExports.test.js +0 -34
- package/tests/onboardingDescriptors.test.js +0 -132
- package/tests/packageTreeShaking.test.js +0 -126
- package/tests/realtime.test.jsx +0 -219
- package/tests/resolveErrorText.test.js +0 -72
- package/tests/stepSelection.test.js +0 -53
- package/tests/themeCompleteness.test.js +0 -626
- package/tests/timeSeriesLegend.test.js +0 -99
- package/tests/userScreenTranslations.test.jsx +0 -218
- package/tsconfig.build.json +0 -18
- package/vite.config.mjs +0 -6
- package/work-orders/AUTH-1.md +0 -74
- package/work-orders/AUTH-2.md +0 -74
- package/work-orders/AUTH-4.md +0 -183
- package/work-orders/AUTH-5.md +0 -154
- package/work-orders/AUTH-7.md +0 -181
- package/work-orders/AUTH-8.md +0 -184
- package/work-orders/CHART-1.md +0 -285
- package/work-orders/CHART-2.md +0 -222
- package/work-orders/CHART-3.md +0 -163
- package/work-orders/CHART-4.md +0 -203
- package/work-orders/CHART-5.md +0 -226
- package/work-orders/CHART-6.md +0 -428
- package/work-orders/CHART-7.md +0 -175
- package/work-orders/DX-1.md +0 -169
- package/work-orders/DX-2.md +0 -188
- package/work-orders/DX-3.md +0 -195
- package/work-orders/I18N-1.md +0 -254
- package/work-orders/I18N-3.md +0 -207
- package/work-orders/MSG-3.md +0 -375
- package/work-orders/MSG-3b.md +0 -1002
- package/work-orders/MSG-3c.md +0 -378
- package/work-orders/MSG-3d.md +0 -268
- package/work-orders/MSG-3e.md +0 -164
- package/work-orders/MSG-3f.md +0 -391
- package/work-orders/MSG-6e.md +0 -308
- package/work-orders/MSG-6f.md +0 -214
- package/work-orders/MSG-6g.md +0 -244
- package/work-orders/MSG-6h.md +0 -238
- package/work-orders/MSG-6i.md +0 -271
- package/work-orders/MSG-6j.md +0 -117
- package/work-orders/NOTIF-12.md +0 -214
- package/work-orders/NOTIF-13.md +0 -142
- package/work-orders/NOTIF-14.md +0 -151
- package/work-orders/PRIM-1.md +0 -177
- package/work-orders/SHELL-1.md +0 -255
- package/work-orders/SHELL-2.md +0 -197
- package/work-orders/SHELL-3.md +0 -359
- package/work-orders/SHELL-4.md +0 -351
- package/work-orders/SHELL-5.md +0 -345
- package/work-orders/SHELL-6.md +0 -210
- package/work-orders/THEME-1.md +0 -587
- package/work-orders/THEME-10.md +0 -303
- package/work-orders/THEME-11.md +0 -208
- package/work-orders/THEME-2.md +0 -339
- package/work-orders/THEME-3.md +0 -210
- package/work-orders/THEME-4.md +0 -271
- package/work-orders/THEME-5.md +0 -341
- package/work-orders/THEME-6.md +0 -247
- package/work-orders/THEME-7.md +0 -82
- package/work-orders/THEME-8.md +0 -211
- package/work-orders/THEME-9.md +0 -194
- package/work-orders/UCM-AUTH-10.md +0 -490
- package/work-orders/UCM-AUTH-11.md +0 -185
- package/work-orders/UCM-AUTH-12.md +0 -98
- package/work-orders/UCM-AUTH-13.md +0 -47
- package/work-orders/UCM-AUTH-9.md +0 -207
- package/work-orders/UCM-CHART-10.md +0 -150
- package/work-orders/UCM-CHART-11.md +0 -132
- package/work-orders/UCM-CHART-12.md +0 -348
- package/work-orders/UCM-CHART-13.md +0 -122
- package/work-orders/UCM-CHART-14.md +0 -198
- package/work-orders/UCM-CHART-15.md +0 -187
- package/work-orders/UCM-CHART-16.md +0 -169
- package/work-orders/UCM-CHART-17.md +0 -195
- package/work-orders/UCM-CHART-18.md +0 -200
- package/work-orders/UCM-CHART-8.md +0 -147
- package/work-orders/UCM-CHART-9.md +0 -265
- package/work-orders/UCM-CHAT-1.md +0 -190
- package/work-orders/UCM-CHAT-2.md +0 -75
- package/work-orders/UCM-CI-1.md +0 -65
- package/work-orders/UCM-DEP-1.md +0 -63
- package/work-orders/UCM-I18N-4.md +0 -226
- package/work-orders/UCM-I18N-5.md +0 -211
- package/work-orders/UCM-MSG-20.md +0 -192
- package/work-orders/UCM-PRIM-2.md +0 -114
- package/work-orders/UCM-SHELL-7.md +0 -134
- package/work-orders/UCM-SHELL-8.md +0 -125
- package/work-orders/UCM-TEST-1.md +0 -304
- package/work-orders/UCM-THEME-13.md +0 -69
- package/work-orders/UCM-THEME-14.md +0 -312
- package/work-orders/UCM-THEME-15.md +0 -356
- package/work-orders/UCM-THEME-16.md +0 -80
- package/work-orders/UCM-THEME-17.md +0 -111
- package/work-orders/UCM-THEME-18.md +0 -184
- package/work-orders/assets/AUTH-4-user-list-card.html +0 -407
- package/work-orders/assets/PRIM-1-dashboard-primitives.html +0 -624
- package/work-orders/assets/SHELL-2-account-navigation.html +0 -1159
- package/work-orders/assets/THEME-1-baseline-reference-sheet.html +0 -1352
- package/work-orders/assets/UCM-CHAT-1-ai-chat.html +0 -447
- package/work-orders/assets/UCM-THEME-13-dark-prototype.html +0 -390
- package/work-orders/assets/UCM-THEME-17-type-scale.html +0 -391
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
-
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
7
|
-
|
|
8
|
-
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key, options) => options?.count !== undefined ? `${key}:${options.count}` : key, i18n: { language: 'en' } }) }));
|
|
9
|
-
|
|
10
|
-
// Thread.jsx (MSG-6f scope C) now subscribes to the messaging envelope
|
|
11
|
-
// independently of MessagingProvider's own subscription -- a Set of handlers
|
|
12
|
-
// per envelope, not one handler per envelope, so a dispatched frame still
|
|
13
|
-
// reaches every current subscriber, matching the real registry's multi-handler support.
|
|
14
|
-
const realtimeSubscribers = new Map();
|
|
15
|
-
vi.mock('../src/notifications/realtime', () => ({
|
|
16
|
-
useRealtime: () => ({
|
|
17
|
-
subscribe: (envelope, handler) => {
|
|
18
|
-
if (!realtimeSubscribers.has(envelope)) realtimeSubscribers.set(envelope, new Set());
|
|
19
|
-
realtimeSubscribers.get(envelope).add(handler);
|
|
20
|
-
return () => realtimeSubscribers.get(envelope)?.delete(handler);
|
|
21
|
-
},
|
|
22
|
-
onReconnect: () => () => {},
|
|
23
|
-
}),
|
|
24
|
-
}));
|
|
25
|
-
function dispatchMessagingFrame(frame) { realtimeSubscribers.get('messaging')?.forEach((handler) => handler(frame)); }
|
|
26
|
-
|
|
27
|
-
import { ConversationList } from '../src/messaging/ConversationList';
|
|
28
|
-
import { Thread } from '../src/messaging/Thread';
|
|
29
|
-
import { applyFrame, MessagingProvider } from '../src/messaging/MessagingProvider';
|
|
30
|
-
|
|
31
|
-
// Server-shaped serialize_message output (django_core_micha/messaging/
|
|
32
|
-
// serializers.py:80-95): reply_count/last_reply_at always present;
|
|
33
|
-
// thread_last_read_at is REST-only and never on a frame — copied from the
|
|
34
|
-
// real _message_response/_message_page_response wiring in views.py, not
|
|
35
|
-
// hand-invented.
|
|
36
|
-
function serverRoot(overrides = {}) {
|
|
37
|
-
return { id: 'root-1', conversation_id: 'conv-1', body: 'Root', sender_id: 'user-1', kind: 'chat', reply_count: 1, last_reply_at: '2026-08-01T09:00:00Z', thread_last_read_at: null, ...overrides };
|
|
38
|
-
}
|
|
39
|
-
function serverReply(overrides = {}) {
|
|
40
|
-
return { id: 'reply-1', conversation_id: 'conv-1', body: 'Reply', sender_id: 'user-2', kind: 'chat', reply_to_id: 'root-1', reply_count: 0, last_reply_at: null, created_at: '2026-08-01T10:00:00Z', ...overrides };
|
|
41
|
-
}
|
|
42
|
-
function baseApi(overrides = {}) {
|
|
43
|
-
return {
|
|
44
|
-
listConversations: vi.fn().mockResolvedValue({ results: [] }), listMessages: vi.fn().mockResolvedValue({ results: [] }),
|
|
45
|
-
getUnreadCount: vi.fn().mockResolvedValue({ unread_count: 0, by_conversation: {} }),
|
|
46
|
-
markConversationRead: vi.fn().mockResolvedValue({}), markThreadRead: vi.fn(),
|
|
47
|
-
...overrides,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
afterEach(() => { cleanup(); realtimeSubscribers.clear(); });
|
|
52
|
-
|
|
53
|
-
describe('the merge trap — thread_last_read_at must survive frames that never carry it', () => {
|
|
54
|
-
function cache() { return { conversations: {}, messages: {}, threads: {}, polls: {}, reactions: {}, receipts: {}, unread: { unread_count: 0, by_conversation: {} }, cursors: { conversations: null, messages: {}, threads: {} } }; }
|
|
55
|
-
|
|
56
|
-
it('a server-shaped message frame does not wipe a previously-fetched thread_last_read_at on an unrelated root', () => {
|
|
57
|
-
const state = { ...cache(), messages: { 'root-1': serverRoot({ thread_last_read_at: '2026-08-01T08:00:00Z' }) } };
|
|
58
|
-
// A brand-new, unrelated root message frame — server-shaped, no
|
|
59
|
-
// thread_last_read_at key, exactly as serialize_message emits it.
|
|
60
|
-
const next = applyFrame(state, { envelope: 'messaging', type: 'message', event_id: 'evt-1', conversation_id: 'conv-1', message: serverRoot({ id: 'root-2', thread_last_read_at: undefined, reply_to_id: undefined }) }, 'conv-1');
|
|
61
|
-
expect(next.messages['root-1'].thread_last_read_at).toBe('2026-08-01T08:00:00Z');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('a server-shaped message_edited frame does not wipe the edited root\'s own thread_last_read_at', () => {
|
|
65
|
-
const state = { ...cache(), messages: { 'root-1': serverRoot({ thread_last_read_at: '2026-08-01T08:00:00Z', body: 'Before' }) } };
|
|
66
|
-
const edited = serverRoot({ body: 'After', thread_last_read_at: undefined });
|
|
67
|
-
delete edited.thread_last_read_at;
|
|
68
|
-
const next = applyFrame(state, { envelope: 'messaging', type: 'message_edited', event_id: 'evt-2', conversation_id: 'conv-1', message_id: 'root-1', message: edited }, null);
|
|
69
|
-
expect(next.messages['root-1'].thread_last_read_at).toBe('2026-08-01T08:00:00Z');
|
|
70
|
-
expect(next.messages['root-1'].body).toBe('After');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('a reply frame bumping a cached root\'s reply_count/last_reply_at does not wipe that root\'s thread_last_read_at — the WO\'s highest-risk path', () => {
|
|
74
|
-
// The receipt is deliberately NEWER than the incoming reply, so
|
|
75
|
-
// hasUnreadReplies-style logic would already read "read" before this
|
|
76
|
-
// frame — if the bump wiped thread_last_read_at to null/undefined instead
|
|
77
|
-
// of preserving it, that derived read-state would flip, which this
|
|
78
|
-
// assertion catches directly (unlike a marker-visibility assertion,
|
|
79
|
-
// which can't distinguish "correctly still read" from "field wiped to
|
|
80
|
-
// null" — both render no marker).
|
|
81
|
-
const state = { ...cache(), messages: { 'root-1': serverRoot({ reply_count: 1, last_reply_at: '2026-08-01T08:00:00Z', thread_last_read_at: '2026-08-01T09:00:00Z' }) } };
|
|
82
|
-
const next = applyFrame(state, { envelope: 'messaging', type: 'message', event_id: 'evt-4', conversation_id: 'conv-1', message: serverReply({ id: 'reply-2', created_at: '2026-08-01T10:00:00Z' }) }, 'conv-1');
|
|
83
|
-
expect(next.messages['root-1'].reply_count).toBe(2);
|
|
84
|
-
expect(next.messages['root-1'].last_reply_at).toBe('2026-08-01T10:00:00Z');
|
|
85
|
-
expect(next.messages['root-1'].thread_last_read_at).toBe('2026-08-01T09:00:00Z');
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('unread-reply marker logic', () => {
|
|
90
|
-
it('shows when last_reply_at is newer than the receipt', async () => {
|
|
91
|
-
const api = baseApi({ listMessages: vi.fn().mockResolvedValue({ results: [serverRoot({ last_reply_at: '2026-08-01T10:00:00Z', thread_last_read_at: '2026-08-01T09:00:00Z' })] }) });
|
|
92
|
-
render(<MessagingProvider api={api} activeConversationId="conv-1"><Thread conversationId="conv-1" /></MessagingProvider>);
|
|
93
|
-
await screen.findByText('Root');
|
|
94
|
-
expect(screen.getByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeTruthy();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('hides when the receipt is equal to or newer than last_reply_at', async () => {
|
|
98
|
-
const api = baseApi({ listMessages: vi.fn().mockResolvedValue({ results: [serverRoot({ last_reply_at: '2026-08-01T09:00:00Z', thread_last_read_at: '2026-08-01T10:00:00Z' })] }) });
|
|
99
|
-
render(<MessagingProvider api={api} activeConversationId="conv-1"><Thread conversationId="conv-1" /></MessagingProvider>);
|
|
100
|
-
await screen.findByText('Root');
|
|
101
|
-
expect(screen.queryByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeNull();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('shows when the receipt is null and reply_count > 0', async () => {
|
|
105
|
-
const api = baseApi({ listMessages: vi.fn().mockResolvedValue({ results: [serverRoot({ thread_last_read_at: null, reply_count: 2, last_reply_at: '2026-08-01T09:00:00Z' })] }) });
|
|
106
|
-
render(<MessagingProvider api={api} activeConversationId="conv-1"><Thread conversationId="conv-1" /></MessagingProvider>);
|
|
107
|
-
await screen.findByText('Root');
|
|
108
|
-
expect(screen.getByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeTruthy();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('renders no toggle and no marker at all when reply_count is 0', async () => {
|
|
112
|
-
const api = baseApi({ listMessages: vi.fn().mockResolvedValue({ results: [serverRoot({ reply_count: 0, last_reply_at: null, thread_last_read_at: null })] }) });
|
|
113
|
-
render(<MessagingProvider api={api} activeConversationId="conv-1"><Thread conversationId="conv-1" /></MessagingProvider>);
|
|
114
|
-
await screen.findByText('Root');
|
|
115
|
-
expect(screen.queryByText(/MessagingThread\.SHOW_REPLIES/)).toBeNull();
|
|
116
|
-
expect(screen.queryByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeNull();
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('opening a thread marks it read from the REST response', () => {
|
|
121
|
-
it('issues the REST read call and updates the cached receipt from last_read_at', async () => {
|
|
122
|
-
const api = baseApi({
|
|
123
|
-
listMessages: vi.fn().mockResolvedValue({ results: [serverRoot({ thread_last_read_at: null, reply_count: 1, last_reply_at: '2026-08-01T09:00:00Z' })] }),
|
|
124
|
-
listThread: vi.fn().mockResolvedValue({ results: [] }),
|
|
125
|
-
markThreadRead: vi.fn().mockResolvedValue({ last_read_at: '2026-08-01T12:00:00Z' }),
|
|
126
|
-
});
|
|
127
|
-
render(<MessagingProvider api={api} activeConversationId="conv-1"><Thread conversationId="conv-1" /></MessagingProvider>);
|
|
128
|
-
await screen.findByText('Root');
|
|
129
|
-
expect(screen.getByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeTruthy();
|
|
130
|
-
fireEvent.click(screen.getByText(/MessagingThread\.SHOW_REPLIES/));
|
|
131
|
-
await waitFor(() => expect(api.markThreadRead).toHaveBeenCalledWith('root-1', undefined));
|
|
132
|
-
await waitFor(() => expect(screen.queryByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeNull());
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('live root update on an incoming reply', () => {
|
|
137
|
-
it('raises reply_count/last_reply_at on the cached root and the marker appears without a refetch when the sender is not the viewer', async () => {
|
|
138
|
-
const api = baseApi({ listMessages: vi.fn().mockResolvedValue({ results: [serverRoot({ reply_count: 1, last_reply_at: '2026-08-01T08:00:00Z', thread_last_read_at: '2026-08-01T08:30:00Z' })] }) });
|
|
139
|
-
render(<MessagingProvider api={api} activeConversationId="conv-1"><Thread conversationId="conv-1" /></MessagingProvider>);
|
|
140
|
-
await screen.findByText(/MessagingThread\.SHOW_REPLIES:1/);
|
|
141
|
-
expect(screen.queryByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeNull();
|
|
142
|
-
// A new reply from someone else — server-shaped message frame with
|
|
143
|
-
// reply_to_id naming the cached root.
|
|
144
|
-
dispatchMessagingFrame({ envelope: 'messaging', type: 'message', event_id: 'evt-3', conversation_id: 'conv-1', message: serverReply() });
|
|
145
|
-
await waitFor(() => expect(screen.getByText(/MessagingThread\.SHOW_REPLIES:2/)).toBeTruthy());
|
|
146
|
-
expect(screen.getByLabelText(/MessagingThread.UNREAD_REPLIES/)).toBeTruthy();
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe('managed-conversation identity (row 42)', () => {
|
|
151
|
-
it('renders two managed conversations with different external_key as distinguishable via a host resolver', async () => {
|
|
152
|
-
const api = baseApi({
|
|
153
|
-
listConversations: vi.fn().mockResolvedValue({ results: [
|
|
154
|
-
{ id: 'c1', kind: 'managed', external_key: 'all' },
|
|
155
|
-
{ id: 'c2', kind: 'managed', external_key: 'team' },
|
|
156
|
-
] }),
|
|
157
|
-
});
|
|
158
|
-
render(<MessagingProvider api={api}><ConversationList resolveManagedLabel={(conversation) => conversation.external_key === 'all' ? 'Everyone' : 'My team'} /></MessagingProvider>);
|
|
159
|
-
await screen.findByText('Everyone');
|
|
160
|
-
expect(screen.getByText('My team')).toBeTruthy();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('falls back to the existing title behavior when no resolver is supplied', async () => {
|
|
164
|
-
const api = baseApi({ listConversations: vi.fn().mockResolvedValue({ results: [{ id: 'c1', kind: 'managed', external_key: 'all', title: 'Fallback title' }] }) });
|
|
165
|
-
render(<MessagingProvider api={api}><ConversationList /></MessagingProvider>);
|
|
166
|
-
await screen.findByText('Fallback title');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('no jg-specific vocabulary (event_all, event_team) appears anywhere in src/', () => {
|
|
170
|
-
const root = path.resolve(import.meta.dirname, '..', 'src');
|
|
171
|
-
const files = fs.readdirSync(root, { recursive: true }).filter((file) => typeof file === 'string' && /\.(jsx?|tsx?)$/.test(file));
|
|
172
|
-
const offenders = files.filter((file) => {
|
|
173
|
-
const contents = fs.readFileSync(path.join(root, file), 'utf8');
|
|
174
|
-
return /event_all|event_team/.test(contents);
|
|
175
|
-
});
|
|
176
|
-
expect(offenders).toEqual([]);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
@@ -1,87 +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?.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 { applyFrame, MessagingProvider } from '../src/messaging/MessagingProvider';
|
|
12
|
-
import { Thread } from '../src/messaging/Thread';
|
|
13
|
-
|
|
14
|
-
function makeApi(messages = []) {
|
|
15
|
-
return {
|
|
16
|
-
listConversations: vi.fn().mockResolvedValue({ results: [{ id: 1, kind: 'group' }] }),
|
|
17
|
-
listMessages: vi.fn().mockResolvedValue({ results: messages }),
|
|
18
|
-
listThread: vi.fn().mockResolvedValue({ results: [] }),
|
|
19
|
-
getUnreadCount: vi.fn().mockResolvedValue({ unread_count: 0, by_conversation: {} }),
|
|
20
|
-
markConversationRead: vi.fn().mockResolvedValue({}),
|
|
21
|
-
markThreadRead: vi.fn().mockResolvedValue({}),
|
|
22
|
-
getReadStatus: vi.fn().mockResolvedValue({ all_read: false }),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function renderBubble(ui) {
|
|
26
|
-
return render(<MessagingProvider api={makeApi()} active={false}>{ui}</MessagingProvider>);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
afterEach(cleanup);
|
|
30
|
-
|
|
31
|
-
describe('messaging threading and quoting', () => {
|
|
32
|
-
it('groups REST-loaded server-shaped reply_to_id messages under their root', async () => {
|
|
33
|
-
const api = makeApi([
|
|
34
|
-
{ id: 10, conversation_id: 1, body: 'Root', sender: { display_name: 'Ava' }, created_at: '2026-07-31T10:00:00Z' },
|
|
35
|
-
{ id: 11, conversation_id: 1, body: 'Server reply', reply_to_id: 10, sender: { display_name: 'Ben' }, created_at: '2026-07-31T10:01:00Z' },
|
|
36
|
-
]);
|
|
37
|
-
render(<MessagingProvider api={api} activeConversationId={1}><Thread conversationId={1} /></MessagingProvider>);
|
|
38
|
-
await screen.findByText('Root');
|
|
39
|
-
expect(screen.queryByText('Server reply')).toBeNull();
|
|
40
|
-
fireEvent.click(screen.getByRole('button', { name: /MessagingThread\.SHOW_REPLIES/ }));
|
|
41
|
-
expect(await screen.findByText('Server reply')).toBeTruthy();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('groups realtime server-shaped reply_to_id messages under their root', () => {
|
|
45
|
-
const state = { conversations: {}, messages: { 10: { id: 10, conversation_id: 1, body: 'Root' } }, threads: {}, polls: {}, reactions: {}, receipts: {}, unread: { unread_count: 0, by_conversation: {} }, cursors: { conversations: null, messages: {}, threads: {} } };
|
|
46
|
-
const next = applyFrame(state, { type: 'message', conversation_id: 1, message: { id: 11, body: 'Realtime reply', reply_to_id: 10 } }, 1);
|
|
47
|
-
expect(next.messages[11].reply_to_id).toBe(10);
|
|
48
|
-
expect(Object.values(next.messages).filter((message) => !((message.reply_to_id ?? message.reply_to))).map((message) => message.id)).toEqual([10]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('renders a quoted sender and snippet, blanking deleted quoted content', () => {
|
|
52
|
-
const { rerender } = renderBubble(<MessageBubble message={{ id: 2, body: 'Reply' }} replyTo={{ id: 1, body: 'Quoted words', sender: { display_name: 'Ava' } }} />);
|
|
53
|
-
expect(screen.getByText('MessagingThread.REPLY_TO:Ava')).toBeTruthy();
|
|
54
|
-
expect(screen.getByText('Quoted words')).toBeTruthy();
|
|
55
|
-
rerender(<MessagingProvider api={makeApi()} active={false}><MessageBubble message={{ id: 2, body: 'Reply' }} replyTo={{ id: 1, body: 'Secret', deleted_at: '2026-07-31T10:00:00Z', sender: { display_name: 'Ava' } }} /></MessagingProvider>);
|
|
56
|
-
expect(screen.getByText('MessagingThread.DELETED')).toBeTruthy();
|
|
57
|
-
expect(screen.queryByText('Secret')).toBeNull();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('labels an attachment-only quoted source distinctly from a deleted one', () => {
|
|
61
|
-
renderBubble(<MessageBubble message={{ id: 2, body: 'Reply' }} replyTo={{ id: 1, attachments: [{ id: 9, filename: 'photo.png' }], sender: { display_name: 'Ava' } }} />);
|
|
62
|
-
expect(screen.getByText('MessagingThread.QUOTE_ATTACHMENT')).toBeTruthy();
|
|
63
|
-
expect(screen.queryByText('MessagingThread.DELETED')).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("clears the Thread's own reply-target state when the message being replied to is deleted", async () => {
|
|
67
|
-
const api = makeApi([{ id: 20, conversation_id: 1, body: 'Reply target', sender: { id: 1, display_name: 'Ava' }, created_at: '2026-07-31T10:00:00Z' }]);
|
|
68
|
-
api.deleteMessage = vi.fn().mockResolvedValue({});
|
|
69
|
-
render(<AuthContext.Provider value={{ user: { id: 1 } }}><MessagingProvider api={api} activeConversationId={1}><Thread conversationId={1} /></MessagingProvider></AuthContext.Provider>);
|
|
70
|
-
await screen.findByText('Reply target');
|
|
71
|
-
fireEvent.click(screen.getByRole('button', { name: /MessagingActions\.MENU/ }));
|
|
72
|
-
fireEvent.click(screen.getByRole('menuitem', { name: /MessagingThread\.REPLY\b/ }));
|
|
73
|
-
expect(screen.getByText(/MessagingThread\.REPLYING_TO/)).toBeTruthy();
|
|
74
|
-
fireEvent.click(screen.getByRole('button', { name: /MessagingActions\.MENU/ }));
|
|
75
|
-
fireEvent.click(screen.getByRole('menuitem', { name: /MessagingActions\.DELETE/ }));
|
|
76
|
-
fireEvent.click(screen.getByRole('button', { name: /MessagingActions\.DELETE/ }));
|
|
77
|
-
await waitFor(() => expect(api.deleteMessage).toHaveBeenCalledWith(20));
|
|
78
|
-
await waitFor(() => expect(screen.queryByText(/MessagingThread\.REPLYING_TO/)).toBeNull());
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('jumps from a quote to the original message', () => {
|
|
82
|
-
const onJumpToMessage = vi.fn();
|
|
83
|
-
renderBubble(<MessageBubble message={{ id: 2, body: 'Reply' }} replyTo={{ id: 1, body: 'Quoted words', sender: { display_name: 'Ava' } }} onJumpToMessage={onJumpToMessage} />);
|
|
84
|
-
fireEvent.click(screen.getByText('Quoted words'));
|
|
85
|
-
expect(onJumpToMessage).toHaveBeenCalledWith(1);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,78 +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) => key }) }));
|
|
7
|
-
vi.mock('../src/notifications/realtime', () => ({ useRealtime: () => ({ subscribe: () => () => {}, onReconnect: () => () => {} }) }));
|
|
8
|
-
|
|
9
|
-
import { ConversationList } from '../src/messaging/ConversationList';
|
|
10
|
-
import { messagingReducer, MessagingProvider, useMessaging } from '../src/messaging/MessagingProvider';
|
|
11
|
-
import { Thread } from '../src/messaging/Thread';
|
|
12
|
-
|
|
13
|
-
function cache() { return { conversations: {}, messages: {}, threads: {}, polls: {}, reactions: {}, receipts: {}, unread: { unread_count: 0, by_conversation: {} }, cursors: { conversations: null, messages: {}, threads: {} } }; }
|
|
14
|
-
function State() { const { cache: current } = useMessaging(); return <output data-testid="cache">{JSON.stringify(current)}</output>; }
|
|
15
|
-
function makeApi(overrides = {}) {
|
|
16
|
-
return {
|
|
17
|
-
listConversations: vi.fn().mockResolvedValue({ results: [] }), listMessages: vi.fn().mockResolvedValue({ results: [] }), listThread: vi.fn().mockResolvedValue({ results: [] }), getUnreadCount: vi.fn().mockResolvedValue({ unread_count: 0, by_conversation: {} }),
|
|
18
|
-
markConversationRead: vi.fn().mockResolvedValue({}), markThreadRead: vi.fn().mockResolvedValue({}),
|
|
19
|
-
...overrides,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
afterEach(cleanup);
|
|
24
|
-
|
|
25
|
-
describe('messaging unread lifecycle', () => {
|
|
26
|
-
it('marks the selected conversation read once its thread mounts', async () => {
|
|
27
|
-
// MSG-6e made `Thread`'s mount effect the sole owner of marking a
|
|
28
|
-
// conversation read (`ConversationList`'s own onClick no longer does it,
|
|
29
|
-
// to stop the double `POST .../read/` this test used to mask) — so the
|
|
30
|
-
// realistic host wiring (onOpen mounts Thread) is what's under test here,
|
|
31
|
-
// not a click on ConversationList in isolation.
|
|
32
|
-
const api = makeApi({ listConversations: vi.fn().mockResolvedValue({ results: [{ id: 12, title: 'Support' }] }) });
|
|
33
|
-
function Surface() {
|
|
34
|
-
const [conversationId, setConversationId] = React.useState(null);
|
|
35
|
-
return <>
|
|
36
|
-
<ConversationList onOpen={(conversation) => setConversationId(conversation.id)} />
|
|
37
|
-
{conversationId != null && <Thread conversationId={conversationId} />}
|
|
38
|
-
</>;
|
|
39
|
-
}
|
|
40
|
-
render(<MessagingProvider api={api}><Surface /></MessagingProvider>);
|
|
41
|
-
fireEvent.click(await screen.findByRole('button', { name: /Support/ }));
|
|
42
|
-
await waitFor(() => expect(api.markConversationRead).toHaveBeenCalledWith(12, undefined));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('marks a conversation read when its thread opens', async () => {
|
|
46
|
-
const api = makeApi();
|
|
47
|
-
render(<MessagingProvider api={api} active={false}><Thread conversationId={12} /></MessagingProvider>);
|
|
48
|
-
await waitFor(() => expect(api.markConversationRead).toHaveBeenCalledWith(12, undefined));
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('decrements the global unread count by the selected conversation prior count', () => {
|
|
52
|
-
const initial = { ...cache(), unread: { unread_count: 5, by_conversation: { 12: 2, 7: 3 } } };
|
|
53
|
-
const next = messagingReducer(initial, { type: 'conversationRead', conversationId: 12 });
|
|
54
|
-
expect(next.unread).toEqual({ unread_count: 3, by_conversation: { 12: 0, 7: 3 } });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('marks a reply thread read when it expands', async () => {
|
|
58
|
-
const api = makeApi({ listMessages: vi.fn().mockResolvedValue({ results: [{ id: 40, conversation_id: 12, body: 'Root', reply_count: 1 }] }) });
|
|
59
|
-
render(<MessagingProvider api={api} activeConversationId={12}><Thread conversationId={12} /></MessagingProvider>);
|
|
60
|
-
// No thread_last_read_at in this fixture — the unread-reply marker
|
|
61
|
-
// (MSG-3d) correctly treats a null receipt with replies as unread, which
|
|
62
|
-
// changes the button's accessible name to include the marker text.
|
|
63
|
-
fireEvent.click(await screen.findByRole('button', { name: /MessagingThread\.SHOW_REPLIES/ }));
|
|
64
|
-
await waitFor(() => expect(api.markThreadRead).toHaveBeenCalledWith(40, undefined));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('increments unread only for a new message in a non-active conversation', () => {
|
|
68
|
-
const initial = { ...cache(), unread: { unread_count: 2, by_conversation: { 7: 2 } } };
|
|
69
|
-
const incoming = { type: 'frame', activeConversationId: 7, frame: { type: 'message', conversation_id: 12, message: { id: 50, body: 'hello' } } };
|
|
70
|
-
const nonActive = messagingReducer(initial, incoming);
|
|
71
|
-
expect(nonActive.unread).toEqual({ unread_count: 3, by_conversation: { 7: 2, 12: 1 } });
|
|
72
|
-
const active = messagingReducer(nonActive, { ...incoming, frame: { type: 'message', conversation_id: 7, message: { id: 51, body: 'active' } } });
|
|
73
|
-
expect(active.unread).toEqual(nonActive.unread);
|
|
74
|
-
const optimistic = messagingReducer(initial, { type: 'messageOptimistic', message: { id: 'local-r1', conversation_id: 12, client_request_id: 'r1', status: 'pending' } });
|
|
75
|
-
const reconciled = messagingReducer(optimistic, { ...incoming, frame: { type: 'message', conversation_id: 12, message: { id: 52, client_request_id: 'r1', body: 'mine' } } });
|
|
76
|
-
expect(reconciled.unread).toEqual(initial.unread);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
const client = vi.hoisted(() => ({
|
|
4
|
-
delete: vi.fn(),
|
|
5
|
-
get: vi.fn(),
|
|
6
|
-
patch: vi.fn(),
|
|
7
|
-
post: vi.fn(),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
vi.mock('../src/auth/apiClient', () => ({ default: client }));
|
|
11
|
-
|
|
12
|
-
import { removePushSubscription, savePushSubscription } from '../src/notifications/api';
|
|
13
|
-
|
|
14
|
-
describe('notifications API', () => {
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
vi.clearAllMocks();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('saves a push subscription with its user agent', async () => {
|
|
20
|
-
client.post.mockResolvedValue({ data: { id: 1 } });
|
|
21
|
-
const subscription = { endpoint: 'https://fcm.googleapis.com/fcm/send/example' };
|
|
22
|
-
|
|
23
|
-
await savePushSubscription(subscription, 'Example Browser');
|
|
24
|
-
|
|
25
|
-
expect(client.post).toHaveBeenCalledWith(
|
|
26
|
-
'/api/notifications/preferences/push-subscription/',
|
|
27
|
-
{ subscription, ua: 'Example Browser' },
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('removes a push subscription by endpoint using an axios delete body', async () => {
|
|
32
|
-
client.delete.mockResolvedValue({ data: null });
|
|
33
|
-
|
|
34
|
-
await removePushSubscription({ endpoint: 'https://updates.push.services.mozilla.com/example' });
|
|
35
|
-
|
|
36
|
-
expect(client.delete).toHaveBeenCalledWith(
|
|
37
|
-
'/api/notifications/preferences/push-subscription/',
|
|
38
|
-
{ data: { endpoint: 'https://updates.push.services.mozilla.com/example' } },
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
NotificationSettings,
|
|
5
|
-
PopupSurface,
|
|
6
|
-
getNotificationPreferences,
|
|
7
|
-
getVapidPublicKey,
|
|
8
|
-
listPushSubscriptions,
|
|
9
|
-
notificationsTranslations,
|
|
10
|
-
patchNotificationPreferences,
|
|
11
|
-
removePushSubscription,
|
|
12
|
-
savePushSubscription,
|
|
13
|
-
urlBase64ToUint8Array,
|
|
14
|
-
} from '../src/index';
|
|
15
|
-
|
|
16
|
-
describe('notification barrel exports', () => {
|
|
17
|
-
it('preserves legacy notification exports and translations', () => {
|
|
18
|
-
[
|
|
19
|
-
NotificationSettings,
|
|
20
|
-
getNotificationPreferences,
|
|
21
|
-
patchNotificationPreferences,
|
|
22
|
-
getVapidPublicKey,
|
|
23
|
-
listPushSubscriptions,
|
|
24
|
-
savePushSubscription,
|
|
25
|
-
removePushSubscription,
|
|
26
|
-
urlBase64ToUint8Array,
|
|
27
|
-
notificationsTranslations,
|
|
28
|
-
].forEach((value) => expect(value).toBeDefined());
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('additively exports the NOTIF-12 popup surface', () => {
|
|
32
|
-
expect(PopupSurface).toBeDefined();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { UNIVERSAL_STEP_DESCRIPTORS } from '../src/onboarding/OnboardingProvider';
|
|
3
|
-
import { selectActiveSteps } from '../src/onboarding/stepSelection';
|
|
4
|
-
|
|
5
|
-
const cookieConsentDescriptor = UNIVERSAL_STEP_DESCRIPTORS.find((step) => step.id === 'cookie_consent');
|
|
6
|
-
const browserPushDescriptor = UNIVERSAL_STEP_DESCRIPTORS.find((step) => step.id === 'browser_push');
|
|
7
|
-
const pwaInstallDescriptor = UNIVERSAL_STEP_DESCRIPTORS.find((step) => step.id === 'pwa_install');
|
|
8
|
-
|
|
9
|
-
describe('cookie_consent descriptor condition', () => {
|
|
10
|
-
it('is active when the user has not accepted the privacy statement, regardless of cookies', () => {
|
|
11
|
-
expect(cookieConsentDescriptor.condition({
|
|
12
|
-
user: { accepted_privacy_statement: false, accepted_convenience_cookies: false },
|
|
13
|
-
})).toBe(true);
|
|
14
|
-
expect(cookieConsentDescriptor.condition({
|
|
15
|
-
user: { accepted_privacy_statement: false, accepted_convenience_cookies: true },
|
|
16
|
-
})).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('is inactive once the privacy statement is accepted, even if cookies were declined', () => {
|
|
20
|
-
expect(cookieConsentDescriptor.condition({
|
|
21
|
-
user: { accepted_privacy_statement: true, accepted_convenience_cookies: false },
|
|
22
|
-
})).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('is inactive with no user', () => {
|
|
26
|
-
expect(cookieConsentDescriptor.condition({ user: null })).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('browser_push descriptor condition', () => {
|
|
31
|
-
it('is active by default only when neither supported channel is configured', () => {
|
|
32
|
-
expect(browserPushDescriptor.condition({
|
|
33
|
-
pushState: { supported: true, subscribed: false },
|
|
34
|
-
emailOptedIn: false,
|
|
35
|
-
})).toBe(true);
|
|
36
|
-
expect(browserPushDescriptor.condition({
|
|
37
|
-
pushState: { supported: true, subscribed: false },
|
|
38
|
-
emailOptedIn: true,
|
|
39
|
-
})).toBe(false);
|
|
40
|
-
expect(browserPushDescriptor.condition({
|
|
41
|
-
pushState: { supported: true, subscribed: true },
|
|
42
|
-
emailOptedIn: false,
|
|
43
|
-
})).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('keeps the legacy condition when configured for all-channels', () => {
|
|
47
|
-
expect(browserPushDescriptor.condition({
|
|
48
|
-
browserPush: { nagUntil: 'all-channels' },
|
|
49
|
-
pushState: { supported: true, subscribed: false },
|
|
50
|
-
emailOptedIn: true,
|
|
51
|
-
})).toBe(true);
|
|
52
|
-
expect(browserPushDescriptor.condition({
|
|
53
|
-
browserPush: { nagUntil: 'all-channels' },
|
|
54
|
-
pushState: { supported: true, subscribed: true },
|
|
55
|
-
emailOptedIn: false,
|
|
56
|
-
})).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('is active when push is unsupported and email notifications are not enabled', () => {
|
|
60
|
-
expect(browserPushDescriptor.condition({
|
|
61
|
-
pushState: { supported: false, subscribed: false },
|
|
62
|
-
emailOptedIn: false,
|
|
63
|
-
})).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('is inactive when push is unsupported with email notifications enabled or both channels are enabled', () => {
|
|
67
|
-
expect(browserPushDescriptor.condition({
|
|
68
|
-
pushState: { supported: false, subscribed: false },
|
|
69
|
-
emailOptedIn: true,
|
|
70
|
-
})).toBe(false);
|
|
71
|
-
expect(browserPushDescriptor.condition({
|
|
72
|
-
pushState: { supported: true, subscribed: true },
|
|
73
|
-
emailOptedIn: true,
|
|
74
|
-
})).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('is excluded after persistent dismissal', () => {
|
|
78
|
-
const activeSteps = selectActiveSteps(
|
|
79
|
-
[browserPushDescriptor],
|
|
80
|
-
{ browser_push: true },
|
|
81
|
-
{ pushState: { supported: true, subscribed: false }, emailOptedIn: false },
|
|
82
|
-
new Set(['browser_push']),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
expect(activeSteps).toEqual([]);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('pwa_install descriptor condition', () => {
|
|
90
|
-
it('is inactive when the app has not opted in, even if the device could install', () => {
|
|
91
|
-
expect(pwaInstallDescriptor.condition({
|
|
92
|
-
pwaInstallEnabled: false,
|
|
93
|
-
pwaInstall: { deferredPrompt: {}, isStandalone: false, isIos: false },
|
|
94
|
-
})).toBe(false);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('is active when opted in and Android/Chrome captured a deferred install prompt', () => {
|
|
98
|
-
expect(pwaInstallDescriptor.condition({
|
|
99
|
-
pwaInstallEnabled: true,
|
|
100
|
-
pwaInstall: { deferredPrompt: {}, isStandalone: false, isIos: false },
|
|
101
|
-
})).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('is active when opted in on iOS (no deferred prompt exists there, only the hint)', () => {
|
|
105
|
-
expect(pwaInstallDescriptor.condition({
|
|
106
|
-
pwaInstallEnabled: true,
|
|
107
|
-
pwaInstall: { deferredPrompt: null, isStandalone: false, isIos: true },
|
|
108
|
-
})).toBe(true);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('is inactive when opted in but neither a deferred prompt nor iOS applies', () => {
|
|
112
|
-
expect(pwaInstallDescriptor.condition({
|
|
113
|
-
pwaInstallEnabled: true,
|
|
114
|
-
pwaInstall: { deferredPrompt: null, isStandalone: false, isIos: false },
|
|
115
|
-
})).toBe(false);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('is inactive once already running standalone, regardless of opt-in or device capability', () => {
|
|
119
|
-
expect(pwaInstallDescriptor.condition({
|
|
120
|
-
pwaInstallEnabled: true,
|
|
121
|
-
pwaInstall: { deferredPrompt: {}, isStandalone: true, isIos: false },
|
|
122
|
-
})).toBe(false);
|
|
123
|
-
expect(pwaInstallDescriptor.condition({
|
|
124
|
-
pwaInstallEnabled: true,
|
|
125
|
-
pwaInstall: { deferredPrompt: null, isStandalone: true, isIos: true },
|
|
126
|
-
})).toBe(false);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('is inactive with no pwaInstall context at all', () => {
|
|
130
|
-
expect(pwaInstallDescriptor.condition({ pwaInstallEnabled: true })).toBe(false);
|
|
131
|
-
});
|
|
132
|
-
});
|