Skip to content

Commit

Permalink
Allow filtering by comment text on the test results overview page
Browse files Browse the repository at this point in the history
The same as the previous commit did for the "All tests" page.

Related ticket: https://progress.opensuse.org/issues/151402
  • Loading branch information
Martchus committed Jan 15, 2024
1 parent 5ac01b5 commit f8f8dc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/OpenQA/WebAPI/Plugin/Helpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ sub _compose_job_overview_search_args ($c) {

my $v = $c->validation;
$v->optional($_, 'not_empty') for JOBS_OVERVIEW_SEARCH_CRITERIA;
$v->optional('comment');
$v->optional('groupid')->num(0, undef);
$v->optional('modules', 'comma_separated');
$v->optional('limit', 'not_empty')->num(0, undef);
Expand Down Expand Up @@ -488,6 +489,9 @@ sub _compose_job_overview_search_args ($c) {
# allow filtering by group ID or group name
$search_args{groupids} = [map { $_->id } @groups] if @groups;

# allow filtering by comment text
$search_args{comment_text} = $v->param('comment');

return (\%search_args, \@groups);
}

Expand Down
8 changes: 8 additions & 0 deletions t/10-tests_overview.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sub get_summary { OpenQA::Test::Case::trim_whitespace($t->tx->res->dom->at('#sum

my $jobs = $schema->resultset('Jobs');
$jobs->find(99928)->update({blocked_by_id => 99927});
$jobs->find($_)->comments->create({text => 'test1', user_id => 99901}) for 99946, 99963;
$t->get_ok('/tests/overview' => form => {distri => 'opensuse', version => '13.1', build => '0091'})->status_is(200);

my $summary = get_summary;
Expand Down Expand Up @@ -346,6 +347,13 @@ like(get_summary, qr/current time Failed: 1$/i);
$t->element_exists('#res_DVD_x86_64_doc .result_failed', 'job with failed module logpackages still shown');
$t->element_exists_not('#res_DVD_x86_64_kde .result_passed', 'passed job hidden');

subtest 'comment parameter' => sub {
$t->get_ok('/tests/overview?groupid=1001&distri=opensuse&version=13.1&build=0091&comment=test1');
$t->status_is(200);
my $ids = $t->tx->res->dom->find('.overview span[id^="res-"]')->map(attr => 'id')->sort->to_array;
is_deeply $ids, [qw(res-99946 res-99963)], 'expected set of jobs present';
};

# Check if another random module has failed
$latest_job->update({DISTRI => 'opensuse'});
my $failing_module = $schema->resultset('JobModules')->create(
Expand Down

0 comments on commit f8f8dc7

Please sign in to comment.