Skip to content

Commit

Permalink
Add 'latest' query route
Browse files Browse the repository at this point in the history
Should always refer to most recent job for the specified scenario.

* have the same link for test development, i.e. if one retriggers tests, the
person has to always update the URL. If there would be a static URL even the
browser can be instructed to reload the page automatically

* for linking to the always current execution of the last job within one
scenario, e.g. to respond faster to the standard question in bug reports "does
this bug still happen?"
  • Loading branch information
okurz committed Aug 2, 2016
1 parent 8671a0b commit c1d7e2e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/OpenQA/WebAPI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ sub startup {

$r->get('/tests')->name('tests')->to('test#list');
$r->get('/tests/overview')->name('tests_overview')->to('test#overview');
$r->get('/tests/latest')->name('latest')->to('test#latest');

$r->get('/tests/export')->name('tests_export')->to('test#export');
$r->post('/tests/list_ajax')->name('tests_ajax')->to('test#list_ajax');
my $test_r = $r->route('/tests/:testid', testid => qr/\d+/);
Expand Down
13 changes: 13 additions & 0 deletions lib/OpenQA/WebAPI/Controller/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,19 @@ sub overview {
);
}

sub latest {
my ($self) = @_;
my %search_args;
for my $arg (@scenario_keys) {
my $key = lc $arg;
next unless defined $self->param($key);
$search_args{$key} = $self->param($key);
}
my $job = $self->db->resultset("Jobs")->complex_query(%search_args)->first;
return $self->render(text => 'No matching job found', status => 404) unless $job;
return $self->redirect_to('test', testid => $job->id);
}

sub add_comment {
my ($self) = @_;

Expand Down
10 changes: 10 additions & 0 deletions t/ui/18-tests-details.t
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ is($num_active_tabs, 1, 'only one tab visible at the same time');
my $href_to_isosize = $t->tx->res->dom->at('.component a[href*=installer_timezone]')->{href};
$t->get_ok($baseurl . ($href_to_isosize =~ s@^/@@r))->status_is(200);

subtest 'route to latest' => sub {
$get = $t->get_ok($baseurl . 'tests/latest?distri=opensuse&version=13.1&flavor=DVD&arch=x86_64&test=kde&machine=64bit')->status_is(302);
is($t->tx->res->headers->location, '/tests/99963', 'latest link shows tests/99963');
$get = $t->get_ok($baseurl . 'tests/latest?flavor=DVD&arch=x86_64&test=kde')->status_is(302);
is($t->tx->res->headers->location, '/tests/99963', '... as long as it is unique');
$get = $t->get_ok($baseurl . 'tests/latest?version=13.1')->status_is(302);
is($t->tx->res->headers->location, '/tests/99981', 'returns highest job nr of ambiguous group');
$get = $t->get_ok($baseurl . 'tests/latest?test=foobar')->status_is(404);
};

#print $driver->get_page_source();
#t::ui::PhantomTest::make_screenshot('mojoResults.png');

Expand Down

0 comments on commit c1d7e2e

Please sign in to comment.