Files
odysseus/tests/test_notes_sidebar_new_note.py
T
Léo 1323fab0bd refactor(tests): read the whole cascade instead of style.css alone
static/style.css no longer holds every rule. 79 rules for the document,
gallery and editor panels now live in static/css/, yet 27 browser tests still
built their synthetic page with a single <link> to style.css, and 51 more read
that one file as though it were the whole cascade. Those tests kept passing
while covering less: a rule that moved became invisible to the assertion that
was meant to pin it.

Python readers now call tests.helpers.stylesheets.app_css(), and synthetic
pages are built from stylesheet_link_tags() so they load exactly what
index.html loads, in the same order. The helper already existed; this moves
the remaining callers onto it.

test_portal_dropdown_z_js parametrised over a file list including style.css to
assert an absence. Checking a negative against one file of a split stylesheet
is how a moved rule escapes, so the CSS case now checks the concatenation.

Two guards keep it from coming back: one fails on any test reading
static/style.css directly, the other on any synthetic page linking it alone.
Both name the helper to use.

No production code changes. Suite is unchanged at 6 pre-existing failures.
2026-09-29 17:05:29 +02:00

86 lines
3.1 KiB
Python

from pathlib import Path
from tests.helpers.stylesheets import app_css
ROOT = Path(__file__).resolve().parents[1]
def test_notes_sidebar_new_action_matches_library_structure_and_animation():
html = (ROOT / "static/index.html").read_text(encoding="utf-8")
css = app_css()
assert 'class="list-item-plus-btn sidebar-new-item-btn" id="notes-new-note-btn"' in html
assert '<span class="list-item-plus-label">new</span>' in html[html.index('id="notes-new-note-btn"'):]
assert "#tool-notes-btn:hover #notes-new-note-btn" in css
assert "#notes-new-note-btn:hover svg" in css
def test_notes_sidebar_new_action_opens_a_note_without_toggling_panel_closed():
app = (ROOT / "static/app.js").read_text(encoding="utf-8")
notes = (ROOT / "static/js/notes.js").read_text(encoding="utf-8")
assert "event.stopPropagation()" in app[app.index("const notesNewNoteBtn"):]
assert "notesModule?.newNote?.()" in app
assert "export function newNote()" in notes
assert "requestAnimationFrame(() => _createNote('note'))" in notes
assert "openNote, newNote, openNotes" in notes
def test_sidebar_new_note_focuses_note_body_instead_of_title():
notes = (ROOT / "static/js/notes.js").read_text(encoding="utf-8")
assert "form.querySelector('.note-form-content')" in notes
assert "initialField?.focus()" in notes
def test_notes_reminder_dot_stays_before_new_note_action():
notes = (ROOT / "static/js/notes.js").read_text(encoding="utf-8")
assert "sidebarBtn.querySelector('#notes-new-note-btn')" in notes
assert "sidebarBtn.insertBefore(dot, newNoteBtn || null)" in notes
def test_checklist_preview_starts_at_first_unfinished_item():
notes = (ROOT / "static/js/notes.js").read_text(encoding="utf-8")
start = notes.index("function _bindCardEvents(body)")
end = notes.index("const tapToEditOrSelect", start)
setup = notes[start:end]
assert ".note-checkbox:not(.done)" in setup
assert "preview.scrollTop" in setup
def test_checklist_preview_releases_scroll_at_its_boundaries():
notes = (ROOT / "static/js/notes.js").read_text(encoding="utf-8")
css = app_css()
assert "el.addEventListener('wheel'" in notes
assert "el.closest('.notes-pane-body')" in notes
assert "pane.scrollTop += e.deltaY" in notes
assert "overscroll-behavior-y: auto" in css
def test_notes_tags_toggle_is_nudged_down():
css = app_css()
rule = css[css.index(".notes-search-bar .notes-label-toggle {"):]
rule = rule[:rule.index("}")]
assert "top: 4px" in rule
def test_notes_body_and_tag_arrow_are_nudged_down():
css = app_css()
assert css.count("padding: 10px 8px 8px") >= 2
assert ".notes-pane-body .doclib-chip-scroll-arrow.right" in css
assert "top: calc(50% - 6px) !important" in css[css.index(".notes-pane-body .doclib-chip-scroll-arrow.right"):]
def test_notes_tag_strip_cannot_grow_into_blank_space():
css = app_css()
rule = css[css.index(".notes-pane-body > .doclib-chip-scroll-frame:has(> .notes-labels-bar) {"):]
rule = rule[:rule.index("}")]
assert "flex: 0 0 auto" in rule
assert "width: 100%" in rule