@semiont/react-ui 0.4.20 → 0.4.22
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 +8 -5
- package/dist/{PdfAnnotationCanvas.client-CHDCGQBR.mjs → PdfAnnotationCanvas.client-5QESNO5H.mjs} +13 -16
- package/dist/PdfAnnotationCanvas.client-5QESNO5H.mjs.map +1 -0
- package/dist/TranslationManager-9Xj3MIWQ.d.mts +16 -0
- package/dist/chunk-4NOUO3W6.mjs +7788 -0
- package/dist/chunk-4NOUO3W6.mjs.map +1 -0
- package/dist/index.d.mts +212 -1206
- package/dist/index.mjs +3332 -13712
- package/dist/index.mjs.map +1 -1
- package/dist/test-utils.d.mts +48 -21
- package/dist/test-utils.mjs +2505 -87
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/AnnotateReferencesProgressWidget.tsx +21 -28
- package/src/components/CodeMirrorRenderer.tsx +12 -12
- package/src/components/LiveRegion.tsx +1 -2
- package/src/components/StatusDisplay.tsx +42 -16
- package/src/components/Toolbar.tsx +4 -4
- package/src/components/__tests__/AnnotateReferencesProgressWidget.test.tsx +34 -20
- package/src/components/__tests__/StatusDisplay.test.tsx +50 -65
- package/src/components/__tests__/Toolbar.test.tsx +4 -4
- package/src/components/annotation/AnnotateToolbar.tsx +8 -9
- package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +31 -77
- package/src/components/annotation-popups/JsonLdView.tsx +1 -2
- package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +1 -2
- package/src/components/image-annotation/AnnotationOverlay.tsx +15 -18
- package/src/components/image-annotation/SvgDrawingCanvas.tsx +12 -17
- package/src/components/modals/ConfigureGenerationStep.tsx +1 -2
- package/src/components/modals/PermissionDeniedModal.tsx +11 -11
- package/src/components/modals/ReferenceWizardModal.tsx +14 -18
- package/src/components/modals/ResourceSearchModal.tsx +12 -8
- package/src/components/modals/SearchModal.tsx +11 -6
- package/src/components/modals/SearchResultsStep.tsx +1 -3
- package/src/components/modals/SessionExpiredModal.tsx +11 -11
- package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +7 -7
- package/src/components/modals/__tests__/ResourceSearchModal.test.tsx +10 -8
- package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +6 -2
- package/src/components/modals/__tests__/SearchModal.basic.test.tsx +6 -2
- package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +6 -2
- package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +10 -7
- package/src/components/modals/__tests__/SearchModal.visual.test.tsx +6 -2
- package/src/components/modals/__tests__/SessionExpiredModal.test.tsx +5 -5
- package/src/components/navigation/CollapsibleResourceNavigation.tsx +10 -10
- package/src/components/navigation/ObservableLink.tsx +6 -6
- package/src/components/navigation/SimpleNavigation.tsx +4 -4
- package/src/components/navigation/__tests__/ObservableLink.test.tsx +4 -4
- package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +4 -4
- package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +15 -18
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +1 -2
- package/src/components/resource/AnnotateView.tsx +8 -10
- package/src/components/resource/AnnotationHistory.tsx +9 -12
- package/src/components/resource/BrowseView.tsx +11 -8
- package/src/components/resource/ResourceViewer.tsx +22 -34
- package/src/components/resource/__tests__/AnnotationHistory.test.tsx +54 -192
- package/src/components/resource/__tests__/BrowseView.test.tsx +38 -87
- package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +41 -31
- package/src/components/resource/__tests__/event-formatting.test.ts +6 -2
- package/src/components/resource/event-formatting.ts +2 -3
- package/src/components/resource/panels/AssessmentEntry.tsx +7 -8
- package/src/components/resource/panels/AssessmentPanel.tsx +21 -17
- package/src/components/resource/panels/AssistSection.tsx +15 -21
- package/src/components/resource/panels/CollaborationPanel.tsx +29 -7
- package/src/components/resource/panels/CommentEntry.tsx +7 -8
- package/src/components/resource/panels/CommentsPanel.tsx +11 -13
- package/src/components/resource/panels/HighlightEntry.tsx +7 -8
- package/src/components/resource/panels/HighlightPanel.tsx +12 -13
- package/src/components/resource/panels/ReferenceEntry.tsx +13 -15
- package/src/components/resource/panels/ReferencesPanel.tsx +17 -19
- package/src/components/resource/panels/ResourceInfoPanel.tsx +8 -7
- package/src/components/resource/panels/StatisticsPanel.tsx +2 -3
- package/src/components/resource/panels/TagEntry.tsx +7 -8
- package/src/components/resource/panels/TaggingPanel.tsx +14 -23
- package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +4 -3
- package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +4 -4
- package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +22 -57
- package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +51 -20
- package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +4 -4
- package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +22 -61
- package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +4 -4
- package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +1 -2
- package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +7 -8
- package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +153 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +51 -106
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +28 -53
- package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +3 -3
- package/src/components/resource/panels/__tests__/TagEntry.test.tsx +4 -4
- package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +19 -52
- package/src/components/settings/SettingsPanel.tsx +9 -9
- package/src/components/settings/__tests__/SettingsPanel.test.tsx +15 -15
- package/src/features/admin-devops/components/AdminDevOpsPage.tsx +1 -2
- package/src/features/admin-exchange/components/AdminExchangePage.tsx +1 -1
- package/src/features/admin-exchange/components/ImportCard.tsx +2 -7
- package/src/features/admin-security/components/AdminSecurityPage.tsx +1 -2
- package/src/features/admin-users/components/AdminUsersPage.tsx +1 -1
- package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +1 -2
- package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +1 -2
- package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +1 -1
- package/src/features/moderation-linked-data/components/LinkedDataPage.tsx +1 -1
- package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +5 -3
- package/src/features/resource-compose/components/ResourceComposePage.tsx +6 -22
- package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +4 -3
- package/src/features/resource-discovery/components/ResourceCard.tsx +1 -2
- package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +3 -4
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +37 -45
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +129 -197
- package/dist/KnowledgeBaseSessionContext-BNNunwzO.d.mts +0 -175
- package/dist/PdfAnnotationCanvas.client-CHDCGQBR.mjs.map +0 -1
- package/dist/chunk-OZICDVH7.mjs +0 -62
- package/dist/chunk-OZICDVH7.mjs.map +0 -1
- package/dist/chunk-R4CCMFJH.mjs +0 -877
- package/dist/chunk-R4CCMFJH.mjs.map +0 -1
- package/dist/chunk-VN5NY4SN.mjs +0 -200
- package/dist/chunk-VN5NY4SN.mjs.map +0 -1
- package/src/components/modals/ProposeEntitiesModal.tsx +0 -179
- package/src/components/modals/__tests__/ProposeEntitiesModal.test.tsx +0 -129
- package/src/features/resource-viewer/__tests__/AnnotationCreationPending.test.tsx +0 -323
- package/src/features/resource-viewer/__tests__/AnnotationDeletionIntegration.test.tsx +0 -245
- package/src/features/resource-viewer/__tests__/AnnotationProgressDismissal.test.tsx +0 -303
- package/src/features/resource-viewer/__tests__/BindFlowIntegration.test.tsx +0 -150
- package/src/features/resource-viewer/__tests__/DetectionFlowBug.test.tsx +0 -243
- package/src/features/resource-viewer/__tests__/DetectionFlowIntegration.test.tsx +0 -383
- package/src/features/resource-viewer/__tests__/ResourceMutations.test.tsx +0 -299
- package/src/features/resource-viewer/__tests__/ToastNotifications.test.tsx +0 -186
- package/src/features/resource-viewer/__tests__/YieldFlowIntegration.test.tsx +0 -429
- package/src/features/resource-viewer/__tests__/annotation-progress-flow.test.tsx +0 -348
|
@@ -9,8 +9,7 @@ import React from 'react';
|
|
|
9
9
|
import {
|
|
10
10
|
CommandLineIcon
|
|
11
11
|
} from '@heroicons/react/24/outline';
|
|
12
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
13
|
-
|
|
12
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
14
13
|
export interface DevOpsFeature {
|
|
15
14
|
title: string;
|
|
16
15
|
description: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
8
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
9
9
|
import { ExportCard, type ExportCardTranslations } from './ExportCard';
|
|
10
10
|
import { ImportCard, type ImportCardProps, type ImportCardTranslations } from './ImportCard';
|
|
11
11
|
import { ImportProgress, type ImportProgressTranslations } from './ImportProgress';
|
|
@@ -5,13 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import React, { useRef, useState, useCallback } from 'react';
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
format: string;
|
|
11
|
-
version: number;
|
|
12
|
-
sourceUrl: string;
|
|
13
|
-
stats: Record<string, number>;
|
|
14
|
-
}
|
|
8
|
+
import type { ImportPreview } from '@semiont/sdk';
|
|
9
|
+
export type { ImportPreview };
|
|
15
10
|
|
|
16
11
|
export interface ImportCardTranslations {
|
|
17
12
|
title: string;
|
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
CheckCircleIcon,
|
|
13
13
|
InformationCircleIcon
|
|
14
14
|
} from '@heroicons/react/24/outline';
|
|
15
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
16
|
-
|
|
15
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
17
16
|
export interface OAuthProvider {
|
|
18
17
|
name: string;
|
|
19
18
|
clientId?: string;
|
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
PlusIcon,
|
|
12
12
|
ExclamationCircleIcon
|
|
13
13
|
} from '@heroicons/react/24/outline';
|
|
14
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
15
|
-
|
|
14
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
16
15
|
export interface EntityTagsPageProps {
|
|
17
16
|
// Data props
|
|
18
17
|
entityTypes: string[];
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { ClockIcon } from '@heroicons/react/24/outline';
|
|
10
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
11
|
-
|
|
10
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
12
11
|
export interface RecentDocumentsPageProps {
|
|
13
12
|
// Data props
|
|
14
13
|
hasDocuments: boolean;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ScaleIcon,
|
|
12
12
|
LightBulbIcon
|
|
13
13
|
} from '@heroicons/react/24/outline';
|
|
14
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
14
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
15
15
|
import type { TagSchema } from '@semiont/react-ui';
|
|
16
16
|
|
|
17
17
|
export interface TagSchemasPageProps {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '
|
|
9
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
10
10
|
import { ExportCard, type ExportCardTranslations } from '../../admin-exchange/components/ExportCard';
|
|
11
11
|
import { ImportCard, type ImportCardProps, type ImportCardTranslations } from '../../admin-exchange/components/ImportCard';
|
|
12
12
|
import { ImportProgress, type ImportProgressTranslations } from '../../admin-exchange/components/ImportProgress';
|
|
@@ -9,7 +9,7 @@ import { describe, it, expect, vi } from 'vitest';
|
|
|
9
9
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
10
10
|
import { ResourceComposePage } from '../components/ResourceComposePage';
|
|
11
11
|
import type { ResourceComposePageProps, SaveResourceParams } from '../components/ResourceComposePage';
|
|
12
|
-
import {
|
|
12
|
+
import { createTestSemiontWrapper } from '../../../test-utils';
|
|
13
13
|
|
|
14
14
|
// Mock CodeMirrorRenderer to avoid CodeMirror dependencies
|
|
15
15
|
vi.mock('../../../components/CodeMirrorRenderer', () => ({
|
|
@@ -72,9 +72,11 @@ const createMockProps = (overrides?: Partial<ResourceComposePageProps>): Resourc
|
|
|
72
72
|
...overrides,
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
// Helper to render with
|
|
75
|
+
// Helper to render with a session-capable tree (provides the event bus the
|
|
76
|
+
// component reaches for via useSemiont/useObservable).
|
|
76
77
|
const renderWithProviders = (ui: React.ReactElement) => {
|
|
77
|
-
|
|
78
|
+
const { SemiontWrapper } = createTestSemiontWrapper();
|
|
79
|
+
return render(<SemiontWrapper>{ui}</SemiontWrapper>);
|
|
78
80
|
};
|
|
79
81
|
|
|
80
82
|
describe('ResourceComposePage', () => {
|
|
@@ -7,34 +7,18 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React, { useState, useEffect } from 'react';
|
|
10
|
-
import type {
|
|
11
|
-
import { isImageMimeType, isPdfMimeType, LOCALES } from '@semiont/
|
|
12
|
-
import {
|
|
10
|
+
import type { GatheredContext } from '@semiont/core';
|
|
11
|
+
import { isImageMimeType, isPdfMimeType, LOCALES } from '@semiont/core';
|
|
12
|
+
import { type CloneData, type ReferenceData } from '@semiont/sdk';
|
|
13
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
13
14
|
import { buttonStyles } from '../../../lib/button-styles';
|
|
14
15
|
import { CodeMirrorRenderer } from '../../../components/CodeMirrorRenderer';
|
|
15
16
|
import { useFormAnnouncements } from '../../../components/LiveRegion';
|
|
16
17
|
|
|
17
|
-
type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
|
|
18
|
-
|
|
19
18
|
export interface ResourceComposePageProps {
|
|
20
|
-
// Mode detection
|
|
21
19
|
mode: 'new' | 'clone' | 'reference';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
cloneData?: {
|
|
25
|
-
sourceResource: ResourceDescriptor;
|
|
26
|
-
sourceContent: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// Reference completion data
|
|
30
|
-
referenceData?: {
|
|
31
|
-
annotationUri: string;
|
|
32
|
-
sourceDocumentId: string;
|
|
33
|
-
name: string;
|
|
34
|
-
entityTypes: string[];
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Gathered context from wizard (optional, for reference mode)
|
|
20
|
+
cloneData?: CloneData | null;
|
|
21
|
+
referenceData?: ReferenceData | null;
|
|
38
22
|
gatheredContext?: GatheredContext | null;
|
|
39
23
|
|
|
40
24
|
// Available options
|
|
@@ -9,7 +9,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
9
9
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
10
10
|
import { ResourceDiscoveryPage } from '../components/ResourceDiscoveryPage';
|
|
11
11
|
import type { ResourceDiscoveryPageProps } from '../components/ResourceDiscoveryPage';
|
|
12
|
-
import {
|
|
12
|
+
import { createTestSemiontWrapper } from '../../../test-utils';
|
|
13
13
|
|
|
14
14
|
const createMockResource = (id: string, name: string, entityTypes: string[] = []) => ({
|
|
15
15
|
'@context': 'https://www.w3.org/ns/anno.jsonld',
|
|
@@ -58,9 +58,10 @@ const createMockProps = (overrides?: Partial<ResourceDiscoveryPageProps>): Resou
|
|
|
58
58
|
...overrides,
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
// Helper to render with
|
|
61
|
+
// Helper to render with SemiontProvider (gives components access to session.emit)
|
|
62
62
|
const renderWithProviders = (ui: React.ReactElement) => {
|
|
63
|
-
|
|
63
|
+
const { SemiontWrapper } = createTestSemiontWrapper();
|
|
64
|
+
return render(<SemiontWrapper>{ui}</SemiontWrapper>);
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
describe('ResourceDiscoveryPage', () => {
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import type { components } from '@semiont/core';
|
|
10
9
|
|
|
11
|
-
type ResourceDescriptor
|
|
10
|
+
import type { ResourceDescriptor } from '@semiont/core';
|
|
12
11
|
|
|
13
12
|
export interface ResourceCardProps {
|
|
14
13
|
resource: ResourceDescriptor;
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, { useState, useCallback, useRef } from 'react';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { COMMON_PANELS, type ToolbarPanelType } from '../../../hooks/usePanelBrowse';
|
|
9
|
+
import { getResourceId } from '@semiont/core';
|
|
10
|
+
import { COMMON_PANELS, type ToolbarPanelType } from '@semiont/sdk';
|
|
12
11
|
import { useRovingTabIndex } from '../../../hooks/useRovingTabIndex';
|
|
13
12
|
import { Toolbar } from '../../../components/Toolbar';
|
|
14
13
|
import { ResourceCard } from './ResourceCard';
|
|
15
14
|
|
|
16
|
-
type ResourceDescriptor
|
|
15
|
+
import type { ResourceDescriptor } from '@semiont/core';
|
|
17
16
|
|
|
18
17
|
export interface ResourceDiscoveryPageProps {
|
|
19
18
|
// Data props
|
|
@@ -10,12 +10,9 @@ import { render, screen, act } from '@testing-library/react';
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { ResourceViewerPage } from '../components/ResourceViewerPage';
|
|
12
12
|
import type { ResourceViewerPageProps } from '../components/ResourceViewerPage';
|
|
13
|
-
// Import directly from context file to bypass mocked barrel export
|
|
14
|
-
import { EventBusProvider } from '../../../contexts/EventBusContext';
|
|
15
|
-
import { ApiClientProvider } from '../../../contexts/ApiClientContext';
|
|
16
|
-
import { AuthTokenProvider } from '../../../contexts/AuthTokenContext';
|
|
17
13
|
import { ToastProvider } from '../../../components/Toast';
|
|
18
14
|
import { ThemeProvider } from '../../../contexts/ThemeContext';
|
|
15
|
+
import { createTestSemiontWrapper } from '../../../test-utils';
|
|
19
16
|
|
|
20
17
|
// jsdom doesn't implement window.matchMedia — mock it for useTheme
|
|
21
18
|
Object.defineProperty(window, 'matchMedia', {
|
|
@@ -37,32 +34,40 @@ vi.mock('../../../hooks/useResourceContent', () => ({
|
|
|
37
34
|
useResourceContent: () => ({ content: 'Test content', loading: false }),
|
|
38
35
|
}));
|
|
39
36
|
|
|
40
|
-
vi.mock('../../../lib/api-hooks', () => ({
|
|
41
|
-
useResources: () => ({
|
|
42
|
-
annotations: { useQuery: () => ({ data: { annotations: [] } }) },
|
|
43
|
-
referencedBy: { useQuery: () => ({ data: { referencedBy: [] }, isLoading: false }) },
|
|
44
|
-
mediaToken: { useQuery: () => ({ data: { token: 'mock-media-token' }, isLoading: false }) },
|
|
45
|
-
update: { useMutation: () => ({ mutateAsync: vi.fn() }) },
|
|
46
|
-
generateCloneToken: { useMutation: () => ({ mutateAsync: vi.fn() }) },
|
|
47
|
-
}),
|
|
48
|
-
useEntityTypes: () => ({
|
|
49
|
-
list: { useQuery: () => ({ data: { entityTypes: ['Document', 'Article', 'Book'] } }) },
|
|
50
|
-
}),
|
|
51
|
-
}));
|
|
52
37
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
// Stub SemiontBrowser whose activeSession$ emits a session carrying a real
|
|
39
|
+
// SemiontClient (wired to a dummy baseUrl). The real client surface lets
|
|
40
|
+
// createResourceViewerPageVM run against the full namespace API without us
|
|
41
|
+
// hand-stubbing every method it touches.
|
|
42
|
+
const { stubBrowser } = vi.hoisted(() => {
|
|
43
|
+
const { BehaviorSubject } = require('rxjs');
|
|
44
|
+
const { SemiontClient, HttpTransport, HttpContentTransport } = require('@semiont/sdk');
|
|
45
|
+
const { baseUrl } = require('@semiont/core');
|
|
46
|
+
const transport = new HttpTransport({ baseUrl: baseUrl('http://localhost:4000') });
|
|
47
|
+
const client = new SemiontClient(transport, new HttpContentTransport(transport));
|
|
48
|
+
const stubActiveSession$ = new BehaviorSubject({ client });
|
|
49
|
+
const stubOpenResources$ = new BehaviorSubject([]);
|
|
50
|
+
const stubBrowser = {
|
|
51
|
+
activeSession$: stubActiveSession$,
|
|
52
|
+
openResources$: stubOpenResources$,
|
|
53
|
+
addOpenResource: vi.fn(),
|
|
54
|
+
removeOpenResource: vi.fn(),
|
|
55
|
+
updateOpenResourceName: vi.fn(),
|
|
56
|
+
reorderOpenResources: vi.fn(),
|
|
57
|
+
emit: vi.fn(),
|
|
58
|
+
on: vi.fn(() => () => {}),
|
|
59
|
+
stream: vi.fn(() => ({ subscribe: () => ({ unsubscribe: () => {} }) })),
|
|
60
|
+
};
|
|
61
|
+
return { stubBrowser };
|
|
62
|
+
});
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
vi.
|
|
59
|
-
|
|
64
|
+
vi.mock('../../../session/SemiontProvider', async () => {
|
|
65
|
+
const actual = await vi.importActual<typeof import('../../../session/SemiontProvider')>(
|
|
66
|
+
'../../../session/SemiontProvider'
|
|
67
|
+
);
|
|
60
68
|
return {
|
|
61
69
|
...actual,
|
|
62
|
-
|
|
63
|
-
invalidateQueries: vi.fn(),
|
|
64
|
-
setQueryData: vi.fn(),
|
|
65
|
-
}),
|
|
70
|
+
useSemiont: () => stubBrowser,
|
|
66
71
|
};
|
|
67
72
|
});
|
|
68
73
|
|
|
@@ -82,12 +87,10 @@ vi.mock('@semiont/react-ui', async () => {
|
|
|
82
87
|
createCancelDetectionHandler: () => vi.fn(),
|
|
83
88
|
useDebouncedCallback: (fn: any) => fn,
|
|
84
89
|
supportsDetection: () => false,
|
|
85
|
-
MakeMeaningEventBusProvider: ({ children }: any) => children,
|
|
86
90
|
useResourceLoadingAnnouncements: () => ({
|
|
87
91
|
announceResourceLoading: vi.fn(),
|
|
88
92
|
announceResourceLoaded: vi.fn(),
|
|
89
93
|
}),
|
|
90
|
-
// Don't mock EventBusProvider, useEventBus - let actual pass through via ...actual
|
|
91
94
|
useEventSubscriptions: vi.fn(),
|
|
92
95
|
useResourceAnnotations: () => ({
|
|
93
96
|
clearNewAnnotationId: vi.fn(),
|
|
@@ -99,15 +102,6 @@ useDebouncedCallback: (fn: any) => fn,
|
|
|
99
102
|
};
|
|
100
103
|
});
|
|
101
104
|
|
|
102
|
-
vi.mock('../../../contexts/OpenResourcesContext', () => ({
|
|
103
|
-
useOpenResources: () => ({
|
|
104
|
-
openResources: [],
|
|
105
|
-
addResource: vi.fn(),
|
|
106
|
-
removeResource: vi.fn(),
|
|
107
|
-
isResourceOpen: vi.fn().mockReturnValue(false),
|
|
108
|
-
}),
|
|
109
|
-
}));
|
|
110
|
-
|
|
111
105
|
vi.mock('../../../contexts/ResourceAnnotationsContext', () => ({
|
|
112
106
|
useResourceAnnotations: () => ({
|
|
113
107
|
clearNewAnnotationId: vi.fn(),
|
|
@@ -123,6 +117,7 @@ vi.mock('../../../contexts/ResourceAnnotationsContext', () => ({
|
|
|
123
117
|
// (the barrel export mock doesn't intercept direct context imports)
|
|
124
118
|
const mockUseEventSubscriptions = vi.fn();
|
|
125
119
|
vi.mock('../../../contexts/useEventSubscription', () => ({
|
|
120
|
+
useEventSubscription: vi.fn(),
|
|
126
121
|
useEventSubscriptions: (...args: unknown[]) => mockUseEventSubscriptions(...args),
|
|
127
122
|
}));
|
|
128
123
|
|
|
@@ -154,7 +149,7 @@ const createMockProps = (overrides?: Partial<ResourceViewerPageProps>): Resource
|
|
|
154
149
|
Link: ({ children }: any) => <a>{children}</a>,
|
|
155
150
|
routes: {},
|
|
156
151
|
refetchDocument: vi.fn().mockResolvedValue(undefined),
|
|
157
|
-
streamStatus: '
|
|
152
|
+
streamStatus: 'open' as const,
|
|
158
153
|
ToolbarPanels: ({ children, activePanel }: any) =>
|
|
159
154
|
!activePanel ? null : <div data-testid="toolbar-panels">{children}</div>,
|
|
160
155
|
...overrides,
|
|
@@ -162,16 +157,13 @@ const createMockProps = (overrides?: Partial<ResourceViewerPageProps>): Resource
|
|
|
162
157
|
|
|
163
158
|
// Test wrapper to provide all required providers
|
|
164
159
|
const renderWithProviders = (ui: React.ReactElement) => {
|
|
160
|
+
const { SemiontWrapper } = createTestSemiontWrapper();
|
|
165
161
|
return render(
|
|
166
162
|
<ThemeProvider>
|
|
167
163
|
<ToastProvider>
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
{ui}
|
|
172
|
-
</ApiClientProvider>
|
|
173
|
-
</EventBusProvider>
|
|
174
|
-
</AuthTokenProvider>
|
|
164
|
+
<SemiontWrapper>
|
|
165
|
+
{ui}
|
|
166
|
+
</SemiontWrapper>
|
|
175
167
|
</ToastProvider>
|
|
176
168
|
</ThemeProvider>
|
|
177
169
|
);
|