mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Custom platforms could only be distinguished by name, which is often not enough context (e.g. a "Sega - Genesis/Mega Drive (Unofficial)" folder holding aftermarket and unlicensed dumps). Platforms now carry an optional free-text description, mirroring collections. The column is nullable and defaults to "", matching custom_name, so a rescan (which merges a freshly scanned Platform over the existing row) leaves it untouched. update_platform patches only the fields sent, so an omitted description is preserved and an empty string clears it. Surfaced in the v2 UI only: the Settings tab name form now covers both custom_name and description, and PlatformHead renders the description as a chip alongside the metadata chips. v1 is frozen and gets no new UI, but round-trips the field unchanged through the shared API service. Closes #3402 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from handler.database import db_platform_handler
|
|
from models.platform import Platform
|
|
|
|
|
|
def test_rescan_preserves_user_authored_fields(platform):
|
|
"""A rescan merges a freshly built Platform over the existing row.
|
|
|
|
The scan pipeline never populates `custom_name` or `description`, so both
|
|
must survive the merge rather than being reset to their column defaults.
|
|
"""
|
|
db_platform_handler.update_platform(
|
|
platform.id,
|
|
{
|
|
"custom_name": "Sega - Genesis/ Mega Drive (Unofficial)",
|
|
"description": "Aftermarket only",
|
|
},
|
|
)
|
|
|
|
# Mirrors endpoints/sockets/scan.py: build a platform from scan metadata,
|
|
# graft the existing id onto it, then merge.
|
|
scanned = Platform(
|
|
name=platform.name,
|
|
slug=platform.slug,
|
|
fs_slug=platform.fs_slug,
|
|
)
|
|
scanned.id = platform.id
|
|
|
|
merged = db_platform_handler.add_platform(scanned)
|
|
|
|
assert merged.custom_name == "Sega - Genesis/ Mega Drive (Unofficial)"
|
|
assert merged.description == "Aftermarket only"
|