blob: 5e23b954168458a67100564d63b29fc2a9c807bc [file] [log] [blame]
Akrone8235be2016-06-27 11:02:18 +02001use Mojo::Base -strict;
2use lib '../lib', 'lib';
Akronbe9d5b32017-04-05 20:48:24 +02003use Test::More;
Akrone8235be2016-06-27 11:02:18 +02004use Test::Mojo;
5use Data::Dumper;
6
Akron741b2b12017-04-13 22:15:59 +02007$ENV{MOJO_MODE} = 'test';
Akrone8235be2016-06-27 11:02:18 +02008
9my $t = Test::Mojo->new('Kalamar');
10
Akronbe9d5b32017-04-05 20:48:24 +020011$t->get_ok('/')
12 ->element_exists('form[action=/user/login] input[name=handle_or_email]');
13
Akron741b2b12017-04-13 22:15:59 +020014#$t->post_ok('/user/login' => form => { handle_or_email => 'test' })
15# ->status_is(302);
Akronbe9d5b32017-04-05 20:48:24 +020016
Akron741b2b12017-04-13 22:15:59 +020017$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
18 ->status_is(302)
19 ->header_is('Location' => '/');
20
21$t->get_ok('/')
22 ->status_is(200)
23 ->element_exists('div.notify-error')
Akron2e3d3772017-04-14 16:20:40 +020024 ->element_exists('input[name=handle_or_email][value=test]')
Akron741b2b12017-04-13 22:15:59 +020025 ;
Akronbe9d5b32017-04-05 20:48:24 +020026
Akron2e3d3772017-04-14 16:20:40 +020027
Akronbe9d5b32017-04-05 20:48:24 +020028done_testing;
29__END__
Akrone8235be2016-06-27 11:02:18 +020030
31
Akron741b2b12017-04-13 22:15:59 +020032
33
34
Akrone8235be2016-06-27 11:02:18 +020035ok(!$c->user->get('details'), 'User not logged in');
36
37# Login with user credentials
38ok($c->user->login('kustvakt', 'kustvakt2015'), 'Login with demo user');
39is($c->stash('user'), 'kustvakt', 'Kustvakt is logged in');
40like($c->stash('auth'), qr/^api_token /, 'Kustvakt is logged in');
41
42my $details = $c->user->get('details');
43is($details->{email}, 'kustvakt@ids-mannheim.de', 'Email');
44is($details->{firstName}, 'Kustvakt', 'Firstname');
45is($details->{lastName}, 'KorAP', 'Lastname');
46is($details->{country}, 'Germany', 'Country');
47is($details->{address}, 'Mannheim', 'Address');
48is($details->{username}, 'kustvakt', 'Username');
49is($details->{institution}, 'IDS Mannheim', 'Institution');
50
51my $settings = $c->user->get('settings');
52is($settings->{username}, 'kustvakt', 'Username');
53
54# ok($c->user->set(details => { firstName => 'Me' }), 'Set first name');
55#ok($c->user->set(details => {
56# firstName => 'Akron',
57# lastName => 'Fuxfell'
58#}), 'Set first name');
59
60# diag Dumper $c->user->get('info');
61
62ok(1,'Fine');
63
64done_testing;
65__END__