Phase 3 : hardening qualite de code - typage strict, securite, dead code, a11y
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>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7db4803b93
commit
c57420c8c9
@@ -4,25 +4,37 @@
|
||||
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, tmp_game_slug_cleanup, name="pytest_overlay"):
|
||||
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, slug, screen_id):
|
||||
resp = client.post(f"/game/{slug}/screens/{screen_id}/scene-objects/add", data={"kind": "decor"}, follow_redirects=False)
|
||||
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(re.search(r"selected=(\d+)", resp.headers["Location"]).group(1))
|
||||
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, tmp_game_slug_cleanup):
|
||||
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)
|
||||
|
||||
@@ -32,7 +44,9 @@ def test_selected_object_renders_the_collision_overlay_with_drag_handlers(client
|
||||
assert f"onCollisionBoxResizeMouseDown(event, {obj_id})" in html
|
||||
|
||||
|
||||
def test_only_the_selected_object_gets_an_overlay(client, tmp_game_slug_cleanup):
|
||||
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
|
||||
@@ -41,7 +55,9 @@ def test_only_the_selected_object_gets_an_overlay(client, tmp_game_slug_cleanup)
|
||||
assert html.count('id="collisionBoxOverlay"') == 1
|
||||
|
||||
|
||||
def test_overlay_reflects_a_custom_collision_box_size_and_offset(client, tmp_game_slug_cleanup):
|
||||
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(
|
||||
@@ -54,9 +70,11 @@ def test_overlay_reflects_a_custom_collision_box_size_and_offset(client, tmp_gam
|
||||
assert "width:40.0px; height:40.0px" in html
|
||||
|
||||
|
||||
def test_disabled_collision_marks_the_overlay(client, tmp_game_slug_cleanup):
|
||||
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")
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user