forked from retoor/devplacepy
FUCKER
This commit is contained in:
@@ -290,6 +290,35 @@ def assert_share_copies(page, expected_fragment):
|
||||
)
|
||||
|
||||
|
||||
def assert_no_horizontal_overflow(page, layout):
|
||||
report = page.evaluate(
|
||||
"""(selector) => {
|
||||
const root = document.documentElement;
|
||||
const container = document.querySelector(selector);
|
||||
const widest = [];
|
||||
document.querySelectorAll("body *").forEach((el) => {
|
||||
if (el.getBoundingClientRect().right <= root.clientWidth + 1) return;
|
||||
widest.push(
|
||||
el.tagName.toLowerCase() + "." + (el.className || "").toString().trim()
|
||||
);
|
||||
});
|
||||
return {
|
||||
page: root.scrollWidth - root.clientWidth,
|
||||
layout: container ? container.scrollWidth - container.clientWidth : null,
|
||||
widest: widest.slice(0, 5),
|
||||
};
|
||||
}""",
|
||||
layout,
|
||||
)
|
||||
assert report["layout"] is not None, f"{layout} not found"
|
||||
assert report["page"] <= 1, (
|
||||
f"page scrolls horizontally by {report['page']}px: {report['widest']}"
|
||||
)
|
||||
assert report["layout"] <= 1, (
|
||||
f"{layout} overflows its own width by {report['layout']}px: {report['widest']}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def seeded_db(app_server):
|
||||
"""Create test users once at session level using requests directly."""
|
||||
|
||||
Reference in New Issue
Block a user