From c5433dd0ede67133eb1bdd1bb33059b2ff5f182e Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 3 Jul 2025 13:31:57 +0200 Subject: [PATCH] Adding extra test --- .../tests/test_history_consistency.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/changedetectionio/tests/test_history_consistency.py b/changedetectionio/tests/test_history_consistency.py index fbcfba4d1..a16e99f73 100644 --- a/changedetectionio/tests/test_history_consistency.py +++ b/changedetectionio/tests/test_history_consistency.py @@ -79,3 +79,48 @@ def test_consistent_history(client, live_server, measure_memory_usage): json_db_file = os.path.join(live_server.app.config['DATASTORE'].datastore_path, 'url-watches.json') with open(json_db_file, 'r') as f: assert '"default"' not in f.read(), "'default' probably shouldnt be here, it came from when the 'default' Watch vars were accidently being saved" + + +def test_check_text_history_view(client, live_server): + + with open("test-datastore/endpoint-content.txt", "w") as f: + f.write("test-one") + + # Add our URL to the import page + test_url = url_for('test_endpoint', _external=True) + res = client.post( + url_for("imports.import_page"), + data={"urls": test_url}, + follow_redirects=True + ) + assert b"1 Imported" in res.data + + # Give the thread time to pick it up + wait_for_all_checks(client) + + # Set second version, Make a change + with open("test-datastore/endpoint-content.txt", "w") as f: + f.write("test-two") + + client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) + wait_for_all_checks(client) + + res = client.get(url_for("ui.ui_views.diff_history_page", uuid="first")) + assert b'test-one' in res.data + assert b'test-two' in res.data + + # Set third version, Make a change + with open("test-datastore/endpoint-content.txt", "w") as f: + f.write("test-three") + + client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) + wait_for_all_checks(client) + + # It should remember the last viewed time, so the first difference is not shown + res = client.get(url_for("ui.ui_views.diff_history_page", uuid="first")) + assert b'test-three' in res.data + assert b'test-two' in res.data + assert b'test-one' not in res.data + + res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) + assert b'Deleted' in res.data