mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-01 00:27:20 -05:00
fix: one short hash length across the site
Merging the card and platform branches left two SHORT_HASH definitions, 8 and 12. The later one silently won, so the platform rows showed 12 characters while their tests expected 8. One constant now, 12, the card anchor's length. The copy-button selector skips buttons that carry their own data-copy, and the tests follow the merged markup.
This commit is contained in:
1 parent
3a5b95eb31
commit
06ca83bdca
4 files changed
+8
-7
No files matched your search
@@ -3426,8 +3426,6 @@ def _launcher_refs(platform: str, config: dict) -> dict[str, list[str]]:
|
||||
return found
|
||||
|
||||
|
||||
# The characters of a hash a row shows, as many as the served copy's sha1.
|
||||
SHORT_HASH = 8
|
||||
# The hash a row shows first, when the list does not say which it checks.
|
||||
_ROW_HASHES = ("sha1", "md5", "sha256", "crc32")
|
||||
# An untested entry whose reason is a hash the bytes do not match.
|
||||
@@ -5856,7 +5854,8 @@ _CARD_HASHES = ("SHA1", "MD5", "CRC32", "SHA256")
|
||||
# The words a card's fold names its other facts by.
|
||||
_CARD_MORE_WORDS = {"Romset": "romset", "Collection path": "collection path",
|
||||
"Catalogued": "catalogues"}
|
||||
# A SHA1 shown short: as long as the card's own address (sha1-<12 hex>).
|
||||
# A hash shown short, in a card, a platform row or an emulator table: as long
|
||||
# as the card's own address (sha1-<12 hex>), one length across the site.
|
||||
SHORT_HASH = 12
|
||||
|
||||
|
||||
|
||||
@@ -260,7 +260,9 @@ class TheScriptWiresBoth(unittest.TestCase):
|
||||
self.assertIn("\ninstallPickers();\n", source)
|
||||
self.assertIn("\ncopyButtons();\n", source)
|
||||
self.assertIn("const SETUP_KEY = 'rb-setup';", source)
|
||||
self.assertIn("const COPYABLE = '[data-copy], .rb-sys-file dd.rb-hash';", source)
|
||||
self.assertIn("const COPYABLE = '[data-copy]:not(button), .rb-sys-file dd.rb-hash';", source)
|
||||
# A platform row's button carries its own data-copy: never given a second button.
|
||||
self.assertIn("const own = button.dataset.copy;", source)
|
||||
|
||||
|
||||
# Visible words of each built page: measured before the round and after it,
|
||||
|
||||
@@ -131,7 +131,7 @@ class ALongEmulatorPageIsOneTable(unittest.TestCase):
|
||||
# and in the card.
|
||||
md5 = f"{9:032x}"
|
||||
self.assertIn(f'MD5 <code title="{md5}">{md5[:12]}</code>', optional)
|
||||
self.assertIn(f'MD5: <code class="rb-hash">{md5}</code>', optional)
|
||||
self.assertRegex(optional, rf'MD5: <code class="rb-hash"[^>]*>{md5}</code>')
|
||||
|
||||
def test_a_shorter_page_keeps_its_cards(self):
|
||||
files = [_archive(i) for i in range(gs.EMULATOR_TABLE_MIN - 1)]
|
||||
|
||||
@@ -102,7 +102,7 @@ class ARowPerFile(unittest.TestCase):
|
||||
details, button = row.split("</details>")
|
||||
self.assertNotIn("<button", details)
|
||||
self.assertEqual(button, f'<button class="rb-copy" data-copy="{md5}" '
|
||||
f'aria-label="Copy MD5 {md5[:8]}">{md5[:8]}</button>')
|
||||
f'aria-label="Copy MD5 {md5[:generate_site.SHORT_HASH]}">{md5[:generate_site.SHORT_HASH]}</button>')
|
||||
# Every hash whole in the details, with the size.
|
||||
for value in (md5, sha1, "0badf00d"):
|
||||
self.assertIn(value, details)
|
||||
@@ -140,7 +140,7 @@ class ARowPerFile(unittest.TestCase):
|
||||
values = ["1" * 32, "2" * 32, "3" * 32]
|
||||
row = self._row({"name": "x", "status": "ok"}, {"md5": ",".join(values)})
|
||||
self.assertIn(f'data-copy="{values[0]}"', row)
|
||||
self.assertIn(f">{values[0][:8]} +2</button>", row)
|
||||
self.assertIn(f">{values[0][:generate_site.SHORT_HASH]} +2</button>", row)
|
||||
for value in values:
|
||||
self.assertIn(f'<code class="rb-hash">{value}</code>', row)
|
||||
|
||||
|
||||
Reference in new issue
Block a user