Add markdown support for notes field in TestCase and TestRun#4267
Add markdown support for notes field in TestCase and TestRun#4267veenone wants to merge 7 commits intokiwitcms:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Enables Markdown editing/rendering for the notes field (primarily for TestCase/TestRun) by switching notes inputs to SimpleMDE-based widgets and rendering notes as Markdown in some UI surfaces.
Changes:
- Use a SimpleMDE-based widget for
notesin TestCase/TestRun forms and render it via{{ form.notes }}. - Render TestCase notes via the
markdown2htmltemplate filter; render notes in TestPlan’s expand area viamarkdown2HTML()in JS. - Adjust SimpleMDE autosave IDs and introduce
SimpleMDENotes(separate upload element ID for notes).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tcms/testruns/templates/testruns/mutable.html | Switch notes input to widget rendering ({{ form.notes }}) |
| tcms/testruns/forms.py | Add SimpleMDE-based widget for TestRun notes |
| tcms/testplans/static/testplans/js/get.js | Render TestCase notes via markdown2HTML() in expand area; propagate from_plan in links |
| tcms/testcases/templates/testcases/mutable.html | Switch notes input to widget rendering ({{ form.notes }}) and propagate from_plan |
| tcms/testcases/templates/testcases/get.html | Render notes via markdown2html; adds new breadcrumbs/navigation markup |
| tcms/testcases/forms.py | Add SimpleMDE-based widget for TestCase notes |
| tcms/static/js/index.js | Make SimpleMDE autosave IDs unique per textarea |
| tcms/core/widgets.py | Add SimpleMDENotes widget (distinct file upload element ID) |
Comments suppressed due to low confidence (1)
tcms/testcases/templates/testcases/mutable.html:33
- This form can submit two
from_planhidden inputs (one fromrequest.GET.from_planand one fromtest_plan.pk). Multiple values for the same field name can lead to ambiguous behavior (Django'srequest.POST.get('from_plan')will pick one value). Ensure only onefrom_planinput is rendered, or make sure they cannot diverge.
{% if request.GET.from_plan %}
<input type="hidden" name="from_plan" value="{{ request.GET.from_plan }}">
{% endif %}
<input type="hidden" name="author" value="{{ form.author.value }}">
<div class="form-group">
<label class="col-md-1 col-lg-1" for="id_summary">{% trans "Summary" %}</label>
<div class="col-md-11 col-lg-11 {% if form.summary.errors %}has-error{% endif %}">
<input type="text" id="id_summary" name="summary" value="{{ form.summary.value|default:'' }}" class="form-control" required>
{% if test_plan %}
<p class="help-block"><a href="{% url 'test_plan_url' test_plan.pk %}">TP-{{ test_plan.pk }}: {{ test_plan.name }}</a></p>
<input type="hidden" name="from_plan" value="{{ test_plan.pk }}">
{% endif %}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
atodorov
left a comment
There was a problem hiding this comment.
Thanks for this PR.
Please leave only the changes related to markdown support for notes field here and move changes related to breadcrumbs and anythhing not related to markdown into a separate pull request so that it is easier to review. See comments from Copilot.
atodorov
left a comment
There was a problem hiding this comment.
Added couple of comments/small changes requested.
| } | ||
|
|
||
| function getTestCaseRowContent (rowContent, testCase, permissions) { | ||
| function getTestCaseRowContent (rowContent, testCase, permissions, testPlanId) { |
There was a problem hiding this comment.
testPlanId is unused and I am assuming it is a left over. Please remove unnecessary changes.
There was a problem hiding this comment.
3 notes:
-
Please don't mark comments as resolved. Strictly speaking that's responsibility of the reviewer but more importantly when comments stay open it is easier to to review again and focus only on the last set of changes. Otherwise I need to double check everything from scratch.
-
When you remove an unused argument from this function don't update only the function signature but also every single place in which this function is called from otherwise there will be errors. I see at least 2 more locations which need changing.
-
Please test these changes on your side before declaring them ready for review. From what I can see these 2 calls will fail b/c the function doesn't take so many arguments:
| // it with something different, restore the server value. | ||
| if (serverValue && simpleMDE.value() !== serverValue) { | ||
| simpleMDE.value(serverValue) | ||
| } |
There was a problem hiding this comment.
Question: is this related to the markdown rendering functionality? Doesn't seem to be IMO so please remove it. Otherwise please explain what the idea here is.
There was a problem hiding this comment.
removed since this is coming from previous trials
There was a problem hiding this comment.
Similar comment to above.
There is a danglign variable called serverValue left in this file + another code snippet which doesn't appear related to the markdown rendering functionality.
|
update code based on review. and add the same implementation for testcase view in testrun @atodorov |
- Add SimpleMDENotes widget with unique file upload ID to prevent conflicts when both text and notes editors are on the same page - Use SimpleMDENotes widget in TestCase and TestRun forms - Render notes with markdown2html filter in display templates - Render notes with markdown2HTML() in testplan JS expand area - Fix SimpleMDE autosave ID to use textarea id for uniqueness
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
c7439a0 to
02a3682
Compare
I'm trying to update notes part in test case and test run to support markdown since currently it's only plain text .
In my usage, I have used markdown syntax in notes since I have multiple entries like below
this leads to mixed formatting in view page
so my update is to enable markdown just like description so we can have better view like this :
what has been implemented :