Re #616 - adding extra test

This commit is contained in:
dgtlmoon
2022-05-21 22:07:27 +02:00
parent 5e7324b0b8
commit 49139e779a
3 changed files with 20 additions and 6 deletions
+9 -2
View File
@@ -57,7 +57,7 @@ class Fetcher():
}
var elements = document.getElementsByTagName("*");
var elements = window.document.querySelectorAll(".hnname");
var size_pos=[];
// after page fetch, inject this JS
// build a map of all elements and their positions (maybe that only include text?)
@@ -65,7 +65,7 @@ class Fetcher():
for (var i = 0; i < elements.length; i++) {
bbox = elements[i].getBoundingClientRect();
// forget reallysmall ones
// forget really small ones
if (bbox['width'] <10 && bbox['height'] <10 ) {
continue;
}
@@ -76,6 +76,7 @@ class Fetcher():
// 1st primitive - if it has class, try joining it all and select, if theres only one.. well thats us.
xpath_result=false;
/*
try {
var d= findUpTag(elements[i]);
if (d) {
@@ -84,6 +85,7 @@ class Fetcher():
} catch (e) {
var x=1;
}
*/
// default back to the less intelligent one
if (!xpath_result) {
@@ -281,10 +283,15 @@ class base_html_playwright(Fetcher):
page.evaluate("var css_filter=''")
self.xpath_data = page.evaluate("async () => {" + self.xpath_element_js + "}")
# Bug 1 in Playwright screenshot handling
# Some bug where it gives the wrong screenshot size, but making a request with the clip set first seems to solve it
# JPEG is better here because the screenshots can be very very large
page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024})
self.screenshot = page.screenshot(type='jpeg', full_page=True, quality=92)
# Bug 2 - screenshot size is not the real size (but reported elements and everything else is fine)
width = page.evaluate('async () => {return Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)}')
context.close()
browser.close()
@@ -59,11 +59,11 @@ $(document).ready(function() {
// - that the widths/sizes really are about the actual screen size cat elements.json |grep -o width......|sort|uniq
selector_image_rect = selector_image.getBoundingClientRect();
console.log(selector_image.getBoundingClientRect());
// make the canvas the same size as the image
$('#selector-canvas').attr('height', selector_image_rect.height);
$('#selector-canvas').attr('width', selector_image_rect.width);
x_scale = selector_image_rect.width / selector_image.naturalWidth;
y_scale = selector_image_rect.height / selector_image.naturalHeight;
ctx.strokeStyle = 'rgb(255,0,0, 0.8)';
ctx.lineWidth = 2;
@@ -80,7 +80,7 @@ $(document).ready(function() {
// highlight the default one if we can find it in the xPath list
// or the xpath matches the default one
for (var i = selector_data.length; i!=0; i--) {
for (var i = selector_data.length; i!==0; i--) {
var sel = selector_data[i-1];
if(selector_data[i - 1].xpath == current_default_xpath) {
ctx.strokeRect(sel.left * x_scale, sel.top * y_scale, sel.width * x_scale, sel.height * y_scale);
@@ -101,7 +101,7 @@ $(document).ready(function() {
// Reverse order - the most specific one should be deeper/"laster"
// Basically, find the most 'deepest'
for (var i = selector_data.length; i!=0; i--) {
for (var i = selector_data.length; i!==0; i--) {
// draw all of them? let them choose somehow?
var sel = selector_data[i-1];
// If we are in a bounding-box
@@ -119,6 +119,7 @@ $(document).ready(function() {
// @todo or, O to go out/up, I to go in
// or double click to go up/out the selector?
current_selected_i=i-1;
console.log(sel);
break;
}
}
+7 -1
View File
@@ -121,7 +121,7 @@ def test_trigger_functionality(client, live_server):
res = client.get(url_for("index"))
assert b'unviewed' not in res.data
# Just to be sure.. set a regular modified change..
# Now set the content which contains the trigger text
time.sleep(sleep_time_for_fetch_thread)
set_modified_with_trigger_text_response()
@@ -130,6 +130,12 @@ def test_trigger_functionality(client, live_server):
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'foobar123' 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