mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
chore(lint): no-explicit-any in dictation-stream-manager.test
This commit is contained in:
@@ -52,11 +52,9 @@ class FakeRealtimeSession extends EventEmitter implements StreamingTranscription
|
||||
class FakeSttProvider implements SpeechToTextProvider {
|
||||
public readonly id = "fake";
|
||||
constructor(private readonly session: FakeRealtimeSession) {}
|
||||
createSession(_params: {
|
||||
logger: any;
|
||||
language?: string;
|
||||
prompt?: string;
|
||||
}): StreamingTranscriptionSession {
|
||||
createSession(
|
||||
_params: Parameters<SpeechToTextProvider["createSession"]>[0],
|
||||
): StreamingTranscriptionSession {
|
||||
return this.session;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +87,7 @@ describe("DictationStreamManager (finish buffer-too-small tolerance)", () => {
|
||||
|
||||
it("treats buffer-too-small as benign and finalizes with existing transcripts", async () => {
|
||||
const session = new FakeRealtimeSession();
|
||||
const emitted: Array<{ type: string; payload: any }> = [];
|
||||
const emitted: Array<{ type: string; payload: unknown }> = [];
|
||||
const manager = new DictationStreamManager({
|
||||
logger: pino({ level: "silent" }),
|
||||
emit: (msg) => emitted.push(msg),
|
||||
@@ -119,7 +117,7 @@ describe("DictationStreamManager (finish buffer-too-small tolerance)", () => {
|
||||
const final = emitted.find((msg) => msg.type === "dictation_stream_final");
|
||||
const error = emitted.find((msg) => msg.type === "dictation_stream_error");
|
||||
expect(error).toBeUndefined();
|
||||
expect(final?.payload.text).toBe("hello world");
|
||||
expect((final?.payload as { text?: string } | undefined)?.text).toBe("hello world");
|
||||
expect(session.closed).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -131,7 +129,7 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
|
||||
try {
|
||||
const session = new FakeRealtimeSession();
|
||||
const emitted: Array<{ type: string; payload: any }> = [];
|
||||
const emitted: Array<{ type: string; payload: unknown }> = [];
|
||||
const manager = new DictationStreamManager({
|
||||
logger: pino({ level: "silent" }),
|
||||
emit: (msg) => emitted.push(msg),
|
||||
@@ -158,7 +156,7 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
|
||||
try {
|
||||
const session = new FakeRealtimeSession();
|
||||
const emitted: Array<{ type: string; payload: any }> = [];
|
||||
const emitted: Array<{ type: string; payload: unknown }> = [];
|
||||
const manager = new DictationStreamManager({
|
||||
logger: pino({ level: "silent" }),
|
||||
emit: (msg) => emitted.push(msg),
|
||||
@@ -195,7 +193,7 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
await tick();
|
||||
|
||||
const final = emitted.find((msg) => msg.type === "dictation_stream_final");
|
||||
expect(final?.payload.text).toBe("hello world");
|
||||
expect((final?.payload as { text?: string } | undefined)?.text).toBe("hello world");
|
||||
} finally {
|
||||
if (originalDebug === undefined) {
|
||||
delete process.env.PASEO_DICTATION_DEBUG;
|
||||
@@ -207,7 +205,7 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
|
||||
it("adapts finish timeout based on pending committed segments", async () => {
|
||||
const session = new FakeRealtimeSession();
|
||||
const emitted: Array<{ type: string; payload: any }> = [];
|
||||
const emitted: Array<{ type: string; payload: unknown }> = [];
|
||||
const manager = new DictationStreamManager({
|
||||
logger: pino({ level: "silent" }),
|
||||
emit: (msg) => emitted.push(msg),
|
||||
@@ -231,12 +229,14 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
|
||||
const finishAccepted = emitted.find((msg) => msg.type === "dictation_stream_finish_accepted");
|
||||
expect(finishAccepted).toBeDefined();
|
||||
expect(finishAccepted?.payload.timeoutMs).toBeGreaterThan(5000);
|
||||
expect(
|
||||
(finishAccepted?.payload as { timeoutMs?: number } | undefined)?.timeoutMs,
|
||||
).toBeGreaterThan(5000);
|
||||
});
|
||||
|
||||
it("adapts finish timeout when only uncommitted non-final transcripts are pending", async () => {
|
||||
const session = new FakeRealtimeSession();
|
||||
const emitted: Array<{ type: string; payload: any }> = [];
|
||||
const emitted: Array<{ type: string; payload: unknown }> = [];
|
||||
const manager = new DictationStreamManager({
|
||||
logger: pino({ level: "silent" }),
|
||||
emit: (msg) => emitted.push(msg),
|
||||
@@ -261,7 +261,9 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
|
||||
const finishAccepted = emitted.find((msg) => msg.type === "dictation_stream_finish_accepted");
|
||||
expect(finishAccepted).toBeDefined();
|
||||
expect(finishAccepted?.payload.timeoutMs).toBeGreaterThan(5000);
|
||||
expect(
|
||||
(finishAccepted?.payload as { timeoutMs?: number } | undefined)?.timeoutMs,
|
||||
).toBeGreaterThan(5000);
|
||||
});
|
||||
|
||||
it("drops dangling uncommitted non-final transcripts when finishing after silence tail clear", async () => {
|
||||
@@ -270,7 +272,7 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
process.env.PASEO_DICTATION_DEBUG = "false";
|
||||
try {
|
||||
const session = new FakeRealtimeSession();
|
||||
const emitted: Array<{ type: string; payload: any }> = [];
|
||||
const emitted: Array<{ type: string; payload: unknown }> = [];
|
||||
const manager = new DictationStreamManager({
|
||||
logger: pino({ level: "silent" }),
|
||||
emit: (msg) => emitted.push(msg),
|
||||
@@ -307,7 +309,7 @@ describe("DictationStreamManager (provider-agnostic provider)", () => {
|
||||
const error = emitted.find((msg) => msg.type === "dictation_stream_error");
|
||||
expect(session.clearCalls).toBeGreaterThan(0);
|
||||
expect(error).toBeUndefined();
|
||||
expect(final?.payload.text).toBe("hello");
|
||||
expect((final?.payload as { text?: string } | undefined)?.text).toBe("hello");
|
||||
} finally {
|
||||
process.env.PASEO_DICTATION_DEBUG = previousDebug;
|
||||
vi.useRealTimers();
|
||||
|
||||
Reference in New Issue
Block a user