@semiont/react-ui 0.2.35-build.98 → 0.2.35
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/README.md +1 -0
- package/dist/{EventBusContext-DMI4uwYk.d.mts → EventBusContext-CLnb2LmB.d.mts} +5 -5
- package/dist/{PdfAnnotationCanvas.client-HNYRKFDS.mjs → PdfAnnotationCanvas.client-COQREPXU.mjs} +7 -7
- package/dist/PdfAnnotationCanvas.client-COQREPXU.mjs.map +1 -0
- package/dist/ar-7SUXNE34.mjs +376 -0
- package/dist/ar-7SUXNE34.mjs.map +1 -0
- package/dist/bn-XOET3DOI.mjs +376 -0
- package/dist/bn-XOET3DOI.mjs.map +1 -0
- package/dist/{chunk-YI5IX5ZA.mjs → chunk-2HGWOLVN.mjs} +1 -1
- package/dist/{chunk-YI5IX5ZA.mjs.map → chunk-2HGWOLVN.mjs.map} +1 -1
- package/dist/{chunk-3FIQXKQF.mjs → chunk-Q2KV6Y2J.mjs} +28 -28
- package/dist/{chunk-MWQ5CNKW.mjs → chunk-ZPV43WN2.mjs} +11 -11
- package/dist/chunk-ZPV43WN2.mjs.map +1 -0
- package/dist/cs-X63DXX7L.mjs +376 -0
- package/dist/cs-X63DXX7L.mjs.map +1 -0
- package/dist/da-OWTCV57A.mjs +376 -0
- package/dist/da-OWTCV57A.mjs.map +1 -0
- package/dist/de-77BMFDVF.mjs +376 -0
- package/dist/de-77BMFDVF.mjs.map +1 -0
- package/dist/el-FIBNLH2V.mjs +376 -0
- package/dist/el-FIBNLH2V.mjs.map +1 -0
- package/dist/fa-3N4CIWE6.mjs +376 -0
- package/dist/fa-3N4CIWE6.mjs.map +1 -0
- package/dist/fi-JOM3M7Z4.mjs +376 -0
- package/dist/fi-JOM3M7Z4.mjs.map +1 -0
- package/dist/fr-56QSXS7E.mjs +376 -0
- package/dist/fr-56QSXS7E.mjs.map +1 -0
- package/dist/he-SNAXPJEK.mjs +376 -0
- package/dist/he-SNAXPJEK.mjs.map +1 -0
- package/dist/hi-CRBRD5TB.mjs +376 -0
- package/dist/hi-CRBRD5TB.mjs.map +1 -0
- package/dist/id-BRCVLICF.mjs +376 -0
- package/dist/id-BRCVLICF.mjs.map +1 -0
- package/dist/index.d.mts +169 -165
- package/dist/index.mjs +317 -313
- package/dist/index.mjs.map +1 -1
- package/dist/it-M2Z27BNB.mjs +376 -0
- package/dist/it-M2Z27BNB.mjs.map +1 -0
- package/dist/ja-TZUKW7HD.mjs +376 -0
- package/dist/ja-TZUKW7HD.mjs.map +1 -0
- package/dist/ko-NKBGGOL6.mjs +376 -0
- package/dist/ko-NKBGGOL6.mjs.map +1 -0
- package/dist/ms-XFXPN6RX.mjs +376 -0
- package/dist/ms-XFXPN6RX.mjs.map +1 -0
- package/dist/nl-MVYXAS5C.mjs +379 -0
- package/dist/nl-MVYXAS5C.mjs.map +1 -0
- package/dist/no-XOLO4JPV.mjs +376 -0
- package/dist/no-XOLO4JPV.mjs.map +1 -0
- package/dist/pl-TRWLMMC4.mjs +376 -0
- package/dist/pl-TRWLMMC4.mjs.map +1 -0
- package/dist/pt-M3TE24UI.mjs +376 -0
- package/dist/pt-M3TE24UI.mjs.map +1 -0
- package/dist/ro-QBFG2T64.mjs +376 -0
- package/dist/ro-QBFG2T64.mjs.map +1 -0
- package/dist/sv-IUECBXWX.mjs +376 -0
- package/dist/sv-IUECBXWX.mjs.map +1 -0
- package/dist/test-utils.d.mts +2 -2
- package/dist/test-utils.mjs +2 -2
- package/dist/th-US7KIN5Q.mjs +376 -0
- package/dist/th-US7KIN5Q.mjs.map +1 -0
- package/dist/tr-DWJ2FFUK.mjs +376 -0
- package/dist/tr-DWJ2FFUK.mjs.map +1 -0
- package/dist/uk-M4ZE4DPZ.mjs +376 -0
- package/dist/uk-M4ZE4DPZ.mjs.map +1 -0
- package/dist/vi-FERZNPSH.mjs +376 -0
- package/dist/vi-FERZNPSH.mjs.map +1 -0
- package/dist/zh-3J2I3WYK.mjs +376 -0
- package/dist/zh-3J2I3WYK.mjs.map +1 -0
- package/package.json +1 -1
- package/src/components/AnnotateReferencesProgressWidget.tsx +5 -5
- package/src/components/CodeMirrorRenderer.tsx +5 -5
- package/src/components/Toolbar.tsx +2 -2
- package/src/components/annotation/AnnotateToolbar.tsx +9 -9
- package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +17 -17
- package/src/components/image-annotation/AnnotationOverlay.tsx +10 -10
- package/src/components/image-annotation/SvgDrawingCanvas.tsx +4 -4
- package/src/components/navigation/CollapsibleResourceNavigation.tsx +7 -7
- package/src/components/navigation/ObservableLink.tsx +3 -3
- package/src/components/navigation/SimpleNavigation.tsx +2 -2
- package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +8 -8
- package/src/components/resource/AnnotateView.tsx +12 -12
- package/src/components/resource/BrowseView.tsx +9 -9
- package/src/components/resource/ResourceViewer.tsx +23 -23
- package/src/components/resource/__tests__/BrowseView.test.tsx +27 -27
- package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +1 -1
- package/src/components/resource/panels/AssessmentEntry.tsx +2 -2
- package/src/components/resource/panels/AssessmentPanel.tsx +7 -7
- package/src/components/resource/panels/AssistSection.tsx +5 -5
- package/src/components/resource/panels/CommentEntry.tsx +2 -2
- package/src/components/resource/panels/CommentsPanel.tsx +7 -7
- package/src/components/resource/panels/HighlightEntry.tsx +2 -2
- package/src/components/resource/panels/HighlightPanel.tsx +5 -5
- package/src/components/resource/panels/ReferenceEntry.tsx +8 -8
- package/src/components/resource/panels/ReferencesPanel.tsx +10 -10
- package/src/components/resource/panels/ResourceInfoPanel.tsx +6 -6
- package/src/components/resource/panels/TagEntry.tsx +2 -2
- package/src/components/resource/panels/TaggingPanel.tsx +8 -8
- package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +2 -2
- package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +4 -4
- package/src/components/resource/panels/__tests__/AssistSection.test.tsx +4 -4
- package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +8 -8
- package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +3 -3
- package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +1 -1
- package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +3 -3
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +9 -9
- package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +5 -5
- package/src/features/admin-devops/components/AdminDevOpsPage.tsx +2 -1
- package/src/features/admin-security/components/AdminSecurityPage.tsx +2 -1
- package/src/features/admin-users/components/AdminUsersPage.tsx +2 -1
- package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +2 -1
- package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +2 -1
- package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +2 -1
- package/src/features/resource-compose/components/ResourceComposePage.tsx +2 -1
- package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +2 -1
- package/src/features/resource-viewer/__tests__/AnnotationCreationPending.test.tsx +26 -26
- package/src/features/resource-viewer/__tests__/AnnotationDeletionIntegration.test.tsx +21 -21
- package/src/features/resource-viewer/__tests__/AnnotationProgressDismissal.test.tsx +23 -23
- package/src/features/resource-viewer/__tests__/{ResolutionFlowIntegration.test.tsx → BindFlowIntegration.test.tsx} +49 -49
- package/src/features/resource-viewer/__tests__/DetectionFlowBug.test.tsx +18 -18
- package/src/features/resource-viewer/__tests__/DetectionFlowIntegration.test.tsx +19 -19
- package/src/features/resource-viewer/__tests__/ResourceMutations.test.tsx +19 -19
- package/src/features/resource-viewer/__tests__/ToastNotifications.test.tsx +13 -13
- package/src/features/resource-viewer/__tests__/{GenerationFlowIntegration.test.tsx → YieldFlowIntegration.test.tsx} +34 -34
- package/src/features/resource-viewer/__tests__/annotation-progress-flow.test.tsx +11 -11
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +55 -55
- package/translations/ar.json +298 -298
- package/translations/bn.json +298 -298
- package/translations/cs.json +295 -295
- package/translations/da.json +282 -282
- package/translations/de.json +281 -281
- package/translations/el.json +298 -298
- package/translations/fa.json +298 -298
- package/translations/fi.json +298 -298
- package/translations/fr.json +279 -279
- package/translations/he.json +298 -298
- package/translations/hi.json +298 -298
- package/translations/id.json +295 -295
- package/translations/it.json +299 -299
- package/translations/ja.json +298 -298
- package/translations/ko.json +298 -298
- package/translations/ms.json +296 -296
- package/translations/nl.json +299 -296
- package/translations/no.json +292 -292
- package/translations/pl.json +297 -297
- package/translations/pt.json +294 -294
- package/translations/ro.json +298 -298
- package/translations/sv.json +293 -293
- package/translations/th.json +298 -298
- package/translations/tr.json +298 -298
- package/translations/uk.json +298 -298
- package/translations/vi.json +298 -298
- package/translations/zh.json +298 -298
- package/dist/PdfAnnotationCanvas.client-HNYRKFDS.mjs.map +0 -1
- package/dist/ar-MDB7HC5S.mjs +0 -376
- package/dist/ar-MDB7HC5S.mjs.map +0 -1
- package/dist/bn-3SAV2ZEM.mjs +0 -376
- package/dist/bn-3SAV2ZEM.mjs.map +0 -1
- package/dist/chunk-MWQ5CNKW.mjs.map +0 -1
- package/dist/cs-AWCETEUV.mjs +0 -376
- package/dist/cs-AWCETEUV.mjs.map +0 -1
- package/dist/da-UZZHXYLC.mjs +0 -376
- package/dist/da-UZZHXYLC.mjs.map +0 -1
- package/dist/de-LQFWN6S5.mjs +0 -376
- package/dist/de-LQFWN6S5.mjs.map +0 -1
- package/dist/el-IWOETBJ7.mjs +0 -376
- package/dist/el-IWOETBJ7.mjs.map +0 -1
- package/dist/fa-BVEJZT5S.mjs +0 -376
- package/dist/fa-BVEJZT5S.mjs.map +0 -1
- package/dist/fi-JBNCGGA6.mjs +0 -376
- package/dist/fi-JBNCGGA6.mjs.map +0 -1
- package/dist/fr-OLH7PNGI.mjs +0 -376
- package/dist/fr-OLH7PNGI.mjs.map +0 -1
- package/dist/he-KOJQ4HMA.mjs +0 -376
- package/dist/he-KOJQ4HMA.mjs.map +0 -1
- package/dist/hi-BKJFZXAY.mjs +0 -376
- package/dist/hi-BKJFZXAY.mjs.map +0 -1
- package/dist/id-DPLHJVNP.mjs +0 -376
- package/dist/id-DPLHJVNP.mjs.map +0 -1
- package/dist/it-JXHAM7NL.mjs +0 -376
- package/dist/it-JXHAM7NL.mjs.map +0 -1
- package/dist/ja-DQRAO3PU.mjs +0 -376
- package/dist/ja-DQRAO3PU.mjs.map +0 -1
- package/dist/ko-6IFCOP6F.mjs +0 -376
- package/dist/ko-6IFCOP6F.mjs.map +0 -1
- package/dist/ms-KF5S2TLL.mjs +0 -376
- package/dist/ms-KF5S2TLL.mjs.map +0 -1
- package/dist/nl-2GUUZLQM.mjs +0 -376
- package/dist/nl-2GUUZLQM.mjs.map +0 -1
- package/dist/no-2IBCZGEF.mjs +0 -376
- package/dist/no-2IBCZGEF.mjs.map +0 -1
- package/dist/pl-ZEUBJ7YU.mjs +0 -376
- package/dist/pl-ZEUBJ7YU.mjs.map +0 -1
- package/dist/pt-WLAFIZWQ.mjs +0 -376
- package/dist/pt-WLAFIZWQ.mjs.map +0 -1
- package/dist/ro-K56IXFGU.mjs +0 -376
- package/dist/ro-K56IXFGU.mjs.map +0 -1
- package/dist/sv-VFJLMJRY.mjs +0 -376
- package/dist/sv-VFJLMJRY.mjs.map +0 -1
- package/dist/th-RICLQ2GW.mjs +0 -376
- package/dist/th-RICLQ2GW.mjs.map +0 -1
- package/dist/tr-SALXWE2M.mjs +0 -376
- package/dist/tr-SALXWE2M.mjs.map +0 -1
- package/dist/uk-3U3T3O2E.mjs +0 -376
- package/dist/uk-3U3T3O2E.mjs.map +0 -1
- package/dist/vi-LIVNZXOB.mjs +0 -376
- package/dist/vi-LIVNZXOB.mjs.map +0 -1
- package/dist/zh-KDUAZPX3.mjs +0 -376
- package/dist/zh-KDUAZPX3.mjs.map +0 -1
- /package/dist/{chunk-3FIQXKQF.mjs.map → chunk-Q2KV6Y2J.mjs.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Regression test: pendingAnnotation cleared after
|
|
2
|
+
* Regression test: pendingAnnotation cleared after mark:createsucceeds
|
|
3
3
|
*
|
|
4
|
-
* Bug: handleAnnotationCreate in
|
|
5
|
-
*
|
|
4
|
+
* Bug: handleAnnotationCreate in useMarkFlow called the API and emitted
|
|
5
|
+
* mark:created, but never called setPendingAnnotation(null). The pending
|
|
6
6
|
* creation form (e.g. "Create Reference", "Save" assessment) remained visible
|
|
7
7
|
* after the user clicked the confirm button.
|
|
8
8
|
*
|
|
9
9
|
* Fix: setPendingAnnotation(null) added in handleAnnotationCreate on success,
|
|
10
|
-
* before emitting
|
|
10
|
+
* before emitting mark:created.
|
|
11
11
|
*
|
|
12
12
|
* This test covers all four motivations that have a pending form:
|
|
13
13
|
* - linking (ReferencesPanel: "Create Reference" button)
|
|
@@ -20,7 +20,7 @@ import React from 'react';
|
|
|
20
20
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
21
21
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
22
22
|
import { act } from 'react';
|
|
23
|
-
import {
|
|
23
|
+
import { useMarkFlow } from '../../../hooks/useMarkFlow';
|
|
24
24
|
import { EventBusProvider, useEventBus, resetEventBusForTesting } from '../../../contexts/EventBusContext';
|
|
25
25
|
import { ApiClientProvider } from '../../../contexts/ApiClientContext';
|
|
26
26
|
import { AuthTokenProvider } from '../../../contexts/AuthTokenContext';
|
|
@@ -71,7 +71,7 @@ function renderDetectionFlow(testUri: string) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
function DetectionFlowHarness() {
|
|
74
|
-
const { pendingAnnotation } =
|
|
74
|
+
const { pendingAnnotation } = useMarkFlow(testUri as any);
|
|
75
75
|
return (
|
|
76
76
|
<div>
|
|
77
77
|
<div data-testid="pending-motivation">
|
|
@@ -122,16 +122,16 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
122
122
|
|
|
123
123
|
// Set a pending annotation
|
|
124
124
|
act(() => {
|
|
125
|
-
emit('
|
|
125
|
+
emit('mark:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
await waitFor(() => {
|
|
129
129
|
expect(screen.getByTestId('pending-motivation')).toHaveTextContent('linking');
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
// Emit
|
|
132
|
+
// Emit mark:create(what ReferencesPanel does when user clicks "Create Reference")
|
|
133
133
|
await act(async () => {
|
|
134
|
-
emit('
|
|
134
|
+
emit('mark:create', {
|
|
135
135
|
motivation: 'linking',
|
|
136
136
|
selector: TEXT_SELECTOR,
|
|
137
137
|
body: [{ type: 'TextualBody', value: 'Person', purpose: 'tagging' }],
|
|
@@ -150,7 +150,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
150
150
|
const { emit } = renderDetectionFlow(TEST_URI);
|
|
151
151
|
|
|
152
152
|
act(() => {
|
|
153
|
-
emit('
|
|
153
|
+
emit('mark:requested', { selector: SVG_SELECTOR, motivation: 'assessing' });
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
await waitFor(() => {
|
|
@@ -158,7 +158,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
await act(async () => {
|
|
161
|
-
emit('
|
|
161
|
+
emit('mark:create', {
|
|
162
162
|
motivation: 'assessing',
|
|
163
163
|
selector: SVG_SELECTOR,
|
|
164
164
|
body: [{ type: 'TextualBody', value: 'Looks good', purpose: 'assessing' }],
|
|
@@ -174,7 +174,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
174
174
|
const { emit } = renderDetectionFlow(TEST_URI);
|
|
175
175
|
|
|
176
176
|
act(() => {
|
|
177
|
-
emit('
|
|
177
|
+
emit('mark:requested', { selector: SVG_SELECTOR, motivation: 'assessing' });
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
await waitFor(() => {
|
|
@@ -183,7 +183,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
183
183
|
|
|
184
184
|
// Empty body is valid for assessments
|
|
185
185
|
await act(async () => {
|
|
186
|
-
emit('
|
|
186
|
+
emit('mark:create', {
|
|
187
187
|
motivation: 'assessing',
|
|
188
188
|
selector: SVG_SELECTOR,
|
|
189
189
|
body: [],
|
|
@@ -199,7 +199,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
199
199
|
const { emit } = renderDetectionFlow(TEST_URI);
|
|
200
200
|
|
|
201
201
|
act(() => {
|
|
202
|
-
emit('
|
|
202
|
+
emit('mark:requested', { selector: TEXT_SELECTOR, motivation: 'commenting' });
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
await waitFor(() => {
|
|
@@ -207,7 +207,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
207
207
|
});
|
|
208
208
|
|
|
209
209
|
await act(async () => {
|
|
210
|
-
emit('
|
|
210
|
+
emit('mark:create', {
|
|
211
211
|
motivation: 'commenting',
|
|
212
212
|
selector: TEXT_SELECTOR,
|
|
213
213
|
body: [{ type: 'TextualBody', value: 'Great point', purpose: 'commenting' }],
|
|
@@ -223,7 +223,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
223
223
|
const { emit } = renderDetectionFlow(TEST_URI);
|
|
224
224
|
|
|
225
225
|
act(() => {
|
|
226
|
-
emit('
|
|
226
|
+
emit('mark:requested', { selector: SVG_SELECTOR, motivation: 'tagging' });
|
|
227
227
|
});
|
|
228
228
|
|
|
229
229
|
await waitFor(() => {
|
|
@@ -231,7 +231,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
231
231
|
});
|
|
232
232
|
|
|
233
233
|
await act(async () => {
|
|
234
|
-
emit('
|
|
234
|
+
emit('mark:create', {
|
|
235
235
|
motivation: 'tagging',
|
|
236
236
|
selector: SVG_SELECTOR,
|
|
237
237
|
body: [{ type: 'TextualBody', value: 'concept:trust', purpose: 'tagging' }],
|
|
@@ -243,20 +243,20 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
-
it('emits
|
|
246
|
+
it('emits mark:created after successful creation', async () => {
|
|
247
247
|
const { emit, getEventBus } = renderDetectionFlow(TEST_URI);
|
|
248
248
|
|
|
249
249
|
const createdListener = vi.fn();
|
|
250
250
|
// Set listener after first render so eventBus is captured
|
|
251
251
|
await waitFor(() => expect(getEventBus()).toBeDefined());
|
|
252
|
-
const subscription = getEventBus().get('
|
|
252
|
+
const subscription = getEventBus().get('mark:created').subscribe(createdListener);
|
|
253
253
|
|
|
254
254
|
act(() => {
|
|
255
|
-
emit('
|
|
255
|
+
emit('mark:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
|
|
256
256
|
});
|
|
257
257
|
|
|
258
258
|
await act(async () => {
|
|
259
|
-
emit('
|
|
259
|
+
emit('mark:create', {
|
|
260
260
|
motivation: 'linking',
|
|
261
261
|
selector: TEXT_SELECTOR,
|
|
262
262
|
body: [],
|
|
@@ -277,7 +277,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
277
277
|
const { emit } = renderDetectionFlow(TEST_URI);
|
|
278
278
|
|
|
279
279
|
act(() => {
|
|
280
|
-
emit('
|
|
280
|
+
emit('mark:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
|
|
281
281
|
});
|
|
282
282
|
|
|
283
283
|
await waitFor(() => {
|
|
@@ -285,7 +285,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
285
285
|
});
|
|
286
286
|
|
|
287
287
|
await act(async () => {
|
|
288
|
-
emit('
|
|
288
|
+
emit('mark:create', {
|
|
289
289
|
motivation: 'linking',
|
|
290
290
|
selector: TEXT_SELECTOR,
|
|
291
291
|
body: [],
|
|
@@ -299,11 +299,11 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
299
299
|
});
|
|
300
300
|
});
|
|
301
301
|
|
|
302
|
-
it('clears pendingAnnotation on cancel (
|
|
302
|
+
it('clears pendingAnnotation on cancel (mark:cancel-pending)', async () => {
|
|
303
303
|
const { emit } = renderDetectionFlow(TEST_URI);
|
|
304
304
|
|
|
305
305
|
act(() => {
|
|
306
|
-
emit('
|
|
306
|
+
emit('mark:requested', { selector: TEXT_SELECTOR, motivation: 'assessing' });
|
|
307
307
|
});
|
|
308
308
|
|
|
309
309
|
await waitFor(() => {
|
|
@@ -311,7 +311,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
|
|
|
311
311
|
});
|
|
312
312
|
|
|
313
313
|
act(() => {
|
|
314
|
-
emit('
|
|
314
|
+
emit('mark:cancel-pending', undefined);
|
|
315
315
|
});
|
|
316
316
|
|
|
317
317
|
await waitFor(() => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Tests the COMPLETE annotation deletion flow with real component composition:
|
|
5
5
|
* - EventBusProvider (REAL)
|
|
6
6
|
* - ApiClientProvider (REAL, with MOCKED client)
|
|
7
|
-
* -
|
|
7
|
+
* - useMarkFlow (REAL) — single registration point for useBindFlow
|
|
8
8
|
* - useEventSubscriptions (REAL)
|
|
9
9
|
*
|
|
10
10
|
* This test focuses on ARCHITECTURE and EVENT WIRING:
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
*
|
|
16
16
|
* CRITICAL: This test prevents regressions where:
|
|
17
17
|
* - Multiple deletion paths exist (event-driven vs direct)
|
|
18
|
-
* -
|
|
18
|
+
* - useBindFlow called in more than one hook (causes duplicate subscriptions)
|
|
19
19
|
* - Auth token missing from API calls (401 errors)
|
|
20
20
|
*
|
|
21
|
-
* ARCHITECTURE:
|
|
22
|
-
*
|
|
23
|
-
* and AI-driven SSE detection) plus all API operations via
|
|
21
|
+
* ARCHITECTURE: useBindFlow is called ONLY in useMarkFlow.
|
|
22
|
+
* useMarkFlow handles all detection state (manual annotation selection
|
|
23
|
+
* and AI-driven SSE detection) plus all API operations via useBindFlow.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
27
27
|
import { render, waitFor } from '@testing-library/react';
|
|
28
28
|
import { act } from 'react';
|
|
29
|
-
import {
|
|
29
|
+
import { useMarkFlow } from '../../../hooks/useMarkFlow';
|
|
30
30
|
import { EventBusProvider, useEventBus, resetEventBusForTesting } from '../../../contexts/EventBusContext';
|
|
31
31
|
|
|
32
32
|
// Mock Toast module to prevent "useToast must be used within a ToastProvider" errors
|
|
@@ -70,9 +70,9 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
70
70
|
|
|
71
71
|
function TestComponent() {
|
|
72
72
|
eventBusInstance = useEventBus();
|
|
73
|
-
//
|
|
74
|
-
// (handles
|
|
75
|
-
|
|
73
|
+
// useMarkFlow is the single registration point for useBindFlow
|
|
74
|
+
// (handles mark:delete mark:create annotate:detect-request, etc.)
|
|
75
|
+
useMarkFlow(testUri);
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -89,14 +89,14 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
89
89
|
return {
|
|
90
90
|
emitDelete: (annotationId: string) => {
|
|
91
91
|
act(() => {
|
|
92
|
-
eventBusInstance!.get('
|
|
92
|
+
eventBusInstance!.get('mark:delete').next({ annotationId });
|
|
93
93
|
});
|
|
94
94
|
},
|
|
95
95
|
eventBus: eventBusInstance!,
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
it('should call deleteAnnotation API exactly ONCE when
|
|
99
|
+
it('should call deleteAnnotation API exactly ONCE when mark:deleteevent is emitted', async () => {
|
|
100
100
|
const { emitDelete } = renderAnnotationFlow();
|
|
101
101
|
const annotationId = 'annotation-123';
|
|
102
102
|
|
|
@@ -133,12 +133,12 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
133
133
|
expect(callArgs[1].auth).toBe(accessToken(testToken));
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
it('should emit
|
|
136
|
+
it('should emit mark:deleted event on successful deletion', async () => {
|
|
137
137
|
const { emitDelete, eventBus } = renderAnnotationFlow();
|
|
138
138
|
const deletedListener = vi.fn();
|
|
139
139
|
|
|
140
140
|
// Subscribe to success event
|
|
141
|
-
eventBus.get('
|
|
141
|
+
eventBus.get('mark:deleted').subscribe(deletedListener);
|
|
142
142
|
|
|
143
143
|
emitDelete('annotation-789');
|
|
144
144
|
|
|
@@ -155,7 +155,7 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
it('should emit
|
|
158
|
+
it('should emit mark:delete-failed event on API error', async () => {
|
|
159
159
|
// Make API call fail
|
|
160
160
|
deleteAnnotationSpy.mockRejectedValue(new Error('Network error'));
|
|
161
161
|
|
|
@@ -163,7 +163,7 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
163
163
|
const failedListener = vi.fn();
|
|
164
164
|
|
|
165
165
|
// Subscribe to failure event
|
|
166
|
-
eventBus.get('
|
|
166
|
+
eventBus.get('mark:delete-failed').subscribe(failedListener);
|
|
167
167
|
|
|
168
168
|
emitDelete('annotation-error');
|
|
169
169
|
|
|
@@ -202,13 +202,13 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
202
202
|
expect(deleteAnnotationSpy.mock.calls[1][0]).toContain('annotation-2');
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
-
it('ARCHITECTURE:
|
|
205
|
+
it('ARCHITECTURE: useBindFlow is called in useMarkFlow (single registration point)', async () => {
|
|
206
206
|
/**
|
|
207
207
|
* This test validates that there's only ONE event-driven deletion path:
|
|
208
|
-
* -
|
|
209
|
-
* -
|
|
208
|
+
* - useMarkFlow calls useBindFlow (the single registration point)
|
|
209
|
+
* - useBindFlow subscribes to annotation:delete
|
|
210
210
|
*
|
|
211
|
-
* If this test fails with 2 API calls, it means
|
|
211
|
+
* If this test fails with 2 API calls, it means useBindFlow was added
|
|
212
212
|
* to a second hook, causing duplicate subscriptions (ARCHITECTURE VIOLATION).
|
|
213
213
|
*/
|
|
214
214
|
|
|
@@ -229,8 +229,8 @@ describe('Annotation Deletion - Feature Integration', () => {
|
|
|
229
229
|
* that bypassed the event bus.
|
|
230
230
|
*
|
|
231
231
|
* The correct pattern is event-driven only:
|
|
232
|
-
* - UI emits
|
|
233
|
-
* -
|
|
232
|
+
* - UI emits mark:deleteevent
|
|
233
|
+
* - useBindFlow handles it
|
|
234
234
|
* - No direct function calls
|
|
235
235
|
*/
|
|
236
236
|
|
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
* 4. BUG: Progress modal stays visible showing "Processing: Location" indefinitely
|
|
9
9
|
*
|
|
10
10
|
* ROOT CAUSE:
|
|
11
|
-
* -
|
|
11
|
+
* - useMarkFlow.ts (line 54-62): mark:assist-finished clears `assistingMotivation` but keeps `progress`
|
|
12
12
|
* - AssistSection.tsx (line 214): Shows progress UI whenever `progress` is not null
|
|
13
13
|
* - No mechanism to auto-dismiss or manually close the progress display
|
|
14
14
|
*
|
|
15
15
|
* FIX OPTIONS:
|
|
16
16
|
* A) Auto-dismiss after timeout (3s after completion)
|
|
17
17
|
* B) Add "Close" button to progress display
|
|
18
|
-
* C) Clear progress on next
|
|
18
|
+
* C) Clear progress on next mark:assist-request (already works but not ideal UX)
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
22
22
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
23
23
|
import { act } from 'react';
|
|
24
|
-
import {
|
|
24
|
+
import { useMarkFlow } from '../../../hooks/useMarkFlow';
|
|
25
25
|
import { EventBusProvider, resetEventBusForTesting, useEventBus } from '../../../contexts/EventBusContext';
|
|
26
26
|
import { ApiClientProvider } from '../../../contexts/ApiClientContext';
|
|
27
27
|
import { AuthTokenProvider } from '../../../contexts/AuthTokenContext';
|
|
@@ -65,7 +65,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
65
65
|
|
|
66
66
|
function TestHarness() {
|
|
67
67
|
eventBusInstance = useEventBus();
|
|
68
|
-
const { assistingMotivation, progress } =
|
|
68
|
+
const { assistingMotivation, progress } = useMarkFlow(rUri);
|
|
69
69
|
|
|
70
70
|
return (
|
|
71
71
|
<div>
|
|
@@ -91,9 +91,9 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
91
91
|
expect(screen.getByTestId('detecting')).toHaveTextContent('none');
|
|
92
92
|
expect(screen.getByTestId('progress')).toHaveTextContent('no progress');
|
|
93
93
|
|
|
94
|
-
// User clicks detect button (emits
|
|
94
|
+
// User clicks detect button (emits mark:assist-request)
|
|
95
95
|
act(() => {
|
|
96
|
-
eventBusInstance.get('
|
|
96
|
+
eventBusInstance.get('mark:assist-request').next({
|
|
97
97
|
motivation: 'linking',
|
|
98
98
|
options: { entityTypes: ['Location'] }
|
|
99
99
|
});
|
|
@@ -106,7 +106,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
106
106
|
|
|
107
107
|
// SSE sends progress update
|
|
108
108
|
act(() => {
|
|
109
|
-
eventBusInstance.get('
|
|
109
|
+
eventBusInstance.get('mark:progress').next({
|
|
110
110
|
status: 'scanning',
|
|
111
111
|
message: 'Processing: Location',
|
|
112
112
|
currentEntityType: 'Location',
|
|
@@ -118,9 +118,9 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
118
118
|
expect(screen.getByTestId('progress')).toHaveTextContent('Processing: Location');
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
// Detection completes (SSE finishes, backend emits
|
|
121
|
+
// Detection completes (SSE finishes, backend emits mark:assist-finished)
|
|
122
122
|
act(() => {
|
|
123
|
-
eventBusInstance.get('
|
|
123
|
+
eventBusInstance.get('mark:assist-finished').next({ motivation: 'linking' });
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
// assistingMotivation cleared immediately
|
|
@@ -138,7 +138,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
138
138
|
|
|
139
139
|
function TestHarness() {
|
|
140
140
|
eventBusInstance = useEventBus();
|
|
141
|
-
const { progress } =
|
|
141
|
+
const { progress } = useMarkFlow(rUri);
|
|
142
142
|
|
|
143
143
|
return (
|
|
144
144
|
<div data-testid="progress">
|
|
@@ -159,15 +159,15 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
159
159
|
|
|
160
160
|
// First detection with stuck progress
|
|
161
161
|
act(() => {
|
|
162
|
-
eventBusInstance.get('
|
|
162
|
+
eventBusInstance.get('mark:assist-request').next({ motivation: 'linking', options: {} });
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
act(() => {
|
|
166
|
-
eventBusInstance.get('
|
|
166
|
+
eventBusInstance.get('mark:progress').next({ message: 'Old progress stuck here' });
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
act(() => {
|
|
170
|
-
eventBusInstance.get('
|
|
170
|
+
eventBusInstance.get('mark:assist-finished').next({ motivation: 'linking' });
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
await waitFor(() => {
|
|
@@ -176,7 +176,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
176
176
|
|
|
177
177
|
// WORKAROUND: Start new detection clears old progress
|
|
178
178
|
act(() => {
|
|
179
|
-
eventBusInstance.get('
|
|
179
|
+
eventBusInstance.get('mark:assist-request').next({ motivation: 'highlighting', options: {} });
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
await waitFor(() => {
|
|
@@ -191,7 +191,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
191
191
|
|
|
192
192
|
function TestHarness() {
|
|
193
193
|
eventBusInstance = useEventBus();
|
|
194
|
-
const { progress } =
|
|
194
|
+
const { progress } = useMarkFlow(rUri);
|
|
195
195
|
|
|
196
196
|
return (
|
|
197
197
|
<div data-testid="progress">
|
|
@@ -212,18 +212,18 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
212
212
|
|
|
213
213
|
// Show progress
|
|
214
214
|
act(() => {
|
|
215
|
-
eventBusInstance.get('
|
|
215
|
+
eventBusInstance.get('mark:assist-request').next({ motivation: 'linking', options: {} });
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
act(() => {
|
|
219
|
-
eventBusInstance.get('
|
|
219
|
+
eventBusInstance.get('mark:progress').next({
|
|
220
220
|
status: 'complete',
|
|
221
221
|
message: 'Complete! Created 5 annotations'
|
|
222
222
|
});
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
act(() => {
|
|
226
|
-
eventBusInstance.get('
|
|
226
|
+
eventBusInstance.get('mark:assist-finished').next({ motivation: 'linking' });
|
|
227
227
|
});
|
|
228
228
|
|
|
229
229
|
// Progress visible initially
|
|
@@ -242,7 +242,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
242
242
|
it('FIXED: SSE emits final completion chunk data as annotate:assist-progress', async () => {
|
|
243
243
|
/**
|
|
244
244
|
* This test verifies that SSE emits the final chunk as annotate:assist-progress
|
|
245
|
-
* BEFORE emitting
|
|
245
|
+
* BEFORE emitting mark:assist-finished.
|
|
246
246
|
*
|
|
247
247
|
* This ensures the UI can display the final completion message with status:'complete'.
|
|
248
248
|
*/
|
|
@@ -251,7 +251,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
251
251
|
|
|
252
252
|
function TestHarness() {
|
|
253
253
|
eventBusInstance = useEventBus();
|
|
254
|
-
const { progress } =
|
|
254
|
+
const { progress } = useMarkFlow(rUri);
|
|
255
255
|
|
|
256
256
|
return (
|
|
257
257
|
<div>
|
|
@@ -273,7 +273,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
273
273
|
|
|
274
274
|
// Start detection (triggers SSE stream creation)
|
|
275
275
|
act(() => {
|
|
276
|
-
eventBusInstance.get('
|
|
276
|
+
eventBusInstance.get('mark:assist-request').next({
|
|
277
277
|
motivation: 'linking',
|
|
278
278
|
options: { entityTypes: ['Location'] }
|
|
279
279
|
});
|
|
@@ -281,7 +281,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
281
281
|
|
|
282
282
|
// Simulate SSE scanning chunk
|
|
283
283
|
act(() => {
|
|
284
|
-
eventBusInstance.get('
|
|
284
|
+
eventBusInstance.get('mark:progress').next({
|
|
285
285
|
status: 'scanning',
|
|
286
286
|
message: 'Processing: Location',
|
|
287
287
|
});
|
|
@@ -293,7 +293,7 @@ describe('Detection Progress Dismissal Bug', () => {
|
|
|
293
293
|
|
|
294
294
|
// Simulate SSE emitting final chunk as annotate:assist-progress
|
|
295
295
|
act(() => {
|
|
296
|
-
eventBusInstance.get('
|
|
296
|
+
eventBusInstance.get('mark:progress').next({
|
|
297
297
|
status: 'complete',
|
|
298
298
|
message: 'Complete! Found 5 entities',
|
|
299
299
|
foundCount: 5,
|