mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-11-08 14:12:22 +01:00
fix(calendar): render multi-day events within their day cells (#6948)
This commit is contained in:
@@ -71,7 +71,7 @@ def test_calendar_event_surfaces_use_computed_foreground_variable():
|
||||
|
||||
assert "_calReadableTextColor" in utils_js
|
||||
assert "function _calEventFg(ev)" in calendar_js
|
||||
assert "--cal-event-fg:${_calEventFg(md)}" in calendar_js
|
||||
# Month events share transparent dot rows; remaining solid tiles need contrast.
|
||||
assert "--cal-event-fg:${_calEventFg(ev)}" in calendar_js
|
||||
assert "color: var(--cal-event-fg, #fff);" in style_css
|
||||
assert "color: var(--cal-event-fg, var(--fg));" in style_css
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Calendar day membership uses the event's exclusive end instant."""
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.helpers.js_modules import js_function_source
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCE = js_function_source("_eventsForDay", (ROOT / "static/js/calendar.js").read_text())
|
||||
ZONES = ["UTC", "Europe/Istanbul", "America/New_York", "Asia/Tokyo"]
|
||||
CASES = [
|
||||
("2026-10-22T17:00:00", "2026-10-23T00:00:00", False, ["2026-10-22"]),
|
||||
("2026-10-22T17:00:00", "2026-10-23T00:01:00", False, ["2026-10-22", "2026-10-23"]),
|
||||
("2026-10-22T17:00:00", "2026-10-22T17:00:00", False, ["2026-10-22"]),
|
||||
("2026-10-15", "2026-10-17", True, ["2026-10-15", "2026-10-16"]),
|
||||
("2026-10-15", "2026-10-15", True, ["2026-10-15"]),
|
||||
("2026-10-31T23:00:00", "2026-11-01T00:00:00", False, ["2026-10-31"]),
|
||||
]
|
||||
|
||||
|
||||
def _coverage(zone, start, end, all_day, days):
|
||||
script = """
|
||||
import { _localDateOf } from './static/js/calendar/utils.js';
|
||||
const {source,event,days}=JSON.parse(process.argv[1]);
|
||||
const filter=new Function('_events','_eventVisible','_localDateOf',source+'; return _eventsForDay;')([event],()=>true,_localDateOf);
|
||||
console.log(JSON.stringify(days.filter(day=>filter(day).length)));
|
||||
"""
|
||||
data = dict(source=SOURCE, event=dict(uid="event", dtstart=start, dtend=end, all_day=all_day), days=days)
|
||||
result = subprocess.run(["node", "--input-type=module", "-e", script, json.dumps(data)],
|
||||
cwd=ROOT, env={**os.environ, "TZ": zone}, capture_output=True,
|
||||
text=True, check=True, timeout=15)
|
||||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not shutil.which("node"), reason="node not installed")
|
||||
@pytest.mark.parametrize("zone", ZONES)
|
||||
@pytest.mark.parametrize("start,end,all_day,expected", CASES)
|
||||
def test_event_day_coverage(zone, start, end, all_day, expected):
|
||||
days = [f"2026-10-{day:02d}" for day in range(14, 32)] + ["2026-11-01", "2026-11-02"]
|
||||
assert _coverage(zone, start, end, all_day, days) == expected
|
||||
|
||||
|
||||
@pytest.mark.skipif(not shutil.which("node"), reason="node not installed")
|
||||
@pytest.mark.parametrize("zone,start,end,days,expected", [
|
||||
("Europe/Berlin", "2026-10-24T20:00:00+02:00", "2026-10-26T00:00:00+01:00", ["2026-10-24", "2026-10-25", "2026-10-26"], ["2026-10-24", "2026-10-25"]),
|
||||
("America/New_York", "2026-10-31T20:00:00-04:00", "2026-11-02T00:00:00-05:00", ["2026-10-31", "2026-11-01", "2026-11-02"], ["2026-10-31", "2026-11-01"]),
|
||||
])
|
||||
def test_midnight_end_across_dst(zone, start, end, days, expected):
|
||||
assert _coverage(zone, start, end, False, days) == expected
|
||||
@@ -2,7 +2,7 @@ from pathlib import Path
|
||||
import re
|
||||
|
||||
from tests.helpers.stylesheets import app_css
|
||||
from tests.helpers.js_modules import email_library_source
|
||||
from tests.helpers.js_modules import email_library_source, js_function_source
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -172,8 +172,7 @@ def test_calendar_event_cards_show_compact_source_badges():
|
||||
style_src = app_css()
|
||||
|
||||
assert "function _eventSourceHtml" in calendar_src
|
||||
assert "${_eventSourceHtml(ev)}" in calendar_src
|
||||
assert "${_eventSourceHtml(md)}" in calendar_src
|
||||
assert "${_eventSourceHtml(ev)}" in js_function_source("_renderMonth", calendar_src)
|
||||
assert ".cal-event-source" in style_src
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user