Config strictement stricte partout (ruff, mypy --strict, bandit, vulture, import-linter, eslint, stylelint), aucune regle desactivee "pour ne pas casser le build" - l'existant a ete corrige pour la satisfaire plutot que l'inverse. Hooks pre-commit locaux (language: system) bloquants. - Typage mypy --strict propage a tout le moteur (db, screens, auth, core, ai, routes, puis publish/scripts/tests/app.py/build_css.py). - Securite : fuite de handle fichier Windows corrigee dans l'export SCORM (routes/publish/export_scorm.py), CSRF/RNG non-crypto/xAPI documentes (# nosec, # NOSONAR justifies), nouveau db.json_for_script() (echappe "</script>" dans le JSON embarque en <script>, 25 sites). - Architecture : imports circulaires/F811 nettoyes, contrats import-linter respectes, code mort retire (vulture). - Accessibilite : 69 champs de formulaire sans label correctement associe corriges (for/id ou aria-label) sur 11 templates. - ESLint/Stylelint : lot mecanique JS/CSS, regles ajustees puis appliquees (aucune desactivee sans verification individuelle). - Tests : isolation du compte admin partage (nettoyage ponctuel + fixture de teardown automatique en filet de securite), suite complete verte (591 tests Python, 241 tests JS). - SonarQube Community Build self-heberge (Docker + PostgreSQL) : rapport complet analyse point par point, faux positifs documentes. - .gitattributes ajoute (LF force) : core.autocrlf=true sur cette machine faisait echouer ESLint (linebreak-style) via un bug connu de git (checkout "en place" qui ignore l'eol force sur un fichier deja present sur disque - contourne en supprimant puis recreant chaque fichier suivi). djLint (H021, styles inline) volontairement saute pour ce commit - backlog assume, deja documente, traite dans un lot separe. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
81 lines
3.5 KiB
Python
81 lines
3.5 KiB
Python
"""Aperçu visuel de la boîte de collision dans l'éditeur de scène (voir
|
|
"🧱 Collision", templates/scene_edit.html) — demandé par l'utilisateur :
|
|
"quand je suis dans l'éditeur je veux voir la boîte de collision et régler
|
|
sa taille". Rendu SEULEMENT pour l'objet sélectionné (voir
|
|
static/js/scenes/scene-editor.js::onCollisionBoxMouseDown/
|
|
onCollisionBoxResizeMouseDown pour le glisser-déplacer/redimensionner)."""
|
|
|
|
import re
|
|
from collections.abc import Callable
|
|
from typing import Any
|
|
|
|
from flask.testing import FlaskClient
|
|
|
|
import screens
|
|
from tests.conftest import not_none
|
|
|
|
|
|
def _create_jeu2d_game(
|
|
client: FlaskClient, tmp_game_slug_cleanup: Callable[[str], str], name: str = "pytest_overlay"
|
|
) -> Any:
|
|
resp = client.post("/games/new", data={"name": name}, follow_redirects=False)
|
|
slug = tmp_game_slug_cleanup(resp.headers["Location"].rstrip("/").split("/")[-1])
|
|
screen_id = screens.create_screen(slug, "Scène 1", kind="jeu_2d")
|
|
return slug, screen_id
|
|
|
|
|
|
def _add_decor(client: FlaskClient, slug: str, screen_id: int) -> Any:
|
|
resp = client.post(
|
|
f"/game/{slug}/screens/{screen_id}/scene-objects/add", data={"kind": "decor"}, follow_redirects=False
|
|
)
|
|
assert resp.status_code == 302, resp.data
|
|
return int(not_none(re.search(r"selected=(\d+)", resp.headers["Location"])).group(1))
|
|
|
|
|
|
def test_selected_object_renders_the_collision_overlay_with_drag_handlers(
|
|
client: FlaskClient, tmp_game_slug_cleanup: Callable[[str], str]
|
|
) -> None:
|
|
slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup)
|
|
obj_id = _add_decor(client, slug, screen_id)
|
|
|
|
html = client.get(f"/game/{slug}/screens/{screen_id}/edit?selected={obj_id}").get_data(as_text=True)
|
|
assert 'id="collisionBoxOverlay"' in html
|
|
assert f"onCollisionBoxMouseDown(event, {obj_id})" in html
|
|
assert f"onCollisionBoxResizeMouseDown(event, {obj_id})" in html
|
|
|
|
|
|
def test_only_the_selected_object_gets_an_overlay(
|
|
client: FlaskClient, tmp_game_slug_cleanup: Callable[[str], str]
|
|
) -> None:
|
|
slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup)
|
|
obj_id = _add_decor(client, slug, screen_id)
|
|
_add_decor(client, slug, screen_id) # un second objet, jamais sélectionné ici
|
|
|
|
html = client.get(f"/game/{slug}/screens/{screen_id}/edit?selected={obj_id}").get_data(as_text=True)
|
|
assert html.count('id="collisionBoxOverlay"') == 1
|
|
|
|
|
|
def test_overlay_reflects_a_custom_collision_box_size_and_offset(
|
|
client: FlaskClient, tmp_game_slug_cleanup: Callable[[str], str]
|
|
) -> None:
|
|
slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup)
|
|
obj_id = _add_decor(client, slug, screen_id)
|
|
client.post(
|
|
f"/game/{slug}/scene-objects/{obj_id}/collision",
|
|
data='{"enabled": true, "shape": "cercle", "width": 40, "height": 40, "offset_x": 10, "offset_y": -10}',
|
|
content_type="application/json",
|
|
)
|
|
html = client.get(f"/game/{slug}/screens/{screen_id}/edit?selected={obj_id}").get_data(as_text=True)
|
|
assert "is-circle" in html
|
|
assert "width:40.0px; height:40.0px" in html
|
|
|
|
|
|
def test_disabled_collision_marks_the_overlay(client: FlaskClient, tmp_game_slug_cleanup: Callable[[str], str]) -> None:
|
|
slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup)
|
|
obj_id = _add_decor(client, slug, screen_id)
|
|
client.post(
|
|
f"/game/{slug}/scene-objects/{obj_id}/collision", data='{"enabled": false}', content_type="application/json"
|
|
)
|
|
html = client.get(f"/game/{slug}/screens/{screen_id}/edit?selected={obj_id}").get_data(as_text=True)
|
|
assert "is-disabled" in html
|