View | Details | Raw Unified | Return to bug 16423
Collapse All | Expand All

(-)a/t/db_dependent/www/batch.t (-16 / +25 lines)
Lines 17-26 Link Here
17
#
17
#
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
20
use utf8;
21
use utf8;
21
use Test::More tests => 20;
22
use Test::More tests => 20;
22
use Test::WWW::Mechanize;
23
use Test::WWW::Mechanize;
23
use Data::Dumper;
24
use XML::Simple;
24
use XML::Simple;
25
use JSON;
25
use JSON;
26
use File::Basename;
26
use File::Basename;
Lines 71-77 $agent->follow_link_ok( { text => 'Stage MARC records for import' }, Link Here
71
    'go to stage MARC' );
71
    'go to stage MARC' );
72
72
73
$agent->post(
73
$agent->post(
74
    "$intranet/cgi-bin/koha/tools/upload-file.pl",
74
    "$intranet/cgi-bin/koha/tools/upload-file.pl?temp=1",
75
    [ 'fileToUpload' => [$file], ],
75
    [ 'fileToUpload' => [$file], ],
76
    'Content_Type' => 'form-data',
76
    'Content_Type' => 'form-data',
77
);
77
);
Lines 96-101 $agent->submit_form_ok( Link Here
96
            'encoding'        => 'utf8',
96
            'encoding'        => 'utf8',
97
            'parse_items'     => '1',
97
            'parse_items'     => '1',
98
            'runinbackground' => '1',
98
            'runinbackground' => '1',
99
            'record_type'     => 'biblio'
99
        }
100
        }
100
    },
101
    },
101
    'stage MARC'
102
    'stage MARC'
Lines 150-161 $agent->submit_form_ok( Link Here
150
            'parse_items'     => '1',
151
            'parse_items'     => '1',
151
            'runinbackground' => '1',
152
            'runinbackground' => '1',
152
            'completedJobID'  => $jobID,
153
            'completedJobID'  => $jobID,
154
            'record_type'     => 'biblio'
153
        }
155
        }
154
    },
156
    },
155
    'stage MARC'
157
    'stage MARC'
156
);
158
);
157
159
158
$agent->follow_link_ok( { text => 'Manage staged records' }, 'view batch' );
160
$agent->follow_link_ok( { text => 'Manage staged records' }, 'view batch' );
161
159
my $bookdescription;
162
my $bookdescription;
160
if ( $marcflavour eq 'UNIMARC' ) {
163
if ( $marcflavour eq 'UNIMARC' ) {
161
    $bookdescription = 'Jeffrey Esakov et Tom Weiss';
164
    $bookdescription = 'Jeffrey Esakov et Tom Weiss';
Lines 163-186 if ( $marcflavour eq 'UNIMARC' ) { Link Here
163
else {
166
else {
164
    $bookdescription = 'Data structures';
167
    $bookdescription = 'Data structures';
165
}
168
}
166
$agent->content_contains( $bookdescription, 'found book' );
169
167
$agent->form_number(5);
170
# Save the staged records URI for later use
171
my $staged_records_uri = $agent->uri;
172
173
my $import_batch_id = ( split( '=', $staged_records_uri->as_string ) )[-1];
174
# Get datatable for the batch id
175
$agent->get_ok(
176
    "$intranet/cgi-bin/koha/tools/batch_records_ajax.pl?import_batch_id=$import_batch_id",
177
    'get the datatable for the new batch id'
178
);
179
$jsonresponse = decode_json $agent->content;
180
like( $jsonresponse->{ aaData }[0]->{ citation }, qr/$bookdescription/, 'found book' );
181
my $biblionumber = $jsonresponse->{ aaData }[0]->{ import_record_id };
182
# Back to the manage staged records page
183
$agent->get($staged_records_uri);
184
$agent->form_number(6);
168
$agent->field( 'framework', '' );
185
$agent->field( 'framework', '' );
169
$agent->click_ok( 'mainformsubmit', "imported records into catalog" );
186
$agent->click_ok( 'mainformsubmit', "imported records into catalog" );
170
my $newbib;
171
foreach my $link ( $agent->links() ) {
172
    if ( $link->url() =~ m#/cgi-bin/koha/catalogue/detail.pl\?biblionumber=# ) {
173
        $newbib = $link->text();
174
        $agent->link_content_like( [$link], qr/$bookdescription/,
175
            'successfully imported record' );
176
        last;
177
    }
178
}
179
187
180
$agent->form_number(4);
188
$agent->form_number(5);
181
$agent->click_ok( 'mainformsubmit', "revert import" );
189
$agent->click_ok( 'mainformsubmit', "revert import" );
182
$agent->get_ok(
190
$agent->get_ok(
183
    "$intranet/cgi-bin/koha/catalogue/detail.pl?biblionumber=$newbib",
191
    "$intranet/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber",
184
    'getting reverted bib' );
192
    'getting reverted bib' );
185
$agent->content_contains( 'The record you requested does not exist',
193
$agent->content_contains( 'The record you requested does not exist',
186
    'bib is gone' );
194
    'bib is gone' );
187
- 
195
196
1;

Return to bug 16423