Files
romm/backend/tests/utils/test_platforms.py
Georges-Antoine Assi e61d6cd5b8 fix(platforms): stop platform variants from renaming the parent platform
get_supported_platforms built a slug->platform map with a plain dict
comprehension. When a folder is mapped as a variant or alias of an
existing platform, scanning resolves it to the parent slug, so two
platform rows share the same slug. The comprehension let the later row
(the variant) overwrite the parent, renaming it in the platform picker
and Folder Mappings page.

Prefer the canonical platform (fs_slug == slug) when building the map so
a variant folder no longer shadows its parent.

Fixes #3157

Generated-By: PostHog Code
Task-Id: 571866ea-86a0-49c2-b62e-dbea077d0181
2026-07-06 10:17:34 -04:00

26 lines
954 B
Python

from handler.database import db_platform_handler
from models.platform import Platform
from utils.platforms import get_supported_platforms
def test_supported_platform_not_shadowed_by_variant():
"""A variant/alias folder bound to a parent slug must not shadow the parent.
Regression for the bug where adding an "fbneo" folder as a variant of
"arcade" renamed the Arcade platform to "FBneo" in the platform picker.
"""
# Canonical Arcade platform (folder name matches the slug).
db_platform_handler.add_platform(
Platform(name="Arcade", slug="arcade", fs_slug="arcade")
)
# Variant folder resolved to the same slug during scan.
db_platform_handler.add_platform(
Platform(name="FBneo", slug="arcade", fs_slug="fbneo")
)
supported = get_supported_platforms()
arcade = next(p for p in supported if p.slug == "arcade")
assert arcade.name == "Arcade"
assert arcade.fs_slug == "arcade"