fix(lobby): normalize host SPA deeplink path segments
This commit is contained in:
@@ -998,6 +998,17 @@ class UiScreenTests(TestCase):
|
|||||||
self.assertContains(response, "data-wpp-shell-route=\"/host/guess/round-1\"")
|
self.assertContains(response, "data-wpp-shell-route=\"/host/guess/round-1\"")
|
||||||
self.assertContains(response, "data-wpp-shell-kind=\"host\"")
|
self.assertContains(response, "data-wpp-shell-kind=\"host\"")
|
||||||
|
|
||||||
|
@override_settings(WPP_SPA_ENABLED=True)
|
||||||
|
def test_host_screen_deeplink_normalizes_redundant_slashes_when_feature_flag_enabled(self):
|
||||||
|
self.client.login(username="host_ui", password="secret123")
|
||||||
|
|
||||||
|
response = self.client.get("/lobby/ui/host//guess///round-1//")
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertContains(response, "<app-root>")
|
||||||
|
self.assertContains(response, "data-wpp-shell-route=\"/host/guess/round-1\"")
|
||||||
|
self.assertContains(response, "data-wpp-shell-kind=\"host\"")
|
||||||
|
|
||||||
@override_settings(WPP_SPA_ENABLED=True)
|
@override_settings(WPP_SPA_ENABLED=True)
|
||||||
def test_player_screen_can_render_angular_shell_when_feature_flag_enabled(self):
|
def test_player_screen_can_render_angular_shell_when_feature_flag_enabled(self):
|
||||||
response = self.client.get(reverse("lobby:player_screen"))
|
response = self.client.get(reverse("lobby:player_screen"))
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ def host_screen(request, spa_path=None):
|
|||||||
if settings.WPP_SPA_ENABLED:
|
if settings.WPP_SPA_ENABLED:
|
||||||
host_route = "/host"
|
host_route = "/host"
|
||||||
if spa_path:
|
if spa_path:
|
||||||
host_route = f"/host/{spa_path.strip('/')}"
|
normalized_spa_path = "/".join(segment for segment in spa_path.split("/") if segment)
|
||||||
|
if normalized_spa_path:
|
||||||
|
host_route = f"/host/{normalized_spa_path}"
|
||||||
return _render_spa_shell(request, host_route, "host")
|
return _render_spa_shell(request, host_route, "host")
|
||||||
|
|
||||||
categories = Category.objects.filter(is_active=True).order_by("name")
|
categories = Category.objects.filter(is_active=True).order_by("name")
|
||||||
|
|||||||
Reference in New Issue
Block a user