Skip to content

Commit

Permalink
templates: Ensure that the link in the news in the front page work
Browse files Browse the repository at this point in the history
  • Loading branch information
psaiz committed Nov 27, 2024
1 parent 87dc66e commit 3b3148e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cernopendata/templates/cernopendata_pages/front/news.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h3 class="">News & Updates</h3>
</p>
<div>
<h4>
<a href="/docs/{{article.docid}}">{{article.title}}</a>
<a href="/docs/{{article.slug}}">{{article.title}}</a>
</h4>
</div>
<div class="tags-box">
Expand Down
31 changes: 31 additions & 0 deletions tests/test_news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Tests for the display experiment exclusion feature."""

import pytest
from bs4 import BeautifulSoup
from invenio_indexer.api import RecordIndexer

from cernopendata.modules.fixtures.cli import create_doc
from cernopendata.modules.pages.views import index


def test_news(app, database, search):
"""Test that news are displayed properly."""
# Let's start by inserting a news item
data = {
"$schema": app.extensions["invenio-jsonschemas"].path_to_url(
"records/docs-v1.0.0.json"
),
"type": {"primary": "news"},
"slug": "dummy_news",
"date_published": "2024-11-27",
"featured": 1,
"title": "DUMMY TEST NEWS",
}
record = create_doc(data, True)

RecordIndexer().index(record, arguments={"refresh":"wait_for"})
with app.test_request_context("/"):
soup = BeautifulSoup(index(), "html.parser")
news = soup.find_all("div", class_="news-card")
assert len(news) == 1
assert news[0].h4.a["href"] == "/docs/dummy_news"

0 comments on commit 3b3148e

Please sign in to comment.