2026-05-19 02:06:52 +03:00
|
|
|
import { describe, expect, it } from 'vitest';
|
2026-04-30 13:07:37 +03:00
|
|
|
import express from 'express';
|
|
|
|
|
import request from 'supertest';
|
|
|
|
|
|
|
|
|
|
import { registerTtsRoutes } from './routes.js';
|
|
|
|
|
|
|
|
|
|
const createApp = () => {
|
|
|
|
|
const app = express();
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
registerTtsRoutes(app, {
|
|
|
|
|
resolveZenModel: async () => 'gpt-5-nano',
|
|
|
|
|
sayTTSCapability: null,
|
|
|
|
|
});
|
|
|
|
|
return app;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
describe('tts routes', () => {
|
2026-05-19 02:06:52 +03:00
|
|
|
it('returns local note fallback while model summarization is retired', async () => {
|
2026-04-30 13:07:37 +03:00
|
|
|
const response = await request(createApp())
|
|
|
|
|
.post('/api/text/summarize')
|
|
|
|
|
.send({
|
|
|
|
|
text: 'First sentence. Second sentence with the useful insight.',
|
|
|
|
|
threshold: 0,
|
|
|
|
|
maxLength: 100,
|
|
|
|
|
mode: 'note',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
expect(response.body).toMatchObject({
|
2026-05-19 02:06:52 +03:00
|
|
|
summary: 'First sentence.',
|
|
|
|
|
summarized: false,
|
|
|
|
|
reason: 'Model summarization provider unavailable',
|
2026-04-30 13:07:37 +03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-19 02:06:52 +03:00
|
|
|
it('keeps notification fallback behavior without calling zen', async () => {
|
2026-04-30 13:07:37 +03:00
|
|
|
const response = await request(createApp())
|
|
|
|
|
.post('/api/text/summarize')
|
|
|
|
|
.send({
|
|
|
|
|
text: 'Notification text that should fall back cleanly.',
|
|
|
|
|
threshold: 0,
|
|
|
|
|
maxLength: 100,
|
|
|
|
|
mode: 'notification',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
expect(response.body).toMatchObject({
|
|
|
|
|
summary: 'Notification text that should fall back cleanly.',
|
|
|
|
|
summarized: false,
|
2026-05-19 02:06:52 +03:00
|
|
|
reason: 'Model summarization provider unavailable',
|
2026-04-30 13:07:37 +03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|