diff --git a/.github/scripts/tests/test_changes_view_post_install_sources.py b/.github/scripts/tests/test_changes_view_post_install_sources.py new file mode 100644 index 00000000..84642ff8 --- /dev/null +++ b/.github/scripts/tests/test_changes_view_post_install_sources.py @@ -0,0 +1,38 @@ +"""The Changes view files a change under the post-install section by the name +its script records itself with. Both post-install scripts have to be known to +it, or what one of them changes is shown as the work of an unnamed script.""" + +from pathlib import Path +import re +import unittest + +ROOT = Path(__file__).resolve().parents[3] +VIEW = (ROOT / "AppImage/components/audit-changes.tsx").read_text() +SCRIPTS = ("scripts/post_install/auto_post_install.sh", "scripts/post_install/customizable_post_install.sh") + + +class PostInstallSourcesTests(unittest.TestCase): + def setUp(self): + declared = re.search(r"const POST_INSTALL_SOURCES = new Set\(\[([^\]]*)\]\)", VIEW) + self.assertIsNotNone(declared) + self.known = set(re.findall(r'"([^"]+)"', declared.group(1))) + + def test_every_post_install_script_is_known_by_the_name_it_records(self): + for script in SCRIPTS: + with self.subTest(script=script): + source = re.search(r'^SCRIPT_SOURCE="([^"]+)"', (ROOT / script).read_text(), re.M) + self.assertIsNotNone(source) + self.assertIn(source.group(1), self.known) + + def test_no_name_is_listed_that_no_script_records(self): + recorded = {re.search(r'^SCRIPT_SOURCE="([^"]+)"', (ROOT / script).read_text(), re.M).group(1) + for script in SCRIPTS} + self.assertEqual(self.known, recorded) + + def test_figurine_and_fastfetch_have_a_name_in_the_view(self): + for function in ("configure_figurine", "configure_fastfetch"): + self.assertRegex(VIEW, rf'\b{function}: "') + + +if __name__ == "__main__": + unittest.main() diff --git a/AppImage/components/audit-changes.tsx b/AppImage/components/audit-changes.tsx index 3b4ab654..d2cc323c 100644 --- a/AppImage/components/audit-changes.tsx +++ b/AppImage/components/audit-changes.tsx @@ -84,7 +84,7 @@ function undoKey(change: { revert: string; exactness: string }): string { const FN_LABEL: Record = { // Internal helpers of a post-install feature show its menu name, not their - // raw name — and never the source ("auto"/"customizable"). + // raw name — and never the source ("auto"/"custom"). _update_existing_log2ram_auto: "Install and configure Log2RAM", _update_existing_log2ram_custom: "Install and configure Log2RAM", update_snapshot_schedule: "Install ZFS auto-snapshot", @@ -130,9 +130,10 @@ const FN_LABEL: Record = { update_pve_appliance_manager: "Update Proxmox VE Appliance Manager", } -// Post-install functions run from the auto/customizable scripts; everything -// else is a general host script (nvidia/tpu installers, PVE update, vfio…). -const POST_INSTALL_SOURCES = new Set(["auto", "customizable"]) +// Post-install functions run from the automatic and the customizable scripts, +// which record themselves as "auto" and "custom"; everything else is a general +// host script (nvidia/tpu installers, PVE update, vfio…). +const POST_INSTALL_SOURCES = new Set(["auto", "custom"]) // A few sources deserve a friendly name instead of a raw script identifier; // everything else shows the script it came from.