diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2020-09-21 17:07:10 +0100 |
---|---|---|
committer | Zarino Zappia <mail@zarino.co.uk> | 2020-09-28 12:00:22 +0100 |
commit | f63e2feb37cc9b1e5aca60d85be166fa84eb5f9f (patch) | |
tree | b607a64f03cc666c2ee19918284ce4770e752e5f | |
parent | ba768bd5f31544dd0ecbc5f910def42debe02129 (diff) |
TestMech->page_errors now handles error markup with leading spaces
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!
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 1b7fba1bd..277eca2b1 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -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; } |