Add duration filters to test case search#4357
Closed
gondamol wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
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/__lteduration params when provided. - Updated RPC
TestCase.filterto support duration parsing/normalization and filtering on computedexpected_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 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 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 on lines
+41
to
+46
| try: | ||
| return timedelta(seconds=float(value)) | ||
| except ValueError: | ||
| parsed = parse_duration(value) | ||
| if parsed is not None: | ||
| return parsed |
Member
|
Stop the AI slop. Duplicate of #4352 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
timedeltavalues inTestCase.filterexpected_durationbefore filtering so the computed duration can be queriedFixes #1923
Verification
cd tcms && .\node_modules\.bin\eslint.cmd testcases\static\testcases\js\search.jspython -m py_compile tcms\rpc\api\testcase.py tcms\rpc\tests\test_testcase.pygit diff --check