Add script for taking screenshots of rendered journals
This commit is contained in:
1 file changed
+64
@@ -0,0 +1,64 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Captures the screenshots used in the README and announcements. Run through the
|
||||
# theme screenshot matrix, for example:
|
||||
#
|
||||
# TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_THEMES=foundation \
|
||||
# SCREENSHOTS_MODES=light SCREENSHOTS_DEVICES=desktop \
|
||||
# SCREENSHOTS_SUBSET=hledger \
|
||||
# bin/rspec spec/system/theme_screenshots_spec.rb
|
||||
#
|
||||
# Without TAKE_SCREENSHOTS the spec is skipped, so it does not run in the normal
|
||||
# system suite.
|
||||
RSpec.describe "Hledger dashboard screenshots" do
|
||||
include ThemeScreenshotMarker
|
||||
|
||||
let(:journal) { File.read(Rails.root.join("plugins/discourse-hledger/docs/example.journal")) }
|
||||
|
||||
fab!(:alice) { Fabricate(:user, username: "alice", name: "Alice") }
|
||||
fab!(:bob) { Fabricate(:user, username: "bob", name: "Bob") }
|
||||
fab!(:carol) { Fabricate(:user, username: "carol", name: "Carol") }
|
||||
|
||||
before do
|
||||
skip "Set TAKE_SCREENSHOTS=1 to run this spec" if ENV["TAKE_SCREENSHOTS"] != "1"
|
||||
|
||||
SiteSetting.title = "Hledger demo"
|
||||
SiteSetting.logo = ""
|
||||
SiteSetting.logo_small = ""
|
||||
SiteSetting.hledger_enabled = true
|
||||
end
|
||||
|
||||
it "captures every report" do
|
||||
post = Fabricate(:post, user: alice, raw: "```hledger\n#{journal}\n```")
|
||||
post.topic.update!(title: "Collective finances 2024")
|
||||
post.rebake!
|
||||
|
||||
visit(post.topic.relative_url)
|
||||
expect(page).to have_css(".hledger-dashboard__table", text: "Assets")
|
||||
capture("accounts")
|
||||
|
||||
open_report(2)
|
||||
expect(page).to have_css(".hledger-dashboard__section-title", text: "Assets")
|
||||
capture("balance-sheet")
|
||||
|
||||
open_report(3)
|
||||
expect(page).to have_css(".hledger-dashboard__section-title", text: "Revenues")
|
||||
capture("pnl")
|
||||
|
||||
open_report(4)
|
||||
expect(page).to have_css(".hledger-dashboard__note")
|
||||
capture("equity")
|
||||
|
||||
open_report(5)
|
||||
expect(page).to have_css(".hledger-dashboard__transaction")
|
||||
capture("journal")
|
||||
end
|
||||
|
||||
def open_report(index)
|
||||
find(".hledger-dashboard__toolbar .btn:nth-of-type(#{index})").click
|
||||
end
|
||||
|
||||
def capture(label)
|
||||
screenshot_marker(label: "hledger-#{label}", only: :desktop)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user