2026-01-14 13:23:31 -05:00
|
|
|
from .base import FunctionalTest
|
2026-03-11 13:59:43 -04:00
|
|
|
from .note_page import NotePage
|
2026-01-14 13:23:31 -05:00
|
|
|
|
2026-02-19 20:31:29 -05:00
|
|
|
|
2026-01-14 13:23:31 -05:00
|
|
|
class LayoutAndStylingTest(FunctionalTest):
|
|
|
|
|
def test_layout_and_styling(self):
|
2026-03-06 21:34:43 -05:00
|
|
|
self.create_pre_authenticated_session("disco@test.io")
|
2026-01-14 13:23:31 -05:00
|
|
|
self.browser.get(self.live_server_url)
|
2026-03-11 13:59:43 -04:00
|
|
|
note_page = NotePage(self)
|
2026-01-14 13:23:31 -05:00
|
|
|
|
|
|
|
|
self.browser.set_window_size(1024, 768)
|
2026-03-15 18:52:09 -04:00
|
|
|
|
|
|
|
|
def section_center(el):
|
|
|
|
|
return self.browser.execute_script("""
|
|
|
|
|
var el = arguments[0];
|
|
|
|
|
var ancestor = el.parentElement;
|
|
|
|
|
while (ancestor && ancestor.tagName !== 'SECTION'
|
|
|
|
|
&& !ancestor.classList.contains('container')) {
|
|
|
|
|
ancestor = ancestor.parentElement;
|
|
|
|
|
}
|
2026-03-24 00:49:04 -04:00
|
|
|
var a = ancestor || document.body;
|
|
|
|
|
var s = a.getBoundingClientRect();
|
|
|
|
|
var cs = window.getComputedStyle(a);
|
|
|
|
|
var pl = parseFloat(cs.paddingLeft);
|
|
|
|
|
var pr = parseFloat(cs.paddingRight);
|
|
|
|
|
var r = el.getBoundingClientRect();
|
|
|
|
|
return [r.x + r.width / 2, s.x + pl + (s.width - pl - pr) / 2];
|
2026-03-15 18:52:09 -04:00
|
|
|
""", el)
|
2026-01-14 13:23:31 -05:00
|
|
|
|
2026-03-11 13:59:43 -04:00
|
|
|
inputbox = note_page.get_item_input_box()
|
2026-03-15 18:52:09 -04:00
|
|
|
input_c, section_c = section_center(inputbox)
|
|
|
|
|
self.assertAlmostEqual(input_c, section_c, delta=10)
|
2026-01-14 13:23:31 -05:00
|
|
|
|
2026-03-11 13:59:43 -04:00
|
|
|
note_page.add_note_item("testing")
|
|
|
|
|
inputbox = note_page.get_item_input_box()
|
2026-03-15 18:52:09 -04:00
|
|
|
input_c, section_c = section_center(inputbox)
|
|
|
|
|
self.assertAlmostEqual(input_c, section_c, delta=10)
|