Skip to content
Merged
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
21 changes: 21 additions & 0 deletions src/tmt_web/templates/_base.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ licensed under CC-BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/).
color: var(--fedora-dark);
font-weight: 600;
}

.description {
margin: 0.75rem 0;
}

.description p {
margin-bottom: 0.5rem;
}

.description-text {
background: white;
padding: 1rem;
border-radius: 4px;
border-left: 4px solid var(--fedora-blue);
margin: 0;
font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
font-size: 0.9rem;
white-space: pre-wrap;
word-wrap: break-word;
overflow-x: auto;
}
</style>
{% block head %}{% endblock %}
</head>
Expand Down
10 changes: 8 additions & 2 deletions src/tmt_web/templates/testandplan.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<p><strong>Summary:</strong> {{ test.summary }}</p>
{% endif %}
{% if test.description %}
<p><strong>Description:</strong> {{ test.description }}</p>
<div class="description">
<p><strong>Description:</strong></p>
<pre class="description-text">{{ test.description }}</pre>
</div>
{% endif %}
{% if test.tier %}
<p><strong>Tier:</strong> {{ test.tier }}</p>
Expand Down Expand Up @@ -66,7 +69,10 @@
<p><strong>Summary:</strong> {{ plan.summary }}</p>
{% endif %}
{% if plan.description %}
<p><strong>Description:</strong> {{ plan.description }}</p>
<div class="description">
<p><strong>Description:</strong></p>
<pre class="description-text">{{ plan.description }}</pre>
</div>
{% endif %}
{% if plan.tier %}
<p><strong>Tier:</strong> {{ plan.tier }}</p>
Expand Down
5 changes: 4 additions & 1 deletion src/tmt_web/templates/testorplan.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<p><strong>Summary:</strong> {{ testorplan.summary }}</p>
{% endif %}
{% if testorplan.description %}
<p><strong>Description:</strong> {{ testorplan.description }}</p>
<div class="description">
<p><strong>Description:</strong></p>
<pre class="description-text">{{ testorplan.description }}</pre>
</div>
{% endif %}
{% if testorplan.tier %}
<p><strong>Tier:</strong> {{ testorplan.tier }}</p>
Expand Down
44 changes: 44 additions & 0 deletions tests/unit/test_html_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,47 @@ def mock_render(*args, **kwargs):
html_generator._render_template("testorplan.html.j2", logger)
assert "Failed to render template" in str(exc.value)
assert "testorplan.html.j2" in str(exc.value)

def test_multiline_description_rendering(self, logger):
"""Test that multiline descriptions are rendered correctly with line breaks preserved."""
# Create test data with multiline description
multiline_description = (
"First line of description\n\nSecond line after empty line\nThird line\n\nFourth line"
)
test_data = TestData(
name="multiline-test",
summary="Test with multiline description",
description=multiline_description,
contact=["Test Contact <test@example.com>"],
component=["component1"],
enabled=True,
environment={"KEY": "value"},
duration="15m",
framework="shell",
manual=False,
path="/path/to/test",
tier="1",
order=50,
id="test-multiline",
tag=["tag1"],
fmf_id=FmfIdData(
name="test",
url="https://example.com/test",
path="/path/to/test",
ref="main",
),
)

data = html_generator.generate_html_page(test_data, logger)

# Check that the description is wrapped in proper HTML structure
assert '<div class="description">' in data
assert '<pre class="description-text">' in data
assert "</pre>" in data
assert "</div>" in data

# Check that the multiline content is preserved
assert "First line of description" in data
assert "Second line after empty line" in data
assert "Third line" in data
assert "Fourth line" in data