Files
simple-aircraft-manager-rails/test/integration/user_guide_test.rb
T
rickyandClaude Opus 5.5 fe3fba1736 User guide in docs/guide, shown in the app under Help
- 16 Markdown pages covering every area for pilots, owners, mechanics
  and admins, readable on GitHub
- /help renders them with a page list; links between pages work in both
  places; only listed pages can be opened
- The electronic records instructions (AC 120-78B user instructions) are
  now the guide's records page, also used as the procedures appendix
- Help link in the main menu

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:40:09 -05:00

45 lines
1.6 KiB
Ruby

require "test_helper"
# The user guide in docs/guide, shown under /help.
class UserGuideTest < ActionDispatch::IntegrationTest
setup { sign_in create_user("pilot@example.com") }
test "every guide page renders with the contents and links between pages" do
get help_path
assert_response :success
assert_select "h1", "User guide"
HelpGuide::ORDER.each do |slug|
assert HelpGuide.find(slug), "docs/guide/#{slug}.md is missing"
get(slug == "README" ? help_path : help_page_path(slug))
assert_response :success
assert_select "nav[aria-label='Help pages'] a", HelpGuide::ORDER.size * 2
assert_no_match(/href="[a-z-]+\.md/, response.body, "#{slug} has an unconverted .md link")
end
get help_page_path("logbook")
assert_select "a[href='/help/records#mistakes']"
end
test "links in the guide point at real pages and headings" do
HelpGuide.pages.each do |page|
page.markdown.scan(/\]\(([a-z-]+|README)\.md(?:#([a-z0-9-]+))?\)/).each do |slug, anchor|
target = HelpGuide.find(slug)
assert target, "#{page.slug} links to missing #{slug}.md"
assert_includes HelpGuide.html(target, link: nil), %(id="#{anchor}"), "#{page.slug} links to missing ##{anchor} in #{slug}" if anchor
end
end
end
test "only guide pages can be opened" do
get "/help/secrets"
assert_response :not_found
get records_help_path
assert_response :success
assert_includes response.body, "Correct this entry"
end
test "the guide is in the menu" do
get root_path
assert_select "a[href='/help']", minimum: 1
end
end