| 1 | #!/usr/bin/perl -w |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | |
| 5 | use Test::More; |
| 6 | use Test::WWW::Mechanize::PSGI; |
| 7 | |
| 8 | use Gruntmaster::Data; |
| 9 | use JSON::MaybeXS qw/decode_json/; |
| 10 | use Log::Log4perl qw/:easy/; |
| 11 | |
| 12 | BEGIN { |
| 13 | eval { |
| 14 | dbinit 'dbi:Pg:dbname=gmtest'; 1; |
| 15 | } or plan skip_all => 'Cannot connect to test database (gmtest).'. "Error: $@"; |
| 16 | plan tests => 22; |
| 17 | } |
| 18 | |
| 19 | Log::Log4perl->easy_init($OFF); |
| 20 | my $mech = Test::WWW::Mechanize::PSGI->new(app => do 'app.psgi'); |
| 21 | |
| 22 | $mech->get_ok('/'); |
| 23 | $mech->title_is('Gruntmaster 6000', 'title'); |
| 24 | |
| 25 | $mech->get_ok('/pb/'); |
| 26 | $mech->title_is('Problems', 'title'); |
| 27 | |
| 28 | $mech->get_ok('/pb/arc'); |
| 29 | $mech->title_is('Problem in archive', 'title'); |
| 30 | |
| 31 | $mech->get_ok('/ct/'); |
| 32 | $mech->title_is('Contests', 'title'); |
| 33 | |
| 34 | $mech->get_ok('/ct/fc'); |
| 35 | $mech->title_is('Finished contest'); |
| 36 | |
| 37 | $mech->get_ok('/log/'); |
| 38 | $mech->title_is('Job log', 'title'); |
| 39 | |
| 40 | $mech->get_ok('/log/1'); |
| 41 | $mech->title_is('Job 1', 'title'); |
| 42 | |
| 43 | $mech->get_ok('/us/'); |
| 44 | $mech->title_is('Users', 'title'); |
| 45 | |
| 46 | $mech->get_ok('/us/MGV'); |
| 47 | # testdata.sql does not set name for users, therefore not checking title |
| 48 | #$mech->title_is('Marius Gavrilescu', 'title'); |
| 49 | |
| 50 | $mech->get_ok('/src/1.c'); |
| 51 | |
| 52 | $mech->get_ok('/st/fc'); |
| 53 | $mech->title_is('Standings', 'title'); |
| 54 | |
| 55 | $mech->get_ok('/ed/fc'); |
| 56 | $mech->title_is('Editorial of Finished contest', 'title'); |