49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
"""1.3.0 : page d'aide, plein écran, navigation, version."""
|
|
|
|
import re
|
|
|
|
from shortstats import __version__
|
|
from shortstats.web import charts
|
|
|
|
from .test_web import ORIGIN, app_client, login, users_file # noqa: F401
|
|
|
|
|
|
def test_help_page(app_client):
|
|
r = app_client.get("/help", follow_redirects=False)
|
|
assert r.status_code == 303 and r.headers["location"] == "/login"
|
|
login(app_client)
|
|
page = app_client.get("/help").text
|
|
assert 'aria-current="page">Aide</a>' in page and 'id="help-q"' in page and "help.js" in page
|
|
# sections attendues et ancres utilisées ailleurs (page Thèmes -> /help#themes)
|
|
for anchor in ("demarrer", "diagrammes", "axes-inverses", "analyse-thematique", "plein-ecran", "calendrier",
|
|
"themes", "regex-syntaxe", "faq"):
|
|
assert f'id="{anchor}"' in page, anchor
|
|
# calendrier tiré du code : 151 étapes, une ligne par rythme
|
|
assert "à 151 étapes" in page
|
|
rows = re.findall(r"<tr><td>(Toutes les|Tous les)[^<]*</td><td class=\"num\">(\d+)</td>", page)
|
|
assert [int(n) for _, n in rows] == [24, 16, 16, 23, 48, 24] and sum(int(n) for _, n in rows) == len(charts.STEPS)
|
|
assert "1 h à 24 h" in page and "13 mois à 36 mois" in page
|
|
assert chr(0x2014) not in page # pas de tiret cadratin
|
|
|
|
|
|
def test_fullscreen_buttons_and_nav(app_client):
|
|
login(app_client)
|
|
dash = app_client.get("/").text
|
|
assert 'data-action="full"' in dash and "Plein écran" in dash
|
|
assert '<a href="/help"' in dash
|
|
assert "requestFullscreen" in app_client.get("/static/chartrender.js").text
|
|
assert "toggleFull" in app_client.get("/static/app.js").text
|
|
|
|
|
|
def test_shared_page_has_fullscreen(app_client):
|
|
login(app_client)
|
|
cid = app_client.post("/api/charts", json={"config": {"x": "publish_date", "y": "views"}},
|
|
headers={"Origin": ORIGIN}).json()["id"]
|
|
url = app_client.post(f"/api/charts/{cid}/share", headers={"Origin": ORIGIN}).json()["url"]
|
|
page = app_client.get(url[url.index("/shared/"):], headers={"Accept": "text/html"}).text
|
|
assert 'data-action="full"' in page
|
|
assert "toggleFull" in app_client.get("/static/shared.js").text
|
|
|
|
|
|
def test_version():
|
|
assert __version__ == "1.3.1"
|