summaryrefslogtreecommitdiff
path: root/t/01-static.t
blob: bbdacf7c6305c2cf5394cbab7961f63a58b28630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env perl

# Copyright (C) 2020 Daniel Friesel <daniel.friesel@uos.de>
#
# 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->get_ok('/')->status_is(200);
$t->text_like( 'a[href="/register"]' => qr{Registrieren} );
$t->text_like( 'a[href="/login"]'    => qr{Anmelden} );

$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{Registrieren} );

$t->get_ok('/login')->status_is(200);
$t->element_exists('input[name="csrf_token"]');
$t->text_like( 'button' => qr{Anmelden} );

$t->get_ok('/about')->status_is(200);

# 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{Anmelden} );
}

# Otherwise, we expect a 404
$t->get_ok('/definitelydoesnotexist')->status_is(404);

done_testing();