From 341ae24b738c8deed7c2360fa4f50c7107f2fc2c Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 25 May 2022 15:03:23 +0200 Subject: [PATCH] Re #616 - content trigger - adding extra test (#620) --- changedetectionio/content_fetcher.py | 3 +++ changedetectionio/tests/test_trigger.py | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index af082a95..7ea31de4 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -293,10 +293,13 @@ class base_html_playwright(Fetcher): # Better to not use any smarts from Playwright and just wait an arbitrary number of seconds # This seemed to solve nearly all 'TimeoutErrors' extra_wait = int(os.getenv("WEBDRIVER_DELAY_BEFORE_CONTENT_READY", 5)) + self.render_extract_delay + p=time.time() page.wait_for_timeout(extra_wait * 1000) except playwright._impl._api_types.TimeoutError as e: raise EmptyReply(url=url, status_code=None) + r=time.time()-p + x=1 if response is None: raise EmptyReply(url=url, status_code=None) diff --git a/changedetectionio/tests/test_trigger.py b/changedetectionio/tests/test_trigger.py index 66b8121e..21174e32 100644 --- a/changedetectionio/tests/test_trigger.py +++ b/changedetectionio/tests/test_trigger.py @@ -43,7 +43,7 @@ def set_modified_with_trigger_text_response(): Some NEW nice initial text

Which is across multiple lines


- foobar123 + Add to cart
So let's see what happens.
@@ -60,7 +60,7 @@ def test_trigger_functionality(client, live_server): live_server_setup(live_server) sleep_time_for_fetch_thread = 3 - trigger_text = "foobar123" + trigger_text = "Add to cart" set_original_ignore_response() # Give the endpoint time to spin up @@ -129,14 +129,20 @@ def test_trigger_functionality(client, live_server): time.sleep(sleep_time_for_fetch_thread) res = client.get(url_for("index")) assert b'unviewed' in res.data + + # https://github.com/dgtlmoon/changedetection.io/issues/616 + # Apparently the actual snapshot that contains the trigger never shows + res = client.get(url_for("diff_history_page", uuid="first")) + assert b'Add to cart' in res.data # https://github.com/dgtlmoon/changedetection.io/issues/616 # Apparently the actual snapshot that contains the trigger never shows res = client.get(url_for("diff_history_page", uuid="first")) - assert b'foobar123' in res.data + assert b'Add to cart' in res.data # Check the preview/highlighter, we should be able to see what we triggered on, but it should be highlighted res = client.get(url_for("preview_page", uuid="first")) - # We should be able to see what we ignored - assert b'
foobar' in res.data \ No newline at end of file + + # We should be able to see what we triggered on + assert b'
Add to cart' in res.data \ No newline at end of file