Akron | e8235be | 2016-06-27 11:02:18 +0200 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use lib '../lib', 'lib'; |
Akron | be9d5b3 | 2017-04-05 20:48:24 +0200 | [diff] [blame^] | 3 | use Test::More; |
Akron | e8235be | 2016-06-27 11:02:18 +0200 | [diff] [blame] | 4 | use Test::Mojo; |
| 5 | use Data::Dumper; |
| 6 | |
| 7 | $ENV{MOJO_USERAGENT_DEBUG} = 1; |
| 8 | |
| 9 | my $t = Test::Mojo->new('Kalamar'); |
| 10 | |
Akron | be9d5b3 | 2017-04-05 20:48:24 +0200 | [diff] [blame^] | 11 | $t->app->mode('test'); |
| 12 | |
| 13 | # my $c = $t->app->build_controller; |
| 14 | |
| 15 | $t->get_ok('/') |
| 16 | ->element_exists('form[action=/user/login] input[name=handle_or_email]'); |
| 17 | |
| 18 | $t->post_ok('/user/login' => form => { handle_or_email => 'test' }) |
| 19 | ->status_is(302); |
| 20 | |
| 21 | $t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'xyz' }); |
| 22 | |
| 23 | done_testing; |
| 24 | __END__ |
Akron | e8235be | 2016-06-27 11:02:18 +0200 | [diff] [blame] | 25 | |
| 26 | |
| 27 | ok(!$c->user->get('details'), 'User not logged in'); |
| 28 | |
| 29 | # Login with user credentials |
| 30 | ok($c->user->login('kustvakt', 'kustvakt2015'), 'Login with demo user'); |
| 31 | is($c->stash('user'), 'kustvakt', 'Kustvakt is logged in'); |
| 32 | like($c->stash('auth'), qr/^api_token /, 'Kustvakt is logged in'); |
| 33 | |
| 34 | my $details = $c->user->get('details'); |
| 35 | is($details->{email}, 'kustvakt@ids-mannheim.de', 'Email'); |
| 36 | is($details->{firstName}, 'Kustvakt', 'Firstname'); |
| 37 | is($details->{lastName}, 'KorAP', 'Lastname'); |
| 38 | is($details->{country}, 'Germany', 'Country'); |
| 39 | is($details->{address}, 'Mannheim', 'Address'); |
| 40 | is($details->{username}, 'kustvakt', 'Username'); |
| 41 | is($details->{institution}, 'IDS Mannheim', 'Institution'); |
| 42 | |
| 43 | my $settings = $c->user->get('settings'); |
| 44 | is($settings->{username}, 'kustvakt', 'Username'); |
| 45 | |
| 46 | # ok($c->user->set(details => { firstName => 'Me' }), 'Set first name'); |
| 47 | #ok($c->user->set(details => { |
| 48 | # firstName => 'Akron', |
| 49 | # lastName => 'Fuxfell' |
| 50 | #}), 'Set first name'); |
| 51 | |
| 52 | # diag Dumper $c->user->get('info'); |
| 53 | |
| 54 | ok(1,'Fine'); |
| 55 | |
| 56 | done_testing; |
| 57 | __END__ |