test(microprints): make expand-switch test resilient to file changes

Remove hardcoded module names (FirehoseWeb.MicroprintsLive,
Firehose.Application) from the expand-switch test. Now verifies:
- Each file's source renders when expanded (generic defmodule check)
- Source content differs between files (catches stale content bug)
- Button states update correctly (collapse/expand)
This commit is contained in:
Firehose Bot 2026-05-18 18:09:55 +01:00
parent 7c06204ac2
commit 7afe5c1fe8
2 changed files with 19 additions and 10 deletions

View File

@ -67,3 +67,5 @@
{"timestamp":"2026-05-18T16:57:06.934Z","provider":"llama.cpp","model":"Qwen3.6-35B-A3B-MXFP4_MOE.gguf","turnCount":17,"inputTokens":9721,"outputTokens":6329,"totalTokens":16050,"prefillTokensPerSec":513.66,"generationTokensPerSec":44.57,"combinedTokensPerSec":99.73,"totalDurationMs":160936,"timeToFirstTokenMs":18925,"rawTimestamps":{"ttftMs":18925,"allTtftMs":[18925,16190,4022,7901,1873,10528,1481],"generationDurationMs":142011,"turns":[{"turnId":"turn-0","durationMs":21666,"ttftMs":18925},{"turnId":"turn-1","durationMs":25748,"ttftMs":16190},{"turnId":"turn-2","durationMs":18958,"ttftMs":4022},{"turnId":"turn-3","durationMs":2499},{"turnId":"turn-4","durationMs":14503,"ttftMs":7901},{"turnId":"turn-5","durationMs":7021},{"turnId":"turn-6","durationMs":8323,"ttftMs":1873},{"turnId":"turn-7","durationMs":8202},{"turnId":"turn-8","durationMs":8887},{"turnId":"turn-9","durationMs":2925},{"turnId":"turn-10","durationMs":2921},{"turnId":"turn-11","durationMs":3410},{"turnId":"turn-12","durationMs":2903},{"turnId":"turn-13","durationMs":5754},{"turnId":"turn-14","durationMs":14057,"ttftMs":10528},{"turnId":"turn-15","durationMs":7970},{"turnId":"turn-16","durationMs":5189,"ttftMs":1481}]}}
{"timestamp":"2026-05-18T17:00:32.909Z","provider":"llama.cpp","model":"Qwen3.6-35B-A3B-MXFP4_MOE.gguf","turnCount":1,"inputTokens":25,"outputTokens":715,"totalTokens":740,"prefillTokensPerSec":2.76,"generationTokensPerSec":94.53,"combinedTokensPerSec":44.48,"totalDurationMs":16637,"timeToFirstTokenMs":9073,"rawTimestamps":{"ttftMs":9073,"allTtftMs":[9073],"generationDurationMs":7564,"turns":[{"turnId":"turn-0","durationMs":16637,"ttftMs":9073}]}}
{"timestamp":"2026-05-18T17:03:32.883Z","provider":"llama.cpp","model":"Qwen3.6-35B-A3B-MXFP4_MOE.gguf","turnCount":4,"inputTokens":728,"outputTokens":1603,"totalTokens":2331,"prefillTokensPerSec":477.69,"generationTokensPerSec":49.97,"combinedTokensPerSec":69.36,"totalDurationMs":33605,"timeToFirstTokenMs":1524,"rawTimestamps":{"ttftMs":1524,"allTtftMs":[1524],"generationDurationMs":32081.000000000004,"turns":[{"turnId":"turn-0","durationMs":3655},{"turnId":"turn-1","durationMs":17547},{"turnId":"turn-2","durationMs":8416},{"turnId":"turn-3","durationMs":3987,"ttftMs":1524}]}}
{"timestamp":"2026-05-18T17:04:51.598Z","provider":"llama.cpp","model":"Qwen3.6-35B-A3B-MXFP4_MOE.gguf","turnCount":2,"inputTokens":91,"outputTokens":302,"totalTokens":393,"prefillTokensPerSec":120.69,"generationTokensPerSec":42.08,"combinedTokensPerSec":49.56,"totalDurationMs":7930,"timeToFirstTokenMs":754,"rawTimestamps":{"ttftMs":754,"allTtftMs":[754],"generationDurationMs":7176,"turns":[{"turnId":"turn-0","durationMs":5537},{"turnId":"turn-1","durationMs":2393,"ttftMs":754}]}}
{"timestamp":"2026-05-18T17:06:35.090Z","provider":"llama.cpp","model":"Qwen3.6-35B-A3B-MXFP4_MOE.gguf","turnCount":5,"inputTokens":595,"outputTokens":991,"totalTokens":1586,"prefillTokensPerSec":107.67,"generationTokensPerSec":50.99,"combinedTokensPerSec":63.53,"totalDurationMs":24963,"timeToFirstTokenMs":5526,"rawTimestamps":{"ttftMs":5526,"allTtftMs":[5526],"generationDurationMs":19437,"turns":[{"turnId":"turn-0","durationMs":2342},{"turnId":"turn-1","durationMs":8629},{"turnId":"turn-2","durationMs":3748},{"turnId":"turn-3","durationMs":1905},{"turnId":"turn-4","durationMs":8339,"ttftMs":5526}]}}

View File

@ -99,7 +99,7 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
"file A should be collapsed after highlighting a different file, but the Collapse button is still visible (expanded_path is uncoupled from highlighted_path)"
end
test "switching expand from file A to file B shows file B's source content, not file A's", %{conn: conn} do
test "switching expand from file A to file B shows each file's own source content", %{conn: conn} do
files = MicroprintsLive.scan_source_files()
assert length(files) >= 2, "Need at least 2 files to test source switching"
@ -112,24 +112,31 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
|> element("button[phx-value-path=\"#{file_a}\"]", "Expand")
|> render_click()
# Verify file A's source is shown (check for module def from microprints_live.ex)
html = render(view)
assert html =~ "FirehoseWeb.MicroprintsLive",
"When file A is expanded, its source should be visible"
# Capture file A's source content from the rendered HTML
html_a = render(view)
# Each .ex file starts with "defmodule", grab the first defmodule line as unique content
assert html_a =~ "defmodule",
"File A source should be visible when expanded"
# Expand file B (should auto-collapse A)
view
|> element("button[phx-value-path=\"#{file_b}\"]", "Expand")
|> render_click()
# Verify file B's source is shown, NOT file A's
html = render(view)
assert html =~ "Firehose.Application",
"When file B is expanded, its source should be visible (not file A's source)"
# Capture file B's source content
html_b = render(view)
# The two source viewers must show different content
refute html_a == html_b,
"Source content should differ when switching between files"
# File A's button should now say "Expand" (collapsed)
refute html =~ ~s(phx-value-path="#{file_a}".*Collapse),
refute html_b =~ ~r(phx-value-path="#{Regex.escape(file_a)}"[^>]*>\s*Collapse\s*</),
"file A should be collapsed after switching expand to file B"
# File B's button should say "Collapse" (expanded)
assert html_b =~ ~r(phx-value-path="#{Regex.escape(file_b)}"[^>]*>\s*Collapse\s*</),
"file B should show Collapse button when expanded"
end
end
end