diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-02-14 12:55:15 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-02-14 12:55:15 +0000 |
commit | a5373a4ce9e966f70cd5edf0334c27781d7a2f04 (patch) | |
tree | 9bf59ec3fd7b9de0194dc8e997e57e18f787629c /t/app/controller | |
parent | 2530538ca6e36b659a63cc3b67099972fe0116af (diff) | |
parent | f0edab7ee84e4358c279a5a8ec37dbb0ae8f1b3d (diff) |
Merge branch 'pwa'
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/offline.t | 48 | ||||
-rw-r--r-- | t/app/controller/root.t | 12 |
2 files changed, 48 insertions, 12 deletions
diff --git a/t/app/controller/offline.t b/t/app/controller/offline.t new file mode 100644 index 000000000..d2a5009ec --- /dev/null +++ b/t/app/controller/offline.t @@ -0,0 +1,48 @@ +use FixMyStreet::TestMech; +use Path::Tiny; + +my $mech = FixMyStreet::TestMech->new; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => 'test' +}, sub { + my $theme_dir = path(FixMyStreet->path_to('web/theme/test')); + $theme_dir->mkpath; + my $image_path = path('t/app/controller/sample.jpg'); + $image_path->copy($theme_dir->child('sample.jpg')); + subtest 'manifest' => sub { + my $j = $mech->get_ok_json('/.well-known/manifest.webmanifest'); + is $j->{name}, 'FixMyStreet', 'correct name'; + is $j->{theme_color}, '#ffd000', 'correct theme colour'; + is_deeply $j->{icons}[0], { + type => 'image/jpeg', + src => '/theme/test/sample.jpg', + sizes => '133x100' + }, 'correct icon'; + }; + $theme_dir->remove_tree; +}; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet' +}, sub { + subtest '.com manifest' => sub { + my $j = $mech->get_ok_json('/.well-known/manifest.webmanifest'); + is $j->{related_applications}[0]{platform}, 'play', 'correct app'; + is $j->{icons}[0]{sizes}, '192x192', 'correct fallback size'; + }; +}; + +subtest 'service worker' => sub { + $mech->get_ok('/service-worker.js'); + $mech->content_contains('translation_strings'); + $mech->content_contains('offline/fallback'); +}; + +subtest 'offline fallback page' => sub { + $mech->get_ok('/offline/fallback'); + $mech->content_contains('Offline'); + $mech->content_contains('offline_list'); +}; + +done_testing();
\ No newline at end of file diff --git a/t/app/controller/root.t b/t/app/controller/root.t index 85119da24..0263b65d7 100644 --- a/t/app/controller/root.t +++ b/t/app/controller/root.t @@ -60,18 +60,6 @@ FixMyStreet::override_config { is $mech->res->previous, undef, 'No redirect'; } }; - - subtest 'LOGIN_REQUIRED = 1 404s blacklisted URLs' => sub { - my @blacklist = ( - '/offline/appcache', - ); - - foreach my $url (@blacklist) { - $mech->get($url); - ok !$mech->res->is_success(), "want a bad response"; - is $mech->res->code, 404, "got 404"; - } - }; }; subtest "check_login_disallowed cobrand hook" => sub { |