Skip to content

test(consumer): cover JusticeHub dashboard preload/spinner embed (DataSpaceFrontend#492) - #186

Merged
saqibmanan merged 1 commit into
CIfrom
test-sync/DataSpaceFrontend-pr492
Oct 9, 2026
Merged

saqibmanan merged 1 commit into
CIfrom
test-sync/DataSpaceFrontend-pr492

Conversation

@saqibmanan

@saqibmanan saqibmanan commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Covers DataSpaceFrontend#492 ("Fixed errors for justice-hub"), merge commit 6e6254995da6a94fd709a2fbf29f324ea42d689b, merged 2026-10-08T10:55:32Z into dev.

Deployed, confirmed before trusting dev: Deploy DataSpace run 37766683337 on that merge commit succeeded, and dev.civicdataspace.in's X-Git-Sha header reads 6e6254995da6a94fd709a2fbf29f324ea42d689b right now — dev genuinely serves this change, not a rolled-back deploy.

What changed (from the real diff, not the title)

JusticeHub dashboards sometimes showed their logo broken/oversized because the generic dashboard iframe rendered before justicehub.in's own stylesheet and logo had loaded in the embedded page. The fix is scoped to JusticeHub links only (isJusticeHubEmbed, by hostname): a new JusticeHubEmbed component (a) adds <link rel="preconnect"> + two <link rel="preload"> tags for JusticeHub's theme CSS and logo, and (b) wraps the iframe in a container with aria-busy, showing a spinner until the iframe has loaded (with one silent reload if the first load looks like a redirect bounce), then reveals it. Every other dashboard type (e.g. Superset, already covered by test_con_usecase_dashboards.py) is untouched — same plain iframe as before.

Why smoke, and deliberately not readonly

This is new, UI-visible behaviour on a use-case detail page → smoke (no Page Object existed yet for this specific embed, so UseCaseLocators/UseCasePage — already home to the sibling Superset-dashboard tests — were extended, not replaced).

Not marked readonly. git merge-base --is-ancestor 6e6254995da6a94fd709a2fbf29f324ea402c... origin/main in DataSpaceFrontend confirms #492 has not reached main yet, and civicdataspace.in (prod) sends no X-Git-Sha header at all to gate on via deployed_pr(..., site=...). Omitting readonly is the simplest safe choice here: the test simply never runs against prod (only readonly-marked tests do), so it can't trip the prod-deploy smoke gate. Once #492 reaches main, a human can add readonly (the assertions themselves need no change).

Tests added (tests/consumer/smoke/test_con_usecase_justicehub_embed.py)

Both pick their use case from the live backend at runtime (never hardcoded) — any published use case whose dashboard link's hostname is justicehub.in/www.justicehub.in.

Test Covers
test_justicehub_dashboard_preloads_theme_assets preconnect + both preload <link> tags are present
test_justicehub_dashboard_is_still_embedded_and_becomes_ready the iframe is still the right one (title/src unchanged from the API's link), and the aria-busy wrapper clears within 12s instead of leaving the spinner up forever

Extended (not edited) pages/consumer/usecase_page.py / locators/consumer/usecase_locators.py with justicehub_theme_preloaded(), justicehub_embed_becomes_ready(), and the matching locators — reusing open_detail, has_dashboards_section, embedded_dashboards from the existing Superset-dashboard tests rather than duplicating them.

Proof (red → green)

Real parent-commit red, not a flipped assertion: git merge-base --is-ancestor confirms #492 hasn't reached main, so prod is genuinely still running the pre-#492 code for the exact same use case (id 302, backend-confirmed present on both dev's and prod's data).

Red — prod (HOME_URL_DEV=https://civicdataspace.in API_BASE_URL=https://api.datakeep.civicdays.in):

FAILED test_justicehub_dashboard_preloads_theme_assets
  AssertionError: use case 302 (https://justicehub.in/dataset/analysis-calpra-2015-2023): JusticeHub theme preload links missing: {'preconnect': False, 'preload_css': False, 'preload_logo': False}
FAILED test_justicehub_dashboard_is_still_embedded_and_becomes_ready
  AssertionError: use case 302 (https://justicehub.in/dataset/analysis-calpra-2015-2023): JusticeHub embed wrapper never cleared aria-busy
2 failed in 65.36s

Green — dev (HOME_URL_DEV=https://dev.civicdataspace.in API_BASE_URL=https://dev.api.civicdataspace.in):

test_justicehub_dashboard_preloads_theme_assets PASSED
test_justicehub_dashboard_is_still_embedded_and_becomes_ready PASSED
2 passed in 22.34s

Both fail/pass at the intended assertions — not a setup error, not a timeout at the wrong line.

Collection, under CI's real marker filter (tests/consumer -m smoke --collect-only): both tests collected (88/92 tests collected, 4 deselected — the 4 are the existing functional/regression-only tests in that tree).

Note on how this was run

This cloud routine has no test credentials, so only unauthenticated/public checks are in scope here — both tests are exactly that (no login, GraphQL reads + a public use-case page). Browser automation in this sandbox needed a manually version-matched chromedriver (141.0.7390.37, fetched directly from storage.googleapis.com since the sandbox's egress proxy blocks webdriver-manager's own download host); CI's browser-actions/setup-chrome resolves this normally with full internet access. Nothing about the committed test or fixtures depends on that workaround.

Duplicate check (§8)

No existing test-sync/DataSpaceFrontend-pr492 branch or PR before this one.

Gaps / not covered

  • The actual FOUC (flash of unstyled logo) this fixes is a transient visual timing issue — not reliably assertable with Selenium without flaking. The tests instead assert the mechanism that prevents it (preload tags present, spinner genuinely clears) rather than pixel-level "did the logo look broken" timing.
  • The retry-on-first-load behaviour (JusticeHubEmbed's one silent reload before committing to reveal) isn't separately asserted; justicehub_embed_becomes_ready only checks the end state (resolves within 12s), which is what matters to a user.

Draft only — not merging, not marking ready, not enabling auto-merge.

@saqibmanan
saqibmanan marked this pull request as ready for review October 9, 2026 04:58
@saqibmanan
saqibmanan merged commit 63ee1da into CI Oct 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant