migration: preserve frontend shell pages and styles

This commit is contained in:
leefer
2026-07-31 15:08:57 +08:00
parent 38de3de0a3
commit dec3cd1236
92 changed files with 10758 additions and 9449 deletions
+8 -6
View File
@@ -5,9 +5,11 @@ import re
import unittest
from pathlib import Path
from tests.preservation_helpers import reassembled_frontend_runtime
ROOT = Path(__file__).resolve().parents[1]
STATIC = ROOT / "static"
STATIC = ROOT / "frontend"
class FrontendBoundaryTests(unittest.TestCase):
@@ -22,7 +24,7 @@ class FrontendBoundaryTests(unittest.TestCase):
def test_shared_dependencies_load_before_application(self) -> None:
html = (STATIC / "index.html").read_text(encoding="utf-8")
ui_position = html.index('/ui-core.js')
ui_position = html.index('/shared/ui-core.js')
components_position = html.index('/shared/components.js')
pages_position = html.index('/pages.config.js')
runtime_position = html.index('/pages/runtime.js')
@@ -40,7 +42,7 @@ class FrontendBoundaryTests(unittest.TestCase):
self.assertLess(shell_position, app_position)
def test_application_state_is_created_through_shared_boundary(self) -> None:
app = (STATIC / "app.js").read_text(encoding="utf-8")
app = reassembled_frontend_runtime()
self.assertIn("const state = window.XiaobaiState.create({", app)
self.assertNotIn("const state = {", app)
@@ -70,7 +72,7 @@ class FrontendBoundaryTests(unittest.TestCase):
self.assertEqual(actual, expected)
def test_shell_owns_navigation_and_page_mounting(self) -> None:
app = (STATIC / "app.js").read_text(encoding="utf-8")
app = reassembled_frontend_runtime()
shell = (STATIC / "shared" / "shell.js").read_text(encoding="utf-8")
self.assertNotIn("function syncNavigationState", app)
self.assertNotIn("function initializeApplicationShell", app)
@@ -109,7 +111,7 @@ class FrontendBoundaryTests(unittest.TestCase):
self.assertEqual(actual, expected)
def test_page_lifecycle_is_owned_outside_application_monolith(self) -> None:
app = (STATIC / "app.js").read_text(encoding="utf-8")
app = reassembled_frontend_runtime()
runtime = (STATIC / "pages" / "runtime.js").read_text(encoding="utf-8")
start = app.index("function openView(")
end = app.index("\nfunction initializeAutoTableSorting", start)
@@ -122,7 +124,7 @@ class FrontendBoundaryTests(unittest.TestCase):
def test_shared_empty_state_component_is_used_by_multiple_features(self) -> None:
components = (STATIC / "shared" / "components.js").read_text(encoding="utf-8")
app = (STATIC / "app.js").read_text(encoding="utf-8")
app = reassembled_frontend_runtime()
self.assertIn("function emptyStateHtml(message, options = {})", components)
self.assertIn("function renderEmptyState(target, message, options = {})", components)
self.assertGreaterEqual(app.count("renderEmptyState("), 8)