import { test } from 'magnitude-test'; test('[Happy Path] User can chat with AI', async (agent) => { // Act: Go to chat page await agent.act('Navigate to /chat'); // Check: Ensure the initial state is correct await agent.check('The title "Ponderants Interview" is visible'); await agent.check('The chat input field is empty'); // Act: Send a message await agent.act( 'Enter "I have an idea about decentralized social media" into the chat input' ); await agent.act('Click the "Send" button'); // Check: User's message appears await agent.check( 'The message "I have an idea about decentralized social media" appears in the chat list' ); // Check: AI response appears (mocked) // We mock the /api/chat response to return a simple text stream await agent.check( 'A new message from "AI" appears in the chat list with a response' ); }); test('[Happy Path] AI can trigger a node suggestion', async (agent) => { // Act: Go to chat page await agent.act('Navigate to /chat'); // Act: Send a message that should trigger a node await agent.act( 'Enter "I think I have a fully formed thought: ATproto is the future of the internet because it separates data from the application." into the chat input' ); // We mock the /api/chat response to return the 'suggest_node' tool call // with specific 'title' and 'body' arguments. await agent.act('Click the "Send" button'); // Check: The 'experimental_onToolCall' handler should fire // and redirect the user to the editor. await agent.check( 'The browser URL is now "http://localhost:3000/editor/new"' ); // Check: The editor page is pre-filled with the AI-generated content await agent.check( 'The page URL contains the query parameter "title=ATproto: The Future of the Internet"' ); await agent.check( 'The page URL contains the query parameter "body=ATproto is the future..."' ); });