diff --git a/lib/OpenQA/WebAPI/Controller/Test.pm b/lib/OpenQA/WebAPI/Controller/Test.pm index 02d71af1dc9..ff4735e70f0 100644 --- a/lib/OpenQA/WebAPI/Controller/Test.pm +++ b/lib/OpenQA/WebAPI/Controller/Test.pm @@ -673,7 +673,7 @@ sub overview { my %stash = ( # build, version, distri are not mandatory and therefore not # necessarily come from the search args so they can be undefined. - build => $search_args->{build}, + build => ref $search_args->{build} eq 'ARRAY' ? join(',', @{$search_args->{build}}) : $search_args->{build}, version => $search_args->{version}, distri => $search_args->{distri}, groups => $groups, diff --git a/lib/OpenQA/WebAPI/Plugin/Helpers.pm b/lib/OpenQA/WebAPI/Plugin/Helpers.pm index 5fb935bd5fe..9fd4d6dc7ef 100644 --- a/lib/OpenQA/WebAPI/Plugin/Helpers.pm +++ b/lib/OpenQA/WebAPI/Plugin/Helpers.pm @@ -382,11 +382,17 @@ sub _compose_job_overview_search_args { # determine build number if (!$search_args{build}) { - # yield the latest build of the first group if (multiple) groups but not build specified - # note: the search arg 'groupid' is ignored by complex_query() because we later assign 'groupids' - $search_args{groupid} = $groups[0]->id if (@groups); - - $search_args{build} = $schema->resultset('Jobs')->latest_build(%search_args); + if (@groups) { + my %builds; + for my $group (@groups) { + my $build = $schema->resultset('Jobs')->latest_build(%search_args, groupid => $group->id) or next; + $builds{$build}++; + } + $search_args{build} = [sort keys %builds]; + } + else { + $search_args{build} = $schema->resultset('Jobs')->latest_build(%search_args); + } # print debug output if (@groups == 0) { diff --git a/t/10-tests_overview.t b/t/10-tests_overview.t index 87781254efa..a87d020ca8e 100644 --- a/t/10-tests_overview.t +++ b/t/10-tests_overview.t @@ -233,11 +233,40 @@ $t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=10 $summary = get_summary; like( $summary, - qr/Summary of opensuse, opensuse test/i, - 'multiple groups with no build specified yield latest build of first group' + qr/Summary of opensuse, opensuse test build 0091[^,]/i, + 'multiple groups with no build specified yield the same, latest build of every group' ); like($summary, qr/Passed: 2 Failed: 0 Scheduled: 1 Running: 2 None: 1/i); +my $jobGroup = $t->app->schema->resultset('JobGroups')->create( + { + id => 1003, + sort_order => 0, + name => 'opensuse test 2' + }); + +my $job = $t->app->schema->resultset('Jobs')->create( + { + id => 99964, + BUILD => '0092', + group_id => 1003, + TEST => 'kde', + DISTRI => 'opensuse', + VERSION => '13.1' + }); + +$t->get_ok('/tests/overview?distri=opensuse&version=13.1&groupid=1001&groupid=1003')->status_is(200); +$summary = get_summary; +like( + $summary, + qr/Summary of opensuse, opensuse test 2 build 0091,0092/i, + 'multiple groups with no build specified yield each build for every group' +); +like($summary, qr/Passed: 3 Failed: 0 Scheduled: 2 Running: 1 None: 1/i); + +$jobGroup->delete(); +$job->delete(); + # overview page searches for all available data with less specified parameters $t->get_ok('/tests/overview' => form => {build => '0091', version => '13.1'})->status_is(200); $t->get_ok('/tests/overview' => form => {build => '0091', distri => 'opensuse'})->status_is(200);