mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
feat(web): launch commander browser with deck builder CTA
This commit is contained in:
parent
6e9ba244c9
commit
8e57588f40
27 changed files with 1960 additions and 45 deletions
61
code/tests/test_home_actions_buttons.py
Normal file
61
code/tests/test_home_actions_buttons.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import os
|
||||
import importlib
|
||||
import types
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
|
||||
def load_app_with_env(**env: str) -> types.ModuleType:
|
||||
for key in (
|
||||
"SHOW_LOGS",
|
||||
"SHOW_DIAGNOSTICS",
|
||||
"SHOW_SETUP",
|
||||
"SHOW_COMMANDERS",
|
||||
"ENABLE_THEMES",
|
||||
"ENABLE_PWA",
|
||||
"ENABLE_PRESETS",
|
||||
"APP_VERSION",
|
||||
"THEME",
|
||||
"RANDOM_UI",
|
||||
):
|
||||
os.environ.pop(key, None)
|
||||
for k, v in env.items():
|
||||
os.environ[k] = v
|
||||
import code.web.app as app_module # type: ignore
|
||||
importlib.reload(app_module)
|
||||
return app_module
|
||||
|
||||
|
||||
def test_home_actions_show_all_enabled_buttons():
|
||||
app_module = load_app_with_env(
|
||||
SHOW_LOGS="1",
|
||||
SHOW_DIAGNOSTICS="1",
|
||||
SHOW_SETUP="1",
|
||||
SHOW_COMMANDERS="1",
|
||||
RANDOM_UI="1",
|
||||
)
|
||||
client = TestClient(app_module.app)
|
||||
response = client.get("/")
|
||||
body = response.text
|
||||
assert 'href="/setup"' in body
|
||||
assert 'href="/commanders"' in body
|
||||
assert 'href="/random"' in body
|
||||
assert 'href="/diagnostics"' in body
|
||||
assert 'href="/logs"' in body
|
||||
|
||||
|
||||
def test_home_actions_hides_disabled_sections():
|
||||
app_module = load_app_with_env(
|
||||
SHOW_LOGS="0",
|
||||
SHOW_DIAGNOSTICS="0",
|
||||
SHOW_SETUP="0",
|
||||
SHOW_COMMANDERS="0",
|
||||
RANDOM_UI="0",
|
||||
)
|
||||
client = TestClient(app_module.app)
|
||||
response = client.get("/")
|
||||
body = response.text
|
||||
assert 'href="/setup"' not in body
|
||||
assert 'href="/commanders"' not in body
|
||||
assert 'href="/random"' not in body
|
||||
assert 'href="/diagnostics"' not in body
|
||||
assert 'href="/logs"' not in body
|
||||
Loading…
Add table
Add a link
Reference in a new issue