soulsync/tests/test_youtube_channel_settings_ui.py
BoulderBadgeDad 23c64e000a youtube playlists: same settings cog/modal as channels
playlist cards on the watchlist tab now get the same hover cog → the per-channel
settings modal (custom show-name + quality override). the modal is kind-aware so
it reads 'Playlist settings' + 'the playlist's real name'.

no backend change needed: playlist videos are wishlisted with channel_id =
playlist_id, so the existing get/set_channel_settings + enqueue override lookup
already key off the playlist id. UI-only: cog on playlistCard + data-kind passed
to openChannelSettings(id, title, kind). test covers both cogs.
2026-06-25 23:07:15 -07:00

41 lines
1.8 KiB
Python

"""Per-channel settings modal — UI wiring (string-contract level, like the other video-JS
tests). The functional core (storage/API/download wiring) is in test_youtube_channel_settings.
"""
from __future__ import annotations
from pathlib import Path
_ROOT = Path(__file__).resolve().parent.parent
_YT = (_ROOT / "webui" / "static" / "video" / "video-youtube.js").read_text(encoding="utf-8")
_WL = (_ROOT / "webui" / "static" / "video" / "video-watchlist.js").read_text(encoding="utf-8")
_CSS = (_ROOT / "webui" / "static" / "video" / "video-side.css").read_text(encoding="utf-8")
def test_channel_and_playlist_cards_both_have_a_settings_cog():
assert 'data-vyt-wsettings' in _WL # cog button on the watchlist cards
assert _WL.count('vyt-wcard-cog') >= 2 # channel + playlist cards
assert '.vyt-wcard-cog' in _CSS
assert 'data-kind="channel"' in _WL and 'data-kind="playlist"' in _WL
def test_cog_click_opens_the_settings_modal_with_kind():
assert 'VideoYoutube.openChannelSettings(' in _WL
assert "cog.getAttribute('data-vyt-wsettings')" in _WL
assert "cog.getAttribute('data-kind')" in _WL # kind passed through
# the modal reads the kind to label channel vs playlist
assert "kind === 'playlist' ? 'Playlist' : 'Channel'" in _YT
def test_modal_is_exposed_and_built():
assert 'openChannelSettings: openChannelSettings' in _YT
assert 'function openChannelSettings(' in _YT
assert '.vyt-cset-overlay' in _CSS # modal styles exist
def test_modal_loads_and_saves_via_the_settings_api():
assert "/channel/' + encodeURIComponent(channelId) + '/settings'" in _YT
assert "method: 'POST'" in _YT
# the form carries the custom name + the optional quality override
assert 'data-cset-name' in _YT and 'data-cset-qon' in _YT
assert 'custom_name' in _YT and 'max_resolution' in _YT