mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-26 02:47:14 +01:00
Compare commits
2 Commits
ae7566628c
...
8df1ff6d09
| Author | SHA1 | Date | |
|---|---|---|---|
| 8df1ff6d09 | |||
| a22ec380ca |
@ -12,6 +12,14 @@ each further one +1h, and an accepted LeetCode submission that day +1h (flat,
|
||||
read from leetcode-guard's ledger, once per day). The config is re-derived from
|
||||
those sources on each new day, so nothing has to be "remembered" across reboots.
|
||||
|
||||
A RunnerUp run is credited from its TCX export, found in the WebDAV drop
|
||||
directory RunnerUp uploads to on this machine (`~/data/cloud/RunnerUp/`, plus
|
||||
`processed/` once endurain-import has taken it) or, when a phone is adb-visible,
|
||||
in `/sdcard/Documents/RunnerUp/`. The 15-minute `workout-sync.timer` scans both,
|
||||
so a run finished after 20:00 pushes the hour later without the phone being
|
||||
plugged in; the per-minute shutdown check then lifts the night lockdown on its
|
||||
own once the hour is past "now" (digital-wellbeing's check script).
|
||||
|
||||
## MCP server (Claude Code integration)
|
||||
|
||||
screen-locker exposes a **read-only** MCP server (`screen_locker._mcp`) so
|
||||
|
||||
@ -19,5 +19,5 @@ pytest-xdist==3.8.0
|
||||
# token over the REST endpoint; crdt-sync already pulls requests in, but this
|
||||
# module imports it itself, so it is declared rather than assumed.
|
||||
requests==2.34.2
|
||||
ruff==0.16.7
|
||||
ruff==0.16.8
|
||||
types-requests==2.33.0.20260906
|
||||
|
||||
@ -4,6 +4,13 @@ Neither early_bird (a same-day pending marker, see ``_early_bird.py``) nor
|
||||
sick_day (tracked in ``sick_history.json`` via ``_sick_tracker.py``) live in
|
||||
log.json — this module only checks their pending state and, on
|
||||
success, writes the *real* outcome (phone_verified/runnerup_verified) there.
|
||||
|
||||
The upgrade credits through ``_apply_workout_credit`` -- save first, reward
|
||||
only if the entry was actually appended. It used to push the shutdown hour
|
||||
and THEN save: when the same run was already in the log (the 15-minute sync
|
||||
pass had pulled the TCX at 20:25 on 2026-09-16) the save deduped to nothing
|
||||
and the +2h landed anyway, and again on every 5-minute tick while the
|
||||
pending marker lasted -- a runaway that only the 23:00 ceiling stopped.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@ -156,8 +163,7 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
||||
self.workout_data["type"] = "phone_verified"
|
||||
self.workout_data["source"] = message
|
||||
self.workout_data["after_sick_day"] = "true"
|
||||
self._adjust_shutdown_time_later()
|
||||
self.save_workout_log()
|
||||
self._apply_workout_credit()
|
||||
return True
|
||||
_logger.info("Auto-upgrade phone skipped (%s), trying RunnerUp...", status)
|
||||
try:
|
||||
@ -177,8 +183,7 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
||||
self.workout_data["type"] = "runnerup_verified"
|
||||
self.workout_data["source"] = runnerup_msg
|
||||
self.workout_data["after_sick_day"] = "true"
|
||||
self._adjust_shutdown_time_later()
|
||||
self.save_workout_log()
|
||||
self._apply_workout_credit()
|
||||
return True
|
||||
|
||||
def _try_auto_upgrade_early_bird(self) -> bool:
|
||||
@ -196,8 +201,7 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
||||
self.workout_data["type"] = "phone_verified"
|
||||
self.workout_data["source"] = message
|
||||
self.workout_data["after_early_bird"] = "true"
|
||||
self._adjust_shutdown_time_later()
|
||||
self.save_workout_log()
|
||||
self._apply_workout_credit()
|
||||
return True
|
||||
_logger.info("Early bird phone skipped (%s), trying RunnerUp...", status)
|
||||
try:
|
||||
@ -218,6 +222,5 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
||||
self.workout_data["type"] = "runnerup_verified"
|
||||
self.workout_data["source"] = runnerup_msg
|
||||
self.workout_data["after_early_bird"] = "true"
|
||||
self._adjust_shutdown_time_later()
|
||||
self.save_workout_log()
|
||||
self._apply_workout_credit()
|
||||
return True
|
||||
|
||||
@ -143,6 +143,17 @@ RUNNERUP_EXPORT_DIRS: tuple[str, ...] = (
|
||||
"/storage/emulated/0/Documents/RunnerUp",
|
||||
)
|
||||
|
||||
# Where RunnerUp's WebDAV synchroniser drops the same exports on this machine
|
||||
# (dufs, see ~/src/dufs-cloud), and where endurain-import moves them once
|
||||
# Endurain has them. Read straight off the disk, so a run is credited without
|
||||
# the phone being adb-reachable -- on 2026-09-16 the TCX landed here at 20:08
|
||||
# and the phone was only plugged in at 20:25. Same filenames as the phone
|
||||
# export, optionally prefixed with the device name (RunnerUp_Pixel_6a_...).
|
||||
RUNNERUP_WEBDAV_DIRS: tuple[Path, ...] = (
|
||||
Path.home() / "data" / "cloud" / "RunnerUp",
|
||||
Path.home() / "data" / "cloud" / "RunnerUp" / "processed",
|
||||
)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Sync (phone workout data) — Workstream C, built on the shared crdt-sync
|
||||
# library. GitHub is used purely as dumb file storage via the REST Contents
|
||||
|
||||
@ -17,15 +17,25 @@ from typing import TYPE_CHECKING
|
||||
from screen_locker._log_mixin import write_signed_entry
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
# Same shape as ``_manual_sync.OnIngestedCallback``: the appended
|
||||
# ``workout_data`` and that day's entries *before* it.
|
||||
OnIngestedCallback = Callable[[dict, "list[dict]"], None]
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RunnerUpBackfillMixin:
|
||||
"""Fills the log from RunnerUp exports for a date or a whole week."""
|
||||
|
||||
def _try_fill_runnerup_for_date(self, date_str: str, log_file: Path) -> bool:
|
||||
def _try_fill_runnerup_for_date(
|
||||
self,
|
||||
date_str: str,
|
||||
log_file: Path,
|
||||
on_ingested: OnIngestedCallback | None = None,
|
||||
) -> bool:
|
||||
"""Append a verified RunnerUp entry for ``date_str`` if not already logged.
|
||||
|
||||
Appends via the write chokepoint, which dedups by ``workout_id``
|
||||
@ -33,6 +43,14 @@ class RunnerUpBackfillMixin:
|
||||
recorded is a no-op, but a day that only holds, say, a manual workout
|
||||
still gets the run appended alongside it (multiple workouts per day).
|
||||
|
||||
``on_ingested(workout_data, prior_entries)`` fires once per appended
|
||||
entry, exactly like manual-sync ingestion, so a run pulled off the
|
||||
phone earns the same day-scaled reward as every other source. It used
|
||||
to earn only a weekly-surplus bonus (+1h per workout above the weekly
|
||||
minimum), which is 0 for most of the week: on 2026-09-16 a run synced
|
||||
at 20:25 left the config at 20:00 while the daily reset would have
|
||||
derived 22:00 from the same log.
|
||||
|
||||
Returns True if a new verified entry was appended for ``date_str``.
|
||||
"""
|
||||
for remote in self._find_runnerup_exports_for_date(date_str):
|
||||
@ -55,20 +73,30 @@ class RunnerUpBackfillMixin:
|
||||
"distance_km": round(data["distance_m"] / 1000, 2),
|
||||
"duration_minutes": round(data["duration_seconds"] / 60, 1),
|
||||
}
|
||||
if write_signed_entry(log_file, date_str, workout_data).appended:
|
||||
_logger.info("Auto-filled RunnerUp entry for %s: %s", date_str, msg)
|
||||
return True
|
||||
return False
|
||||
result = write_signed_entry(log_file, date_str, workout_data)
|
||||
if not result.appended:
|
||||
return False
|
||||
_logger.info("Auto-filled RunnerUp entry for %s: %s", date_str, msg)
|
||||
if on_ingested is not None:
|
||||
on_ingested(workout_data, result.prior_entries)
|
||||
return True
|
||||
return False
|
||||
|
||||
def _scan_and_fill_week_runnerup(self, log_file: Path) -> int:
|
||||
def _scan_and_fill_week_runnerup(
|
||||
self, log_file: Path, on_ingested: OnIngestedCallback | None = None
|
||||
) -> int:
|
||||
"""Scan the current ISO week for RunnerUp runs and append any not logged.
|
||||
|
||||
Returns the count of newly appended entries (0 if phone not connected).
|
||||
``on_ingested`` is passed through to every appended entry; see
|
||||
:meth:`_try_fill_runnerup_for_date`.
|
||||
|
||||
Returns the count of newly appended entries (0 if no export source --
|
||||
neither the WebDAV drop directory nor an adb-visible phone).
|
||||
"""
|
||||
if not self._has_adb_device():
|
||||
if not self._has_runnerup_source():
|
||||
_logger.info(
|
||||
"Phone not connected; skipping auto-scan for past RunnerUp exports."
|
||||
"No RunnerUp source (no WebDAV drop dir, phone not connected); "
|
||||
"skipping auto-scan for past RunnerUp exports."
|
||||
)
|
||||
return 0
|
||||
|
||||
@ -79,7 +107,9 @@ class RunnerUpBackfillMixin:
|
||||
filled = 0
|
||||
current = week_start
|
||||
while current <= today:
|
||||
if self._try_fill_runnerup_for_date(current.strftime("%Y-%m-%d"), log_file):
|
||||
if self._try_fill_runnerup_for_date(
|
||||
current.strftime("%Y-%m-%d"), log_file, on_ingested
|
||||
):
|
||||
filled += 1
|
||||
current += timedelta(days=1)
|
||||
|
||||
|
||||
@ -41,7 +41,15 @@ class RunnerUpTcxMixin:
|
||||
"""Pulls and parses RunnerUp's TCX exports over adb."""
|
||||
|
||||
def _pull_and_parse_tcx(self, remote_path: str) -> dict[str, Any] | None:
|
||||
"""Pull a remote TCX file and parse it. Returns activity dict or None."""
|
||||
"""Parse a TCX export, pulling it over adb first unless it is local.
|
||||
|
||||
A path that exists on this machine (the WebDAV drop directory, see
|
||||
``RUNNERUP_WEBDAV_DIRS``) is parsed in place; anything else is a
|
||||
phone path and goes through ``adb pull``. Returns the activity dict
|
||||
or None.
|
||||
"""
|
||||
if Path(remote_path).is_file():
|
||||
return self._parse_tcx(remote_path)
|
||||
tmp_dir = tempfile.mkdtemp(prefix="runnerup_tcx_")
|
||||
local_path = str(Path(tmp_dir) / "activity.tcx")
|
||||
try:
|
||||
|
||||
@ -15,6 +15,7 @@ from screen_locker._constants import (
|
||||
MIN_WORKOUT_DURATION_MINUTES,
|
||||
RUNNERUP_DISTANCE_TOLERANCE,
|
||||
RUNNERUP_EXPORT_DIRS,
|
||||
RUNNERUP_WEBDAV_DIRS,
|
||||
WORKOUT_DURATION_ACCEPT_MINUTES,
|
||||
)
|
||||
from screen_locker._day import today_str
|
||||
@ -50,14 +51,43 @@ class RunnerUpVerificationMixin(
|
||||
# File-based path (no root required)
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _has_runnerup_source(self) -> bool:
|
||||
"""Whether any RunnerUp export source is reachable right now.
|
||||
|
||||
The WebDAV drop directory on this disk counts as much as an
|
||||
adb-visible phone: both hold the same TCX files.
|
||||
"""
|
||||
return self._has_local_runnerup_dir() or self._has_adb_device()
|
||||
|
||||
@staticmethod
|
||||
def _has_local_runnerup_dir() -> bool:
|
||||
return any(d.is_dir() for d in RUNNERUP_WEBDAV_DIRS)
|
||||
|
||||
@staticmethod
|
||||
def _find_local_runnerup_exports_for_date(date_str: str) -> list[str]:
|
||||
"""TCX files for ``date_str`` in the WebDAV drop directories, sorted."""
|
||||
found: list[str] = []
|
||||
for local_dir in RUNNERUP_WEBDAV_DIRS:
|
||||
if not local_dir.is_dir():
|
||||
continue
|
||||
for path in sorted(local_dir.glob("*.tcx")):
|
||||
if date_str in path.name and str(path) not in found:
|
||||
found.append(str(path))
|
||||
return found
|
||||
|
||||
def _find_runnerup_exports_for_date(self, date_str: str) -> list[str]:
|
||||
"""Return adb paths of RunnerUp TCX exports for the given date, or empty list.
|
||||
"""Return paths of RunnerUp TCX exports for the given date, or empty list.
|
||||
|
||||
Local WebDAV copies come first (no phone needed), then the phone's
|
||||
export directories over adb when a device is attached.
|
||||
|
||||
Args:
|
||||
date_str: ISO date string in ``YYYY-MM-DD`` format matched against
|
||||
TCX filenames (``RunnerUp_YYYY-MM-DD-HH-MM-SS_xxx.tcx``).
|
||||
"""
|
||||
found: list[str] = []
|
||||
found = self._find_local_runnerup_exports_for_date(date_str)
|
||||
if not self._has_adb_device():
|
||||
return found
|
||||
for dirpath in RUNNERUP_EXPORT_DIRS:
|
||||
ok, out = self._run_adb(["shell", "ls", dirpath])
|
||||
if not ok or not out.strip():
|
||||
@ -165,13 +195,13 @@ class RunnerUpVerificationMixin(
|
||||
if not skew_ok:
|
||||
return "clock_tampered", skew_msg
|
||||
|
||||
if not self._has_adb_device():
|
||||
if not self._has_runnerup_source():
|
||||
return (
|
||||
"no_phone",
|
||||
"Phone not connected — plug in via USB or enable wireless ADB",
|
||||
)
|
||||
|
||||
# Path 1: file-based (no root needed).
|
||||
# Path 1: file-based (no root needed; WebDAV copies first, then adb).
|
||||
file_result = self._verify_runnerup_via_files()
|
||||
if file_result is not None:
|
||||
_logger.info("RunnerUp file-based result: %s", file_result[0])
|
||||
@ -179,5 +209,11 @@ class RunnerUpVerificationMixin(
|
||||
|
||||
# Path 2: root DB pull (fallback when no export files found yet).
|
||||
# On a non-rooted device this path cannot succeed; _verify_runnerup_via_db
|
||||
# reports that plainly rather than as a generic failure.
|
||||
# reports that plainly rather than as a generic failure. Needs adb.
|
||||
if not self._has_adb_device():
|
||||
return (
|
||||
"not_verified",
|
||||
f"No RunnerUp export for today in {RUNNERUP_WEBDAV_DIRS} and the "
|
||||
"phone is not adb-reachable",
|
||||
)
|
||||
return self._verify_runnerup_via_db()
|
||||
|
||||
@ -95,18 +95,19 @@ def run_status(locker: ScreenLocker) -> None:
|
||||
# which would undercount a day holding two verified workouts.
|
||||
before_count = count_weekly_workouts(log_file)
|
||||
|
||||
# RunnerUp scan
|
||||
n_filled = locker._scan_and_fill_week_runnerup(log_file)
|
||||
# RunnerUp scan. Each fill is credited by the shared ingestion callback
|
||||
# (+2h first counted workout of its day, +1h each further one), the same
|
||||
# rule the timer's sync pass and the daily base reset use.
|
||||
n_filled = locker._scan_and_fill_week_runnerup(
|
||||
log_file, on_ingested=locker._credit_ingested_workout
|
||||
)
|
||||
locker.workout_data = {}
|
||||
if n_filled > 0:
|
||||
print(f" Auto-filled {n_filled} workout(s) from RunnerUp exports.")
|
||||
after_count = count_weekly_workouts(log_file)
|
||||
bonus = max(0, after_count - max(WEEKLY_WORKOUT_MINIMUM, before_count))
|
||||
if bonus > 0:
|
||||
ok = locker._adjust_shutdown_time_by(bonus)
|
||||
if ok:
|
||||
print(f" +{bonus}h shutdown bonus applied.")
|
||||
else:
|
||||
print(f" +{bonus}h shutdown bonus pending (config write failed).")
|
||||
_, mw_hour, _ = locker._read_shutdown_config() or (None, None, None)
|
||||
if mw_hour is not None:
|
||||
print(f" Shutdown tonight: {mw_hour:02d}:00.")
|
||||
else:
|
||||
print(" No new workouts found via RunnerUp scan.")
|
||||
after_count = before_count
|
||||
|
||||
@ -59,24 +59,34 @@ def _make_bare_verifier(log_file: Path) -> ScreenLocker:
|
||||
def _backfill_week_and_apply_bonus(verifier: ScreenLocker) -> str | None:
|
||||
"""Scan the current week for unlogged RunnerUp/StrongLifts and credit it.
|
||||
|
||||
Reuses the exact prev/new-count + ``_adjust_shutdown_time_by`` bonus
|
||||
pattern already proven by the automatic lock-check
|
||||
(``screen_lock.py:_auto_fill_week_runnerup_bonus``) and the ``--status``
|
||||
CLI (``_status.py``) — deliberately *not* routed through
|
||||
``_apply_workout_credit``, which always files under today by design and
|
||||
would mis-date a backfilled entry.
|
||||
Each RunnerUp fill is credited through the same ``on_ingested`` callback
|
||||
as the timer's sync pass and every other ingestion source
|
||||
(``_sync_mixin._credit_ingested_workout``): +2h for the first counted
|
||||
workout of its day, +1h for each further one. The callback files the
|
||||
reward against the entry's OWN day, so a back-dated fill is not mis-dated
|
||||
the way routing it through ``_apply_workout_credit`` (always today) would.
|
||||
|
||||
The StrongLifts fill keeps the weekly-surplus rule for now (+1h per
|
||||
workout above the weekly minimum); it is a separate source with its own
|
||||
dedup and is out of scope for the RunnerUp credit fix.
|
||||
|
||||
Returns a human-readable summary if anything was filled, else ``None``.
|
||||
"""
|
||||
prev_count = count_weekly_workouts(verifier.log_file)
|
||||
filled = verifier._scan_and_fill_week_runnerup(verifier.log_file)
|
||||
filled += verifier._try_fill_stronglifts_for_week(verifier.log_file)
|
||||
filled = verifier._scan_and_fill_week_runnerup(
|
||||
verifier.log_file, on_ingested=verifier._credit_ingested_workout
|
||||
)
|
||||
verifier.workout_data = {}
|
||||
sl_filled = verifier._try_fill_stronglifts_for_week(verifier.log_file)
|
||||
bonus = 0
|
||||
if sl_filled:
|
||||
new_count = count_weekly_workouts(verifier.log_file)
|
||||
bonus = max(0, new_count - max(WEEKLY_WORKOUT_MINIMUM, prev_count + filled))
|
||||
if bonus > 0:
|
||||
verifier._adjust_shutdown_time_by(bonus)
|
||||
filled += sl_filled
|
||||
if not filled:
|
||||
return None
|
||||
new_count = count_weekly_workouts(verifier.log_file)
|
||||
bonus = max(0, new_count - max(WEEKLY_WORKOUT_MINIMUM, prev_count))
|
||||
if bonus > 0:
|
||||
verifier._adjust_shutdown_time_by(bonus)
|
||||
plural = "workout" if filled == 1 else "workouts"
|
||||
message = f"Auto-filled {filled} {plural} from earlier this week."
|
||||
if bonus > 0:
|
||||
|
||||
@ -16,10 +16,6 @@ from screen_locker._manual_push import push_pc_workouts
|
||||
from screen_locker._manual_sync import ingest_manual_records
|
||||
from screen_locker._session_sync import ingest_session_records
|
||||
from screen_locker._shutdown_base import apply_leetcode_bonus_if_new
|
||||
from screen_locker._weekly_check import (
|
||||
WEEKLY_WORKOUT_MINIMUM,
|
||||
count_weekly_workouts,
|
||||
)
|
||||
from screen_locker._workout_sync import (
|
||||
pull_all_manual_records,
|
||||
pull_all_session_records,
|
||||
@ -67,7 +63,7 @@ class SyncMixin:
|
||||
ingested = ingest_manual_records(
|
||||
self.log_file,
|
||||
pull_all_manual_records(),
|
||||
on_ingested=self._credit_ingested_manual_workout,
|
||||
on_ingested=self._credit_ingested_workout,
|
||||
)
|
||||
for record_id in ingested:
|
||||
_logger.info("Ingested synced manual workout: %s", record_id)
|
||||
@ -88,42 +84,51 @@ class SyncMixin:
|
||||
ingested = ingest_session_records(
|
||||
self.log_file,
|
||||
pull_all_session_records(),
|
||||
on_ingested=self._credit_ingested_manual_workout,
|
||||
on_ingested=self._credit_ingested_workout,
|
||||
)
|
||||
for record_id in ingested:
|
||||
_logger.info("Ingested synced StrongLifts session: %s", record_id)
|
||||
self.workout_data = {}
|
||||
|
||||
def _credit_ingested_manual_workout(
|
||||
def _credit_ingested_workout(
|
||||
self, entry: dict[str, str], prior_entries: list[dict]
|
||||
) -> None:
|
||||
"""Apply the live-workout reward to a manual workout ingested via sync."""
|
||||
"""Apply the live-workout reward to a workout ingested from another source.
|
||||
|
||||
Shared by manual-workout sync, StrongLifts session sync and the
|
||||
RunnerUp TCX backfill -- one reward rule for every non-interactive way
|
||||
a workout can land in the log.
|
||||
"""
|
||||
self.workout_data = entry
|
||||
credit = self._apply_credit_for_written_entry(prior_entries)
|
||||
if credit.shutdown_adjusted:
|
||||
_logger.info(
|
||||
"Synced manual workout pushed shutdown time +2h: %s",
|
||||
"Ingested workout pushed shutdown time +2h: %s",
|
||||
entry.get("source", ""),
|
||||
)
|
||||
elif credit.extra_bonus_delta:
|
||||
_logger.info(
|
||||
"Synced manual workout added +%dh shutdown time: %s",
|
||||
"Ingested workout added +%dh shutdown time: %s",
|
||||
credit.extra_bonus_delta,
|
||||
entry.get("source", ""),
|
||||
)
|
||||
|
||||
def _auto_fill_week_runnerup_bonus(self) -> None:
|
||||
"""Auto-fill missed RunnerUp workouts and award any earned bonus."""
|
||||
prev_count = count_weekly_workouts(self.log_file)
|
||||
n_filled = self._scan_and_fill_week_runnerup(self.log_file)
|
||||
if not n_filled:
|
||||
return
|
||||
new_count = count_weekly_workouts(self.log_file)
|
||||
_logger.info("Auto-filled %d RunnerUp workout(s) from TCX exports.", n_filled)
|
||||
# Award +1h for each newly auto-filled workout above the minimum.
|
||||
bonus = max(0, new_count - max(WEEKLY_WORKOUT_MINIMUM, prev_count))
|
||||
if bonus > 0 and self._adjust_shutdown_time_by(bonus):
|
||||
_logger.info("Auto-fill extra bonus: +%dh shutdown time.", bonus)
|
||||
"""Auto-fill missed RunnerUp workouts and credit each one.
|
||||
|
||||
Every appended run goes through the same
|
||||
:meth:`_credit_ingested_workout` callback as a synced manual workout
|
||||
or StrongLifts session, so the reward is the documented day rule
|
||||
(+2h first counted workout of its day, +1h each further one).
|
||||
"""
|
||||
n_filled = self._scan_and_fill_week_runnerup(
|
||||
self.log_file, on_ingested=self._credit_ingested_workout
|
||||
)
|
||||
if n_filled:
|
||||
_logger.info(
|
||||
"Auto-filled %d RunnerUp workout(s) from TCX exports.", n_filled
|
||||
)
|
||||
self.workout_data = {}
|
||||
|
||||
def _apply_weekly_shutdown_bonus(self) -> None:
|
||||
"""Layer this week's earned shutdown bonus back on top of the fresh base."""
|
||||
|
||||
@ -32,6 +32,7 @@ def _make_locker(
|
||||
workout_data={},
|
||||
)
|
||||
locker._scan_and_fill_week_runnerup = MagicMock(return_value=n_filled)
|
||||
locker._credit_ingested_workout = MagicMock()
|
||||
locker._adjust_shutdown_time_by = MagicMock(return_value=bonus_applied)
|
||||
locker._read_shutdown_config = MagicMock(return_value=cfg)
|
||||
return locker
|
||||
|
||||
@ -70,3 +70,18 @@ def _isolate_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[N
|
||||
monkeypatch.setenv("HOME", str(tmp_path))
|
||||
with patch.object(Path, "home", lambda: tmp_path):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_real_runnerup_webdav_dir(tmp_path: Path) -> Iterator[None]:
|
||||
"""Never let the RunnerUp scan read the developer's real WebDAV drop dir.
|
||||
|
||||
``RUNNERUP_WEBDAV_DIRS`` is bound from ``Path.home()`` at *import* time,
|
||||
so ``_isolate_home`` cannot reach it. On this machine the real directory
|
||||
holds today's run, which made every "phone absent → not verified" test
|
||||
pass verification the day the source was added (2026-09-16). Tests that
|
||||
want the local source point the tuple at directories they populate.
|
||||
"""
|
||||
absent = (tmp_path / "no-runnerup-webdav",)
|
||||
with patch("screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS", absent):
|
||||
yield
|
||||
|
||||
157
screen_locker/tests/test_runnerup_backfill_credit.py
Normal file
157
screen_locker/tests/test_runnerup_backfill_credit.py
Normal file
@ -0,0 +1,157 @@
|
||||
"""The RunnerUp backfill credits each fill through the shared ``on_ingested``.
|
||||
|
||||
Regression for 2026-09-16: a run synced off the phone at 20:25 was appended
|
||||
to the log but earned only the weekly-surplus bonus (+1h per workout above
|
||||
the weekly minimum), which was 0 that early in the week -- the shutdown hour
|
||||
stayed at 20:00 while the daily base reset would have derived 22:00 from the
|
||||
very same log. Every fill now goes through the same credit callback as a
|
||||
synced manual workout or StrongLifts session.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from screen_locker._log_io import load_workout_log
|
||||
from screen_locker.tests.conftest import create_locker
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
_RUN = {"sport": 0, "duration_seconds": 4200, "distance_m": 5800}
|
||||
|
||||
|
||||
def _stub_phone(locker: object, dates: set[str]) -> None:
|
||||
"""Make the scan see one verified run on each of ``dates``."""
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_find_runnerup_exports_for_date",
|
||||
MagicMock(side_effect=lambda d: ["/sdcard/run.tcx"] if d in dates else []),
|
||||
)
|
||||
object.__setattr__(locker, "_pull_and_parse_tcx", MagicMock(return_value=_RUN))
|
||||
object.__setattr__(
|
||||
locker, "_validate_runnerup_data", MagicMock(return_value=("verified", "ok"))
|
||||
)
|
||||
|
||||
|
||||
class TestBackfillCreditCallback:
|
||||
"""``_try_fill_runnerup_for_date`` / ``_scan_and_fill_week_runnerup``."""
|
||||
|
||||
def test_callback_gets_workout_data_and_prior_entries(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""The callback sees the appended entry and that day's prior entries."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
log_file = tmp_path / "log.json"
|
||||
log_file.write_text(
|
||||
'{"2026-09-16": [{"workout_data": {"type": "manual_workout"}}]}'
|
||||
)
|
||||
_stub_phone(locker, {"2026-09-16"})
|
||||
seen: list[tuple[dict, list[dict]]] = []
|
||||
|
||||
with patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"):
|
||||
appended = locker._try_fill_runnerup_for_date(
|
||||
"2026-09-16", log_file, lambda e, p: seen.append((e, p))
|
||||
)
|
||||
|
||||
assert appended is True
|
||||
assert len(seen) == 1
|
||||
entry, prior = seen[0]
|
||||
assert entry["type"] == "runnerup_verified"
|
||||
assert entry["distance_km"] == 5.8
|
||||
assert [e["workout_data"]["type"] for e in prior] == ["manual_workout"]
|
||||
|
||||
def test_duplicate_fill_does_not_fire_callback(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""A re-scan of an already-logged run appends nothing and credits nothing."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
log_file = tmp_path / "log.json"
|
||||
log_file.write_text("{}")
|
||||
_stub_phone(locker, {"2026-09-16"})
|
||||
callback = MagicMock()
|
||||
|
||||
with patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"):
|
||||
first = locker._try_fill_runnerup_for_date("2026-09-16", log_file, callback)
|
||||
second = locker._try_fill_runnerup_for_date(
|
||||
"2026-09-16", log_file, callback
|
||||
)
|
||||
|
||||
assert (first, second) == (True, False)
|
||||
assert callback.call_count == 1
|
||||
assert len(load_workout_log(log_file)["2026-09-16"]) == 1
|
||||
|
||||
def test_no_callback_still_appends(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""Callers that only want the log filled (no reward) keep working."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
log_file = tmp_path / "log.json"
|
||||
log_file.write_text("{}")
|
||||
_stub_phone(locker, {"2026-09-16"})
|
||||
|
||||
with patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"):
|
||||
assert locker._try_fill_runnerup_for_date("2026-09-16", log_file) is True
|
||||
|
||||
def test_week_scan_passes_callback_to_every_fill(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""The week scan forwards ``on_ingested`` to each day it fills."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
log_file = tmp_path / "log.json"
|
||||
log_file.write_text("{}")
|
||||
fill = MagicMock(return_value=True)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
object.__setattr__(locker, "_try_fill_runnerup_for_date", fill)
|
||||
callback = MagicMock()
|
||||
|
||||
filled = locker._scan_and_fill_week_runnerup(log_file, on_ingested=callback)
|
||||
|
||||
assert filled == fill.call_count >= 1
|
||||
assert all(call.args[2] is callback for call in fill.call_args_list)
|
||||
|
||||
|
||||
class TestSyncPassCreditsRunnerUp:
|
||||
"""``_auto_fill_week_runnerup_bonus`` (the 15-minute timer path)."""
|
||||
|
||||
def test_first_run_of_the_day_pushes_shutdown_two_hours(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""Base 20:00 + today's first counted workout = 22:00 -- the day rule."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
locker.log_file.write_text("{}")
|
||||
_stub_phone(locker, {"2026-09-16"})
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_scan_and_fill_week_runnerup",
|
||||
lambda log, on_ingested=None: locker._try_fill_runnerup_for_date(
|
||||
"2026-09-16", log, on_ingested
|
||||
),
|
||||
)
|
||||
config = {"hours": (20, 20, 5)}
|
||||
|
||||
def write(mw: int, ts: int, me: int, restore: bool = False) -> bool:
|
||||
config["hours"] = (mw, ts, me)
|
||||
return True
|
||||
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_read_shutdown_config",
|
||||
MagicMock(side_effect=lambda: config["hours"]),
|
||||
)
|
||||
object.__setattr__(
|
||||
locker, "_write_shutdown_config", MagicMock(side_effect=write)
|
||||
)
|
||||
|
||||
with (
|
||||
patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"),
|
||||
patch("screen_locker._workout_credit._sick_tracker.load_history") as hist,
|
||||
):
|
||||
hist.return_value.debt = 0
|
||||
locker._auto_fill_week_runnerup_bonus()
|
||||
locker._auto_fill_week_runnerup_bonus()
|
||||
|
||||
assert config["hours"] == (22, 22, 5)
|
||||
assert locker.workout_data == {}
|
||||
@ -89,6 +89,9 @@ class TestBranchCoverageGaps:
|
||||
"_run_adb",
|
||||
MagicMock(return_value=(True, dup_files)),
|
||||
)
|
||||
# The adb listing only runs with a device attached (the WebDAV drop
|
||||
# dir is searched first and needs no phone).
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
result = locker._find_runnerup_exports_for_date("2024-03-15")
|
||||
# Dedup: only one path in the result
|
||||
assert len(result) >= 1
|
||||
|
||||
@ -141,6 +141,7 @@ class TestFindRunnerupExportsForDate:
|
||||
) -> None:
|
||||
"""_run_adb returning False → empty list."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
object.__setattr__(locker, "_run_adb", MagicMock(return_value=(False, "")))
|
||||
assert locker._find_runnerup_exports_for_date("2024-03-15") == []
|
||||
|
||||
@ -152,6 +153,7 @@ class TestFindRunnerupExportsForDate:
|
||||
) -> None:
|
||||
"""ADB listing with no date-matching .tcx files → empty list."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_run_adb",
|
||||
@ -172,6 +174,9 @@ class TestFindRunnerupExportsForDate:
|
||||
"_run_adb",
|
||||
MagicMock(return_value=(True, "RunnerUp_2024-03-15-10-30-00_act.tcx\n")),
|
||||
)
|
||||
# The adb listing only runs with a device attached (the WebDAV drop
|
||||
# dir is searched first and needs no phone).
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
result = locker._find_runnerup_exports_for_date("2024-03-15")
|
||||
assert len(result) >= 1
|
||||
assert "2024-03-15" in result[0]
|
||||
|
||||
198
screen_locker/tests/test_runnerup_webdav_source.py
Normal file
198
screen_locker/tests/test_runnerup_webdav_source.py
Normal file
@ -0,0 +1,198 @@
|
||||
"""RunnerUp exports are read from the WebDAV drop directory, phone optional.
|
||||
|
||||
RunnerUp's WebDAV synchroniser uploads every export to dufs on this machine
|
||||
(``RUNNERUP_WEBDAV_DIRS``), minutes after the run ends, and endurain-import
|
||||
moves them to ``processed/``. Reading those files credits the run without the
|
||||
phone being adb-reachable: on 2026-09-16 the TCX was on disk at 20:08 and the
|
||||
phone was only plugged in at 20:25.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from screen_locker.tests.conftest import create_locker
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
_TCX = """\
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TrainingCenterDatabase
|
||||
xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2">
|
||||
<Activities>
|
||||
<Activity Sport="Running">
|
||||
<Lap>
|
||||
<TotalTimeSeconds>4200.0</TotalTimeSeconds>
|
||||
<DistanceMeters>5800.0</DistanceMeters>
|
||||
</Lap>
|
||||
</Activity>
|
||||
</Activities>
|
||||
</TrainingCenterDatabase>
|
||||
"""
|
||||
|
||||
|
||||
def _webdav_tree(tmp_path: Path) -> tuple[Path, Path]:
|
||||
inbox = tmp_path / "cloud" / "RunnerUp"
|
||||
processed = inbox / "processed"
|
||||
processed.mkdir(parents=True)
|
||||
return inbox, processed
|
||||
|
||||
|
||||
class TestLocalExportDiscovery:
|
||||
"""``_find_runnerup_exports_for_date`` / ``_has_runnerup_source``."""
|
||||
|
||||
def test_local_files_found_without_adb(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""Inbox and processed/ are both searched; adb is never asked."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
inbox, processed = _webdav_tree(tmp_path)
|
||||
(inbox / "RunnerUp_Pixel_6a_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
||||
(processed / "RunnerUp_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
||||
(inbox / "RunnerUp_2026-09-16-18-58-28_Running.gpx").write_text("<gpx/>")
|
||||
(processed / "RunnerUp_2026-09-01-18-04-41_Running.tcx").write_text(_TCX)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
||||
object.__setattr__(locker, "_run_adb", MagicMock())
|
||||
|
||||
with patch(
|
||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
||||
(inbox, processed),
|
||||
):
|
||||
assert locker._has_runnerup_source() is True
|
||||
found = locker._find_runnerup_exports_for_date("2026-09-16")
|
||||
|
||||
assert found == [
|
||||
str(inbox / "RunnerUp_Pixel_6a_2026-09-16-18-58-28_Running.tcx"),
|
||||
str(processed / "RunnerUp_2026-09-16-18-58-28_Running.tcx"),
|
||||
]
|
||||
locker._run_adb.assert_not_called()
|
||||
|
||||
def test_phone_paths_appended_after_local_when_adb_present(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""With a phone attached the adb listing follows the local copies."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
inbox, processed = _webdav_tree(tmp_path)
|
||||
(inbox / "RunnerUp_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_run_adb",
|
||||
MagicMock(
|
||||
return_value=(True, "RunnerUp_2026-09-16-18-58-28_Running.tcx\n")
|
||||
),
|
||||
)
|
||||
|
||||
with (
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
||||
(inbox, processed),
|
||||
),
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.RUNNERUP_EXPORT_DIRS",
|
||||
("/sdcard/Documents/RunnerUp",),
|
||||
),
|
||||
):
|
||||
found = locker._find_runnerup_exports_for_date("2026-09-16")
|
||||
|
||||
assert found == [
|
||||
str(inbox / "RunnerUp_2026-09-16-18-58-28_Running.tcx"),
|
||||
"/sdcard/Documents/RunnerUp/RunnerUp_2026-09-16-18-58-28_Running.tcx",
|
||||
]
|
||||
|
||||
def test_no_source_when_dir_missing_and_no_phone(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""Neither directory nor phone → no source, verify reports no_phone."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
||||
|
||||
with (
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
||||
(tmp_path / "absent",),
|
||||
),
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.check_clock_skew",
|
||||
return_value=(True, ""),
|
||||
),
|
||||
):
|
||||
assert locker._has_runnerup_source() is False
|
||||
status, _ = locker._verify_runnerup_workout()
|
||||
assert locker._scan_and_fill_week_runnerup(tmp_path / "log.json") == 0
|
||||
|
||||
assert status == "no_phone"
|
||||
|
||||
|
||||
class TestLocalVerifyAndParse:
|
||||
"""The local file is parsed in place; the root-DB fallback needs adb."""
|
||||
|
||||
def test_verify_today_from_local_file_without_adb(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""A today's TCX on disk verifies with the phone detached."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
inbox, processed = _webdav_tree(tmp_path)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
||||
object.__setattr__(locker, "_run_adb", MagicMock())
|
||||
|
||||
with (
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
||||
(inbox, processed),
|
||||
),
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.check_clock_skew",
|
||||
return_value=(True, ""),
|
||||
),
|
||||
patch("screen_locker._runnerup_verification.today_str") as today,
|
||||
):
|
||||
today.return_value = "2026-09-16"
|
||||
(inbox / "RunnerUp_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
||||
status, message = locker._verify_runnerup_workout()
|
||||
|
||||
assert status == "verified"
|
||||
assert "5.8 km" in message
|
||||
locker._run_adb.assert_not_called()
|
||||
|
||||
def test_no_file_and_no_adb_is_not_verified_without_db_fallback(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""An empty drop dir with no phone cannot fall back to the root DB."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
inbox, processed = _webdav_tree(tmp_path)
|
||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
||||
object.__setattr__(locker, "_verify_runnerup_via_db", MagicMock())
|
||||
|
||||
with (
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
||||
(inbox, processed),
|
||||
),
|
||||
patch(
|
||||
"screen_locker._runnerup_verification.check_clock_skew",
|
||||
return_value=(True, ""),
|
||||
),
|
||||
):
|
||||
status, message = locker._verify_runnerup_workout()
|
||||
|
||||
assert status == "not_verified"
|
||||
assert "not adb-reachable" in message
|
||||
locker._verify_runnerup_via_db.assert_not_called()
|
||||
|
||||
def test_pull_and_parse_reads_local_path_in_place(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""A path that exists locally is parsed without any adb pull."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
tcx = tmp_path / "run.tcx"
|
||||
tcx.write_text(_TCX)
|
||||
object.__setattr__(locker, "_run_adb", MagicMock())
|
||||
|
||||
data = locker._pull_and_parse_tcx(str(tcx))
|
||||
|
||||
assert data is not None
|
||||
assert data["distance_m"] == 5800.0
|
||||
locker._run_adb.assert_not_called()
|
||||
@ -14,19 +14,22 @@ if TYPE_CHECKING:
|
||||
class TestCheckNonVerifyExitsExtras:
|
||||
"""Tests for _check_non_verify_exits coverage gaps (lines 228, 233, 251-254)."""
|
||||
|
||||
def test_logs_auto_filled_runnerup_entries(
|
||||
def test_auto_fill_credits_through_shared_callback(
|
||||
self,
|
||||
mock_tk: MagicMock,
|
||||
mock_sys_exit: MagicMock,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""_scan_and_fill_week_runnerup > 0 + bonus > 0 → bonus logger.info (line 188)."""
|
||||
"""The login-time scan hands every fill to ``_credit_ingested_workout``.
|
||||
|
||||
It used to compute a weekly-surplus bonus here (+1h per workout above
|
||||
the weekly minimum), which is 0 for most of the week and silently
|
||||
left a synced run uncredited (2026-09-16). No bonus is computed on
|
||||
this path any more; the callback owns the reward.
|
||||
"""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_scan_and_fill_week_runnerup",
|
||||
MagicMock(return_value=2),
|
||||
)
|
||||
scan = MagicMock(return_value=2)
|
||||
object.__setattr__(locker, "_scan_and_fill_week_runnerup", scan)
|
||||
# Short-circuit _check_today_state_exits so the test is time-independent.
|
||||
object.__setattr__(
|
||||
locker,
|
||||
@ -40,9 +43,6 @@ class TestCheckNonVerifyExitsExtras:
|
||||
)
|
||||
with (
|
||||
patch("screen_locker._startup_checks.reset_to_base_if_new_day"),
|
||||
patch(
|
||||
"screen_locker._sync_mixin.count_weekly_workouts", side_effect=[0, 6]
|
||||
),
|
||||
patch(
|
||||
"screen_locker._startup_checks.process_week_transition",
|
||||
return_value=[],
|
||||
@ -54,43 +54,10 @@ class TestCheckNonVerifyExitsExtras:
|
||||
patch("screen_locker.screen_lock.sys.exit"),
|
||||
):
|
||||
locker._check_non_verify_exits()
|
||||
locker._adjust_shutdown_time_by.assert_called_once_with(1) # bonus = 6-max(5,0)
|
||||
|
||||
def test_auto_fill_no_bonus_when_min_not_exceeded(
|
||||
self,
|
||||
mock_tk: MagicMock,
|
||||
mock_sys_exit: MagicMock,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""n_filled > 0 but new_count <= min → bonus=0 → branch 187->190 (no bonus log)."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_scan_and_fill_week_runnerup",
|
||||
MagicMock(return_value=1),
|
||||
scan.assert_called_once_with(
|
||||
locker.log_file, on_ingested=locker._credit_ingested_workout
|
||||
)
|
||||
object.__setattr__(
|
||||
locker,
|
||||
"_check_today_state_exits",
|
||||
MagicMock(return_value=False),
|
||||
)
|
||||
with (
|
||||
patch("screen_locker._startup_checks.reset_to_base_if_new_day"),
|
||||
# prev=2, new=3 → bonus=max(0,3-max(5,2))=0 → no bonus logger call
|
||||
patch(
|
||||
"screen_locker._sync_mixin.count_weekly_workouts", side_effect=[2, 3]
|
||||
),
|
||||
patch(
|
||||
"screen_locker._startup_checks.process_week_transition",
|
||||
return_value=[],
|
||||
),
|
||||
patch("screen_locker._startup_checks.is_relaxed_day", return_value=False),
|
||||
patch(
|
||||
"screen_locker._startup_checks.has_weekly_minimum", return_value=False
|
||||
),
|
||||
patch("screen_locker.screen_lock.sys.exit"),
|
||||
):
|
||||
locker._check_non_verify_exits()
|
||||
locker._adjust_shutdown_time_by.assert_not_called()
|
||||
|
||||
def test_logs_weekly_reward_message(
|
||||
self,
|
||||
|
||||
@ -56,7 +56,7 @@ class TestIngestSyncedManualWorkouts:
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""The callback wired into ingest_manual_records must be
|
||||
``locker._credit_ingested_manual_workout``, so a synced manual
|
||||
``locker._credit_ingested_workout``, so a synced manual
|
||||
workout earns the same reward a live one would; workout_data is reset
|
||||
afterward so it can't leak into a later interactive flow."""
|
||||
locker = create_locker(mock_tk, tmp_path)
|
||||
@ -73,14 +73,14 @@ class TestIngestSyncedManualWorkouts:
|
||||
):
|
||||
locker._ingest_synced_manual_workouts()
|
||||
assert ingest.call_args.kwargs["on_ingested"] == (
|
||||
locker._credit_ingested_manual_workout
|
||||
locker._credit_ingested_workout
|
||||
)
|
||||
assert locker.workout_data == {}
|
||||
|
||||
def test_credit_ingested_manual_workout_applies_reward(
|
||||
def test_credit_ingested_workout_applies_reward(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""_credit_ingested_manual_workout sets workout_data to the ingested
|
||||
"""_credit_ingested_workout sets workout_data to the ingested
|
||||
entry and applies the shared credit logic — proving a synced manual
|
||||
workout (today's or back-dated) earns full shutdown/debt credit,
|
||||
exactly like a live-logged one."""
|
||||
@ -92,11 +92,11 @@ class TestIngestSyncedManualWorkouts:
|
||||
"_apply_credit_for_written_entry",
|
||||
return_value=MagicMock(shutdown_adjusted=True, extra_bonus_delta=0),
|
||||
) as apply_credit:
|
||||
locker._credit_ingested_manual_workout(entry, prior)
|
||||
locker._credit_ingested_workout(entry, prior)
|
||||
assert locker.workout_data == entry
|
||||
apply_credit.assert_called_once_with(prior)
|
||||
|
||||
def test_credit_ingested_manual_workout_logs_extra_bonus(
|
||||
def test_credit_ingested_workout_logs_extra_bonus(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""A second same-day synced manual workout (extra_bonus_delta, not the
|
||||
@ -110,11 +110,11 @@ class TestIngestSyncedManualWorkouts:
|
||||
"_apply_credit_for_written_entry",
|
||||
return_value=MagicMock(shutdown_adjusted=False, extra_bonus_delta=1),
|
||||
) as apply_credit:
|
||||
locker._credit_ingested_manual_workout(entry, prior)
|
||||
locker._credit_ingested_workout(entry, prior)
|
||||
assert locker.workout_data == entry
|
||||
apply_credit.assert_called_once_with(prior)
|
||||
|
||||
def test_credit_ingested_manual_workout_no_reward_logs_nothing(
|
||||
def test_credit_ingested_workout_no_reward_logs_nothing(
|
||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||
) -> None:
|
||||
"""A duplicate/no-op credit result (neither shutdown_adjusted nor
|
||||
@ -128,7 +128,7 @@ class TestIngestSyncedManualWorkouts:
|
||||
"_apply_credit_for_written_entry",
|
||||
return_value=MagicMock(shutdown_adjusted=False, extra_bonus_delta=0),
|
||||
) as apply_credit:
|
||||
locker._credit_ingested_manual_workout(entry, prior)
|
||||
locker._credit_ingested_workout(entry, prior)
|
||||
assert locker.workout_data == entry
|
||||
apply_credit.assert_called_once_with(prior)
|
||||
|
||||
@ -191,8 +191,5 @@ class TestIngestSyncedSessions:
|
||||
) as ingest,
|
||||
):
|
||||
locker._ingest_synced_sessions()
|
||||
assert (
|
||||
ingest.call_args.kwargs["on_ingested"]
|
||||
== locker._credit_ingested_manual_workout
|
||||
)
|
||||
assert ingest.call_args.kwargs["on_ingested"] == locker._credit_ingested_workout
|
||||
assert locker.workout_data == {}
|
||||
|
||||
@ -19,64 +19,54 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class TestRunStatusFill:
|
||||
"""Tests for RunnerUp scan paths in run_status."""
|
||||
"""The RunnerUp scan block of run_status()."""
|
||||
|
||||
def test_fill_with_bonus_applied(
|
||||
def test_fill_is_credited_by_the_shared_callback(
|
||||
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
||||
) -> None:
|
||||
"""n_filled > 0, bonus > 0, adjust succeeds → bonus line shown.
|
||||
"""A fill is handed to ``_credit_ingested_workout``; no bonus math here.
|
||||
|
||||
count_weekly_workouts is called twice: before the fill (3) and after
|
||||
(6) — a flat return_value would collapse both calls to the same
|
||||
number and mask the bonus math, so this uses side_effect instead.
|
||||
The weekly-surplus rule this block used to apply (+1h per workout
|
||||
above the weekly minimum) is 0 for most of the week and left a
|
||||
synced run uncredited on 2026-09-16. The reward now lives in the
|
||||
callback; the CLI just reports the resulting shutdown hour.
|
||||
"""
|
||||
eb_file = tmp_path / "eb.json"
|
||||
locker = _make_locker(tmp_path / "log.json", n_filled=2, bonus_applied=True)
|
||||
locker = _make_locker(tmp_path / "log.json", n_filled=2, cfg=(22, 22, 5))
|
||||
with (
|
||||
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
||||
patch("screen_locker._status.current_streak", return_value=0),
|
||||
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[3, 6]),
|
||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[3, 5]),
|
||||
patch("sys.exit"),
|
||||
):
|
||||
run_status(locker)
|
||||
out = capsys.readouterr().out
|
||||
assert "Auto-filled 2 workout(s)" in out
|
||||
assert "+1h shutdown bonus applied." in out
|
||||
assert "Shutdown tonight: 22:00." in out
|
||||
locker._scan_and_fill_week_runnerup.assert_called_once_with(
|
||||
locker.log_file, on_ingested=locker._credit_ingested_workout
|
||||
)
|
||||
locker._adjust_shutdown_time_by.assert_not_called()
|
||||
assert locker.workout_data == {}
|
||||
|
||||
def test_fill_bonus_pending_when_adjust_fails(
|
||||
def test_fill_with_unreadable_config_omits_hour_line(
|
||||
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
||||
) -> None:
|
||||
"""n_filled > 0, bonus > 0, adjust returns False → 'bonus pending' shown."""
|
||||
"""No readable config → the fill is reported without a shutdown hour."""
|
||||
eb_file = tmp_path / "eb.json"
|
||||
locker = _make_locker(tmp_path / "log.json", n_filled=2, bonus_applied=False)
|
||||
locker = _make_locker(tmp_path / "log.json", n_filled=1, cfg=None)
|
||||
with (
|
||||
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
||||
patch("screen_locker._status.current_streak", return_value=0),
|
||||
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[0, 6]),
|
||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[0, 1]),
|
||||
patch("sys.exit"),
|
||||
):
|
||||
run_status(locker)
|
||||
out = capsys.readouterr().out
|
||||
assert "bonus pending" in out
|
||||
|
||||
def test_fill_no_bonus_when_still_below_min(
|
||||
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
||||
) -> None:
|
||||
"""n_filled=1 but count still < 5, before and after the fill → no bonus."""
|
||||
eb_file = tmp_path / "eb.json"
|
||||
locker = _make_locker(tmp_path / "log.json", n_filled=1, bonus_applied=False)
|
||||
with (
|
||||
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
||||
patch("screen_locker._status.current_streak", return_value=0),
|
||||
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[2, 3]),
|
||||
patch("sys.exit"),
|
||||
):
|
||||
run_status(locker)
|
||||
out = capsys.readouterr().out
|
||||
assert "shutdown bonus" not in out
|
||||
assert "Auto-filled 1 workout(s)" in out
|
||||
assert "Shutdown tonight" not in out
|
||||
|
||||
|
||||
class TestRunStatusMinimumStatus:
|
||||
|
||||
@ -25,23 +25,32 @@ class TestBackfillWeekAndApplyBonus:
|
||||
assert _backfill_week_and_apply_bonus(verifier) is None
|
||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||
|
||||
def test_fill_at_or_below_minimum_earns_no_bonus(self) -> None:
|
||||
"""Filling up to (not past) the weekly minimum earns no shutdown push."""
|
||||
def test_runnerup_fill_is_credited_through_the_shared_callback(self) -> None:
|
||||
"""A RunnerUp fill earns its day-scaled reward via ``on_ingested``.
|
||||
|
||||
The weekly-surplus rule used to apply here too, which is 0 for most
|
||||
of the week: on 2026-09-16 a run synced at 20:25 left the shutdown
|
||||
hour at 20:00. The scan now receives the same credit callback as
|
||||
every other ingestion source, and this path adds no bonus of its own.
|
||||
"""
|
||||
verifier = MagicMock()
|
||||
verifier._scan_and_fill_week_runnerup.return_value = 1
|
||||
verifier._try_fill_stronglifts_for_week.return_value = 0
|
||||
|
||||
with patch(
|
||||
"screen_locker._status_view_verify.count_weekly_workouts",
|
||||
side_effect=[3, 4],
|
||||
return_value=3,
|
||||
):
|
||||
message = _backfill_week_and_apply_bonus(verifier)
|
||||
|
||||
assert message == "Auto-filled 1 workout from earlier this week."
|
||||
verifier._scan_and_fill_week_runnerup.assert_called_once_with(
|
||||
verifier.log_file, on_ingested=verifier._credit_ingested_workout
|
||||
)
|
||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||
|
||||
def test_fill_past_minimum_applies_bonus(self) -> None:
|
||||
"""Fill past minimum applies bonus."""
|
||||
def test_stronglifts_fill_past_minimum_applies_surplus_bonus(self) -> None:
|
||||
"""The StrongLifts fill keeps the weekly-surplus rule, net of RunnerUp fills."""
|
||||
verifier = MagicMock()
|
||||
verifier._scan_and_fill_week_runnerup.return_value = 1
|
||||
verifier._try_fill_stronglifts_for_week.return_value = 1
|
||||
@ -52,7 +61,23 @@ class TestBackfillWeekAndApplyBonus:
|
||||
):
|
||||
message = _backfill_week_and_apply_bonus(verifier)
|
||||
|
||||
# prev 4 + 1 RunnerUp fill already credited = 5; 7 - 5 = 2 surplus.
|
||||
assert message == (
|
||||
"Auto-filled 2 workouts from earlier this week. +2h shutdown time."
|
||||
)
|
||||
verifier._adjust_shutdown_time_by.assert_called_once_with(2)
|
||||
|
||||
def test_stronglifts_fill_below_minimum_earns_no_surplus(self) -> None:
|
||||
"""A StrongLifts fill that leaves the week under the minimum adds nothing."""
|
||||
verifier = MagicMock()
|
||||
verifier._scan_and_fill_week_runnerup.return_value = 0
|
||||
verifier._try_fill_stronglifts_for_week.return_value = 1
|
||||
|
||||
with patch(
|
||||
"screen_locker._status_view_verify.count_weekly_workouts",
|
||||
side_effect=[2, 3],
|
||||
):
|
||||
message = _backfill_week_and_apply_bonus(verifier)
|
||||
|
||||
assert message == "Auto-filled 1 workout from earlier this week."
|
||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||
|
||||
@ -63,7 +63,7 @@ class TestVerifyPhoneThenRunnerup:
|
||||
|
||||
with patch(
|
||||
"screen_locker._status_view_verify.count_weekly_workouts",
|
||||
side_effect=[2, 3],
|
||||
return_value=2,
|
||||
):
|
||||
result = _verify_phone_then_runnerup(verifier)
|
||||
|
||||
@ -71,4 +71,5 @@ class TestVerifyPhoneThenRunnerup:
|
||||
assert (
|
||||
result.week_fill_message == "Auto-filled 1 workout from earlier this week."
|
||||
)
|
||||
# The RunnerUp fill is credited by the shared callback, not here.
|
||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||
|
||||
@ -291,10 +291,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_secure_storage
|
||||
sha256: d87713a152ee2f255117bdbbf43da1dea1797e0551e499e0334f0c9dcfafddd2
|
||||
sha256: d4e1fb6b2cb524868929e78dc0282fa000554b22060fb53789dc481c9fc95bb8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.1.1"
|
||||
version: "11.2.0"
|
||||
flutter_secure_storage_darwin:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -24,7 +24,7 @@ dependencies:
|
||||
# The break-end alert itself, on its own high-importance channel so the OS
|
||||
# rings even if the Flutter isolate is busy.
|
||||
flutter_local_notifications: 22.3.1
|
||||
flutter_secure_storage: 11.1.1
|
||||
flutter_secure_storage: 11.2.0
|
||||
|
||||
# One-tap sign-in for the sync account. App-side only: crdt_sync stays pure
|
||||
# Dart so it keeps working on Linux desktop and headless.
|
||||
|
||||
74
web/package-lock.json
generated
74
web/package-lock.json
generated
@ -21,7 +21,7 @@
|
||||
"@types/react": "19.3.0",
|
||||
"@types/react-dom": "19.3.0",
|
||||
"@vitejs/plugin-react": "6.1.1",
|
||||
"@vitest/coverage-v8": "5.0.0",
|
||||
"@vitest/coverage-v8": "5.0.1",
|
||||
"eslint": "10.10.0",
|
||||
"eslint-plugin-react-hooks": "7.1.1",
|
||||
"eslint-plugin-react-refresh": "0.5.7",
|
||||
@ -30,7 +30,7 @@
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.70.0",
|
||||
"vite": "8.3.0",
|
||||
"vitest": "5.0.0"
|
||||
"vitest": "5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@adobe/css-tools": {
|
||||
@ -124,6 +124,7 @@
|
||||
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.29.7",
|
||||
"@babel/generator": "^7.29.7",
|
||||
@ -478,6 +479,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
@ -526,6 +528,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
}
|
||||
@ -1094,6 +1097,7 @@
|
||||
"integrity": "sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.10.4",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
@ -1238,6 +1242,7 @@
|
||||
"integrity": "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~8.9.0"
|
||||
}
|
||||
@ -1248,6 +1253,7 @@
|
||||
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"csstype": "^3.2.2"
|
||||
}
|
||||
@ -1258,6 +1264,7 @@
|
||||
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
"@types/react": "^19.3.0"
|
||||
}
|
||||
@ -1307,6 +1314,7 @@
|
||||
"integrity": "sha512-zYvrmj9Yxd63UGaXw+kdt6A0F0s0qveJyuatIM77bYC2DE4pgmg7a50u8LR7PRtXd0x+h+Tl3eXabGm06SWd3Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.70.0",
|
||||
"@typescript-eslint/types": "8.70.0",
|
||||
@ -1536,11 +1544,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/coverage-v8": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.0.tgz",
|
||||
"integrity": "sha512-toMg6PZGCIa/lQNCDoASrfb1ly4hsUKXFtFYC9kD4t78o5Y6LyNJU7AENt8eHPr3quYdxaxK7hj2mnbFfUk9NA==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.1.tgz",
|
||||
"integrity": "sha512-FRC8ACiudC3dI6MTplzRSYWHDRnIv2IPfbzs4FdoJNsMal/35sWV8hwIfV8ZcqzSPy+uXHeMVONt9CEqtOU17w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@bcoe/v8-coverage": "^1.0.2",
|
||||
"@vitest/istanbul-lib-coverage": "^1.0.0",
|
||||
@ -1555,8 +1564,8 @@
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vitest/browser": "5.0.0",
|
||||
"vitest": "5.0.0"
|
||||
"@vitest/browser": "5.0.1",
|
||||
"vitest": "5.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vitest/browser": {
|
||||
@ -1588,14 +1597,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/mocker": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.0.tgz",
|
||||
"integrity": "sha512-66PGTMIiVJP3t4a5yxU9qPtf7MdTBs8jmToMvy+HVflB3Yy13WJZTtPePdvU+wjRV02SKK5doLbSA6o9pwOmiA==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.1.tgz",
|
||||
"integrity": "sha512-6K1DoBNAPGvuOcSsGA4D6x+5zEEff/KmOOP3uetT2TrGpVfI+HRHRnJJfKi5ib/g1vx8IYHQD8s0pbJz8WQI7Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "0.3.31",
|
||||
"@vitest/spy": "5.0.0",
|
||||
"@vitest/spy": "5.0.1",
|
||||
"estree-walker": "^3.0.3",
|
||||
"magic-string": "^1.2.3"
|
||||
},
|
||||
@ -1616,9 +1625,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/spy": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.0.tgz",
|
||||
"integrity": "sha512-uy+luWBAPw9XfthoHi5AkfHUnuPYEESjl0p/r+meoBnU8bxg5GDQ3Ey8MjcJ6sqahkL4PFyrvfMJJBw7LbU06g==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.1.tgz",
|
||||
"integrity": "sha512-rbto/mF/SGERxEgYOek7Xm6B9b+y+mVoo+f4b2LymYO8zM1b7uB5nHuhVMTP2hxdzgxvGiZYGxGIaMvL5y180Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
@ -1631,6 +1640,7 @@
|
||||
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@ -1793,6 +1803,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.11.12",
|
||||
"caniuse-lite": "^1.0.30001809",
|
||||
@ -2046,6 +2057,7 @@
|
||||
"integrity": "sha512-NPXn6r5zl4uET1DAVPaOwzX3rut4c0wcmw3dWJAfOsTM5+TogXo0DDjz8pwm/hL8cyVNpHqeK4JpN0NjnyFFNw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
@ -2602,6 +2614,7 @@
|
||||
"integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@keyv/serialize": "^1.1.1"
|
||||
}
|
||||
@ -2918,13 +2931,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.2.3.tgz",
|
||||
"integrity": "sha512-Bpb0W2TbLKOZ7vJnOUnVRGq3WL2p+ISV29M6hYPL1AFCpyKZpdr5ytiXoTSSxRVhg8YW7f65+6gbG8WG6PCa/g==",
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.1.tgz",
|
||||
"integrity": "sha512-8lyCu36ErXR0J9uaGKlKQoiLZKmtI63YGLE8G2o9jyRPdr4X47LusSOwgOJOzcVtp81fTAAjxR7BwKz682Jhow==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
"@jridgewell/sourcemap-codec": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/magicast": {
|
||||
@ -3125,6 +3138,7 @@
|
||||
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@ -3221,6 +3235,7 @@
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",
|
||||
"integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
@ -3230,6 +3245,7 @@
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz",
|
||||
"integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"scheduler": "^0.28.0"
|
||||
},
|
||||
@ -3530,6 +3546,7 @@
|
||||
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@ -3626,6 +3643,7 @@
|
||||
"integrity": "sha512-lhZBVvEHefgE+HQZC9O7EBJgCU/nVzFNl7vkS4RE0APtWLP02/8QVIkQtzBxPquh7lq5/78NHipTj7ODQ6XuyQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"lightningcss": "^1.33.0",
|
||||
"picomatch": "^4.0.7",
|
||||
@ -3699,14 +3717,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vitest": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.0.tgz",
|
||||
"integrity": "sha512-gpsMNoRhMjMktVxPtstOH4/PJuPyovVaMDr4oDilXaGH1EcqM2OE96SoHT2VIQ6fTGtTjqmHDrEu2X9RQiXf8Q==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.1.tgz",
|
||||
"integrity": "sha512-iA95lQbKEkvrtTkdAgnWbXfbipWiiWe/hDl2P5tMi6WFwD76G0NxXAGp/M9EOcYupeGJRr6wppMc7CoA41TQjg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/chai": "^5.2.2",
|
||||
"@vitest/mocker": "5.0.0",
|
||||
"@vitest/mocker": "5.0.1",
|
||||
"chai": "^6.2.2",
|
||||
"es-module-lexer": "^2.3.2",
|
||||
"expect-type": "^1.4.0",
|
||||
@ -3732,12 +3751,12 @@
|
||||
"@edge-runtime/vm": "*",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@types/node": "^22.0.0 || >=24.0.0",
|
||||
"@vitest/browser-playwright": "5.0.0",
|
||||
"@vitest/browser-preview": "5.0.0",
|
||||
"@vitest/browser-playwright": "5.0.1",
|
||||
"@vitest/browser-preview": "5.0.1",
|
||||
"@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0",
|
||||
"@vitest/coverage-istanbul": "5.0.0",
|
||||
"@vitest/coverage-v8": "5.0.0",
|
||||
"@vitest/ui": "5.0.0",
|
||||
"@vitest/coverage-istanbul": "5.0.1",
|
||||
"@vitest/coverage-v8": "5.0.1",
|
||||
"@vitest/ui": "5.0.1",
|
||||
"happy-dom": "*",
|
||||
"jsdom": "*",
|
||||
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
|
||||
@ -3915,6 +3934,7 @@
|
||||
"integrity": "sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
"@types/react": "19.3.0",
|
||||
"@types/react-dom": "19.3.0",
|
||||
"@vitejs/plugin-react": "6.1.1",
|
||||
"@vitest/coverage-v8": "5.0.0",
|
||||
"@vitest/coverage-v8": "5.0.1",
|
||||
"eslint": "10.10.0",
|
||||
"eslint-plugin-react-hooks": "7.1.1",
|
||||
"eslint-plugin-react-refresh": "0.5.7",
|
||||
@ -36,6 +36,6 @@
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.70.0",
|
||||
"vite": "8.3.0",
|
||||
"vitest": "5.0.0"
|
||||
"vitest": "5.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user