From 204ba1c125dd2aa80a2208d0f44d2826aae19d02 Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Fri, 15 Oct 2010 13:53:11 +1300 Subject: [PATCH] bug 5309: Adjust progres bar Also added some test facilities wr73785 Signed-off-by: Galen Charlton (cherry picked from commit e2e1dfd86e2f4a6ef63829551c58c728633fa893) Signed-off-by: Chris Nighswonger --- .../prog/en/includes/background-job.inc | 4 +- .../intranet-tmpl/prog/en/modules/test/README | 1 + .../prog/en/modules/test/progressbar.tmpl | 43 ++++++++ test/README | 3 + test/progressbar.pl | 55 +++++++++ test/progressbarsubmit.pl | 104 ++++++++++++++++++ test/search.pl | 74 +++++++++++++ 7 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/test/README create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/test/progressbar.tmpl create mode 100644 test/README create mode 100755 test/progressbar.pl create mode 100755 test/progressbarsubmit.pl create mode 100755 test/search.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background-job.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background-job.inc index 46922e11d3..7d65d4d538 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/background-job.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background-job.inc @@ -15,7 +15,7 @@ if (json.job_status == 'completed') { percentage = 100; } - var bgproperty = (parseInt(percentage)*2-300)+"px 0px"; + var bgproperty = (parseInt(percentage/2)*3-300)+"px 0px"; $("#jobprogress").css("background-position",bgproperty); $("#jobprogresspercent").text(percentage); @@ -66,7 +66,7 @@ data: inputs.join('&'), url: f.action, dataType: 'json', - type: 'post', + type: 'post', success: function(json) { jobID = json.jobID; inBackgroundJobProgressTimer = false; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/test/README b/koha-tmpl/intranet-tmpl/prog/en/modules/test/README new file mode 100644 index 0000000000..20fe504cc4 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/test/README @@ -0,0 +1 @@ +Test templates, to be used with test scripts diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/test/progressbar.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/test/progressbar.tmpl new file mode 100644 index 0000000000..73f148fbdd --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/test/progressbar.tmpl @@ -0,0 +1,43 @@ + +Koha › Tools › Stage MARC Records For Import + + + + + + + +
+ +
+ + + + + + +
+
Job progress:
0%
+
+
+ +
+
+ +
+Completed: +
+ diff --git a/test/README b/test/README new file mode 100644 index 0000000000..fe2895c163 --- /dev/null +++ b/test/README @@ -0,0 +1,3 @@ +A collection of cgi and command line scripts that are useful for some testing, +but for one reason or another cannot be made into automated test in t. +Use with templates in koha-tmpl/intranet-tmpl/prog/en/modules/test diff --git a/test/progressbar.pl b/test/progressbar.pl new file mode 100755 index 0000000000..142184be30 --- /dev/null +++ b/test/progressbar.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl + +# Script for testing progressbar, part 1 - initial screem +# it is split into two scripts so we can use firebug to debug it + +# Koha library project www.koha.org + +# Licensed under the GPL + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +#use warnings; FIXME - Bug 2505 + +# standard or CPAN modules used +use CGI; +use CGI::Cookie; + +# Koha modules used +use C4::Context; +use C4::Auth; +use C4::Output; +use C4::BackgroundJob; + +my $input = new CGI; +my $dbh = C4::Context->dbh; +$dbh->{AutoCommit} = 0; + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "test/progressbar.tmpl", + query => $input, + type => "intranet", + debug => 1, + }); + +output_html_with_http_headers $input, $cookie, $template->output; + +exit 0; + + diff --git a/test/progressbarsubmit.pl b/test/progressbarsubmit.pl new file mode 100755 index 0000000000..a0dbde1510 --- /dev/null +++ b/test/progressbarsubmit.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +# Script for testing progressbar, part 2 - json submit handler +# and Z39.50 lookups + +# Koha library project www.koha.org + +# Licensed under the GPL + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +#use warnings; FIXME - Bug 2505 + +# standard or CPAN modules used +use CGI; +use CGI::Cookie; + +# Koha modules used +use C4::Context; +use C4::Auth; +use C4::Output; +use C4::BackgroundJob; + +my $input = new CGI; + +my $submitted=$input->param('submitted'); +my $runinbackground = $input->param('runinbackground'); +my $jobID = $input->param('jobID'); +my $completedJobID = $input->param('completedJobID'); + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "test/progressbar.tmpl", + query => $input, + type => "intranet", + debug => 1, + }); + +my %cookies = parse CGI::Cookie($cookie); +my $sessionID = $cookies{'CGISESSID'}->value; +if ($completedJobID) { +} elsif ($submitted) { + my $job = undef; + if ($runinbackground) { + my $job_size = 100; + $job = C4::BackgroundJob->new($sessionID, undef, $ENV{'SCRIPT_NAME'}, $job_size); + $jobID = $job->id(); + + # fork off + if (my $pid = fork) { + # parent + # return job ID as JSON + + # prevent parent exiting from + # destroying the kid's database handle + # FIXME: according to DBI doc, this may not work for Oracle + + my $reply = CGI->new(""); + print $reply->header(-type => 'text/html'); + print "{ jobID: '$jobID' }"; + exit 0; + } elsif (defined $pid) { + # if we get here, we're a child that has detached + # itself from Apache + + # close STDOUT to signal to Apache that + # we're now running in the background + close STDOUT; + close STDERR; + + foreach (1..100) { + sleep 1; + $job->progress( $_ ); + } + $job->finish(); + } else { + # fork failed, so exit immediately + die "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job"; + } + + } +} else { + # initial form + die "We should not be here"; +} + +exit 0; + + diff --git a/test/search.pl b/test/search.pl new file mode 100755 index 0000000000..4362791b74 --- /dev/null +++ b/test/search.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl -w + +use C4::Search; + +my @SEARCH = ( + { operators => [ + 'and', + 'and' + ], + operands => [ + 'shakespeare, "(william)"', + 'dream' + ], + indexes => [ + 'au,wrdl', + 'ti', + 'kw' + ], + limits => [ + 'yr,st-numeric=2000-' + ], + sort_by => [ + 'relevance' + ], + lang => 'en', + }, +); + + +foreach ( @SEARCH ) { + my ($expected, @mismatch); + my( $error, + $query, + $simple_query, + $query_cgi, + $query_desc, + $limit, + $limit_cgi, + $limit_desc, + $stopwords_removed, + $query_type ) + = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0, $_->{lang} ); + + die $error if $error; + + $expected = $_->{query}; + push @mismatch, "Query: $query (not: $expected)" unless $query eq $expected; + + $expected = $_->{simple_query}; + push @mismatch, "Simple Query: $simple_query (not: $expected)" unless $simple_query eq $expected; + + $expected = $_->{query_cgi}; + push @mismatch, "Query CGI: $query_cgi (not: $expected)" unless $query_cgi eq $expected; + + $expected = $_->{query_desc}; + push @mismatch, "Query desc: $query_desc (not: $expected)" unless $query_desc eq $expected; + + $expected = $_->{limit}; + push @mismatch, "Limit: $limit (not: $expected)" unless $limit eq $expected; + + $expected = $_->{limit_cgi}; + push @mismatch, "Limit CGI: $limit_cgi (not: $expected)" unless $limit_cgi eq $expected; + + $expected = $_->{limit_desc}; + push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected; + + $expected = $_->{stopwords_removed}; + push @mismatch, "Stopwords removed: $stopwords_removed (not: $expected)" unless $stopwords_removed eq $expected; + + $expected = $_->{query_type}; + push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected; + + die map "$_\n", @mismatch if @mismatch; +} -- 2.39.5