Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mod_regression/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ def __repr__(self) -> str:
"""
return f"<RegressionTest {self.id}>"

@property
def never_worked(self) -> bool:
"""
Determine if this regression test has never passed on any platform.

:return: True if the test has no pass history on either platform
:rtype: bool
"""
return self.last_passed_on_linux is None and self.last_passed_on_windows is None


class RegressionTestOutput(Base):
"""Model to store output of regression test."""
Expand Down
13 changes: 13 additions & 0 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
{% endif %}
{% endmacro %}

{% macro platform_history_cell(test) %}
{% if test.never_worked %}
<span class="label alert">Never Worked</span>
{% else %}
{% if test.last_passed_on_linux %}
<i class="fa fa-linux" title="Linux"></i> <a href="{{ url_for('test.by_id', test_id=test.last_passed_on_linux) }}">#{{ test.last_passed_on_linux }}</a>&nbsp;
{% endif %}
{% if test.last_passed_on_windows %}
<i class="fa fa-windows" title="Windows"></i> <a href="{{ url_for('test.by_id', test_id=test.last_passed_on_windows) }}">#{{ test.last_passed_on_windows }}</a>
{% endif %}
{% endif %}
{% endmacro %}

{% macro render_media_info(info) %}
<ul style="list-style: none; margin-bottom: 0;">
{% for entry in info recursive %}
Expand Down
3 changes: 3 additions & 0 deletions templates/regression/by_sample.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "base.html" %}
{% from "macros.html" import platform_history_cell %}

{% block title %}Regression tests for sample {{ sample.id }} {{ super() }}{% endblock %}
{% block body %}
Expand All @@ -13,6 +14,7 @@ <h1>Regression tests for sample {{ sample.id }}</h1>
<tr>
<th>ID</th>
<th>Command</th>
<th>Platform History</th>
<th>Actions</th>
</tr>
</thead>
Expand All @@ -21,6 +23,7 @@ <h1>Regression tests for sample {{ sample.id }}</h1>
<tr>
<td>{{ test.id }}</td>
<td>{{ test.command }}</td>
<td>{{ platform_history_cell(test) }}</td>
<td>
<a href="{{ url_for('.test_view', regression_id=test.id) }}" title="View details"><i class="fa fa-info-circle"></i></a>&nbsp;
{% if user is not none and user.has_role('contributor') %}
Expand Down
3 changes: 3 additions & 0 deletions templates/regression/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "base.html" %}
{% from "macros.html" import platform_history_cell %}

{% block title %}Regression tests {{ super() }}{% endblock %}
{% block body %}
Expand Down Expand Up @@ -63,6 +64,7 @@ <h1>Regression tests</h1>
<th>ID</th>
<th>Command</th>
<th>Active</th>
<th>Platform History</th>
<th>Actions</th>
<th>Tags</th>
</tr>
Expand All @@ -76,6 +78,7 @@ <h1>Regression tests</h1>
<td>{{ test.id }}</td>
<td>{{ test.command }}</td>
<td id="status-toggle-{{test.id}}">{{ test.active }}</td>
<td>{{ platform_history_cell(test) }}</td>
<td>
<a href="{{ url_for('.test_view', regression_id=test.id) }}" title="View details"><i class="fa fa-info-circle"></i></a>&nbsp;
{% if user is not none and user.has_role('contributor') %}
Expand Down
17 changes: 17 additions & 0 deletions templates/regression/test_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ <h1>Regression test {{ test.id }}</h1>
<p>Input type: {{ test.input_type.description }}</p>
<p>Output type: {{ test.output_type.description }}</p>
<p>Description: {{ test.description or "No description" }}</p>
<p>Platform history:</p>
<ul>
<li>Linux:
{% if test.last_passed_on_linux %}
Last passed on <a href="{{ url_for('test.by_id', test_id=test.last_passed_on_linux) }}">Test #{{ test.last_passed_on_linux }}</a>
{% else %}
<span class="label alert">Never passed</span>
{% endif %}
</li>
<li>Windows:
{% if test.last_passed_on_windows %}
Last passed on <a href="{{ url_for('test.by_id', test_id=test.last_passed_on_windows) }}">Test #{{ test.last_passed_on_windows }}</a>
{% else %}
<span class="label alert">Never passed</span>
{% endif %}
</li>
</ul>
<p id="tags" href="#tags">
{% set sample = test.sample %}
Tags of sample:
Expand Down
52 changes: 52 additions & 0 deletions tests/test_regression/test_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,55 @@ def test_category_description_shown_without_tags(self):
self.assertIn('data-category="1"', str(response.data))
# The JavaScript should ensure the description is visible, but we can't test JS execution in unit tests
# This test verifies the HTML structure is correct for the fix to work

def test_never_worked_when_both_platforms_null(self):
"""Check never_worked is True when neither platform has a passing run."""
regression_test = RegressionTest.query.filter(RegressionTest.id == 1).first()
self.assertIsNone(regression_test.last_passed_on_linux)
self.assertIsNone(regression_test.last_passed_on_windows)
self.assertTrue(regression_test.never_worked)

def test_never_worked_false_when_linux_has_passed(self):
"""Check never_worked is False when Linux has a recorded pass."""
regression_test = RegressionTest.query.filter(RegressionTest.id == 1).first()
regression_test.last_passed_on_linux = 1
g.db.commit()
self.assertFalse(regression_test.never_worked)

def test_never_worked_false_when_windows_has_passed(self):
"""Check never_worked is False when Windows has a recorded pass."""
regression_test = RegressionTest.query.filter(RegressionTest.id == 1).first()
regression_test.last_passed_on_windows = 1
g.db.commit()
self.assertFalse(regression_test.never_worked)

def test_never_worked_false_when_both_platforms_have_passed(self):
"""Check never_worked is False when both platforms have a recorded pass."""
regression_test = RegressionTest.query.filter(RegressionTest.id == 1).first()
regression_test.last_passed_on_linux = 1
regression_test.last_passed_on_windows = 2
g.db.commit()
self.assertFalse(regression_test.never_worked)

def test_regression_index_shows_never_worked_badge(self):
"""Check the index page renders the Never Worked label for tests with no pass history."""
response = self.app.test_client().get('/regression/')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Never Worked', response.data)

def test_regression_view_shows_platform_history_section(self):
"""Check the test detail page renders the platform history section."""
response = self.app.test_client().get('/regression/test/1/view')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Platform history', response.data)
self.assertIn(b'Never passed', response.data)

def test_regression_view_shows_last_passed_link_when_set(self):
"""Check the test detail page links to the last passing test run when history exists."""
regression_test = RegressionTest.query.filter(RegressionTest.id == 1).first()
regression_test.last_passed_on_linux = 1
g.db.commit()
response = self.app.test_client().get('/regression/test/1/view')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Test #1', response.data)
self.assertNotIn(b'Never Worked', response.data)