Bug 16423: (followup) Add more tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 2 May 2016 20:42:29 +0000 (17:42 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 3 May 2016 15:33:00 +0000 (15:33 +0000)
On fixing this tests, we retrieved the JSON data for the datatable used on
the 'Manage staged records' page. It would be cool to check the data it
carries makes sense.

To test:
- Run t/db_dependent/www/batch.t
=> SUCCESS: Tests pass
- Sign off :-D

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
All test pass
prove t/db_dependent/www/batch.t
t/db_dependent/www/batch.t .. ok
All tests successful.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/db_dependent/www/batch.t

index bf04ea1..0390cf7 100644 (file)
@@ -19,7 +19,7 @@
 use Modern::Perl;
 
 use utf8;
-use Test::More tests => 20;
+use Test::More tests => 24;
 use Test::WWW::Mechanize;
 use XML::Simple;
 use JSON;
@@ -178,6 +178,9 @@ $agent->get_ok(
 );
 $jsonresponse = decode_json $agent->content;
 like( $jsonresponse->{ aaData }[0]->{ citation }, qr/$bookdescription/, 'found book' );
+is( $jsonresponse->{ aaData }[0]->{ status }, 'staged', 'record marked as staged' );
+is( $jsonresponse->{ aaData }[0]->{ overlay_status }, 'no_match', 'record has no matches' );
+
 my $biblionumber = $jsonresponse->{ aaData }[0]->{ import_record_id };
 # Back to the manage staged records page
 $agent->get($staged_records_uri);
@@ -185,6 +188,11 @@ $agent->form_number(6);
 $agent->field( 'framework', '' );
 $agent->click_ok( 'mainformsubmit', "imported records into catalog" );
 
+$agent->get("$intranet/cgi-bin/koha/tools/batch_records_ajax.pl?import_batch_id=$import_batch_id");
+$jsonresponse = decode_json $agent->content;
+is( $jsonresponse->{ aaData }[0]->{ status }, 'imported', 'record marked as imported' );
+
+$agent->get($staged_records_uri);
 $agent->form_number(5);
 $agent->click_ok( 'mainformsubmit', "revert import" );
 $agent->get_ok(
@@ -193,4 +201,8 @@ $agent->get_ok(
 $agent->content_contains( 'The record you requested does not exist',
     'bib is gone' );
 
+$agent->get("$intranet/cgi-bin/koha/tools/batch_records_ajax.pl?import_batch_id=$import_batch_id");
+$jsonresponse = decode_json $agent->content;
+is( $jsonresponse->{ aaData }[0]->{ status }, 'reverted', 'record marked as reverted' );
+
 1;