blob: ac81b5c7c5d0b32a943deb2a1a6572f4e11aed3e [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
7$ENV{MOJO_USERAGENT_DEBUG} = 1;
Akron741b2b12017-04-13 22:15:59 +02008$ENV{MOJO_MODE} = 'test';
Akrone8235be2016-06-27 11:02:18 +02009
10my $t = Test::Mojo->new('Kalamar');
11
Akronbe9d5b32017-04-05 20:48:24 +020012$t->get_ok('/')
13 ->element_exists('form[action=/user/login] input[name=handle_or_email]');
14
Akron741b2b12017-04-13 22:15:59 +020015#$t->post_ok('/user/login' => form => { handle_or_email => 'test' })
16# ->status_is(302);
Akronbe9d5b32017-04-05 20:48:24 +020017
Akron741b2b12017-04-13 22:15:59 +020018# TODO: Use csrf!!!
19
20$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
21 ->status_is(302)
22 ->header_is('Location' => '/');
23
24$t->get_ok('/')
25 ->status_is(200)
26 ->element_exists('div.notify-error')
27 # ->element_exists('input[name=handle_or_email][value=test]')
28 ;
Akronbe9d5b32017-04-05 20:48:24 +020029
30done_testing;
31__END__
Akrone8235be2016-06-27 11:02:18 +020032
33
Akron741b2b12017-04-13 22:15:59 +020034
35
36
Akrone8235be2016-06-27 11:02:18 +020037ok(!$c->user->get('details'), 'User not logged in');
38
39# Login with user credentials
40ok($c->user->login('kustvakt', 'kustvakt2015'), 'Login with demo user');
41is($c->stash('user'), 'kustvakt', 'Kustvakt is logged in');
42like($c->stash('auth'), qr/^api_token /, 'Kustvakt is logged in');
43
44my $details = $c->user->get('details');
45is($details->{email}, 'kustvakt@ids-mannheim.de', 'Email');
46is($details->{firstName}, 'Kustvakt', 'Firstname');
47is($details->{lastName}, 'KorAP', 'Lastname');
48is($details->{country}, 'Germany', 'Country');
49is($details->{address}, 'Mannheim', 'Address');
50is($details->{username}, 'kustvakt', 'Username');
51is($details->{institution}, 'IDS Mannheim', 'Institution');
52
53my $settings = $c->user->get('settings');
54is($settings->{username}, 'kustvakt', 'Username');
55
56# ok($c->user->set(details => { firstName => 'Me' }), 'Set first name');
57#ok($c->user->set(details => {
58# firstName => 'Akron',
59# lastName => 'Fuxfell'
60#}), 'Set first name');
61
62# diag Dumper $c->user->get('info');
63
64ok(1,'Fine');
65
66done_testing;
67__END__