//! Tests: unit tables + in-process integration (mock OpenRouter + mock
//! runner + temp git repos).
//!
//! Run: `cargo test -p agentd`.
#[cfg(test)]
mod unit {
use crate::auth::{origin_allowed, session_token_from_cookie, Auth};
use crate::models::{
branch_name, cap_final_diff, cap_plan_markdown, plan_gate_message, render_todos, slugify,
truncate_result, trim_placeholder, validate_commit_message,
validate_commit_message_for_issue, validate_todos, TodoItem,
FINAL_DIFF_CAP_BYTES, MAX_TODOS, MAX_TODO_CHARS, PLAN_MD_CAP_BYTES,
RESULT_TRUNCATE_BYTES, INBOX_PLAN_APPROVE, INBOX_PLAN_CHANGES, INBOX_REVIEW_CHANGES,
PENDING_PLAN, PENDING_REVIEW,
};
use crate::openrouter::{parse_chat_response, Message};
use crate::agent::{format_pending_answer, trim_messages};
use crate::markdown::render_markdown;
use crate::models::{
Event, Pending, Task, TaskStatus, EVENT_ASSISTANT, EVENT_STATUS, EVENT_TODOS,
EVENT_TOOL_CALL, EVENT_TOOL_RESULT, EVENT_USER_MESSAGE, PENDING_BUDGET, PENDING_CHAT,
PENDING_QUESTION,
};
use crate::ui::{
dashboard_title, render_cards, render_dashboard_page, render_diff_lines, render_panel,
render_task_page, render_timeline_events,
};
use crate::rules::ancestor_dirs;
use crate::store::{InboxRow, Store};
use crate::tools::{shell_looks_mutating, validate_build_command, validate_shell_command};
fn test_store() -> (Store, tempfile::TempDir) {
let dir = tempfile::tempdir().unwrap();
let store = Store::open(dir.path()).unwrap();
(store, dir)
}
#[test]
fn markdown_safe_subset() {
// Basic blocks + inline formatting.
let html = render_markdown("Hello **bold** and *italic* with `code`.");
assert!(html.contains("bold"), "bold: {html}");
assert!(html.contains("italic"), "italic: {html}");
assert!(html.contains("code"), "code: {html}");
// Fenced code block is escaped.
let html = render_markdown("```rust\nlet x = a < b;\n```");
assert!(html.contains("
") && html.contains("