Skip to content

Added settings acceptance coverage for migration gaps - #29408

Merged
9larsons merged 1 commit into
mainfrom
slars/settings-acceptance-gap-coverage
Jul 20, 2026
Merged

9larsons merged 1 commit into
mainfrom
slars/settings-acceptance-gap-coverage

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

Additive test coverage for the Admin settings acceptance tier (apps/admin/src/settings/**), plus one flake hardening. Test code only — no production changes.

Coverage restored from the retired settings acceptance suites

  • Unsplash integration enable/disable: the {unsplash: true|false} settings PUT contract, and the Active badge tracking the saved state
  • Pintura enable toggle: the {pintura: true} save contract and the JS/CSS upload fields hiding while the toggle is off
  • Upgrade CTA on host-limited integration cards (Zapier + Transistor) when hostSettings.limits.customIntegrations disables them, including the external pro route from the CTA — host limits are faked by overriding the boot browseConfig response
  • Site visibility public↔private switching: access code entry, the private RSS link rendering only after a successful save, and the {is_private, password} / {is_private: false} PUT contracts
  • Theme-tab dirty-state leave guard in the design modal (mirrors the existing Brand-tab case)
  • Theme code editor opened from the active theme's overflow menu, and closing the editor returning to /settings
  • Staff profile picture + cover image uploads: rendered previews and the profile_image/cover_image keys in the users PUT
  • Welcome-email stale-preview race: with two preview requests in flight, a late-arriving response for the older draft must not clobber the newest draft's preview. Implemented with deterministic deferred fake responses (the test resolves the newer one first, then the stale one) plus a pass-through fetch tap that lets the test await full delivery of the stale response before asserting it was ignored — no timing sleeps
  • Explicit newsletter reply-to address surfacing as the customize modal's reply-to placeholder

Parity for client-side behaviors previously asserted only in browser e2e

Thin cases asserting the client contract against the faked Admin API:

  • Transistor shows the Active badge after enabling and saving
  • Portal signup options render a hidden paid tier as an unchecked checkbox; checking it saves visibility: "public" on the tier
  • Archiving/reactivating a tier moves it between the Active/Archived tabs, with the PUT bodies asserted
  • The free-tier option renders in the portal modal when Stripe is disconnected
  • Welcome-email customize modal dismissal family: Escape closes when pristine; a dirty modal prompts for confirmation on Escape/Close; Stay preserves the edit; Leave discards
  • The paid welcome email row renders when Stripe is connected
  • /my-profile redirects to the current user's own staff profile

Flake hardening

default-recipients.acceptance.test.tsx "saves the standard recipient choices" chained three Save→"Saved" cycles in one render and intermittently timed out on the transient "Saved" label under parallel load. Split into three independent parameterized cases that assert the PUT /settings/ capture via toHaveEditedSettings — the actual contract — instead of reading transient button labels. Same payload coverage, no retries, no timeout bumps.

Test-infra support (test lane only)

  • api.unsplash.com added to the acceptance worker's external-origin blocklist so an unfaked Unsplash call fails the test instead of hitting the network; the design spec fakes /photos and the download ping with fakeEndpoint
  • Welcome-email selector constants added to the @tryghost/test-data settings registry and exposed on settingsScreen

Verification

  • pnpm nx run @tryghost/admin:test:acceptance: 50 files / 347 tests green
  • vitest run -c vitest.acceptance.config.ts src/settings run 3× consecutively: 283 tests green each run
  • pnpm lint and pnpm typecheck clean in apps/admin and packages/testing/test-data

@coderabbitai

coderabbitai Bot commented Jul 16, 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

Run ID: 28a9469f-7025-4743-bfb5-e4a06282fccc

📥 Commits

Reviewing files that changed from the base of the PR and between c48e13c and 5d2a581.

📒 Files selected for processing (12)
  • apps/admin/src/settings/advanced/integrations.acceptance.test.tsx
  • apps/admin/src/settings/email/default-recipients.acceptance.test.tsx
  • apps/admin/src/settings/general/staff-profile.acceptance.test.tsx
  • apps/admin/src/settings/membership/access.acceptance.test.tsx
  • apps/admin/src/settings/membership/member-welcome-emails.acceptance.test.tsx
  • apps/admin/src/settings/membership/portal.acceptance.test.tsx
  • apps/admin/src/settings/membership/tiers.acceptance.test.tsx
  • apps/admin/src/settings/settings.screen.ts
  • apps/admin/src/settings/site/design.acceptance.test.tsx
  • apps/admin/src/settings/site/theme.acceptance.test.tsx
  • apps/admin/test-utils/acceptance/worker.ts
  • packages/testing/test-data/src/selectors/settings.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/testing/test-data/src/selectors/settings.ts
  • apps/admin/src/settings/site/theme.acceptance.test.tsx
  • apps/admin/src/settings/membership/access.acceptance.test.tsx
  • apps/admin/test-utils/acceptance/worker.ts
  • apps/admin/src/settings/email/default-recipients.acceptance.test.tsx
  • apps/admin/src/settings/membership/portal.acceptance.test.tsx
  • apps/admin/src/settings/advanced/integrations.acceptance.test.tsx
  • apps/admin/src/settings/membership/member-welcome-emails.acceptance.test.tsx
  • apps/admin/src/settings/site/design.acceptance.test.tsx

Walkthrough

Expanded Admin acceptance coverage for integrations, welcome emails, membership settings, staff profiles, and site design. Tests now verify persisted settings payloads, modal dirty-state behavior, tier lifecycle changes, image uploads, navigation routes, Unsplash handling, and theme editor routing. Shared selectors and the acceptance worker were updated for welcome-email and Unsplash scenarios.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is related to the main change: expanded settings acceptance coverage, even though it is somewhat broad.
Description check ✅ Passed The description clearly matches the test-only settings coverage and flake-hardening changes in this PR.
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/settings-acceptance-gap-coverage

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 Jul 16, 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 5d2a581

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 5m 16s View ↗
nx run-many -t test:unit -p @tryghost/admin,@tr... ✅ Succeeded 1m 41s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 22s View ↗
nx run-many -t lint -p @tryghost/admin,@tryghos... ✅ Succeeded 59s View ↗
nx run @tryghost/admin:build ✅ Succeeded 27s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-07-16 20:48:33 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/admin/src/settings/membership/member-welcome-emails.acceptance.test.tsx`:
- Around line 529-579: Wrap the test flow that uses the window.fetch spy in a
try...finally block, and move fetchSpy.mockRestore() into the finally block so
it always executes when assertions or other operations fail. Keep the existing
preview assertions and cleanup behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: caeb1e47-8be6-4ffd-b79d-c1d5935ae781

📥 Commits

Reviewing files that changed from the base of the PR and between 17397db and c48e13c.

📒 Files selected for processing (12)
  • apps/admin/src/settings/advanced/integrations.acceptance.test.tsx
  • apps/admin/src/settings/email/default-recipients.acceptance.test.tsx
  • apps/admin/src/settings/general/staff-profile.acceptance.test.tsx
  • apps/admin/src/settings/membership/access.acceptance.test.tsx
  • apps/admin/src/settings/membership/member-welcome-emails.acceptance.test.tsx
  • apps/admin/src/settings/membership/portal.acceptance.test.tsx
  • apps/admin/src/settings/membership/tiers.acceptance.test.tsx
  • apps/admin/src/settings/settings.screen.ts
  • apps/admin/src/settings/site/design.acceptance.test.tsx
  • apps/admin/src/settings/site/theme.acceptance.test.tsx
  • apps/admin/test-utils/acceptance/worker.ts
  • packages/testing/test-data/src/selectors/settings.ts

no ref

- covers integration toggle save contracts (Unsplash, Pintura, Transistor
  Active badge) and the upgrade CTA on host-limited integration cards
- covers site visibility public/private switching, tier archive/reactivate
  tab movement, and portal signup-option tier checkbox states
- covers the welcome-email customize modal Escape/dirty confirmation family,
  the paid welcome row with Stripe connected, the newsletter reply-to
  placeholder branch, and a deterministic stale-preview race case
- covers the design Unsplash photo grid (faked external origin), the
  Theme-tab dirty leave guard, the theme editor overflow-menu entry path,
  staff profile/cover image uploads, and the my-profile redirect
- hardens the flaky default-recipients spec by splitting its chained
  Save->Saved cycles into independent cases that assert the settings PUT
  capture instead of transient button labels
@9larsons
9larsons force-pushed the slars/settings-acceptance-gap-coverage branch from c48e13c to 5d2a581 Compare July 16, 2026 20:41
@9larsons
9larsons merged commit a857810 into main Jul 20, 2026
41 checks passed
@9larsons
9larsons deleted the slars/settings-acceptance-gap-coverage branch July 20, 2026 13:02
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