using System.IO; using System.Text.Json; using AxCopilot.Services.Agent; using FluentAssertions; using Xunit; namespace AxCopilot.Tests.Services; public class HtmlSkillConsultingSectionsTests { [Fact] public async Task ExecuteAsync_WithConsultingSections_ShouldRenderAdvancedBlocks() { var workDir = Path.Combine(Path.GetTempPath(), "ax-html-consulting-" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(workDir); try { var tool = new HtmlSkill(); var context = new AgentContext { WorkFolder = workDir, Permission = "Auto", OperationMode = "external", }; var args = JsonDocument.Parse( """ { "path": "consulting.html", "title": "Executive Report", "body": "", "sections": [ { "type": "comparison", "title": "Option Comparison", "items": [ { "name": "Option A", "summary": "Fast rollout", "pros": "Low setup effort", "cons": "Limited scale", "verdict": "Fast" } ] }, { "type": "roadmap", "title": "Delivery Roadmap", "phases": [ { "title": "Phase 1", "detail": "Assess and design", "timeline": "0-30 days", "owner": "PMO" } ] }, { "type": "matrix", "title": "Priority Matrix", "quadrants": [ { "title": "Quick Wins", "items": ["Automate reporting", "Standardize templates"] }, { "title": "Strategic Bets", "items": ["Operating model redesign"] } ] }, { "type": "decision_summary", "title": "Decision", "decision": "Approve pilot expansion", "rationale": "Retention and margin improved in the pilot region.", "actions": ["Approve budget", "Launch phase 2"] }, { "type": "kpi_panel", "title": "KPI Panel", "headline": "Pilot economics remain above threshold", "items": [ { "label": "Margin", "value": "+4.2pt", "trend": "up", "note": "pilot" }, { "label": "Lead Time", "value": "-18%", "trend": "down", "note": "handoff" } ], "takeaway": "The pilot shows both service and margin improvement." }, { "type": "evidence_cards", "title": "Evidence", "items": [ { "title": "Margin uplift", "detail": "+4.2p improvement after workflow change", "source": "Finance close", "tag": "KPI" }, { "title": "Cycle time", "detail": "Lead time reduced from 12 to 8 days", "source": "PMO tracker", "tag": "Ops" } ] }, { "type": "board_report", "title": "Board Ask", "decision": "Approve the next rollout wave", "recommendation": "Release the phase-2 budget now", "rationale": "The pilot hit margin and lead-time targets.", "metrics": [ { "label": "Margin", "value": "+4.2p", "note": "pilot" } ], "risks": ["Adoption lag in region B"], "next_steps": ["Confirm budget", "Launch phase 2"] }, { "type": "strategy_brief", "title": "Strategy Brief", "strategic_question": "Where should we scale first?", "thesis": "Scale the high-retention segment first.", "implications": ["Refocus sales coverage", "Prioritize onboarding"], "decisions": ["Approve segment focus", "Adjust regional targets"] } ] } """).RootElement; var result = await tool.ExecuteAsync(args, context, CancellationToken.None); result.Success.Should().BeTrue(); result.Output.Should().Contain("Repair guide:"); var html = File.ReadAllText(Path.Combine(workDir, "consulting.html")); html.Should().Contain("comparison-grid"); html.Should().Contain("roadmap-block"); html.Should().Contain("matrix-grid"); html.Should().Contain("decision-summary"); html.Should().Contain("kpi-panel"); html.Should().Contain("evidence-cards"); html.Should().Contain("board-report-panel"); html.Should().Contain("strategy-brief-panel"); } finally { try { if (Directory.Exists(workDir)) Directory.Delete(workDir, true); } catch { } } } }