travelynx/t/01-static.t

43 lines
1 KiB
Perl
Raw Normal View History

2019-04-18 16:22:17 +00:00
#!/usr/bin/env perl
2020-11-27 21:12:56 +00:00
2023-06-24 16:36:59 +00:00
# Copyright (C) 2020 Birthe Friesel <derf@finalrewind.org>
2020-11-27 21:12:56 +00:00
#
# SPDX-License-Identifier: MIT
2019-04-18 16:22:17 +00:00
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
# Include application
use FindBin;
require "$FindBin::Bin/../index.pl";
2019-04-18 18:52:51 +00:00
my $t = Test::Mojo->new('Travelynx');
2019-04-18 16:22:17 +00:00
$t->get_ok('/')->status_is(200);
2019-04-18 18:52:51 +00:00
$t->text_like( 'a[href="/register"]' => qr{Registrieren} );
$t->text_like( 'a[href="/login"]' => qr{Anmelden} );
2019-04-18 16:22:17 +00:00
$t->get_ok('/register')->status_is(200);
$t->element_exists('input[name="csrf_token"]');
$t->element_exists('a[href="/impressum"]');
2019-04-18 18:52:51 +00:00
$t->text_like( 'button' => qr{Registrieren} );
2019-04-18 16:22:17 +00:00
$t->get_ok('/login')->status_is(200);
$t->element_exists('input[name="csrf_token"]');
2019-04-18 18:52:51 +00:00
$t->text_like( 'button' => qr{Anmelden} );
2019-04-18 16:22:17 +00:00
$t->get_ok('/about')->status_is(200);
# Protected sites should redirect to login form
for my $protected (qw(/account /account/password /history /s/EE)) {
2019-04-18 18:52:51 +00:00
$t->get_ok($protected)->text_like( 'button' => qr{Anmelden} );
2019-04-18 16:22:17 +00:00
}
# Otherwise, we expect a 404
$t->get_ok('/definitelydoesnotexist')->status_is(404);
done_testing();