### Victauri CLI Setup Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Install the Victauri CLI and initialize the project. This is the first step in setting up Victauri for testing your Tauri application. ```bash cargo install victauri-cli victauri init ``` -------------------------------- ### Verify Victauri with CLI Source: https://github.com/4da-systems/victauri/blob/main/docs/src/getting-started.md Install the `victauri-cli` and use the `victauri check` command for an alternative way to verify your setup. ```bash cargo install victauri-cli victauri check ``` -------------------------------- ### Install Rust and Tools on Host Source: https://github.com/4da-systems/victauri/blob/main/scripts/deep-test/README.md Installs Rust and essential tools like jq, sqlite, and git. Adapt package manager commands for Linux. Ensure Rustup is sourced. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source "$HOME/.cargo/env" # macOS: brew install jq sqlite git # Linux: sudo apt-get install -y jq sqlite3 git libwebkit2gtk-4.1-dev xvfb git clone https://github.com/4DA-Systems/victauri.git cd victauri ``` -------------------------------- ### Install victauri-cli Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-cli/README.md Installs the victauri-cli tool using cargo. ```bash cargo install victauri-cli ``` -------------------------------- ### Run Victauri Demo App Source: https://github.com/4da-systems/victauri/blob/main/examples/demo-app/README.md Navigate to the demo app directory and start the Tauri development server. ```bash cd examples/demo-app cargo tauri dev ``` -------------------------------- ### Start, Checkpoint, Stop, and Replay Recording Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Use these actions to manage session recording. Start recording, create checkpoints for specific states, stop recording to finalize the session, and then replay it. ```json {"action": "start"} ``` ```json {"action": "checkpoint", "label": "after-login"} ``` ```json {"action": "stop"} ``` ```json {"action": "replay"} ``` -------------------------------- ### Install victauri-watchdog Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-watchdog/README.md Installs the victauri-watchdog tool using cargo. ```bash cargo install victauri-watchdog ``` -------------------------------- ### Full VictauriBuilder Example in Rust Source: https://github.com/4da-systems/victauri/blob/main/docs/src/configuration.md A comprehensive example of configuring the Victauri plugin using VictauriBuilder in Rust. It demonstrates setting network options, authentication, privacy profiles, redaction patterns, capacity limits, event listening, and command definitions. ```rust use std::time::Duration; use victauri_plugin::{VictauriBuilder, PrivacyProfile}; tauri::Builder::default() .plugin( VictauriBuilder::new() // Network .port(7373) .eval_timeout(Duration::from_secs(30)) // Auth .auth_token("dev-token-123") // Privacy .privacy_profile(PrivacyProfile::Test) .command_blocklist(&["dangerous_command"]) .disable_tools(&["screenshot"]) // Redaction .enable_redaction() .add_redaction_pattern(r"password=\w+") // Capacity .event_capacity(20_000) .recorder_capacity(100_000) .console_log_capacity(2000) // Commands .commands(&[greet__schema(), increment__schema()]) // Event bus .listen_events(&["app-event", "sync-complete"]) // Callback .on_ready(|port| println!("MCP server on :{:?}", port)) .build().unwrap(), ) .invoke_handler(tauri::generate_handler![greet, increment]) .run(tauri::generate_context!()) .unwrap(); ``` -------------------------------- ### Manual CI Setup for Tauri App Testing Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Set up a manual CI process to test your Tauri application. This involves starting the app, waiting for it to become available, and then running Victauri tests and coverage checks. ```yaml - name: Start app run: xvfb-run --auto-servernum cargo run -p my-app & - name: Wait for server run: | for i in $(seq 1 30); do curl -sf http://127.0.0.1:7373/health && break sleep 1 done - name: Test run: victauri test --junit results.xml - name: Coverage run: victauri coverage --threshold 80 ``` -------------------------------- ### Victauri Locator API Example Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Demonstrates using Victauri's Locator API for composable element queries, similar to Playwright. This example shows filling an input, clicking a button, and asserting text content using locators. ```rust e2e_test!(locator_example, |client| async move { Locator::test_id("name-input") .fill(&mut client, "Bob") .await .unwrap(); Locator::text("Greet") .click(&mut client) .await .unwrap(); Locator::test_id("greet-result") .expect(&mut client) .to_contain_text("Hello, Bob!") .await .unwrap(); }); ``` -------------------------------- ### Initialize Victauri Project Setup Source: https://github.com/4da-systems/victauri/blob/main/README.md Run this command from your Tauri project root to add Victauri plugin and test dependencies to your Cargo.toml and create starter smoke tests. ```bash victauri init ``` -------------------------------- ### Run victauri-watchdog with default settings Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-watchdog/README.md Starts the watchdog to poll localhost on port 7373 every 5 seconds. ```bash victauri-watchdog ``` -------------------------------- ### Start, Status, Stop, and Frame Capture for Trace Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Use this JSON to control the trace tool. Start capturing with specified intervals and frame limits, check the status, stop the capture, and retrieve frames as base64 PNGs. Set `with_events: true` to bundle IPC/DOM/console timelines. ```json {"action": "start", "interval_ms": 250, "max_frames": 40, "with_events": true} ``` ```json {"action": "status"} ``` ```json {"action": "stop"} ``` ```json {"action": "frames", "limit": 10} ``` -------------------------------- ### Locator API Examples Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-test/README.md Illustrates the usage of the Locator API for finding and interacting with elements, including filling input fields and performing actions. ```rust use victauri_test::locator::Locator; // Factory → refinement → action Locator::role("button").and_text("Save").click(&mut client).await?; Locator::test_id("email-input").fill(&mut client, "user@example.com").await?; Locator::placeholder("Search...").fill(&mut client, "query").await?; ``` ```rust use victauri_test::locator::Locator; // Expectations with auto-wait Locator::test_id("toast") .expect(&mut client) .to_be_visible() .await?; ``` ```rust use victauri_test::locator::Locator; Locator::css("#counter") .expect(&mut client) .to_have_text("42") .await?; ``` -------------------------------- ### Basic Victauri Setup with Tauri Source: https://github.com/4da-systems/victauri/blob/main/docs/src/configuration.md Integrates the Victauri plugin into a Tauri application, setting a specific port and authentication token. ```rust use victauri_plugin::VictauriBuilder; tauri::Builder::default() .plugin( VictauriBuilder::new() .port(8080) .auth_token("my-fixed-token") .build().unwrap(), ) .run(tauri::generate_context!().unwrap(); ``` -------------------------------- ### Initialize Victauri Plugin Source: https://github.com/4da-systems/victauri/blob/main/docs/src/faq.md Ensure the Victauri plugin is initialized before calling `.run()`. This is crucial for the MCP server to start correctly. ```rust .plugin(victauri_plugin::init()) ``` -------------------------------- ### Time-Travel Recording and Replay Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Record user interactions and replay them later. This example starts recording, performs actions, stops recording, and asserts that events were captured. ```rust e2e_test!(recording, |client| async move { client.start_recording(None).await.unwrap(); // Do some actions client.invoke_command("increment", None).await.unwrap(); client.invoke_command("increment", None).await.unwrap(); let session = client.stop_recording().await.unwrap(); let events = session["events"].as_array().unwrap(); assert!(!events.is_empty()); }); ``` -------------------------------- ### Full Locator Example in a Test Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Demonstrates a complete test flow using Victauri's Locator API, including client discovery, element interaction (fill, click), and assertions with auto-waiting expectations. ```rust use victauri_test::prelude::*; #[tokio::test] async fn settings_flow() { if !is_e2e() { return; } let mut client = VictauriClient::discover().await.unwrap(); let save_btn = Locator::role("button").and_text("Save"); let email = Locator::label("Email address"); let toast = Locator::test_id("toast-message"); email.fill(&mut client, "user@example.com").await.unwrap(); save_btn.click(&mut client).await.unwrap(); toast.expect(&mut client) .to_contain_text("Settings saved") .await .unwrap(); toast.expect(&mut client) .timeout_ms(10_000) .not() .to_be_visible() .await .unwrap(); } ``` -------------------------------- ### Diagnose Tauri Project Setup Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-cli/README.md Runs a comprehensive diagnostic check on the project structure, dependencies, and Victauri plugin wiring. ```bash victauri doctor ``` -------------------------------- ### Initialize Victauri Plugin in Tauri Builder Source: https://github.com/4da-systems/victauri/blob/main/docs/src/getting-started.md Integrate the victauri::init() function into your Tauri application's builder in `src-tauri/src/main.rs`. This starts an MCP server in debug builds and is a no-op in release builds. ```rust fn main() { tauri::Builder::default() .plugin(victauri_plugin::init()) // ... your other plugins and setup .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` -------------------------------- ### Advanced Victauri Plugin Configuration Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-plugin/README.md Use `VictauriBuilder` for advanced setup options such as setting the port, authentication token, disabling specific tools, and enabling redaction with custom patterns. ```rust victauri_plugin::VictauriBuilder::new() .port(8080) .auth_token("my-secret-token") .disable_tools(&["screenshot"]) .add_redaction_pattern(r"\b\d{3}-\d{2}-\d{4}\b") .enable_redaction() .build() .expect("valid config") ``` -------------------------------- ### Inspect UI with dom_snapshot() Source: https://github.com/4da-systems/victauri/blob/main/examples/agent-session.md Use `dom_snapshot()` to get a compact, accessible-text representation of the current UI. This is useful for understanding the rendered elements and their hierarchy. ```shell → dom_snapshot() Result (compact accessible-text format): [e0] main [e1] div.todo-list [e2] listitem "Buy groceries" [e3] listitem "Write tests" [e4] listitem "Deploy v2" [e5] div.settings-panel [hidden] Note: ref handles (e0-e5) are stable across calls. Use format: "json" for full accessibility tree. ``` -------------------------------- ### GitHub Actions for Victauri Testing Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Example GitHub Actions workflow for running Victauri tests, including coverage and JUnit reporting. ```yaml # .github/workflows/test.yml - name: Start app run: xvfb-run --auto-servernum cargo run -p my-app & - uses: 4DA-Systems/victauri/.github/actions/victauri-test@v0.8.1 with: max-load-ms: 5000 max-heap-mb: 256 coverage: true coverage-threshold: 80 junit-path: results.xml ``` -------------------------------- ### Get Settings from Backend Source: https://github.com/4da-systems/victauri/blob/main/scripts/agent-eval/tasks.md Retrieve current settings persisted on the backend. This command is used to verify the backend's truth state for settings. ```bash invoke_command get_settings ``` -------------------------------- ### Window: Get State Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieves the current state (position, size, visibility) of a specified window. ```json {"action": "get_state", "label": "main"} ``` -------------------------------- ### Configure victauri-watchdog with Environment Variables Source: https://github.com/4da-systems/victauri/blob/main/docs/src/configuration.md Set environment variables to customize the behavior of the victauri-watchdog. This example overrides the default port, sets the maximum number of failures before recovery, and specifies a shell command to execute on failure. ```bash VICTAURI_PORT=7373 VICTAURI_MAX_FAILURES=5 VICTAURI_ON_FAILURE="notify-send 'App crashed'" victauri-watchdog ``` -------------------------------- ### Window Tool Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Manage browser windows, including getting state, listing windows, manipulating size and position, and setting titles. Also includes an introspectability check. ```APIDOC ## window Window management operations. ### Actions - **get_state**: Get window state (position, size, visibility). Requires `label`. - **list**: List all window labels. No parameters. - **manage**: Minimize/unminimize/maximize/unmaximize/close a window. Requires `label` and `operation`. - **resize**: Resize a window. Requires `label`, `width`, and `height`. - **move_to**: Move a window. Requires `label`, `x`, and `y`. - **set_title**: Change window title. Requires `label` and `title`. - **introspectability**: Probe every window's JS bridge and report which are introspectable vs. blind. No parameters. ### Introspectability Explanation `introspectability` answers "which windows can Victauri actually see?" A window that returns `introspectable: false` while `visible: true` is almost always missing the `victauri:default` capability — Tauri's per-window permission ACL silently blocks the bridge's callback IPC, so `eval_js`/`dom_snapshot`/`animation`/`find_elements` see nothing with no error. The diagnostic names the exact capability file to edit. Required per window (not just `main`). ### Examples ```json {"action": "list"} {"action": "get_state", "label": "main"} {"action": "resize", "label": "main", "width": 1200, "height": 800} {"action": "introspectability"} ``` ``` -------------------------------- ### Introspect Actions for Backend Source: https://github.com/4da-systems/victauri/blob/main/MIGRATION.md Use the introspect tool to perform deep backend analysis. Examples include command timings, coverage, and contract checks. ```json {"action": "command_timings", "slow_threshold_ms": 100} ``` ```json {"action": "coverage"} ``` ```json {"action": "contract_record", "command": "get_settings"} ``` ```json {"action": "contract_check"} ``` ```json {"action": "startup_timing"} ``` ```json {"action": "capabilities"} ``` ```json {"action": "db_health"} ``` ```json {"action": "plugin_state"} ``` ```json {"action": "processes"} ``` ```json {"action": "plugin_tasks"} ``` ```json {"action": "event_bus"} ``` -------------------------------- ### Run Victauri Smoke Tests Source: https://github.com/4da-systems/victauri/blob/main/README.md Start your Tauri application in development mode and then run the smoke test suite using Cargo. This verifies your integration. ```bash pnpm tauri dev # start your app VICTAURI_E2E=1 cargo test --test smoke # run tests ``` -------------------------------- ### List Available Tools via REST API Source: https://github.com/4da-systems/victauri/blob/main/docs/src/getting-started.md Query the `/api/tools` endpoint using `curl` to get a list of all available tools provided by Victauri. ```bash curl http://127.0.0.1:7373/api/tools ``` -------------------------------- ### Configure WebDriver for Tauri Apps Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Configure WebdriverIO to run tests against a Tauri application. This setup requires specifying the path to the Tauri application binary. ```javascript // wdio.conf.js exports.config = { capabilities: [{ 'tauri:options': { application: '../src-tauri/target/debug/my-app', }, }], }; ``` -------------------------------- ### CI Build and Test Local CLI Source: https://github.com/4da-systems/victauri/blob/main/CHANGELOG.md Configures the CI job to build and test the local `victauri-cli` instead of installing the published crate. This ensures that the code being released is validated. ```bash victauri test --cli-source-path=../victauri-cli ``` -------------------------------- ### Basic Victauri Interaction Test Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md A fundamental e2e test using Victauri's `e2e_test!` macro. This example demonstrates filling an input field, clicking a button, and verifying the UI update. ```rust use victauri_test::{e2e_test, locator::Locator}; use serde_json::json; // Basic interaction test e2e_test!(greet_flow, |client| async move { // Fill the input client.fill_by_id("name-input", "Alice").await.unwrap(); // Click the button client.click_by_id("greet-btn").await.unwrap(); // Verify the UI updated client.expect_text("Hello, Alice!").await.unwrap(); }); ``` -------------------------------- ### Perform Fluent Verification in Rust Source: https://github.com/4da-systems/victauri/blob/main/README.md This example shows how to chain multiple verification checks into a single operation for comprehensive testing. It covers UI text, IPC calls, console errors, ghost commands, IPC health, and code coverage. Use this for a consolidated test report. ```rust client.verify() .has_text("Settings saved") .ipc_was_called("save_settings") .no_console_errors() .no_ghost_commands() .ipc_healthy() .coverage_above(80.0) .run() .await? .assert_all_passed(); ``` -------------------------------- ### Build Demo App Source: https://github.com/4da-systems/victauri/blob/main/CONTRIBUTING.md Build the demo application located in `examples/demo-app/` to verify that changes to the plugin API do not break its functionality. ```bash cargo build -p demo-app ``` -------------------------------- ### Run Victauri Smoke Tests in GitHub Actions Source: https://github.com/4da-systems/victauri/blob/main/README.md Use this composite action in your CI to run Victauri smoke tests. It installs the CLI, waits for the server, and executes tests. Configure inputs like `max-load-ms` and `max-heap-mb` as needed. ```yaml - name: Build my app run: cargo build -p my-app - name: Start app under xvfb run: | xvfb-run -a ./target/debug/my-app & sleep 3 - uses: 4DA-Systems/victauri/.github/actions/victauri-test@v0.8.1 with: max-load-ms: 10000 max-heap-mb: 512 ``` -------------------------------- ### End-to-End Test with Composable Locators Source: https://github.com/4da-systems/victauri/blob/main/README.md For complex queries, utilize the composable Locator API with auto-waiting expectations. This example shows filling an input and clicking a button using locators, then asserting that a toast message appears. ```rust use victauri_test::prelude::*; e2e_test!(settings_flow, |client| async move { let save = Locator::role("button").and_text("Save"); let email = Locator::label("Email address"); email.fill(&mut client, "user@example.com").await.unwrap(); save.click(&mut client).await.unwrap(); Locator::test_id("toast-message") .expect(&mut client) .to_contain_text("Settings saved") .await .unwrap(); }); ``` -------------------------------- ### Configure AI Agent Connection Source: https://github.com/4da-systems/victauri/blob/main/README.md Add a .mcp.json file to your project root to configure how an AI agent connects to your Victauri-enabled application. This example uses the 'victauri bridge' command for dynamic port discovery. ```json { "mcpServers": { "my-app": { "command": "victauri", "args": ["bridge", "--wait"] } } } ``` -------------------------------- ### Playwright Electron App Example (Not for Tauri) Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md This Playwright code snippet demonstrates connecting to an Electron app. It is explicitly noted that this approach does not work for Tauri apps, which require connecting to the webview's DevTools port with platform-dependent CDP support. ```typescript import { _electron as electron } from 'playwright'; // This only works for Electron apps, not Tauri. // For Tauri, you'd need to connect to the webview's DevTools port, // which requires CDP support that varies by platform. ``` -------------------------------- ### Evaluate JavaScript in Specific Window via REST Source: https://github.com/4da-systems/victauri/blob/main/docs/src/compatibility.md This example shows how to evaluate JavaScript in a specific window by using the webview_label field when calling the eval_js tool over the REST API. It targets the 'settings' window to get its document title. ```json POST /api/tools/eval_js {"code": "document.title", "webview_label": "settings"} ``` -------------------------------- ### Initialize and Use EventLog and CommandRegistry Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-core/README.md Demonstrates initializing an EventLog with a specific capacity and creating a CommandRegistry. Includes registering a command and performing a search. ```rust use victauri_core::{EventLog, CommandRegistry, CommandInfo}; // Ring buffer with capacity 1000 let log = EventLog::new(1000); assert!(log.is_empty()); assert_eq!(log.capacity(), 1000); // Command registry with search let registry = CommandRegistry::new(); registry.register(CommandInfo { name: "greet".to_string(), plugin: None, description: Some("Greet the user".to_string()), args: vec![], return_type: None, is_async: false, intent: None, category: None, examples: vec![], }); let results = registry.search("greet"); assert_eq!(results.len(), 1); ``` -------------------------------- ### GitHub Actions for Tauri App Testing Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Configure GitHub Actions to automatically build and test your Tauri application. This includes starting the app and running Victauri tests with coverage reporting. ```yaml - name: Start app run: xvfb-run --auto-servernum cargo run -p my-app & - uses: 4DA-Systems/victauri/.github/actions/victauri-test@v0.8.1 with: max-load-ms: 5000 coverage: true coverage-threshold: 80 junit-path: results.xml ``` -------------------------------- ### Initialize Victauri Project Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-cli/README.md Sets up a new Tauri project with Victauri. Can be run without arguments for the current directory or with a specific path. ```bash victauri init victauri init ./my-tauri-app ``` -------------------------------- ### Navigation: Get History Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieves the browser's navigation history log. ```json {"action": "history"} ``` -------------------------------- ### Get Memory Stats Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Retrieves detailed memory usage statistics for the Victauri process. ```APIDOC ## POST /api/tools/get_memory_stats ### Description Fetches memory statistics for the Victauri application. ### Method POST ### Endpoint /api/tools/get_memory_stats ### Response #### Success Response (200) - stats (object) - An object containing memory usage details. ``` -------------------------------- ### Interact with UI and Verify Backend Calls Source: https://github.com/4da-systems/victauri/blob/main/examples/agent-session.md Simulate user interactions like filling input fields and clicking buttons, then verify that the expected backend commands are invoked with the correct arguments. ```shell → input(action: "fill", ref_id: "e10", value: "Write tests") → interact(action: "click", ref_id: "e12") → logs(action: "ipc", limit: 1) Result: IPC call captured command: "add_item" request_args: {"text": "Write tests"} response_body: {"id": 6, "text": "Write tests", "done": false} duration: 2ms ``` -------------------------------- ### Storage: Get LocalStorage Item Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieves a value from the browser's localStorage using its key. ```json {"action": "get", "key": "theme"} ``` -------------------------------- ### Clone Repository and Build Project Source: https://github.com/4da-systems/victauri/blob/main/CONTRIBUTING.md Clone the Victauri repository, navigate into the directory, and build the entire workspace. This also includes running all tests to ensure a clean state. ```bash git clone https://github.com/4DA-Systems/victauri.git cd victauri cargo build --workspace cargo test --workspace ``` -------------------------------- ### Inspect App Configuration and Paths Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Retrieve application information, including its configuration and file paths. Useful for verifying deployment settings. ```rust let info = client.app_info().await?; println!("App: {}", info["config"]["product_name"]); println!("Data dir: {}", info["paths"]["data"]); println!("Databases found: {:?}", info["databases"]) ``` -------------------------------- ### Build, Test, and Lint Rust Workspace Source: https://github.com/4da-systems/victauri/blob/main/README.md Commands for building all crates, running tests, executing benchmarks, linting with clippy, and formatting code. Use `cargo build --workspace` to build all crates, `cargo test --workspace` to run all tests, `cargo bench -p victauri-core` for benchmarks, `cargo clippy --workspace --all-targets` for linting, and `cargo fmt --all -- --check` for formatting. ```bash cargo build --workspace ``` ```bash cargo test --workspace ``` ```bash cargo bench -p victauri-core ``` ```bash cargo clippy --workspace --all-targets ``` ```bash cargo fmt --all -- --check ``` ```bash RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps ``` -------------------------------- ### Initialize Victauri CI Workflow Source: https://github.com/4da-systems/victauri/blob/main/README.md Run this command to generate a complete CI workflow file for your project, typically named `.github/workflows/victauri.yml`. ```bash victauri init # generates .github/workflows/victauri.yml ``` -------------------------------- ### Opt-in to file:// URL Navigation Source: https://github.com/4da-systems/victauri/blob/main/MIGRATION.md Use this method to explicitly allow navigation to local file URLs, which is blocked by default for security reasons. ```rust VictauriBuilder::new() .allow_file_navigation() .build() ``` -------------------------------- ### Storage Tool Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Interact with browser's localStorage and cookies. Supports getting, setting, and deleting localStorage items, and retrieving all cookies. ```APIDOC ## storage Browser storage operations. ### Actions - **get**: Get localStorage value. Requires `key`. - **set**: Set localStorage value. Requires `key` and `value`. - **delete**: Delete localStorage key. Requires `key`. - **cookies**: Get all cookies. No parameters. ### Examples ```json {"action": "set", "key": "theme", "value": "dark"} {"action": "get", "key": "theme"} ``` ``` -------------------------------- ### Victauri REST API: Get Memory Stats Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Fetch memory usage statistics from the Tauri application using the Victauri REST API. ```bash # Get memory stats curl -X POST http://127.0.0.1:7373/api/tools/get_memory_stats ``` -------------------------------- ### Greet Functionality Source: https://github.com/4da-systems/victauri/blob/main/examples/demo-app/frontend/index.html Invokes the 'greet' backend command with a user-provided name and displays the result. Supports Enter key submission. ```javascript // === Greet === document.getElementById("greet-btn").addEventListener("click", async () => { const name = document.getElementById("name-input").value || "World"; const result = await invoke("greet", { name }); document.getElementById("greet-result").textContent = result; }); document.getElementById("name-input").addEventListener("keydown", (e) => { if (e.key === "Enter") document.getElementById("greet-btn").click(); }); ``` -------------------------------- ### Initialize Victauri Plugin Source: https://github.com/4da-systems/victauri/blob/main/docs/src/architecture.md Initializes the Victauri plugin. In debug builds, it sets up the full MCP server. In release builds, it's a no-op to ensure zero runtime cost. ```rust pub fn init() -> TauriPlugin { #[cfg(debug_assertions)] { /* full MCP server setup */ } #[cfg(not(debug_assertions))] { /* no-op plugin — zero runtime cost */ } } ``` -------------------------------- ### Recording Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Time-travel recording for session capture and replay. Allows starting, stopping, creating checkpoints, retrieving events, exporting, importing, and replaying sessions. ```APIDOC ## recording ### Description Time-travel recording for session capture and replay. ### Actions - `start`: Start recording events - `stop`: Stop recording and return session - `checkpoint`: Create a named checkpoint. Parameters: `label` (alias: `checkpoint_label`) - `events`: Get recorded events. Parameters: `since`, `limit` - `export`: Export full session data (works after stop) - `import`: Import a session for replay. Parameters: `session` - `replay`: Re-execute recorded IPC commands and report pass/fail per command (works after stop). Parameters: `webview_label` ### Example ```json {"action": "start"} {"action": "checkpoint", "label": "after-login"} {"action": "stop"} {"action": "replay"} ``` ``` -------------------------------- ### Allow File Navigation Source: https://github.com/4da-systems/victauri/blob/main/docs/src/configuration.md Enable the `navigate` tool to access `file://` URLs, in addition to the default `http://` and `https://`. ```rust VictauriBuilder::new() .allow_file_navigation() .build().unwrap() ``` -------------------------------- ### app_info Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieves application configuration, directory paths, environment details, discovered databases, and process information. ```APIDOC ## POST /api/tools/app_info ### Description Get application configuration, directory paths, environment, discovered databases, and process info. ### Method POST ### Endpoint /api/tools/app_info ### Parameters None required. ### Response #### Success Response (200) - **config** (object) - Application configuration details. - **paths** (object) - Application directory paths. - **databases** (array) - List of discovered databases. - **process** (object) - Information about the application process. - **environment** (object) - Environment variables. ``` -------------------------------- ### Verify Victauri Health and Info Endpoints Source: https://github.com/4da-systems/victauri/blob/main/docs/src/getting-started.md After starting your Tauri app, use `curl` to check the `/health` and `/info` endpoints to ensure Victauri is running correctly. ```bash curl http://127.0.0.1:7373/health # Returns: ok curl http://127.0.0.1:7373/info # Returns: {"name":"victauri","port":7373,"protocol":"mcp","version":"0.7.8",...} ``` -------------------------------- ### Load Application Settings Source: https://github.com/4da-systems/victauri/blob/main/examples/demo-app/frontend/index.html Asynchronously loads application settings (theme, language, notifications) from the backend and updates the UI elements accordingly. ```javascript async function loadSettings() { const s = await invoke("get_settings"); document.getElementById("theme-select").value = s.theme; document.getElementById("lang-select").value = s.language; const toggle = document.getElementById("notif-toggle"); toggle.className = "toggle" + (s.notifications_enabled ? " on" : ""); toggle.setAttribute("aria-checked", s.notifications_enabled); } ``` -------------------------------- ### Record Interactions Programmatically Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Start, perform actions, and stop recording user interactions within your Rust application. The `stop_recording` function returns the complete session data. ```rust client.start_recording(Some("my-session")).await?; client.fill_by_id("email", "user@example.com").await?; client.click_by_id("login-btn").await?; // `stop_recording` returns the full session (events + any checkpoints). let session = client.stop_recording().await?; // Mid-session checkpoints and events-between-checkpoints are available through the // `recording` tool's actions (checkpoint / events / events_between) via call_tool, // or through the core `EventRecorder` API when embedding directly. ``` -------------------------------- ### System and Plugin State Introspection Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Inspect Victauri's startup phase timings, system capabilities (Tauri v2, security config, plugins, windows), and database health for SQLite. Also, view plugin internal state and spawned async task information. ```json {"action": "startup_timing"} ``` ```json {"action": "capabilities"} ``` ```json {"action": "db_health"} ``` ```json {"action": "plugin_state"} ``` ```json {"action": "plugin_tasks"} ``` -------------------------------- ### Victauri Accessibility Auditing Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Performs WCAG accessibility checks directly within the test environment using Victauri. This example audits accessibility and asserts that no violations are found. ```rust e2e_test!(accessibility_check, |client| async move { let audit = client.audit_accessibility().await.unwrap(); let violations = audit["summary"]["violations"].as_u64().unwrap_or(0); assert!(violations == 0, "a11y violations found: {}", serde_json::to_string_pretty(&audit["violations"]).unwrap_or_default() ); }); ``` -------------------------------- ### Run Compatibility Retest for All Apps Source: https://github.com/4da-systems/victauri/blob/main/scripts/compat/README.md Execute the compatibility retest process for all applications. This command generates a Markdown summary table of the results. ```bash scripts/compat/retest-all.sh ``` -------------------------------- ### Inspect Element Styles and Bounds Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieve computed CSS styles for elements using their reference IDs and properties, or get bounding box information for multiple elements. ```json {"action": "styles", "ref_id": "e3", "properties": ["color", "font-size"]} ``` ```json {"action": "bounds", "ref_ids": ["e1", "e2", "e3"]} ``` -------------------------------- ### Run Integration Tests for Victauri Demo App Source: https://github.com/4da-systems/victauri/blob/main/examples/demo-app/README.md Execute integration tests for the demo app with the Victauri end-to-end testing environment enabled. ```bash VICTAURI_E2E=1 cargo test -p demo-app --test integration ``` -------------------------------- ### Register a Ready Callback Source: https://github.com/4da-systems/victauri/blob/main/docs/src/configuration.md Execute a closure once the server has successfully bound to a port. The closure receives the bound port number as an argument. ```rust VictauriBuilder::new() .on_ready(|port| { println!("Victauri ready on port {}", port); }) .build().unwrap() ``` -------------------------------- ### Discover Available Commands with get_registry() Source: https://github.com/4da-systems/victauri/blob/main/examples/agent-session.md Use the `get_registry()` command to list all available commands exposed by the Tauri app. This helps in understanding the app's API. ```shell → get_registry() Result: 12 commands registered - get_items (category: data, description: "Fetch all todo items") - add_item (category: data, description: "Add a new todo item") - delete_item (category: data, description: "Delete a todo item by ID") - save_api_key (category: settings, description: "Save API key for a provider") ... ``` -------------------------------- ### Victauri REST API: Evaluate JavaScript Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Execute JavaScript code within the Tauri application's context using the Victauri REST API. This example evaluates `document.title`. ```bash # Evaluate JS curl -X POST http://127.0.0.1:7373/api/tools/eval_js \ -H "Content-Type: application/json" \ -d '{"code": "document.title"}' ``` -------------------------------- ### Victauri Cross-Boundary State Verification Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Tests synchronization between the DOM and the backend. This example resets a counter, interacts with it via the UI, and then verifies that both the frontend display and the backend state match. ```rust e2e_test!(counter_state_sync, |client| async move { client.invoke_command("reset_counter", None).await.unwrap(); // Interact via UI client.click_by_id("increment-btn").await.unwrap(); client.click_by_id("increment-btn").await.unwrap(); // Verify both layers agree let report = client.verify() .state_matches( "parseInt(document.getElementById('counter-value').textContent)", json!({"counter": 2}), ) .ipc_was_called("increment") .no_console_errors() .run() .await .unwrap(); report.assert_all_passed(); }); ``` -------------------------------- ### Browse and Read Backend Files Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md List files within the application's directory and read their content. Useful for checking generated files or configuration. ```rust let files = client.list_app_dir(Some("data"), None).await?; for entry in files["entries"].as_array().unwrap() { println!(" {} ({} bytes)", entry["name"], entry["size"]); } let content = client.read_app_file("settings.json", Some("config")).await?; println!("{}", content["content"]) ``` -------------------------------- ### Run Compatibility Retest Harness Source: https://github.com/4da-systems/victauri/blob/main/docs/src/compatibility.md These bash commands are used to run the reproducible retest harness. `retest-app.sh` tests a single application, while `retest-all.sh` tests all five applications and generates a results table. This harness ensures compatibility claims remain honest against the current Victauri version. ```bash scripts/compat/retest-app.sh duckling # one app ``` ```bash scripts/compat/retest-all.sh # all five, with a results table ``` -------------------------------- ### Verify UI to IPC to Database Flow in Rust Source: https://github.com/4da-systems/victauri/blob/main/README.md This snippet demonstrates how to verify a complete user interaction flow. It clicks a UI element, checks if the correct IPC command was invoked, and then confirms that the database was updated as expected. Ensure the client is initialized and connected. ```rust // Click "Save" in the UI client.click_by_id("save-btn").await?; // Verify the IPC command was called let log = client.get_ipc_log(None).await?; assert_ipc_called(&log, "save_settings"); // Verify the database was actually written let result = client.query_db( "SELECT value FROM settings WHERE key = 'theme'", None, None, ).await?; assert_eq!(result["rows"][0]["value"], "dark"); ``` -------------------------------- ### Fluent Verification with Assertions Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-test/README.md Demonstrates chaining multiple verification steps using the client.verify() method for comprehensive testing of application state and behavior. ```rust let report = client.verify() .has_text("Settings saved") .has_no_text("Error") .ipc_was_called("save_settings") .ipc_was_called_with("save_settings", json!({"theme": "dark"})) .ipc_was_not_called("delete_account") .no_console_errors() .coverage_above(80.0) .run().await?; report.assert_all_passed(); ``` -------------------------------- ### WebDriver Test for Increment Functionality Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing-tauri-apps.md Write a WebDriver test to interact with a UI element and verify its updated state. This example clicks an increment button and checks the displayed counter value. ```javascript // test.js describe('counter', () => { it('increments', async () => { await $('[data-testid="increment-btn"]').click(); const value = await $('[data-testid="counter-value"]').getText(); expect(value).toBe('1'); }); }); ``` -------------------------------- ### Initialize Victauri Plugin (Debug vs. Release) Source: https://github.com/4da-systems/victauri/blob/main/docs/src/security.md This function initializes the Victauri plugin. In debug builds, it enables the full MCP server and JS bridge. In release builds, it acts as a no-op to ensure zero runtime cost. ```rust pub fn init() -> TauriPlugin { #[cfg(debug_assertions)] { /* Full MCP server, JS bridge, everything */ } #[cfg(not(debug_assertions))] { /* Empty no-op plugin — the server never starts */ } } ``` -------------------------------- ### Run Compatibility Retest for a Single App Source: https://github.com/4da-systems/victauri/blob/main/scripts/compat/README.md Execute the compatibility retest process for a specific application. Use the --keep flag to retain the cloned repository for debugging purposes. ```bash scripts/compat/retest-app.sh kanri ``` ```bash scripts/compat/retest-app.sh en-croissant --keep ``` -------------------------------- ### Run victauri-watchdog with recovery command Source: https://github.com/4da-systems/victauri/blob/main/crates/victauri-watchdog/README.md Enables a recovery command that executes 'systemctl restart my-tauri-app' after 3 consecutive failures. ```bash VICTAURI_ON_FAILURE="systemctl restart my-tauri-app" victauri-watchdog ``` -------------------------------- ### Analyze Performance with logs(action: 'slow_ipc') Source: https://github.com/4da-systems/victauri/blob/main/examples/agent-session.md Identify slow IPC calls by using `logs(action: 'slow_ipc')` with a specified threshold. This helps pinpoint performance bottlenecks, such as file I/O on the main thread. ```shell → logs(action: "slow_ipc", threshold_ms: 100) Result: 1 slow call - save_api_key: 340ms (file I/O on main thread) ``` -------------------------------- ### get_plugin_info Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieves version, uptime, configuration, and capabilities information for the plugin. ```APIDOC ## get_plugin_info ### Description Get plugin version, uptime, configuration, and capabilities. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Response #### Success Response (200) - **version** (string) - The plugin version. - **uptime_ms** (number) - The plugin uptime in milliseconds. - **configuration** (object) - The plugin configuration. - **capabilities** (array) - A list of plugin capabilities. #### Response Example ```json {"version": "1.0.0", "uptime_ms": 3600000, "configuration": {"log_level": "info"}, "capabilities": ["feature_a", "feature_b"]} ``` ``` -------------------------------- ### Low-Level Client Methods Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Direct access to MCP tool functionalities using ref handles for advanced control. ```APIDOC ## Low-Level Client Methods ### Description These methods provide direct access to the underlying Message Channel Protocol (MCP) tools, requiring ref handles or specific identifiers for interaction. ### Methods - **`eval_js(expr: &str)`** - Evaluates a JavaScript expression in the application's context. - **`dom_snapshot()`** - Retrieves the entire DOM tree of the application. - **`find_elements(selector: &str)`** - Finds multiple elements using a CSS selector. - **`click(ref_id: &str)`** - Clicks an element identified by its ref handle. - **`fill(ref_id: &str, value: &str)`** - Fills an input element identified by its ref handle with a given value. - **`type_text(ref_id: &str, text: &str)`** - Types text character by character into an input element identified by its ref handle. - **`press_key(key: &str)`** - Simulates pressing a keyboard key. - **`screenshot(label: &str)`** - Captures a screenshot of the application, identified by a label. - **`get_window_state(label: &str)`** - Retrieves the position and size of a window identified by its label. - **`list_windows()`** - Lists all available window labels. - **`invoke_command(name: &str, args: &str)`** - Invokes a Tauri command with the specified name and arguments. - **`get_ipc_log(limit: u32)`** - Retrieves the IPC call history up to a specified limit. - **`get_registry()`** - Gets a list of registered commands. - **`get_memory_stats()`** - Retrieves memory statistics for the application process. - **`verify_state(frontend: &str, backend: &str)`** - Performs a cross-boundary state verification. - **`detect_ghost_commands()`** - Detects unregistered commands. - **`check_ipc_integrity()`** - Checks the integrity of IPC communication. - **`assert_semantic(expr: &str, label: &str, cond: &str, expected: &str)`** - Performs a semantic assertion based on an expression, label, condition, and expected value. - **`wait_for(condition: &str, value: &str, timeout: u64)`** - Waits for a specific condition to be met within a given timeout. - **`start_recording(session_id: &str)`** - Begins time-travel recording for a given session ID. - **`stop_recording()`** - Ends the current time-travel recording session. - **`logs(log_type: &str, limit: u32)`** - Retrieves logs of a specified type (e.g., "console", "network", "IPC") up to a limit. - **`audit_accessibility()`** - Performs a WCAG accessibility audit. - **`get_performance_metrics()`** - Retrieves performance metrics such as navigation timing, heap usage, and resource loading. - **`query_db(sql: &str, db_path: &str, params: &str)`** - Executes an SQL query against a specified SQLite database. - **`app_info()`** - Retrieves application configuration and path information. ### Example Usage ```rust let title = client.eval_js("document.title").await.unwrap(); let elements = client.find_elements(".my-class").await.unwrap(); client.fill("my-input-ref", "some value").await.unwrap(); ``` ``` -------------------------------- ### Get Diagnostics with curl Source: https://github.com/4da-systems/victauri/blob/main/docs/src/compatibility.md Use this command to call the get_diagnostics tool via MCP or REST API to check for known edge cases at runtime. The output provides details on warnings and general information about the application environment. ```bash curl -X POST http://127.0.0.1:7373/api/tools/get_diagnostics -d '{}' ``` -------------------------------- ### Connect to Application with VictauriClient Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Establishes a connection to the application using `VictauriClient` on a specified port. This client handles MCP session lifecycle automatically. ```rust use victauri_test::VictauriClient; #[tokio::test] async fn test_my_app() { let client = VictauriClient::connect(7373).await.unwrap(); let title = client.eval_js("document.title").await.unwrap(); assert!(title.contains("My App")); client.click("e3").await.unwrap(); client.fill("e5", "hello@example.com").await.unwrap(); } ``` -------------------------------- ### Monitor Performance Metrics Source: https://github.com/4da-systems/victauri/blob/main/docs/src/testing.md Track navigation timing, memory usage, and resource loading. Use this to identify performance bottlenecks. ```rust let metrics = client.get_performance_metrics().await?; let heap_mb = metrics["heap"]["usedJSHeapSize"] .as_f64().unwrap_or(0.0) / 1_048_576.0; assert!(heap_mb < 256.0, "Heap usage too high: {heap_mb:.1} MB"); let load_ms = metrics["navigation"]["loadEventEnd"] .as_f64().unwrap_or(0.0); assert!(load_ms < 3000.0, "Page load too slow: {load_ms:.0}ms"); ``` ```rust use victauri_test::assert_performance_budget; let metrics = client.get_performance_metrics().await?; assert_performance_budget(&metrics, 5000.0, 512.0); // max load ms, max heap MB ``` -------------------------------- ### Query Database for Settings Source: https://github.com/4da-systems/victauri/blob/main/scripts/agent-eval/tasks.md Directly query the database to retrieve settings. This is an alternative method to confirm backend truth, bypassing application logic. ```bash query_db ``` -------------------------------- ### Update Setting via Command Source: https://github.com/4da-systems/victauri/blob/main/scripts/agent-eval/tasks.md Use this command to update a setting on the backend. This is part of a test case to verify UI-backend state consistency. ```bash invoke_command update_setting ``` -------------------------------- ### Window: List Windows Source: https://github.com/4da-systems/victauri/blob/main/docs/src/tools-reference.md Retrieves a list of all available window labels. ```json {"action": "list"} ```