"""Characterization test for the slides (TV slideshow) plugin feed.

The slide manager rework moved the public playlist to /api/slides/feed with a
flat (non-enveloped) response shape so the screensaver's existing parser needs
no change. Pin that contract here.
"""


def test_slides_feed_shape(client, db):
    """GET /api/slides/feed returns a flat playlist for a surface (no auth)."""
    resp = client.get('/api/slides/feed?surface=lobby')
    assert resp.status_code == 200
    data = resp.get_json()
    assert data['success'] is True
    assert data['surface'] == 'lobby'
    assert isinstance(data['slides'], list)
    assert data['basepath'] == '/api/slides/img/lobby/'
    assert 'interval' in data


def test_slides_feed_unknown_surface_falls_back(client, db):
    """An invalid surface name falls back to lobby instead of erroring."""
    resp = client.get('/api/slides/feed?surface=../etc')
    assert resp.status_code == 200
    assert resp.get_json()['surface'] == 'lobby'
