Skip to content

Added per-role first-login smoke tests for Ghost Admin - #29815

Merged
9larsons merged 2 commits into
mainfrom
slars/login-race-condition-ember-react-157801
Aug 10, 2026
Merged

Added per-role first-login smoke tests for Ghost Admin#29815
9larsons merged 2 commits into
mainfrom
slars/login-race-condition-ember-react-157801

Conversation

@9larsons

@9larsons 9larsons commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What

  • New e2e spec e2e/tests/admin/staff-role-smoke.test.ts: every staff role performs a real first login in a fresh browser context and the test asserts the role's landing view plus the navigation it should (and should not) have:
    • Administrator/analytics, full sidebar (Analytics, View site, Posts, Pages, Tags, Members, Settings)
    • Editor/site, sidebar with Posts, Pages, Tags, Settings (no Analytics/View site/Members)
    • Super Editor/site, Editor set plus Members
    • Author/site, Posts and Pages only
    • Contributor/posts, no sidebar at all — floating avatar menu with Posts / View site / Your profile
  • New Playwright fixtures ghostAccountEditor, ghostAccountSuperEditor, ghostAccountAdministrator, reusing the existing StaffAccountFactory invite + MailPit flow (Author/Contributor already existed).
  • New ContributorUserMenu page object backed by new selector constants in @tryghost/test-data.
  • Corrected the stale NAV_ITEMS role-visibility metadata in the sidebar page object (it claimed Editors see View site and Members, contradicting the shipped gating) and added Super Editor to its UserRole union.

Why

A recent production regression left non-admin staff with blank or wrong landing views immediately after login — only a hard refresh recovered — and nothing in the suite walked a non-admin role through a real first login, so it shipped unnoticed. The four non-admin tests anchor their landing waits on Ember-rendered content (site preview iframe, posts list), which is exactly what fails to render when the React and Ember routers desync, so this class of regression now fails loudly. First-ever logins skip staff device verification (the session endpoint checks user.hasLoggedIn()), which is what makes fresh-context signin deterministic here.

A console-error tripwire was considered and deliberately deferred — the admin console is currently too noisy to fail on. Tracked in PLA-314.

Verification

  • Spec green across three full local runs (dev mode), including one after the final revision; first test ~13s (instance boot), ~5s per test after.
  • pnpm lint (0 errors) and pnpm test:types in e2e/; lint + typecheck in packages/testing/test-data.
  • Every asserted expectation traced to product source (home-redirect.tsx, sidebar gating in nav-main/nav-content/nav-settings, admin-layout.tsx, role predicates in admin-x-framework).
  • Three independent review passes (mechanical, e2e-conventions/flakiness, adversarial correctness); all findings addressed. The adversarial pass traced the pre-regression code path and confirmed each non-admin test would have caught it.

no ref

- a production regression left Contributors, Authors and Editors with blank or wrong landing views after login, and nothing in the suite walked a non-admin role through a real first login
- each staff role now signs in through the real signin form in a fresh browser context and asserts its landing view plus the navigation it should (and should not) see
- Editor, Super Editor and Administrator had no e2e fixtures at all; they now reuse the existing StaffAccountFactory invite flow
- corrected the stale NAV_ITEMS role-visibility metadata to match the shipped sidebar gating and moved the contributor menu selectors into a page object
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 31584fe6-f9d7-4504-b2f4-c51a6c502de5

📥 Commits

Reviewing files that changed from the base of the PR and between f236e9c and 61b3846.

📒 Files selected for processing (1)
  • e2e/tests/admin/staff-role-smoke.test.ts
💤 Files with no reviewable changes (1)
  • e2e/tests/admin/staff-role-smoke.test.ts

Walkthrough

Added role-specific sidebar visibility rules, including support for Super Editor. Added Playwright fixtures for Editor, Super Editor, and Administrator accounts. Added contributor user-menu selectors and a page object. Added smoke tests for first-login landing pages and navigation for Administrators, Editors, Super Editors, Authors, and Contributors.

Possibly related PRs

  • TryGhost/Ghost#29785: Implements the contributor-specific Posts list targeted by the role-based sidebar and smoke tests.
  • TryGhost/Ghost#29791: Adds related contributor menu navigation and staff-account E2E fixture behavior.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding first-login smoke tests for each Ghost Admin staff role.
Description check ✅ Passed The description directly explains the new per-role smoke tests, fixtures, page object, selectors, and sidebar metadata updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/login-race-condition-ember-react-157801

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 61b3846

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 6m 42s View ↗
nx run-many -t test:unit -p @tryghost/test-data... ✅ Succeeded 3m 41s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded <1s View ↗
nx run-many -t lint -p @tryghost/e2e,@tryghost/... ✅ Succeeded 2m 24s View ↗
nx run @tryghost/admin:build ✅ Succeeded 1m 52s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 32s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-10 14:11:13 UTC

no ref

The test and helper names already describe the enduring behavior, while the removed comments captured temporary incident and implementation details.
@9larsons
9larsons merged commit c76e3c2 into main Aug 10, 2026
48 checks passed
@9larsons
9larsons deleted the slars/login-race-condition-ember-react-157801 branch August 10, 2026 14:20
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