Skip to content

Commit e99ae3a

Browse files
test: align 2 stale specs to ratified behavior (whisper size floor, TTS override-loads)
- nativeBoundary.smoke: seed a 20MB whisper file (was 5MB) — listDownloadedModels floors at MIN_MODEL_FILE_SIZE (10MB, V2 truncated-file guard), so a listable model must exceed it. - ttsStore.extra: override + tight RAM now LOADS (initializes, resident) — Load-Anyway is unconditional (no survival floor); the old 'override refuses below the floor' was removed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5b35ac2 commit e99ae3a

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

__tests__/harness/nativeBoundary.smoke.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ describe('nativeBoundary harness — injection mechanism', () => {
4444

4545
it('installs a stateful FS that the REAL whisperService.listDownloadedModels reads (overrides the dumb stub)', async () => {
4646
const boundary = installNativeBoundary({ fs: true });
47-
boundary.fs!.seedFile(`${boundary.fs!.DocumentDirectoryPath}/whisper-models/ggml-base.en.bin`, 5 * 1024 * 1024);
47+
// Seed ABOVE the MIN_MODEL_FILE_SIZE (10MB) floor — listDownloadedModels drops sub-floor
48+
// (truncated) files (V2), so a listable model must exceed it.
49+
boundary.fs!.seedFile(`${boundary.fs!.DocumentDirectoryPath}/whisper-models/ggml-base.en.bin`, 20 * 1024 * 1024);
4850
// eslint-disable-next-line @typescript-eslint/no-var-requires
4951
const { whisperService } = require('../../src/services/whisperService');
5052
const listed = await whisperService.listDownloadedModels();
5153
// Proves the stateful FS reached the service (the dumb global stub returns []).
5254
expect(listed.map((m: { modelId: string }) => m.modelId)).toEqual(['base.en']);
53-
expect(listed[0].sizeBytes).toBe(5 * 1024 * 1024);
55+
expect(listed[0].sizeBytes).toBe(20 * 1024 * 1024);
5456
});
5557

5658
it('seeds the RAM leaf so DeviceMemoryModule reports the seeded free bytes', async () => {

__tests__/pro/audio/ttsStore.extra.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,20 @@ describe('ttsStore — extra branch coverage', () => {
201201
expect(getState().error).toBeNull();
202202
});
203203

204-
it('override load: NO room → throws → surfaces error, still not resident', async () => {
205-
// Even override can't cross the survival floor (1200MB). With ~500MB real free
206-
// RAM, makeRoomFor REFUSES under override (fits=false), so the store hits the
207-
// `throw new Error('Not enough free memory...')` branch (line 267).
204+
it('override load: bypasses the budget → evicts everything else and initializes (Load Anyway always loads)', async () => {
205+
// Load Anyway is UNCONDITIONAL: makeRoomFor under override always returns fits=true (no
206+
// survival floor — the user accepted the risk), so even at ~500MB real free RAM the override
207+
// load proceeds — evict, initialize, tts becomes resident. (The old "override still refuses
208+
// below the floor" behavior was removed.)
208209
modelResidencyManager.setBudgetOverrideMB(4000);
209-
availSpy.mockReturnValue(0.5); // ~500MB free < 1200MB survival floor
210+
availSpy.mockReturnValue(0.5); // ~500MB free — tight, but override ignores the budget
210211
mockCurrentEngine.capabilities.peakRamMB = 100;
211212

212213
await getState().initializeEngine({ override: true });
213214

214-
expect(mockCurrentEngine.initialize).not.toHaveBeenCalled();
215-
expect(modelResidencyManager.isResident('tts')).toBe(false);
216-
expect(getState().error).toMatch(/not enough free memory/i);
215+
expect(mockCurrentEngine.initialize).toHaveBeenCalled();
216+
expect(modelResidencyManager.isResident('tts')).toBe(true);
217+
expect(getState().error).toBeNull();
217218
});
218219

219220
it('derives sizeMB from required-asset bytes when peakRamMB is 0', async () => {

0 commit comments

Comments
 (0)