Skip to content

Commit 853720e

Browse files
authored
Merge pull request #26 from reach2jeyan/25-ability-to-search-related-cases-by-link-ids
Ability to search by test name or pytest mark link content
2 parents 06d7f3c + 15e5f2e commit 853720e

4 files changed

Lines changed: 77 additions & 28 deletions

File tree

README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,46 @@ A powerful, plug-and-play Pytest plugin to generate **HTML + JSON reports**, det
66

77
## ✨ Features
88

9-
🧩 Unified Test Reports: Get a single, easy-to-read HTML report summarizing all your test results — no hassle, just clarity.
9+
#### 🧩 Unified Test Reports: Get a single, easy-to-read HTML report summarizing all your test results — no hassle, just clarity.
1010

11-
🔄 Flaky Test Detection: Automatically flags flaky tests so you can spot and fix inconsistent failures quickly.
11+
#### 🔄 Flaky Test Detection: Automatically flags flaky tests so you can spot and fix inconsistent failures quickly.
1212

1313
![Screenshot 2025-05-28 at 3 43 17 PM](https://github.com/user-attachments/assets/6fd7a419-58c1-4651-96f7-093ced1f02ee)
1414

15-
📸 Screenshot Support: View screenshots directly in the report to understand failures faster.
15+
#### 📸 Screenshot Support: View screenshots directly in the report to understand failures faster.
1616

17-
📝 Comprehensive output capture: All your test logs with loggers, print() statements, and screenshots are automatically captured and embedded in the report...
17+
#### 📝 Comprehensive output capture: All your test logs with loggers, print() statements, and screenshots are automatically captured and embedded in the report...
1818

1919
![ezgif-744a5d34a4c46d](https://github.com/user-attachments/assets/209cd2c0-d33b-48ec-b58b-8c8991ce35be)
2020

21-
📧 Email Test Reports: Send your reports via email effortlessly using SendGrid integration.
21+
#### 📧 Email Test Reports: Send your reports via email effortlessly using SendGrid integration.
2222

2323
![Screenshot 2025-05-28 at 4 38 49 PM](https://github.com/user-attachments/assets/3f40e206-5dfd-45e9-a511-4dd206cf3318)
2424

25-
🐢 Spot Slow Tests: Highlights the slowest tests so you know where to optimize your suite.
25+
#### 🐢 Spot Slow Tests: Highlights the slowest tests so you know where to optimize your suite.
2626

2727
![ezgif-64896277dcf8f8](https://github.com/user-attachments/assets/f5616a07-0dd9-40ed-aa9a-cf9adee3a0b8)
2828

29-
⏱️ Sort & Filter: Easily sort tests by duration or filter by custom tags and skip status to focus on what matters.
29+
#### ⏱️ Sort & Filter: Easily sort tests by duration or filter by custom tags and skip status to focus on what matters.
3030

3131
![ezgif-3056394be0e9a4](https://github.com/user-attachments/assets/bb60c50a-4709-42f3-8571-19cbd76a93cf)
3232

33-
🔗 Enhance your test reports by embedding clickable links directly beside each test:
34-
Effortlessly jump to related tickets, documentation, or external tools right from your pytest reporter plus!
33+
#### 🔍 Universal Test Search + Smart Link Navigation
34+
35+
Whether you're trying to trace coverage or track unlinked test cases — this search has your back!
36+
37+
Just start typing, and the dashboard will instantly filter tests by:
38+
39+
✅ Test name
40+
41+
✅ Linked issue/documentation IDs (like JIRA, Testmo, Notion, etc.)
42+
43+
✅ Custom URLs or keywords present in the links
44+
45+
46+
![Screen Recording 2025-06-01 at 2 48 08 PM](https://github.com/user-attachments/assets/057441ac-06a3-421f-aafc-915968a90463)
47+
48+
3549

3650

3751
---

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pytest-reporter-plus"
3-
version = "0.1.9"
3+
version = "0.2.0"
44
description = "Lightweight enhanced HTML reporter for Pytest"
55
readme = "README.md"
66
authors = ["Emjey","Karan"]

pytest_reporter_plus/generate_html_report.py

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ def generate_html_report(self):
193193
}}
194194
filterByMarkers(); // Reapply marker filter
195195
}}
196+
function initializeUniversalSearch() {{
197+
const searchInput = document.getElementById('universal-search');
198+
if (!searchInput) return;
199+
200+
searchInput.addEventListener('input', function (e) {{
201+
const filter = e.target.value.toLowerCase();
202+
document.querySelectorAll('.test-card').forEach(card => {{
203+
const name = card.getAttribute('data-name') || '';
204+
const link = card.getAttribute('data-link') || '';
205+
const isVisible = name.toLowerCase().includes(filter) || link.toLowerCase().includes(filter);
206+
card.style.display = isVisible ? '' : 'none';
207+
}});
208+
}});
209+
}}
210+
211+
document.addEventListener('DOMContentLoaded', initializeUniversalSearch);
196212
197213
function filterByMarkers() {{
198214
const selected = Array.from(document.querySelectorAll('.marker-filter input[type="checkbox"]:checked')).map(cb => cb.value);
@@ -232,6 +248,15 @@ def generate_html_report(self):
232248
Sort by longest running tests
233249
</label>
234250
</div>
251+
<div class="search-container">
252+
<input
253+
type="text"
254+
id="universal-search"
255+
placeholder="🔍 Search by anything, testname? link ids?..."
256+
style="width: 100%; padding: 10px; margin-bottom: 20px; font-size: 16px; border: 1px solid #ccc; border-radius: 5px;"
257+
/>
258+
</div>
259+
235260
236261
<div id="markersFilter" class="marker-filter" style="margin-bottom: 1rem;">
237262
<strong>Filter by Markers:</strong><br/>
@@ -279,29 +304,31 @@ def generate_html_report(self):
279304
f'<a href="{url}" target="_blank" '
280305
f'style="background:#3498db;color:white;padding:2px 6px;'
281306
f'border-radius:3px;font-weight:bold;font-size:0.85em;'
282-
f'text-decoration:none;margin-right:6px;">Link</a>'
307+
f'text-decoration:none;margin-right:6px;"> Link </a>'
283308
)
284309

285310
html += f'''
311+
286312
287313
288-
<div class="test" data-markers="{marker_str}">
289-
<div class="header {status_class}" onclick="toggleDetails(this)">
290-
<span class="toggle"></span>
291-
<span><strong>{test["test"]}</strong> — {test["status"].upper()}</span>
292-
<span class="worker-id" style="background: #ddd; border-radius: 3px; padding: 2px 5px; font-size: 0.85em; font-weight: bold;">{test["worker"]}</span>
293-
<span class="worker-id" style="background: #ddd; border-radius: 3px; padding: 2px 5px; font-size: 0.85em; font-weight: bold;">{flaky_badge}</span>
294-
<span class="worker-id" style="background: #ddd; border-radius: 3px; padding: 2px 5px; font-size: 0.85em; font-weight: bold;">{link_html}</span>
295-
<span class="timestamp">⏱ {test.get("duration", 0):.2f}s</span>
296-
</div>
297-
<div class="details">
298-
{error_html}
299-
{screenshot_html}
300-
{stdout_html}
301-
{stderr_html}
302-
{logs_html}
303-
</div>
304-
</div>
314+
<div class="test test-card" data-name="{test['test']}" data-link="{','.join(test.get('links', []))}" data-markers="{marker_str}">
315+
<div class="header {status_class}" onclick="toggleDetails(this)">
316+
<span class="toggle"></span>
317+
<span><strong>{test["test"]}</strong> — {test["status"].upper()}</span>
318+
<span class="worker-id" style="background: #ddd; border-radius: 3px; padding: 2px 5px; font-size: 0.85em; font-weight: bold;">{test["worker"]}</span>
319+
<span class="worker-id" style="background: #f39c12; color:white; border-radius: 3px; padding: 2px 5px; font-size: 0.85em; font-weight: bold;">{flaky_badge}</span>
320+
<span class="worker-id" style="background: #3498db; color:white; border-radius: 3px; padding: 2px 5px; font-size: 0.85em; font-weight: bold;">{link_html}</span>
321+
<span class="timestamp">⏱ {test.get("duration", 0):.2f}s</span>
322+
</div>
323+
<div class="details">
324+
{error_html}
325+
{screenshot_html}
326+
{stdout_html}
327+
{stderr_html}
328+
{logs_html}
329+
</div>
330+
</div>
331+
305332
'''
306333

307334
# Add summary

tests/test_initial_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ def test_show_link():
1010
@pytest.mark.link("https://jira.company.com/testcase/12345")
1111
def test_show_multiplelinks():
1212
assert True
13+
@pytest.mark.link("https://github.com/reach2jeyan/pytest-reporter-plus/issues/15")
14+
@pytest.mark.link("https://github.com/reach2jeyan/pytest-reporter-plus/issues/25")
15+
def test_github_link():
16+
assert True
17+
18+
@pytest.mark.link("https://github.com/reach2jeyan/pytest-reporter-plus/issues/25")
19+
def test_github_link_another_case():
20+
assert True

0 commit comments

Comments
 (0)