Improve unit test (#2071)
This commit is contained in:
parent
a0ef149b5f
commit
04912c7854
|
@ -1,9 +1,10 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use strict;
|
use strict;
|
||||||
use IO::String;
|
use IO::String;
|
||||||
|
use JSON qw(from_json);
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
my $maintests = 10;
|
my $maintests = 17;
|
||||||
require 't/test-lib.pm';
|
require 't/test-lib.pm';
|
||||||
my $file = tempdb();
|
my $file = tempdb();
|
||||||
|
|
||||||
|
@ -105,7 +106,8 @@ q{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',?,
|
||||||
notificationStorageOptions => {
|
notificationStorageOptions => {
|
||||||
dbiChain => "dbi:SQLite:dbname=$file",
|
dbiChain => "dbi:SQLite:dbname=$file",
|
||||||
},
|
},
|
||||||
oldNotifFormat => 0,
|
oldNotifFormat => 0,
|
||||||
|
notificationsExplorer => 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -179,7 +181,7 @@ q{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',?,
|
||||||
!defined( $cookies->{lemonldappdata} ),
|
!defined( $cookies->{lemonldappdata} ),
|
||||||
" Make sure no pdata is returned"
|
" Make sure no pdata is returned"
|
||||||
);
|
);
|
||||||
$client->logout($id);
|
$id = expectCookie($res);
|
||||||
|
|
||||||
# Verify that notification was tagged as 'done'
|
# Verify that notification was tagged as 'done'
|
||||||
my $sth =
|
my $sth =
|
||||||
|
@ -189,6 +191,32 @@ q{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',?,
|
||||||
while ( $sth->fetchrow_hashref ) { $i++ }
|
while ( $sth->fetchrow_hashref ) { $i++ }
|
||||||
ok( $i == 2, 'Notification was deleted' );
|
ok( $i == 2, 'Notification was deleted' );
|
||||||
|
|
||||||
|
# GET notifications explorer
|
||||||
|
ok(
|
||||||
|
$res = $client->_get(
|
||||||
|
'/mynotifications', cookie => "lemonldap=$id",
|
||||||
|
),
|
||||||
|
'Notifications explorer query'
|
||||||
|
);
|
||||||
|
|
||||||
|
my $json;
|
||||||
|
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
|
||||||
|
or print STDERR "$@\n" . Dumper($res);
|
||||||
|
ok( $json->{result} == 2, ' Result is 2' )
|
||||||
|
or explain( $json, "result => 2" );
|
||||||
|
ok( $json->{MSG} == 'myNotifications', ' MSG is myNotifications' )
|
||||||
|
or explain( $json, "result => 2" );
|
||||||
|
ok( $json->{NOTIFICATIONS}->[0]->{reference} =~ /testref2?/,
|
||||||
|
' Notification 1 found' )
|
||||||
|
or explain( $json, "Notification 1" );
|
||||||
|
ok( $json->{NOTIFICATIONS}->[0]->{reference} =~ /testref2?/,
|
||||||
|
' Notification 2 found' )
|
||||||
|
or explain( $json, "Notification 2" );
|
||||||
|
ok( $json->{NOTIFICATIONS}->[0]->{epoch} =~ /\d{10}/, ' epoch found' )
|
||||||
|
or explain( $json, "Epoch found" );
|
||||||
|
|
||||||
|
$client->logout($id);
|
||||||
|
|
||||||
# Try to authenticate
|
# Try to authenticate
|
||||||
# -------------------
|
# -------------------
|
||||||
ok(
|
ok(
|
||||||
|
|
|
@ -150,6 +150,7 @@ qq{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00','
|
||||||
!defined( $cookies->{lemonldappdata} ),
|
!defined( $cookies->{lemonldappdata} ),
|
||||||
" Make sure no pdata is returned"
|
" Make sure no pdata is returned"
|
||||||
);
|
);
|
||||||
|
$id = expectCookie($res);
|
||||||
$client->logout($id);
|
$client->logout($id);
|
||||||
|
|
||||||
# Verify that notification was tagged as 'done'
|
# Verify that notification was tagged as 'done'
|
||||||
|
|
|
@ -29,9 +29,10 @@ my $client = LLNG::Manager::Test->new( {
|
||||||
notification => 1,
|
notification => 1,
|
||||||
notificationStorage => 'File',
|
notificationStorage => 'File',
|
||||||
notificationStorageOptions => { dirName => $main::tmpDir },
|
notificationStorageOptions => { dirName => $main::tmpDir },
|
||||||
|
portalMainLogo => 'common/logos/logo_llng_old.png',
|
||||||
oldNotifFormat => 0,
|
oldNotifFormat => 0,
|
||||||
notificationsExplorer => 1,
|
notificationsExplorer => 1,
|
||||||
portalMainLogo => 'common/logos/logo_llng_old.png', }
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -82,8 +83,7 @@ expectForm( $res, undef, '/notifback', 'reference1x1' );
|
||||||
# Verify that cookie is ciphered (session unvalid)
|
# Verify that cookie is ciphered (session unvalid)
|
||||||
ok(
|
ok(
|
||||||
$res = $client->_get(
|
$res = $client->_get(
|
||||||
'/',
|
'/', cookie => "lemonldap=$id",
|
||||||
cookie => "lemonldap=$id",
|
|
||||||
),
|
),
|
||||||
'Test cookie received'
|
'Test cookie received'
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,7 @@ require 't/test-lib.pm';
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.xml";
|
my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.xml";
|
||||||
my $maintests = 34;
|
my $maintests = 36;
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
eval { require XML::LibXML; require XML::LibXSLT; };
|
eval { require XML::LibXML; require XML::LibXSLT; };
|
||||||
|
@ -23,6 +23,12 @@ SKIP: {
|
||||||
<text>This is a test text</text>
|
<text>This is a test text</text>
|
||||||
<check>Accept test</check>
|
<check>Accept test</check>
|
||||||
<check>Accept test2</check>
|
<check>Accept test2</check>
|
||||||
|
</notification><notification uid="dwho" date="2016-05-30" reference="testref2">
|
||||||
|
<title>Test title</title>
|
||||||
|
<subtitle>Test subtitle</subtitle>
|
||||||
|
<text>This is a test text</text>
|
||||||
|
<check>Accept test</check>
|
||||||
|
<check>Accept test2</check>
|
||||||
</notification></root>';
|
</notification></root>';
|
||||||
close F;
|
close F;
|
||||||
|
|
||||||
|
@ -33,9 +39,9 @@ SKIP: {
|
||||||
notification => 1,
|
notification => 1,
|
||||||
notificationStorage => 'File',
|
notificationStorage => 'File',
|
||||||
notificationStorageOptions => { dirName => $main::tmpDir },
|
notificationStorageOptions => { dirName => $main::tmpDir },
|
||||||
|
portalMainLogo => 'common/logos/logo_llng_old.png',
|
||||||
oldNotifFormat => 1,
|
oldNotifFormat => 1,
|
||||||
notificationsExplorer => 1,
|
notificationsExplorer => 1,
|
||||||
portalMainLogo => 'common/logos/logo_llng_old.png',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -81,13 +87,12 @@ SKIP: {
|
||||||
count(1);
|
count(1);
|
||||||
expectOK($res);
|
expectOK($res);
|
||||||
$id = expectCookie($res);
|
$id = expectCookie($res);
|
||||||
expectForm( $res, undef, '/notifback', 'reference1x1' );
|
expectForm( $res, undef, '/notifback', 'reference1x1', 'reference1x2' );
|
||||||
|
|
||||||
# Verify that cookie is ciphered (session unvalid)
|
# Verify that cookie is ciphered (session unvalid)
|
||||||
ok(
|
ok(
|
||||||
$res = $client->_get(
|
$res = $client->_get(
|
||||||
'/',
|
'/', cookie => "lemonldap=$id",
|
||||||
cookie => "lemonldap=$id",
|
|
||||||
),
|
),
|
||||||
'Test cookie received'
|
'Test cookie received'
|
||||||
);
|
);
|
||||||
|
@ -95,7 +100,8 @@ SKIP: {
|
||||||
expectReject($res);
|
expectReject($res);
|
||||||
|
|
||||||
# Try to validate notification with accepting all checkboxes
|
# Try to validate notification with accepting all checkboxes
|
||||||
my $str = 'reference1x1=testref&check1x1x1=accepted&check1x1x2=accepted';
|
my $str =
|
||||||
|
'reference1x1=testref&check1x1x1=accepted&check1x1x2=accepted&reference1x2=testref2&check1x2x1=accepted&check1x2x2=accepted';
|
||||||
ok(
|
ok(
|
||||||
$res = $client->_post(
|
$res = $client->_post(
|
||||||
'/notifback',
|
'/notifback',
|
||||||
|
@ -140,9 +146,10 @@ SKIP: {
|
||||||
ok( $res->[2]->[0] =~ m%<span id="languages"></span>%,
|
ok( $res->[2]->[0] =~ m%<span id="languages"></span>%,
|
||||||
' Language icons found' )
|
' Language icons found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ m%<span id="msg" trspan=\'myNotification\'></span>%,
|
ok(
|
||||||
' trspan="myNotification" found' )
|
$res->[2]->[0] =~ m%<span id="msg" trspan=\'myNotifications\'></span>%,
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
' trspan="myNotifications" found'
|
||||||
|
) or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ m%<th><span trspan="date">Date</span></th>%,
|
ok( $res->[2]->[0] =~ m%<th><span trspan="date">Date</span></th>%,
|
||||||
' trspan="date" found' )
|
' trspan="date" found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
|
@ -159,8 +166,16 @@ SKIP: {
|
||||||
ok( $res->[2]->[0] =~ m%<td class="align-middle">testref</td>%,
|
ok( $res->[2]->[0] =~ m%<td class="align-middle">testref</td>%,
|
||||||
' testref found' )
|
' testref found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
|
ok( $res->[2]->[0] =~ m%<td class="align-middle">testref2</td>%,
|
||||||
|
' testref2 found' )
|
||||||
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ m%class="fa fa-eye"></span>%, ' fa-eye found' )
|
ok( $res->[2]->[0] =~ m%class="fa fa-eye"></span>%, ' fa-eye found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
|
ok(
|
||||||
|
$res->[2]->[0] =~
|
||||||
|
m%<span id=\'icon-testref2-\d{10}\' class="fa fa-eye"></span>%,
|
||||||
|
' fa-eye 2 found'
|
||||||
|
) or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ m%<span id=\'displayNotif\'></span>%,
|
ok( $res->[2]->[0] =~ m%<span id=\'displayNotif\'></span>%,
|
||||||
' Notififcation container found' )
|
' Notififcation container found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user