fix(progress): separate model warmup state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -123,7 +123,7 @@ describe('setJobStatus', () => {
|
||||
|
||||
it('transitions through all valid statuses', () => {
|
||||
const job = createJob('src', 'title', 'auto');
|
||||
const statuses = ['downloading', 'preparing', 'transcribing', 'processing', 'done'] as const;
|
||||
const statuses = ['downloading', 'preparing', 'warming_model', 'transcribing', 'processing', 'done'] as const;
|
||||
for (const status of statuses) {
|
||||
setJobStatus(job.id, status, 50);
|
||||
expect(getJob(job.id)!.status).toBe(status);
|
||||
|
||||
49
src/tests/job-progress.test.ts
Normal file
49
src/tests/job-progress.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { getDisplayJobProgress, getJobStatusLabel, isTerminalJobStatus } from '$lib/job-progress.js';
|
||||
import type { Job } from '$lib/types.js';
|
||||
|
||||
function makeJob(overrides: Partial<Job> = {}): Job {
|
||||
return {
|
||||
id: 'job-1',
|
||||
status: 'transcribing',
|
||||
title: 'Job',
|
||||
source: 'https://example.com/audio.mp3',
|
||||
audioMode: 'auto',
|
||||
meanVolume: null,
|
||||
whisperJobId: null,
|
||||
progress: 42,
|
||||
outputDir: null,
|
||||
segmentsJson: null,
|
||||
error: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
...overrides
|
||||
};
|
||||
}
|
||||
|
||||
describe('job progress helpers', () => {
|
||||
it('keeps active jobs below 100 percent', () => {
|
||||
expect(getDisplayJobProgress(makeJob({ status: 'transcribing', progress: 100 }))).toBe(99);
|
||||
});
|
||||
|
||||
it('keeps model loading in an early progress band', () => {
|
||||
expect(getDisplayJobProgress(makeJob({ status: 'warming_model', progress: 80 }))).toBe(15);
|
||||
});
|
||||
|
||||
it('allows 100 percent once finished job has transcript payload', () => {
|
||||
expect(
|
||||
getDisplayJobProgress(makeJob({ status: 'done', progress: 100, segmentsJson: JSON.stringify([]) }), {
|
||||
hasTranscript: true
|
||||
})
|
||||
).toBe(100);
|
||||
});
|
||||
|
||||
it('holds done jobs below 100 percent until transcript data exists', () => {
|
||||
expect(getDisplayJobProgress(makeJob({ status: 'done', progress: 100 }))).toBe(99);
|
||||
});
|
||||
|
||||
it('exposes model-loading label as active state', () => {
|
||||
expect(getJobStatusLabel('warming_model')).toBe('Loading model');
|
||||
expect(isTerminalJobStatus('warming_model')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user