chore: apply formatter updates

This commit is contained in:
Evandro committed 2026-06-11 01:19:07 -03:00
1 parent 8f754b3f00
commit b111ae0a76
5 files changed
+110 -97

No files matched your search

+82 -77
View File
@@ -1,98 +1,103 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { beforeEach, describe, expect, it } from "vitest";
import { createTranscriptionApp, type AppSnapshot, type NativeClient } from './app';
import {
createTranscriptionApp,
type AppSnapshot,
type NativeClient,
} from "./app";
const baseSnapshot: AppSnapshot = {
recordingStatus: 'idle',
transcript: {
text: 'Texto inicial',
lastMessage: 'Revise o texto antes de inserir.',
},
settings: {
transcription: {
mode: 'localFirst',
modelId: 'parakeet-tdt-0.6b-v3-q8_0',
language: null,
openaiCompatible: {
endpoint: 'https://api.openai.com/v1/audio/transcriptions',
apiKeyConfigured: false,
model: 'whisper-1',
},
},
insertion: {
method: 'clipboardPaste',
restoreClipboard: true,
waylandManualFallback: true,
},
storage: {
keepAudio: false,
audioFormat: 'wav',
},
},
models: [
{
model: {
id: 'parakeet-tdt-0.6b-v3-q8_0',
displayName: 'Parakeet TDT 0.6B v3 Q8',
repository: 'cstr/parakeet-tdt-0.6b-v3-GGUF',
filename: 'parakeet-tdt-0.6b-v3-q8_0.gguf',
quantization: 'Q8_0',
sizeBytes: 745_121_600,
languages: ['pt'],
recommendedForSimplePc: true,
},
status: 'notInstalled',
},
],
recordingStatus: "idle",
transcript: {
text: "Texto inicial",
lastMessage: "Revise o texto antes de inserir.",
},
settings: {
transcription: {
mode: "localFirst",
modelId: "parakeet-tdt-0.6b-v3-q8_0",
language: null,
openaiCompatible: {
endpoint: "https://api.openai.com/v1/audio/transcriptions",
apiKeyConfigured: false,
model: "whisper-1",
},
},
insertion: {
method: "clipboardPaste",
restoreClipboard: true,
waylandManualFallback: true,
},
storage: {
keepAudio: false,
audioFormat: "wav",
},
},
models: [
{
model: {
id: "parakeet-tdt-0.6b-v3-q8_0",
displayName: "Parakeet TDT 0.6B v3 Q8",
repository: "cstr/parakeet-tdt-0.6b-v3-GGUF",
filename: "parakeet-tdt-0.6b-v3-q8_0.gguf",
quantization: "Q8_0",
sizeBytes: 745_121_600,
languages: ["pt"],
recommendedForSimplePc: true,
},
status: "notInstalled",
},
],
};
function createFakeClient(): NativeClient & { calls: string[] } {
const calls: string[] = [];
const calls: string[] = [];
return {
calls,
async invoke<T>(command: string): Promise<T> {
calls.push(command);
return baseSnapshot as T;
},
};
return {
calls,
async invoke<T>(command: string): Promise<T> {
calls.push(command);
return baseSnapshot as T;
},
};
}
async function flushPromises(): Promise<void> {
await new Promise((resolve) => window.setTimeout(resolve, 0));
await new Promise((resolve) => window.setTimeout(resolve, 0));
}
describe('createTranscriptionApp', () => {
beforeEach(() => {
document.body.textContent = '';
});
describe("createTranscriptionApp", () => {
beforeEach(() => {
document.body.textContent = "";
});
it('renders editable transcript modal with offline model details', async () => {
const mount = document.createElement('main');
const client = createFakeClient();
it("renders editable transcript modal with offline model details", async () => {
const mount = document.createElement("main");
const client = createFakeClient();
createTranscriptionApp(mount, client);
await flushPromises();
createTranscriptionApp(mount, client);
await flushPromises();
const editor = mount.querySelector<HTMLTextAreaElement>('#transcript-editor');
const editor =
mount.querySelector<HTMLTextAreaElement>("#transcript-editor");
expect(editor?.value).toBe('Texto inicial');
expect(mount.textContent).toContain('Parakeet TDT 0.6B v3 Q8');
expect(mount.textContent).toContain('Offline primeiro');
});
expect(editor?.value).toBe("Texto inicial");
expect(mount.textContent).toContain("Parakeet TDT 0.6B v3 Q8");
expect(mount.textContent).toContain("Offline primeiro");
});
it('calls native start command when record button is pressed', async () => {
const mount = document.createElement('main');
const client = createFakeClient();
it("calls native start command when record button is pressed", async () => {
const mount = document.createElement("main");
const client = createFakeClient();
createTranscriptionApp(mount, client);
await flushPromises();
createTranscriptionApp(mount, client);
await flushPromises();
const button = mount.querySelector<HTMLButtonElement>('.primary-button');
button?.click();
await flushPromises();
const button = mount.querySelector<HTMLButtonElement>(".primary-button");
button?.click();
await flushPromises();
expect(client.calls).toContain('get_app_snapshot');
expect(client.calls).toContain('start_recording');
});
expect(client.calls).toContain("get_app_snapshot");
expect(client.calls).toContain("start_recording");
});
});
+4 -4
View File
@@ -1,10 +1,10 @@
import './styles.css';
import { createTranscriptionApp } from './app';
import "./styles.css";
import { createTranscriptionApp } from "./app";
const app = document.querySelector<HTMLElement>('#app');
const app = document.querySelector<HTMLElement>("#app");
if (!app) {
throw new Error('Elemento #app não encontrado.');
throw new Error("Elemento #app não encontrado.");
}
createTranscriptionApp(app);