diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-07-25 14:53:14 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-07-25 14:59:57 +0200 |
commit | a75597fd73b4effd6ec3163c2b8741ffa2a83aa2 (patch) | |
tree | dd5b0b6d812fa24fbf2851dc2f02105e057dfe26 | |
parent | bdc5cb4ec35357562329d8ecb69ae91d2d9a4593 (diff) |
add very basic locale tests
-rw-r--r-- | t/02-static-en.t | 50 | ||||
-rw-r--r-- | t/03-static-fr.t | 50 | ||||
-rw-r--r-- | t/10-registration.t (renamed from t/02-registration.t) | 0 |
3 files changed, 100 insertions, 0 deletions
diff --git a/t/02-static-en.t b/t/02-static-en.t new file mode 100644 index 0000000..26641cb --- /dev/null +++ b/t/02-static-en.t @@ -0,0 +1,50 @@ +#!/usr/bin/env perl + +# Copyright (C) 2020 Birte Kristina Friesel <derf@finalrewind.org> +# +# SPDX-License-Identifier: MIT + +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +# Include application +use FindBin; +require "$FindBin::Bin/../index.pl"; + +my $t = Test::Mojo->new('Travelynx'); + +$t->ua->on( start => sub { $_[1]->req->headers->accept_language('en-GB') } ); + +$t->get_ok('/')->status_is(200); +$t->text_like( 'a[href="/register"]' => qr{Register} ); +$t->text_like( 'a[href="/login"]' => qr{Login} ); + +$t->get_ok('/about')->status_is(200); +$t->get_ok('/api')->status_is(200); +$t->get_ok('/changelog')->status_is(200); +$t->get_ok('/legend')->status_is(200); +$t->get_ok('/offline.html')->status_is(200); + +$t->get_ok('/login')->status_is(200); +$t->element_exists('input[name="csrf_token"]'); +$t->text_like( 'button' => qr{Login} ); + +$t->get_ok('/recover')->status_is(200); + +$t->get_ok('/register')->status_is(200); +$t->element_exists('input[name="csrf_token"]'); +$t->element_exists('a[href="/impressum"]'); +$t->text_like( 'button' => qr{Register} ); + +# Protected sites should redirect to login form + +for my $protected (qw(/account /account/password /history /s/EE)) { + $t->get_ok($protected)->text_like( 'button' => qr{Login} ); +} + +# Otherwise, we expect a 404 +$t->get_ok('/definitelydoesnotexist')->status_is(404); + +done_testing(); diff --git a/t/03-static-fr.t b/t/03-static-fr.t new file mode 100644 index 0000000..dc4c278 --- /dev/null +++ b/t/03-static-fr.t @@ -0,0 +1,50 @@ +#!/usr/bin/env perl + +# Copyright (C) 2020 Birte Kristina Friesel <derf@finalrewind.org> +# +# SPDX-License-Identifier: MIT + +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +# Include application +use FindBin; +require "$FindBin::Bin/../index.pl"; + +my $t = Test::Mojo->new('Travelynx'); + +$t->ua->on( start => sub { $_[1]->req->headers->accept_language('fr-FR') } ); + +$t->get_ok('/')->status_is(200); +$t->text_like( 'a[href="/register"]' => qr{Inscription} ); +$t->text_like( 'a[href="/login"]' => qr{Connexion} ); + +$t->get_ok('/about')->status_is(200); +$t->get_ok('/api')->status_is(200); +$t->get_ok('/changelog')->status_is(200); +$t->get_ok('/legend')->status_is(200); +$t->get_ok('/offline.html')->status_is(200); + +$t->get_ok('/login')->status_is(200); +$t->element_exists('input[name="csrf_token"]'); +$t->text_like( 'button' => qr{Connexion} ); + +$t->get_ok('/recover')->status_is(200); + +$t->get_ok('/register')->status_is(200); +$t->element_exists('input[name="csrf_token"]'); +$t->element_exists('a[href="/impressum"]'); +$t->text_like( 'button' => qr{Inscription} ); + +# Protected sites should redirect to login form + +for my $protected (qw(/account /account/password /history /s/EE)) { + $t->get_ok($protected)->text_like( 'button' => qr{Connexion} ); +} + +# Otherwise, we expect a 404 +$t->get_ok('/definitelydoesnotexist')->status_is(404); + +done_testing(); diff --git a/t/02-registration.t b/t/10-registration.t index ec09eaf..ec09eaf 100644 --- a/t/02-registration.t +++ b/t/10-registration.t |