diff --git a/frontend/src/components/AgentPanel.test.tsx b/frontend/src/components/AgentPanel.test.tsx index fc57b9e..8e72384 100644 --- a/frontend/src/components/AgentPanel.test.tsx +++ b/frontend/src/components/AgentPanel.test.tsx @@ -1,4 +1,4 @@ -import { render, screen, waitFor } from "@testing-library/react"; +import { act, render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { AgentConfigInfo, AgentInfo } from "../api/agents"; @@ -315,7 +315,7 @@ describe("AgentPanel fade-out", () => { describe("removes the agent entry after 60s", () => { beforeEach(() => { - vi.useFakeTimers(); + vi.useFakeTimers({ shouldAdvanceTime: true }); }); afterEach(() => { @@ -346,17 +346,17 @@ describe("AgentPanel fade-out", () => { ).toBeInTheDocument(); }); - // Advance timers by 60 seconds - vi.advanceTimersByTime(60_000); + // Advance timers by 60 seconds and flush React state updates + await act(async () => { + vi.advanceTimersByTime(60_000); + }); // Entry should be removed - await waitFor(() => { - expect( - container.querySelector( - '[data-testid="agent-entry-73_remove_test:coder-1"]', - ), - ).not.toBeInTheDocument(); - }); + expect( + container.querySelector( + '[data-testid="agent-entry-73_remove_test:coder-1"]', + ), + ).not.toBeInTheDocument(); }); }); }); diff --git a/server/src/http/workflow.rs b/server/src/http/workflow.rs index a6a625c..98e43a1 100644 --- a/server/src/http/workflow.rs +++ b/server/src/http/workflow.rs @@ -238,6 +238,10 @@ pub fn create_bug_file( .to_string(); let mut content = String::new(); + content.push_str("---\n"); + content.push_str(&format!("name: \"{}\"\n", name.replace('"', "\\\""))); + content.push_str("test_plan: pending\n"); + content.push_str("---\n\n"); content.push_str(&format!("# Bug {bug_number}: {name}\n\n")); content.push_str("## Description\n\n"); content.push_str(description); @@ -1266,6 +1270,10 @@ mod tests { .join(".story_kit/work/1_upcoming/1_bug_login_crash.md"); assert!(filepath.exists()); let contents = fs::read_to_string(&filepath).unwrap(); + assert!( + contents.starts_with("---\nname: \"Login Crash\"\ntest_plan: pending\n---"), + "bug file must start with YAML front matter" + ); assert!(contents.contains("# Bug 1: Login Crash")); assert!(contents.contains("## Description")); assert!(contents.contains("The login page crashes on submit.")); @@ -1305,6 +1313,10 @@ mod tests { let filepath = tmp.path().join(".story_kit/work/1_upcoming/1_bug_some_bug.md"); let contents = fs::read_to_string(&filepath).unwrap(); + assert!( + contents.starts_with("---\nname: \"Some Bug\"\ntest_plan: pending\n---"), + "bug file must have YAML front matter" + ); assert!(contents.contains("- [ ] Bug is fixed and verified")); } }