From f63e2feb37cc9b1e5aca60d85be166fa84eb5f9f Mon Sep 17 00:00:00 2001 From: Zarino Zappia Date: Mon, 21 Sep 2020 17:07:10 +0100 Subject: TestMech->page_errors now handles error markup with leading spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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! --- perllib/FixMyStreet/TestMech.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/TestMech.pm') 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; } -- cgit v1.2.3 From 245f12237ad2c796667d5d4736483474c1b481ce Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Tue, 11 Aug 2020 09:18:12 +0100 Subject: Enable HTML in update alert emails. --- perllib/FixMyStreet/TestMech.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'perllib/FixMyStreet/TestMech.pm') diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 277eca2b1..f6854fc98 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -276,6 +276,24 @@ sub get_text_body_from_email { return $body; } +sub get_html_body_from_email { + my ($mech, $email, $obj) = @_; + unless ($email) { + $email = $mech->get_email; + $mech->clear_emails_ok; + } + + my $body; + $email->walk_parts(sub { + my $part = shift; + return if $part->subparts; + return if $part->content_type !~ m{text/html}; + $body = $obj ? $part : $part->body_str; + ok $body, "Found HTML body"; + }); + return $body; +} + sub get_link_from_email { my ($mech, $email, $multiple, $mismatch) = @_; unless ($email) { -- cgit v1.2.3 From e3e1e9d54999692dc01f3fdd32693547af8deb7b Mon Sep 17 00:00:00 2001 From: M Somerville Date: Thu, 1 Oct 2020 14:44:07 +0100 Subject: Do not display deleted priorities in inspect form. --- perllib/FixMyStreet/TestMech.pm | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'perllib/FixMyStreet/TestMech.pm') diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index f6854fc98..7f7104d3d 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -609,29 +609,6 @@ sub get_ok_json { return decode_json( $res->content ); } -sub delete_body { - my $mech = shift; - my $body = shift; - - $mech->delete_problems_for_body($body->id); - $mech->delete_defect_type($_) for $body->defect_types; - $mech->delete_contact($_) for $body->contacts; - $mech->delete_user($_) for $body->users; - $_->delete for $body->response_templates; - $_->delete for $body->response_priorities; - $body->body_areas->delete; - $body->delete; -} - -sub delete_contact { - my $mech = shift; - my $contact = shift; - - $contact->contact_response_templates->delete_all; - $contact->contact_response_priorities->delete_all; - $contact->delete; -} - sub delete_problems_for_body { my $mech = shift; my $body = shift; @@ -646,14 +623,6 @@ sub delete_problems_for_body { } } -sub delete_defect_type { - my $mech = shift; - my $defect_type = shift; - - $defect_type->contact_defect_types->delete_all; - $defect_type->delete; -} - sub delete_response_template { my $mech = shift; my $response_template = shift; -- cgit v1.2.3