diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index fb4a7a3..29fcf63 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -18,7 +18,10 @@ serde_json = "1" tauri = { version = "2", features = ["tray-icon", "image-png"] } tauri-plugin-opener = "2" tauri-plugin-global-shortcut = "2" -reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"] } +reqwest = { version = "0.12", default-features = false, features = [ + "blocking", + "rustls-tls", +] } cpal = "0.15.3" hound = "3.5" arboard = "3.6" diff --git a/src-tauri/src/models/mod.rs b/src-tauri/src/models/mod.rs index 6bbf50d..3d55198 100644 --- a/src-tauri/src/models/mod.rs +++ b/src-tauri/src/models/mod.rs @@ -87,7 +87,8 @@ pub fn status_for_path(path: &Path, expected_size: u64) -> ModelInstallStatus { Ok(metadata) if metadata.len() >= expected_size => ModelInstallStatus::Ready, Ok(metadata) => ModelInstallStatus::Error(format!( "arquivo incompleto: {} de {} bytes", - metadata.len(), expected_size + metadata.len(), + expected_size )), Err(_) => ModelInstallStatus::NotInstalled, } @@ -132,7 +133,8 @@ pub fn download_default_model(model_dir: &Path) -> AppResult(command: string): Promise { - calls.push(command); - return baseSnapshot as T; - }, - }; + return { + calls, + async invoke(command: string): Promise { + calls.push(command); + return baseSnapshot as T; + }, + }; } async function flushPromises(): Promise { - 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('#transcript-editor'); + const editor = + mount.querySelector("#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('.primary-button'); - button?.click(); - await flushPromises(); + const button = mount.querySelector(".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"); + }); }); diff --git a/src/main.ts b/src/main.ts index fb55759..ae0ae65 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,10 +1,10 @@ -import './styles.css'; -import { createTranscriptionApp } from './app'; +import "./styles.css"; +import { createTranscriptionApp } from "./app"; -const app = document.querySelector('#app'); +const app = document.querySelector("#app"); if (!app) { - throw new Error('Elemento #app não encontrado.'); + throw new Error("Elemento #app não encontrado."); } createTranscriptionApp(app); diff --git a/vite.config.ts b/vite.config.ts index e624133..80c167b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,14 +1,14 @@ -import { defineConfig } from 'vitest/config'; +import { defineConfig } from "vitest/config"; export default defineConfig({ - clearScreen: false, - server: { - host: '127.0.0.1', - port: 1420, - strictPort: true, - }, - envPrefix: ['VITE_', 'TAURI_'], - test: { - environment: 'jsdom', - }, + clearScreen: false, + server: { + host: "127.0.0.1", + port: 1420, + strictPort: true, + }, + envPrefix: ["VITE_", "TAURI_"], + test: { + environment: "jsdom", + }, });