Skip to content

Commit 4c93edc

Browse files
test: mock the image-integrity boundary in download/residency suites
The new extraction-completeness + load-time integrity checks run real RNFS validation. Four pre-existing suites (imageDownloadActions/resume, imageDownloadRecovery, activeModelService) mock RNFS/services and never lay a complete model dir on disk, so the new gate threw ImageModelIncompleteError where they expected success. Those suites cover download/residency ORCHESTRATION, not the completeness rule (which has its own dedicated tests in imageModelIntegrity.test + imageGenerationFlow), so mock the integrity boundary to "complete" in each. Full suite green (330 suites, 6960 tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8a26aaf commit 4c93edc

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

__tests__/integration/models/activeModelService.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import { createDownloadedModel, createONNXImageModel, createDeviceInfo } from '.
2727
jest.mock('../../../src/services/llm');
2828
jest.mock('../../../src/services/localDreamGenerator');
2929
jest.mock('../../../src/services/hardware');
30+
// Integrity is a boundary for these residency/memory tests (the model files aren't laid
31+
// down on a real disk here). The completeness rule has its own dedicated tests.
32+
jest.mock('../../../src/utils/imageModelIntegrity', () => ({
33+
validateImageModelDir: jest.fn(async () => ({ complete: true, missing: [] })),
34+
ensureImageExtractionComplete: jest.fn(async () => {}),
35+
}));
3036

3137
const mockLlmService = llmService as jest.Mocked<typeof llmService>;
3238
const mockLocalDreamService = localDreamGeneratorService as jest.Mocked<typeof localDreamGeneratorService>;

__tests__/integration/models/imageDownloadRecovery.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ const mockModelManager = {
1212
addDownloadedImageModel: jest.fn(),
1313
};
1414

15+
// Integrity is a boundary for this recovery test (it exercises the resume/move
16+
// orchestration, not the completeness rule — that has its own dedicated tests).
17+
jest.mock('../../../src/utils/imageModelIntegrity', () => ({
18+
validateImageModelDir: jest.fn(async () => ({ complete: true, missing: [] })),
19+
ensureImageExtractionComplete: jest.fn(async () => {}),
20+
}));
21+
1522
jest.mock('../../../src/services/backgroundDownloadService', () => ({
1623
backgroundDownloadService: mockBackgroundDownloadService,
1724
}));

__tests__/unit/screens/ModelsScreen/imageDownloadActions.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ jest.mock('react-native-zip-archive', () => ({
2525
unzip: jest.fn(() => Promise.resolve('/unzipped')),
2626
}));
2727

28+
// Integrity is a boundary here (these tests cover download orchestration, not the
29+
// completeness rule — that has its own tests). Default it to "complete" so the mocked
30+
// RNFS fixtures don't trip the post-unzip gate.
31+
jest.mock('../../../../src/utils/imageModelIntegrity', () => ({
32+
validateImageModelDir: jest.fn(async () => ({ complete: true, missing: [] })),
33+
ensureImageExtractionComplete: jest.fn(async () => {}),
34+
}));
35+
2836
jest.mock('../../../../src/components/CustomAlert', () => ({
2937
showAlert: jest.fn((...args: any[]) => ({ visible: true, title: args[0], message: args[1], buttons: args[2] })),
3038
hideAlert: jest.fn(() => ({ visible: false })),

__tests__/unit/screens/ModelsScreen/imageDownloadResume.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ jest.mock('react-native-zip-archive', () => ({
1818
unzip: jest.fn(),
1919
}));
2020

21+
// Integrity is a boundary here (resume orchestration is under test, not the completeness
22+
// rule). Default to "complete" so mocked RNFS fixtures don't trip the post-unzip gate.
23+
jest.mock('../../../../src/utils/imageModelIntegrity', () => ({
24+
validateImageModelDir: jest.fn(async () => ({ complete: true, missing: [] })),
25+
ensureImageExtractionComplete: jest.fn(async () => {}),
26+
}));
27+
2128
jest.mock('../../../../src/services', () => ({
2229
modelManager: {
2330
getImageModelsDirectory: jest.fn(),

0 commit comments

Comments
 (0)