Skip to content

Add duration filters to test case search#4357

Closed
gondamol wants to merge 1 commit into
kiwitcms:masterfrom
gondamol:testcase-duration-search-filters
Closed

Add duration filters to test case search#4357
gondamol wants to merge 1 commit into
kiwitcms:masterfrom
gondamol:testcase-duration-search-filters

Conversation

@gondamol

Copy link
Copy Markdown

Summary

  • add setup, testing, and expected duration range filters to the Test Case search page
  • normalize duration filter values from seconds into timedelta values in TestCase.filter
  • annotate expected_duration before filtering so the computed duration can be queried
  • add RPC coverage for setup/testing/expected duration range filters

Fixes #1923

Verification

  • cd tcms && .\node_modules\.bin\eslint.cmd testcases\static\testcases\js\search.js
  • python -m py_compile tcms\rpc\api\testcase.py tcms\rpc\tests\test_testcase.py
  • git diff --check

Copilot AI review requested due to automatic review settings May 20, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds duration range filtering to the TestCase search UI and RPC API so users can filter by setup/testing/expected durations using min/max bounds.

Changes:

  • Added min/max inputs for setup, testing, and expected duration to the testcase search form.
  • Extended search JS to include __gte/__lte duration params when provided.
  • Updated RPC TestCase.filter to support duration parsing/normalization and filtering on computed expected_duration, with new tests for duration range filters.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tcms/testcases/templates/testcases/search.html Adds UI inputs for duration min/max filters.
tcms/testcases/static/testcases/js/search.js Serializes duration inputs into RPC filter params (__gte/__lte).
tcms/rpc/api/testcase.py Normalizes duration filter values (seconds or duration strings) and enables filtering by computed expected_duration.
tcms/rpc/tests/test_testcase.py Adds RPC tests for filtering by duration ranges.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +152 to +182
<div class="form-group">
<label class="col-md-1 col-lg-1">{% trans "Setup duration" %}</label>
<div class="col-md-3 col-lg-3">
<div class="input-group">
<span class="input-group-addon">{% trans "Min" %}</span>
<input id="id_setup_duration_min" type="number" min="0" class="form-control" placeholder="{% trans 'Seconds' %}">
<span class="input-group-addon">{% trans "Max" %}</span>
<input id="id_setup_duration_max" type="number" min="0" class="form-control" placeholder="{% trans 'Seconds' %}">
</div>
</div>

<label class="col-md-1 col-lg-1">{% trans "Testing duration" %}</label>
<div class="col-md-3 col-lg-3">
<div class="input-group">
<span class="input-group-addon">{% trans "Min" %}</span>
<input id="id_testing_duration_min" type="number" min="0" class="form-control" placeholder="{% trans 'Seconds' %}">
<span class="input-group-addon">{% trans "Max" %}</span>
<input id="id_testing_duration_max" type="number" min="0" class="form-control" placeholder="{% trans 'Seconds' %}">
</div>
</div>

<label class="col-md-1 col-lg-1">{% trans "Expected duration" %}</label>
<div class="col-md-3 col-lg-3">
<div class="input-group">
<span class="input-group-addon">{% trans "Min" %}</span>
<input id="id_expected_duration_min" type="number" min="0" class="form-control" placeholder="{% trans 'Seconds' %}">
<span class="input-group-addon">{% trans "Max" %}</span>
<input id="id_expected_duration_max" type="number" min="0" class="form-control" placeholder="{% trans 'Seconds' %}">
</div>
</div>
</div>
Comment thread tcms/rpc/api/testcase.py
Comment on lines +36 to +48
if isinstance(value, str):
value = value.strip()
if value == "":
return value

try:
return timedelta(seconds=float(value))
except ValueError:
parsed = parse_duration(value)
if parsed is not None:
return parsed

return value
Comment thread tcms/rpc/api/testcase.py
Comment on lines +314 to +319
query = _normalize_duration_filter_query(query)

test_case_ids = TestCase.objects.filter(**query).values("id")
test_cases = TestCase.objects.annotate(
expected_duration=_expected_duration_expression()
)
test_case_ids = test_cases.filter(**query).values("id")
Comment thread tcms/rpc/api/testcase.py
Comment on lines +41 to +46
try:
return timedelta(seconds=float(value))
except ValueError:
parsed = parse_duration(value)
if parsed is not None:
return parsed
@atodorov

Copy link
Copy Markdown
Member

Stop the AI slop.

Duplicate of #4352

@atodorov atodorov closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 duration fields in TestCase class

3 participants