UI - Fixing HTML <title> versus custom title settings display in overview (#3430) #3429

browser-notifications^2
dgtlmoon 2025-09-17 11:52:08 +02:00 zatwierdzone przez GitHub
rodzic 6e1f5a8503
commit 8fe7aec3c6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 78 dodań i 5 usunięć

Wyświetl plik

@ -158,9 +158,9 @@ document.addEventListener('DOMContentLoaded', function() {
<div>
<span class="watch-title">
{% if system_use_url_watchlist or watch.get('use_page_title_in_list') %}
{{watch.label}}
{{ watch.label }}
{% else %}
{{watch.url}}
{{ watch.get('title') or watch.link }}
{% endif %}
<a class="external" target="_blank" rel="noopener" href="{{ watch.link.replace('source:','') }}">&nbsp;</a>
</span>

Wyświetl plik

@ -170,7 +170,7 @@ class model(watch_base):
@property
def label(self):
# Used for sorting, display, etc
return self.get('title') or self.get('page_title') or self.get('url')
return self.get('title') or self.get('page_title') or self.link
@property
def last_changed(self):

Wyświetl plik

@ -6,8 +6,6 @@ from .util import set_original_response, set_modified_response, live_server_setu
def test_checkbox_open_diff_in_new_tab(client, live_server):
set_original_response()
# live_server_setup(live_server) # Setup on conftest per function
# Add our URL to the import page
res = client.post(
url_for("imports.import_page"),
@ -78,3 +76,78 @@ def test_checkbox_open_diff_in_new_tab(client, live_server):
# Cleanup everything
res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_page_title_listing_behaviour(client, live_server):
set_original_response(extra_title="custom html")
# either the manually entered title/description or the page link should be visible
res = client.post(
url_for("settings.settings_page"),
data={"application-ui-use_page_title_in_list": "",
"requests-time_between_check-minutes": 180,
'application-fetch_backend': "html_requests"},
follow_redirects=True
)
assert b"Settings updated." in res.data
# Add our URL to the import page
res = client.post(
url_for("imports.import_page"),
data={"urls": url_for('test_endpoint', _external=True)},
follow_redirects=True
)
assert b"1 Imported" in res.data
wait_for_all_checks(client)
# We see the URL only, no title/description was manually entered
res = client.get(url_for("watchlist.index"))
assert url_for('test_endpoint', _external=True).encode('utf-8') in res.data
# Now 'my title' should override
res = client.post(
url_for("ui.ui_edit.edit_page", uuid="first"),
data={
"url": url_for('test_endpoint', _external=True),
"title": "my title",
"fetch_backend": "html_requests",
"time_between_check_use_default": "y"},
follow_redirects=True
)
assert b"Updated watch." in res.data
res = client.get(url_for("watchlist.index"))
assert b"my title" in res.data
# Now we enable page <title> and unset the override title/description
res = client.post(
url_for("settings.settings_page"),
data={"application-ui-use_page_title_in_list": "y",
"requests-time_between_check-minutes": 180,
'application-fetch_backend': "html_requests"},
follow_redirects=True
)
assert b"Settings updated." in res.data
# Page title description override should take precedence
res = client.get(url_for("watchlist.index"))
assert b"my title" in res.data
# Remove page title description override and it should fall back to title
res = client.post(
url_for("ui.ui_edit.edit_page", uuid="first"),
data={
"url": url_for('test_endpoint', _external=True),
"title": "",
"fetch_backend": "html_requests",
"time_between_check_use_default": "y"},
follow_redirects=True
)
assert b"Updated watch." in res.data
# No page title description, and 'use_page_title_in_list' is on, it should show the <title>
res = client.get(url_for("watchlist.index"))
assert b"head titlecustom html" in res.data