Skip to content

Commit

Permalink
TestMech->page_errors now handles error markup with leading spaces
Browse files Browse the repository at this point in the history
The "error" output in our new `.search-help__header` element begins and
ends with whitespace. The test really shouldn’t care about whitespace
at the start and end of HTML tags, so this commit makes page_errors
trim whitespace from the errors it passes to the tests.

Also adds `.search-help__header` as a location to find page errors!
  • Loading branch information
zarino committed Sep 28, 2020
1 parent ba768bd commit f63e2fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion perllib/FixMyStreet/TestMech.pm
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,13 @@ arrayref of TEXTs. If none found return empty arrayref.
sub page_errors {
my $mech = shift;
my $result = scraper {
process 'div.form-error, p.form-error, p.error, ul.error li', 'errors[]', 'TEXT';
process 'div.form-error, p.form-error, p.error, ul.error li, .search-help__header', 'errors[]', 'TEXT';
}
->scrape( $mech->response );
my $err = $result->{errors} || [];
my %seen = ();
$err = [ grep { not $seen{$_}++ } @$err ];
@$err = map { s/^\s+|\s+$//g; $_ } @$err;
return $err;
}

Expand Down

0 comments on commit f63e2fe

Please sign in to comment.