import pytest
from bs4 import BeautifulSoup

from addon.plugins.serienstream_plugin import _extract_episodes


def test_extract_episodes_skips_upcoming():
    html = """
    <table class='episode-table'>
      <tbody>
        <tr class='episode-row' onclick="window.location='https://s.to/serie/x/staffel-1/episode-1'">
          <th class='episode-number-cell'>1</th>
          <td><strong class='episode-title-ger'>Ep1</strong></td>
          <td class='episode-watch-cell'><img alt='VOE'></td>
        </tr>
        <tr class='episode-row upcoming' onclick="window.location='https://s.to/serie/x/staffel-1/episode-2'">
          <th class='episode-number-cell'>2</th>
          <td>
            <strong class='episode-title-ger'></strong>
            <span class='badge badge-upcoming'>DEMNÄCHST</span>
          </td>
          <td class='episode-watch-cell'>— TBA —</td>
        </tr>
      </tbody>
    </table>
    """
    soup = BeautifulSoup(html, "html.parser")
    episodes = _extract_episodes(soup)
    assert [e.number for e in episodes] == [1]
