refactor(transcript): drop Tonemark rewrite
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -7,7 +7,6 @@ const {
|
||||
mockGetJob,
|
||||
mockUpdateJob,
|
||||
mockSetJobStatus,
|
||||
mockDeduplicateSegments,
|
||||
mockWriteOutputs,
|
||||
mockSendNotification,
|
||||
mockCleanupJobTmp,
|
||||
@@ -16,7 +15,6 @@ const {
|
||||
mockGetJob: vi.fn(),
|
||||
mockUpdateJob: vi.fn(),
|
||||
mockSetJobStatus: vi.fn(),
|
||||
mockDeduplicateSegments: vi.fn((segs: Segment[]) => segs),
|
||||
mockWriteOutputs: vi.fn(),
|
||||
mockSendNotification: vi.fn(),
|
||||
mockCleanupJobTmp: vi.fn(),
|
||||
@@ -29,10 +27,6 @@ vi.mock('$lib/server/db.js', () => ({
|
||||
setJobStatus: mockSetJobStatus
|
||||
}));
|
||||
|
||||
vi.mock('$lib/server/postprocess.js', () => ({
|
||||
deduplicateSegments: mockDeduplicateSegments
|
||||
}));
|
||||
|
||||
vi.mock('$lib/server/formatter.js', () => ({
|
||||
writeOutputs: mockWriteOutputs
|
||||
}));
|
||||
@@ -91,7 +85,6 @@ function makeSeg(index: number, text: string): Segment {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockDeduplicateSegments.mockImplementation((segs: Segment[]) => segs);
|
||||
mockWriteOutputs.mockResolvedValue({
|
||||
srt: '/out/dir/title.srt',
|
||||
txt: '/out/dir/title.txt',
|
||||
@@ -218,25 +211,21 @@ describe('POST /api/webhook/[jobId] — whisper failure', () => {
|
||||
describe('POST /api/webhook/[jobId] — success with segments', () => {
|
||||
const segments = [makeSeg(0, 'Hello world.'), makeSeg(1, 'This is a test.')];
|
||||
|
||||
it('runs deduplication on received segments', async () => {
|
||||
it('passes received segments through unchanged', async () => {
|
||||
mockGetJob.mockReturnValue(makeJob('job-3'));
|
||||
await POST(makeEvent('job-3', makeWhisperJob({ segments })) as any);
|
||||
expect(mockDeduplicateSegments).toHaveBeenCalledWith(segments);
|
||||
expect(mockWriteOutputs).toHaveBeenCalledWith(segments, 'Test Video', 'job-3');
|
||||
});
|
||||
|
||||
it('calls writeOutputs with the deduplicated segments and job title', async () => {
|
||||
it('calls writeOutputs with the received segments and job title', async () => {
|
||||
mockGetJob.mockReturnValue(makeJob('job-4', 'My Lecture'));
|
||||
const deduped = [makeSeg(0, 'Hello world.')];
|
||||
mockDeduplicateSegments.mockReturnValue(deduped);
|
||||
|
||||
await POST(makeEvent('job-4', makeWhisperJob({ segments })) as any);
|
||||
expect(mockWriteOutputs).toHaveBeenCalledWith(deduped, 'My Lecture', 'job-4');
|
||||
expect(mockWriteOutputs).toHaveBeenCalledWith(segments, 'My Lecture', 'job-4');
|
||||
});
|
||||
|
||||
it('stores serialised segments_json in the database', async () => {
|
||||
mockGetJob.mockReturnValue(makeJob('job-5'));
|
||||
const deduped = [makeSeg(0, 'Result text.')];
|
||||
mockDeduplicateSegments.mockReturnValue(deduped);
|
||||
|
||||
await POST(makeEvent('job-5', makeWhisperJob({ segments })) as any);
|
||||
|
||||
@@ -244,7 +233,7 @@ describe('POST /api/webhook/[jobId] — success with segments', () => {
|
||||
expect.objectContaining({
|
||||
id: 'job-5',
|
||||
status: 'done',
|
||||
segmentsJson: JSON.stringify(deduped)
|
||||
segmentsJson: JSON.stringify(segments)
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user