Skip to content

Commit

Permalink
Polish tests to check prev/naext navigation text in PJ pages
Browse files Browse the repository at this point in the history
  • Loading branch information
yasulab committed Dec 30, 2024
1 parent 1941170 commit 5c97473
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/custom_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,13 @@ def check_yaml_data
# Check if navigation text in each PJ page fails to be encoded. (文字化け)
# Fetched sample PJ page: https://jr.mitou.org/projects/2024/qwet
def check_navi_text
projects = YAML.load_file("_data/projects.yml", symbolize_names: true).select{ it[:year] == 2024 }
prev_text = @html.css('nav > p.prev').text
next_text = @html.css('nav > p.next').text

add_failure("Failed to render navigation text: #{prev_text}") unless prev_text.include? projects[1][:title]
add_failure("Failed to render navigation text: #{next_text}") unless next_text.include? projects[1][:title]
projects = YAML.load_file("_data/projects.yml", symbolize_names: true).select{ it[:year] == 2024 }
prev_text = @html.css('nav > p.prev').text.strip.lines.last.strip[0..-4]
next_text = @html.css('nav > p.next').text.strip.lines.last.strip[0..-4]
prev_title = projects[-1][:title]
next_title = projects[ 1][:title]

add_failure("Unmatched nav text and title:\n\t#{prev_text}\n\t#{prev_title}") unless prev_title.start_with? prev_text
add_failure("Unmatched nav text and title:\n\t#{next_text}\n\t#{next_title}") unless next_title.start_with? next_text
end
end

0 comments on commit 5c97473

Please sign in to comment.