Files
gridline/desktop/src/components/editor/DestructiveQueryDialog.test.tsx
T
adrianbonpin 6854d889c5 refactor: convert to bun-workspaces monorepo (desktop/ + www/)
- Move the Tauri app (React frontend + Rust backend) into desktop/ via
  git mv — configs unchanged (relative paths: tauri.conf.json, vite.config.ts)
- Root package.json becomes a private bun workspace container with
  orchestration scripts; desktop package renamed gridline-desktop
- Scaffold www/ with Astro 7 + Tailwind v4 (hand-wired vite plugin,
  static output, ready for Dokploy)
- Update release.yml for the new layout: projectPath: desktop,
  desktop/src-tauri resource paths, rust-cache workspace path
- Update README + AGENTS.md structure trees and dev commands
- Verified: vitest (1074), cargo test (354), desktop build, tauri dev
  (window launches), tauri build (dmg + app bundles), Astro build
2026-08-16 19:31:53 +08:00

40 lines
1.5 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { DestructiveQueryDialog } from "./DestructiveQueryDialog";
describe("DestructiveQueryDialog", () => {
it("renders warning message with the SQL shown", () => {
render(
<DestructiveQueryDialog open={true} query="DROP TABLE users" onConfirm={() => {}} onCancel={() => {}} />
);
expect(screen.getByText(/destructive/i)).toBeInTheDocument();
expect(screen.getByText(/DROP TABLE users/)).toBeInTheDocument();
});
it("calls onConfirm when 'Execute' is clicked", () => {
const onConfirm = vi.fn();
render(
<DestructiveQueryDialog open={true} query="DELETE FROM users" onConfirm={onConfirm} onCancel={() => {}} />
);
fireEvent.click(screen.getByText("Execute"));
expect(onConfirm).toHaveBeenCalledTimes(1);
});
it("calls onCancel when 'Cancel' is clicked", () => {
const onCancel = vi.fn();
render(
<DestructiveQueryDialog open={true} query="DROP TABLE users" onConfirm={() => {}} onCancel={onCancel} />
);
fireEvent.click(screen.getByText("Cancel"));
expect(onCancel).toHaveBeenCalledTimes(1);
});
it("truncates long queries in the dialog", () => {
const longQuery = "DROP TABLE " + "x".repeat(500);
render(
<DestructiveQueryDialog open={true} query={longQuery} onConfirm={() => {}} onCancel={() => {}} />
);
const displayed = screen.getByText(/DROP TABLE/);
expect(displayed.textContent!.length).toBeLessThan(longQuery.length + 20);
});
});