Skip to content

Commit 7348634

Browse files
V48 (impl-only): Fix uapi CI unit test suites
Mock matchMedia in jest setup, correct package import paths, virtual PipelineExecution mock, and marketing AssetPacks assertions.
1 parent d36d161 commit 7348634

6 files changed

Lines changed: 31 additions & 8 deletions

File tree

apps/uapi/lib/search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
normalizeAssetPackEmbeddingVector,
55
resolveAssetPackEmbeddingConfig,
66
type OpenAIEmbeddingCreateParams,
7-
} from '@bitcode/asset-packs-pipelines-syntheses-domain/src/embedding-config';
7+
} from '@bitcode/asset-packs-pipelines-syntheses-domain/embedding-config';
88
let supabaseModulePromise: Promise<typeof import('@bitcode/supabase')> | null = null;
99

1010
async function getSupabaseAdmin() {

apps/uapi/scripts/sync-asset-pack-evidence-embeddings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {
1515
buildOpenAIEmbeddingCreateParams,
1616
normalizeAssetPackEmbeddingVector,
1717
resolveAssetPackEmbeddingConfig,
18-
} = require('@bitcode/asset-packs-pipelines-syntheses-domain/src/embedding-config');
18+
} = require('@bitcode/asset-packs-pipelines-syntheses-domain/embedding-config');
1919

2020
// Retained Exchange storage identifiers; this script owns AssetPack evidence semantics.
2121
const ASSET_PACK_EVIDENCE_TABLE = 'deliverables';

apps/uapi/tests/api/assetPack.notifications.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ jest.mock('@bitcode/execution-generics', () => ({
6464
ExecutionStreamAdapter: jest.fn(),
6565
NS_EXEC_ASSET_PACK_VALIDATION_READY_TO_FINISH: 'validation-rts',
6666
}));
67-
jest.mock('@bitcode/pipelines-generics/src/execution/PipelineExecution', () => ({
68-
PipelineExecution: jest.fn().mockImplementation(() => ({})),
69-
}));
67+
jest.mock(
68+
'@bitcode/pipelines-generics/src/execution/PipelineExecution',
69+
() => ({
70+
PipelineExecution: jest.fn().mockImplementation(() => ({})),
71+
}),
72+
{ virtual: true },
73+
);
7074
jest.mock('@bitcode/errors', () => ({
7175
BitcodeError: class BitcodeError extends Error {},
7276
reportError: jest.fn((error: unknown) =>

apps/uapi/tests/marketingLandingPage.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ describe('MarketingLandingPage', () => {
148148
),
149149
).toBeInTheDocument();
150150
expect(screen.getByText(/Measured/u)).toBeInTheDocument();
151-
expect(screen.getByText(/AssetPacks/u)).toBeInTheDocument();
152-
expect(screen.getByText(/delightful applications/i)).toBeInTheDocument();
151+
// "AssetPacks" appears in multiple marketing spans/paragraphs.
152+
expect(screen.getAllByText(/AssetPacks/u).length).toBeGreaterThan(0);
153+
expect(screen.getByText(/delightful user applications/i)).toBeInTheDocument();
153154
expect(screen.queryByText(/testnet/i)).toBeNull();
154155
expect(screen.queryByText(/on Bitcoin/i)).toBeNull();
155156
expect(screen.getByText('Website Application')).toBeInTheDocument();

apps/uapi/tests/searchRelevantAssetPackEvidence.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { searchRelevantAssetPackEvidence } from '@bitcode/asset-packs-pipelines-syntheses-domain/src/tools/search';
1+
import { searchRelevantAssetPackEvidence } from '@bitcode/asset-packs-pipelines-syntheses-domain/tools/search';
22
import { supabaseAdmin } from '@bitcode/supabase';
33

44
jest.mock('exa-js', () => {

apps/uapi/tests/setupTests.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
process.env.GITHUB_APP_ID = process.env.GITHUB_APP_ID || 'test-app-id';
1212
process.env.GITHUB_PRIVATE_KEY = process.env.GITHUB_PRIVATE_KEY || 'private\\nkey';
1313

14+
// jsdom does not implement matchMedia (QuantumOrb, marketing landing, etc.).
15+
if (typeof window !== 'undefined' && typeof window.matchMedia !== 'function') {
16+
Object.defineProperty(window, 'matchMedia', {
17+
writable: true,
18+
configurable: true,
19+
value: (query: string) => ({
20+
matches: false,
21+
media: query,
22+
onchange: null,
23+
addListener: () => {},
24+
removeListener: () => {},
25+
addEventListener: () => {},
26+
removeEventListener: () => {},
27+
dispatchEvent: () => false,
28+
}),
29+
});
30+
}
31+
1432
// Stub the Next.js "server-only" module to a no-op so that API route files
1533
// importing it don’t fail under Jest’s node environment.
1634
jest.mock('server-only', () => ({}), { virtual: true });

0 commit comments

Comments
 (0)