blob: 1942158c62346895274ec63a636722803c702aa4 [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$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
19 ->status_is(302)
20 ->header_is('Location' => '/');
21
22$t->get_ok('/')
23 ->status_is(200)
24 ->element_exists('div.notify-error')
Akron2e3d3772017-04-14 16:20:40 +020025 ->element_exists('input[name=handle_or_email][value=test]')
Akron741b2b12017-04-13 22:15:59 +020026 ;
Akronbe9d5b32017-04-05 20:48:24 +020027
Akron2e3d3772017-04-14 16:20:40 +020028
Akronbe9d5b32017-04-05 20:48:24 +020029done_testing;
30__END__
Akrone8235be2016-06-27 11:02:18 +020031
32
Akron741b2b12017-04-13 22:15:59 +020033
34
35
Akrone8235be2016-06-27 11:02:18 +020036ok(!$c->user->get('details'), 'User not logged in');
37
38# Login with user credentials
39ok($c->user->login('kustvakt', 'kustvakt2015'), 'Login with demo user');
40is($c->stash('user'), 'kustvakt', 'Kustvakt is logged in');
41like($c->stash('auth'), qr/^api_token /, 'Kustvakt is logged in');
42
43my $details = $c->user->get('details');
44is($details->{email}, 'kustvakt@ids-mannheim.de', 'Email');
45is($details->{firstName}, 'Kustvakt', 'Firstname');
46is($details->{lastName}, 'KorAP', 'Lastname');
47is($details->{country}, 'Germany', 'Country');
48is($details->{address}, 'Mannheim', 'Address');
49is($details->{username}, 'kustvakt', 'Username');
50is($details->{institution}, 'IDS Mannheim', 'Institution');
51
52my $settings = $c->user->get('settings');
53is($settings->{username}, 'kustvakt', 'Username');
54
55# ok($c->user->set(details => { firstName => 'Me' }), 'Set first name');
56#ok($c->user->set(details => {
57# firstName => 'Akron',
58# lastName => 'Fuxfell'
59#}), 'Set first name');
60
61# diag Dumper $c->user->get('info');
62
63ok(1,'Fine');
64
65done_testing;
66__END__