mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 01:04:55 +08:00
Previously, there was no systematic way to visually review changes across multiple screens in a theme. Or to compare how Foundation and Horizon render key UI screens This adds a `screenshot_marker(label:)` helper in system specs (globally included via ThemeScreenshotMarker) that captures a PNG at that point in a test. A matrix runner spec at `theme_screenshots_spec.rb` auto-discovers any system spec containing screenshot markers and runs those blocks against each theme × color mode × device combination. At the end it generates a `compare.html` viewer for side-by-side comparison. <img width="3399" height="1400" alt="image" src="https://github.com/user-attachments/assets/4ddd650a-6133-4da5-901e-5ec2f2d0906a" /> This can be run via CLI or via the attached skill. Directly: ### All themes × light/dark × desktop/mobile (default) TAKE_SCREENSHOTS=1 bin/rspec spec/system/theme_screenshots_spec.rb #### Foundation only, dark mode, desktop only TAKE_SCREENSHOTS=1 SCREENSHOTS_THEMES=foundation SCREENSHOTS_MODES=dark SCREENSHOTS_DEVICES=desktop bin/rspec spec/system/theme_screenshots_spec.rb #### Third-party theme in addition to core themes TAKE_SCREENSHOTS=1 SCREENSHOTS_THEME_URL=https://github.com/discourse/discourse-air bin/rspec spec/system/theme_screenshots_spec.rb You can also run this via the agent skill, which builds the command from natural language: `/discourse-screenshots` for the full default matrix, or `/discourse-screenshots foundation only, dark only, desktop` and similar limited runs. ### Use cases - review broad changes in core against key UI screens across the app - compare layouts/screens between core themes and/or a custom theme - preview a new theme's look and feel across different areas of the app --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
1.2 KiB
Ruby
Vendored
39 lines
1.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe "Admin Dashboard General Tab" do
|
|
fab!(:admin)
|
|
fab!(:user)
|
|
fab!(:user_visit) { Fabricate(:user_visit, user: admin) }
|
|
fab!(:user_visit_2) { Fabricate(:user_visit, user: user, mobile: true) }
|
|
fab!(:user_visit_3) { Fabricate(:user_visit, user: user, visited_at: 1.day.ago) }
|
|
|
|
before { sign_in(admin) }
|
|
|
|
context "when reporting_improvements is enabled" do
|
|
before { SiteSetting.reporting_improvements = true }
|
|
|
|
it "displays correct visit counters combining desktop and mobile visits" do
|
|
visit("/admin")
|
|
|
|
screenshot_marker(label: "admin-dashboard")
|
|
|
|
within ".admin-report.visits .admin-report-counters" do
|
|
expect(page).to have_css(".today-count", text: "2")
|
|
expect(page).to have_css(".yesterday-count", text: "1")
|
|
end
|
|
end
|
|
end
|
|
|
|
context "when reporting_improvements is disabled" do
|
|
before { SiteSetting.reporting_improvements = false }
|
|
|
|
it "displays correct visit counters" do
|
|
visit("/admin")
|
|
|
|
within ".admin-report.visits .admin-report-counters" do
|
|
expect(page).to have_css(".today-count", text: "2")
|
|
expect(page).to have_css(".yesterday-count", text: "1")
|
|
end
|
|
end
|
|
end
|
|
end
|