Skip to content

Conversation

@vershwal
Copy link
Member

@vershwal vershwal commented Dec 3, 2025

ref https://linear.app/ghost/issue/PRO-1512/

  • Created 2 test posts and 2 snippets containing all media types for testing CDN url behavior.
  • Added a tag and newsletter
  • Updated tests for new fixtures

Note

Adds media-rich post/snippet fixtures plus a tag and newsletter, and updates tests/snapshots and limits to reflect increased counts and content.

  • Fixtures:
    • Add 2 posts (Mobiledoc + Lexical) and 2 snippets containing all media types for CDN URL testing.
    • Add tag tag-with-images and newsletter new-newsletter.
  • Tests/Snapshots Updated:
    • Adjust counts/pagination across Admin & Content APIs (posts, tags, newsletters, snippets, activity feed, search-index, exports, bulk ops, users).
    • Update CSV exports to include new posts; content-length and headers adjusted where applicable.
    • Increase newsletter host limit assertions (3 → 4) and related pagination/ordering expectations.
    • Update URL service generators’ expected URL counts.

Written by Cursor Bugbot for commit 532e035. This will update automatically on new commits. Configure here.

@vershwal vershwal marked this pull request as draft December 3, 2025 06:00
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

Walkthrough

Fixture data was expanded with two new rich-media posts, a new tag with images, an additional newsletter, and new snippets. Many tests across admin, content, legacy, integration, and utils suites were updated to reflect the larger dataset: snapshots, pagination totals, array lengths, and index-based assertions were adjusted. Activity-feed and newsletters tests include updated totals/limits and error messages. Changes are limited to test fixtures and expectations; no production code, public API signatures, or exported entity declarations were modified.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review fixture changes in core/test/utils/fixtures/data-generator.js: verify payload shapes for new posts/snippets (Mobiledoc/Lexical), media card wiring, post_meta (og/twitter images), newsletters, tags, and relation tables (posts_tags, posts_authors, newsletters).
  • Inspect all test expectation updates for off-by-one or indexing errors (posts, content/admin/legacy tests that moved indices from 11→13, 12→14, etc.).
  • Verify pagination and snapshot adjustments in activity-feed tests (totals, limits, aggregated event counts) and newsletters tests (hostSettings limits and error text).
  • Check search-index, tags, snippets, and URL generator expectation changes for consistent counts across admin/content/integration suites.
  • Spot-check a representative set of updated snapshots to ensure test intent remains correct (not accidental data mismatches).

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main objective of adding test fixtures for CDN URL testing, which aligns with the primary change in the changeset.
Description check ✅ Passed The PR description is comprehensive and directly related to the changeset, clearly documenting the new fixtures added and test updates made throughout the suite.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hitests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.40.0)
ghost/core/test/legacy/models/model_posts.test.js

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 and usage tips.

@vershwal vershwal marked this pull request as ready for review December 8, 2025 07:03
@vershwal
Copy link
Member Author

vershwal commented Dec 8, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vershwal vershwal changed the title Tests Created test fixtures for testing CDN urls Dec 8, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ghost/core/test/e2e-api/admin/newsletters.test.js (1)

327-339: Comment slightly misleading but code is correct.

Line 332's comment states "Reset the limit back to 4" but the limit is being changed from 3 to 4 (not reset "back" to 4). The code is correct for the expanded dataset, but the comment could be clearer: perhaps "Update the limit to 4 for remaining tests" would be more accurate.

Consider updating the comment for clarity:

-                // Reset the limit back to 4 for other tests
+                // Update the limit to 4 to match the expanded dataset for remaining tests
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25af482 and 79dc95d.

⛔ Files ignored due to path filters (10)
  • ghost/core/test/e2e-api/admin/__snapshots__/activity-feed.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/newsletters.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts-bulk.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/search-index.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/snippets.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/users.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/newsletters.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/search-index.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (18)
  • ghost/core/test/e2e-api/admin/activity-feed.test.js (5 hunks)
  • ghost/core/test/e2e-api/admin/newsletters.test.js (12 hunks)
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js (4 hunks)
  • ghost/core/test/e2e-api/admin/search-index.test.js (2 hunks)
  • ghost/core/test/e2e-api/admin/snippets.test.js (2 hunks)
  • ghost/core/test/e2e-api/admin/tags.test.js (2 hunks)
  • ghost/core/test/e2e-api/admin/users.test.js (1 hunks)
  • ghost/core/test/e2e-api/content/authors.test.js (1 hunks)
  • ghost/core/test/e2e-api/content/newsletters.test.js (2 hunks)
  • ghost/core/test/e2e-api/content/posts.test.js (6 hunks)
  • ghost/core/test/e2e-api/content/search-index.test.js (2 hunks)
  • ghost/core/test/integration/url_service.test.js (3 hunks)
  • ghost/core/test/legacy/api/admin/posts.test.js (3 hunks)
  • ghost/core/test/legacy/api/content/posts.test.js (6 hunks)
  • ghost/core/test/legacy/api/content/tags.test.js (1 hunks)
  • ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js (1 hunks)
  • ghost/core/test/legacy/models/model_posts.test.js (2 hunks)
  • ghost/core/test/utils/fixtures/data-generator.js (10 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: mike182uk
Repo: TryGhost/Ghost PR: 22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in the Ghost ActivityPub module are covered by tests in the file `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`.
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:28:50.351Z
Learning: Run `yarn test:integration` for integration tests in ghost/core
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-11-24T17:29:43.865Z
Learning: Each test receives fresh Ghost instance for automatic isolation
Learnt from: kevinansfield
Repo: TryGhost/Ghost PR: 24651
File: ghost/core/test/utils/urlUtils.js:53-57
Timestamp: 2025-08-11T19:39:00.428Z
Learning: In Ghost's test utilities, when fixing specific issues like async behavior, it's preferred to maintain existing error handling patterns (even if suboptimal) to keep PRs focused on their primary objective. Error handling improvements can be addressed in separate, dedicated PRs.
Learnt from: ErisDS
Repo: TryGhost/Ghost PR: 23588
File: ghost/core/test/e2e-api/admin/backup.test.js:136-148
Timestamp: 2025-05-29T10:37:26.369Z
Learning: In the Ghost test framework, when testing CSV exports via the admin API, the response `body` field is empty while the actual CSV data is provided through the `text` field. Tests should use `expectEmptyBody()` and then validate the CSV content via `.expect(({text}) => ...)` - this is not contradictory behavior.
📚 Learning: 2025-05-29T10:37:26.369Z
Learnt from: ErisDS
Repo: TryGhost/Ghost PR: 23588
File: ghost/core/test/e2e-api/admin/backup.test.js:136-148
Timestamp: 2025-05-29T10:37:26.369Z
Learning: In the Ghost test framework, when testing CSV exports via the admin API, the response `body` field is empty while the actual CSV data is provided through the `text` field. Tests should use `expectEmptyBody()` and then validate the CSV content via `.expect(({text}) => ...)` - this is not contradictory behavior.

Applied to files:

  • ghost/core/test/e2e-api/admin/search-index.test.js
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js
  • ghost/core/test/e2e-api/content/posts.test.js
  • ghost/core/test/e2e-api/content/search-index.test.js
  • ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js
  • ghost/core/test/legacy/api/content/posts.test.js
📚 Learning: 2025-03-13T09:00:20.205Z
Learnt from: mike182uk
Repo: TryGhost/Ghost PR: 22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in the Ghost ActivityPub module are covered by tests in the file `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`.

Applied to files:

  • ghost/core/test/e2e-api/admin/search-index.test.js
  • ghost/core/test/legacy/api/admin/posts.test.js
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js
  • ghost/core/test/e2e-api/admin/activity-feed.test.js
  • ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js
  • ghost/core/test/legacy/api/content/posts.test.js
📚 Learning: 2025-11-24T17:29:43.865Z
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-11-24T17:29:43.865Z
Learning: Applies to e2e/**/*.test.ts : Test suite names should follow the format 'Ghost Admin - Feature' or 'Ghost Public - Feature'

Applied to files:

  • ghost/core/test/e2e-api/admin/search-index.test.js
  • ghost/core/test/e2e-api/admin/tags.test.js
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js
📚 Learning: 2025-09-11T07:31:40.433Z
Learnt from: aileen
Repo: TryGhost/Ghost PR: 24879
File: apps/admin-x-settings/src/hooks/useLimiter.tsx:125-125
Timestamp: 2025-09-11T07:31:40.433Z
Learning: In apps/admin-x-settings/src/hooks/useLimiter.tsx, the useMemo dependency array intentionally includes the entire `config` object rather than just `config.hostSettings?.limits` to enforce re-renders when anything in the config changes, particularly for subscription/plan change scenarios.

Applied to files:

  • ghost/core/test/e2e-api/admin/newsletters.test.js
📚 Learning: 2025-03-13T09:00:20.205Z
Learnt from: mike182uk
Repo: TryGhost/Ghost PR: 22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in Ghost's ActivityPub module are thoroughly tested in `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`, which covers `generatePendingActivityId`, `isPendingActivity`, and `generatePendingActivity` functions.

Applied to files:

  • ghost/core/test/e2e-api/admin/activity-feed.test.js
📚 Learning: 2025-11-24T17:29:43.865Z
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-11-24T17:29:43.865Z
Learning: Applies to e2e/**/*.test.ts : Use factory pattern for all test data creation instead of hard-coded data or direct database manipulation

Applied to files:

  • ghost/core/test/utils/fixtures/data-generator.js
🧬 Code graph analysis (5)
ghost/core/test/e2e-api/admin/search-index.test.js (1)
ghost/core/test/e2e-api/content/search-index.test.js (2)
  • searchIndexPostMatcher (18-26)
  • searchIndexTagMatcher (73-78)
ghost/core/test/e2e-api/content/posts.test.js (1)
ghost/core/test/unit/server/data/schema/fixtures/fixture-manager.test.js (1)
  • fixtureManager (9-9)
ghost/core/test/e2e-api/content/authors.test.js (4)
ghost/core/test/e2e-api/admin/search-index.test.js (1)
  • assert (3-3)
ghost/core/test/e2e-api/admin/users.test.js (1)
  • assert (1-1)
ghost/core/test/e2e-api/content/search-index.test.js (1)
  • assert (1-1)
ghost/core/test/unit/server/services/update-check.test.js (1)
  • assert (6-6)
ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js (3)
ghost/core/test/e2e-frontend/default_routes.test.js (3)
  • $ (64-64)
  • $ (83-83)
  • $ (103-103)
ghost/core/test/legacy/site/frontend.test.js (1)
  • $ (123-123)
ghost/core/test/legacy/site/dynamic_routing.test.js (2)
  • $ (59-59)
  • $ (132-132)
ghost/core/test/utils/fixtures/data-generator.js (7)
ghost/core/test/legacy/api/admin/posts.test.js (1)
  • ObjectId (4-4)
ghost/core/test/unit/server/data/migrations/utils.test.js (1)
  • ObjectId (172-172)
ghost/core/core/server/data/migrations/utils/permissions.js (1)
  • ObjectId (1-1)
ghost/core/core/server/data/importer/importers/data/Base.js (1)
  • ObjectId (3-3)
ghost/core/core/server/models/base/plugins/events.js (1)
  • ObjectId (3-3)
ghost/core/test/utils/fixture-utils.js (2)
  • ObjectId (6-6)
  • DataGenerator (20-20)
ghost/core/test/e2e-browser/portal/invites.spec.js (1)
  • DataGenerator (5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: E2E Tests (Ember 4/4)
  • GitHub Check: [Optional] E2E Tests (React 2/4)
  • GitHub Check: [Optional] E2E Tests (React 4/4)
  • GitHub Check: E2E Tests (Ember 3/4)
  • GitHub Check: [Optional] E2E Tests (React 3/4)
  • GitHub Check: E2E Tests (Ember 1/4)
  • GitHub Check: [Optional] E2E Tests (React 1/4)
  • GitHub Check: E2E Tests (Ember 2/4)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Unit tests (Node 22.18.0)
🔇 Additional comments (36)
ghost/core/test/e2e-api/admin/tags.test.js (1)

28-37: Updated tag count and pagination total look consistent

Expecting jsonResponse.tags length 7 and pagination total 7 matches a single-page result with limit: 15 and aligns with the expanded fixtures described in this PR. No issues spotted around these updated expectations.

ghost/core/test/e2e-api/admin/users.test.js (1)

114-114: LGTM!

The posts count expectation correctly increased from 8 to 10 to reflect the two new posts (posts[8] and posts[9]) added to the data generator fixtures, both of which are authored by users[0].

ghost/core/test/utils/fixtures/data-generator.js (7)

96-216: Well-structured Mobiledoc fixture for URL transformation testing.

The new post fixture comprehensively covers all media types (images, galleries, files, videos, audio) with __GHOST_URL__ placeholders, which is excellent for testing URL transformations. The Mobiledoc structure follows the expected format.


217-592: Comprehensive Lexical fixture mirrors Mobiledoc coverage.

The Lexical post fixture parallels the Mobiledoc version with equivalent media types and URL placeholders, ensuring consistent test coverage across both content formats.


622-630: Good addition of tag with image fields for URL transformation testing.

The new tag includes feature_image, og_image, and twitter_image with __GHOST_URL__ placeholders, which expands test coverage for tag-related URL transformations.


1398-1623: Comprehensive snippet fixtures for both Mobiledoc and Lexical formats.

The new snippets provide excellent coverage for testing URL transformations in reusable content blocks across both content formats, including all media types (images, files, videos, audio).


2164-2166: Correctly extends forKnex posts array.

The posts array properly includes the two new posts from the Content definition.


2705-2705: Good defensive fix using modulo for member references.

Using members[index % members.length] prevents index out of bounds errors when the number of redirects/posts exceeds the number of members in the fixture data.


2722-2724: Correctly extends snippets array to include new fixtures.

The snippets array now includes all three snippet entries from the Content definition.

ghost/core/test/legacy/api/content/tags.test.js (1)

55-55: LGTM!

The pagination total correctly increased from 56 to 57 to account for the new tag added in the data generator fixtures.

ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js (1)

1314-1314: LGTM!

The post count correctly increased from 4 to 6 for the author:joe-bloggs channel filter. The two new published posts (posts[8] and posts[9]), both authored by joe-bloggs (users[0]), are now included in the results.

ghost/core/test/e2e-api/admin/snippets.test.js (2)

44-44: LGTM!

The browse count correctly increased from 2 to 4, accounting for the 2 new snippets added to the fixtures (now 3 total) plus the 1 snippet created by the "Can add" test that runs before this test.


202-202: LGTM!

The lexical browse count correctly increased from 1 to 2. The new "Snippet with all media types - Lexical" fixture has a lexical field, and combined with the "test lexical" snippet added earlier in the test suite, this gives 2 snippets matching the lexical:-null filter.

ghost/core/test/integration/url_service.test.js (1)

54-54: LGTM! URL generation expectations updated consistently.

The expected URL count for posts has been correctly updated from 2 to 4 across all three routing scenarios (default, extended/modified, and subdirectory). This aligns with the expanded test fixtures.

Also applies to: 155-155, 249-249

ghost/core/test/e2e-api/admin/activity-feed.test.js (5)

186-186: LGTM! Event count updated correctly.

The expected events array length has been updated from 3 to 4 for the "CAN AND two ORs" test case, consistent with the expanded activity feed fixtures.


204-204: LGTM! Pagination expectations updated.

The total expected events count for all posts pagination has been correctly updated to 40, aligning with the expanded dataset.


229-229: LGTM! Aggregated clicks pagination updated.

The total expected count for aggregated clicks across all posts has been correctly updated to 35.


265-265: LGTM! Click events expectations updated.

The expected array length for click events has been correctly updated to 10, consistent with the expanded fixture data.


298-298: LGTM! Feedback events expectations updated.

The expected array length for feedback events has been correctly updated to 10, aligning with the larger dataset.

ghost/core/test/e2e-api/admin/search-index.test.js (2)

34-34: LGTM! Posts array length updated correctly.

The expected posts array length has been updated from 13 to 15, consistent with the expanded test fixtures.


96-96: LGTM! Tags array length updated correctly.

The expected tags array length has been updated from 6 to 7, aligning with the larger dataset.

ghost/core/test/e2e-api/content/authors.test.js (1)

75-75: LGTM! Author post count updated correctly.

The expected post count for the 'joe-bloggs' author has been correctly updated from 4 to 6, reflecting the expanded post fixtures.

ghost/core/test/e2e-api/content/search-index.test.js (2)

36-36: LGTM! Posts array length updated correctly.

The expected posts array length has been updated from 11 to 13 for the Content API search index, consistent with the expanded fixtures.


88-88: LGTM! Tags array length updated correctly.

The expected tags array length has been updated from 6 to 7, aligning with the expanded dataset.

ghost/core/test/legacy/models/model_posts.test.js (2)

134-134: LGTM! Total posts count updated correctly.

The expected data length for limit: 'all' with status: 'all' has been updated from 108 to 110, reflecting the expanded post fixtures.


168-168: LGTM! Tag-filtered pagination updated correctly.

The expected data length for page 2 of the 'injection' tag filter has been updated from 10 to 11, consistent with the larger dataset.

ghost/core/test/legacy/api/admin/posts.test.js (2)

49-49: LGTM! Posts array length updated consistently.

The expected posts array length has been correctly updated from 13 to 15 across multiple test cases, reflecting the expanded post fixtures.

Also applies to: 80-80, 172-172


175-176: LGTM! Array indices adjusted correctly.

The array index has been correctly updated from [12] to [14] (now accessing the 15th element) to match the expanded posts array. The assertions verify the expected post slug and meta_description for the last item when ordered by meta_description ASC.

ghost/core/test/e2e-api/content/newsletters.test.js (1)

27-27: LGTM! Newsletter count updated consistently.

The expected newsletters array length has been correctly updated from 3 to 4 in both test cases, reflecting the expanded newsletter fixtures for active newsletters.

Also applies to: 39-39

ghost/core/test/legacy/api/content/posts.test.js (2)

121-142: LGTM! Consistent fixture expansion.

The test expectations have been correctly updated to reflect the expanded dataset with 13 posts (previously 11). Both the posts array length and pagination total are consistent.


478-484: LGTM! Pagination logic correctly updated.

The pagination changes are mathematically correct: with 17 total posts and a limit of 15 per page, the result correctly shows 2 pages with the next page being page 2.

ghost/core/test/e2e-api/admin/posts-legacy.test.js (1)

55-84: LGTM! Index adjustments are consistent.

All test expectations have been correctly updated to accommodate the expanded dataset with 15 posts (previously 13). Index references have been consistently shifted by 2 positions (e.g., posts[12] → posts[14], posts[11] → posts[13]).

ghost/core/test/e2e-api/content/posts.test.js (2)

69-96: LGTM! Post indices correctly adjusted for expanded dataset.

The test expectations have been properly updated to reflect the addition of 2 posts to the fixtures. The index adjustments account for the new sort order: the 'ghostly-kitchen-sink' post shifted from index 9 to 11, while 'not-so-short-bit-complex' is now at index 9.


176-196: LGTM! Author filter test correctly updated.

The posts array length increased from 11 to 13, and the joe_primary_authors count increased from 4 to 6, indicating the 2 new posts have 'joe-bloggs' as the primary author. This is internally consistent with the fixture expansion.

ghost/core/test/e2e-api/admin/newsletters.test.js (2)

64-96: LGTM! Newsletter count correctly updated.

The test expectations have been properly updated to reflect the expanded dataset with 5 newsletters (previously 4).


356-534: LGTM! Host limit tests consistently updated.

All assertions regarding the newsletter count and limits have been correctly updated from 3→4 active newsletters to match the expanded fixture dataset. The test flow correctly tracks the active newsletter count decreasing from 4→3 after archiving one newsletter.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
ghost/core/test/e2e-api/content/tags.test.js (2)

38-51: Tag count and kitchen sink index update match new fixtures, but index check is brittle

Bumping the tag count to 5 and shifting kitchen sink to index 4 makes sense with the new tag fixture. However, this assertion is tightly coupled to ordering (and already has DB-specific branching), so it’s likely to break again as fixtures evolve.

You could instead assert presence by name and keep only minimal order checks (e.g. just first element), similar to how the post-count test uses _.find:

jsonResponse.tags.map(t => t.name).should.containEql('kitchen sink');

100-107: Post-count test now expects 5 tags; consider also asserting on the new tag

The length check of 5 is consistent with the added tag fixture. Right now, the test only checks count.posts for four named tags; the fifth tag is effectively unchecked.

Optionally, you could add an assertion that the new tag is present and has the expected count.posts to tighten coverage for the new fixture.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f902ee0 and c1771f8.

⛔ Files ignored due to path filters (2)
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • ghost/core/test/e2e-api/content/tags.test.js (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: E2E Tests (Ember 4/4)
  • GitHub Check: [Optional] E2E Tests (React 4/4)
  • GitHub Check: E2E Tests (Ember 3/4)
  • GitHub Check: E2E Tests (Ember 2/4)
  • GitHub Check: [Optional] E2E Tests (React 3/4)
  • GitHub Check: [Optional] E2E Tests (React 2/4)
  • GitHub Check: [Optional] E2E Tests (React 1/4)
  • GitHub Check: E2E Tests (Ember 1/4)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Unit tests (Node 22.18.0)
🔇 Additional comments (1)
ghost/core/test/e2e-api/content/tags.test.js (1)

69-72: limit=all tag length change to 5 looks correct

Updating the limit=all expectation from 4 to 5 aligns with the expanded tag fixtures and keeps the test consistent with the default browse test above. No further issues here.

@vershwal vershwal force-pushed the hitests branch 2 times, most recently from c630d4e to 68451a6 Compare December 8, 2025 08:34
- Added posts and snippets
- Added Tag and Newsletter
- members_click_events and members_feedback assumed posts.length ===members.length. This broke
after adding extra posts.
- Used modulo to safely wrap around the members array when there are more posts than members.
- The tests expect 2 published posts, but now there are 4 published posts because of 2 new posts
- tags are updated 3 -> 4
- Adjusted post counts and pagination values to account for 2 new posts
- Updated tag total count for 1 new tag
- Fixed post ordering index in meta_description sort test
- Fixed post counts: 13 → 15 posts, 6 → 7 tags, 4 → 6 joe-bloggs posts
- Fixed post order assertions after new posts shifted indices
- Updated snippet array sizes (2 → 4 total, lexical filter stays at 2)
- Updated search-index post/tag counts (13 → 15 posts, 6 → 7 tags)
- Updated users test post count matcher (8 → 10)
- Changed conflicting post ID to avoid UNIQUE constraint with gated posts fixture
- Added required mobiledoc field to Lexical snippet fixture
- Updated test for new newsletter
- admin/posts: Updated pagination (13→15 posts) and CSV export data
- admin/posts-bulk: Updated snapshot for bulk operations
 - content/posts: Updated array sizes (11→13), post indices, and author counts
@vershwal
Copy link
Member Author

vershwal commented Dec 8, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
ghost/core/test/e2e-api/admin/tags.test.js (1)

24-51: Tag counts & kitchen‑sink URL assertions look good; add explicit existence check

The increased tag length/total (7) and the new kitchen-sink URL and count.posts === 2 checks align with the expanded fixtures and help validate URL generation.

To make failures clearer if the fixture ever changes, consider asserting that the tag was found before dereferencing:

-        const kitchenSinkTag = jsonResponse.tags.find(t => t.slug === 'kitchen-sink');
-
-        // kitchen-sink has published posts, so it should have a valid URL
-        kitchenSinkTag.url.should.eql(`${config.get('url')}/tag/kitchen-sink/`);
+        const kitchenSinkTag = jsonResponse.tags.find(t => t.slug === 'kitchen-sink');
+        should.exist(kitchenSinkTag, 'Expected a tag with slug "kitchen-sink"');
+
+        // kitchen-sink has published posts, so it should have a valid URL
+        kitchenSinkTag.url.should.eql(`${config.get('url')}/tag/kitchen-sink/`);
ghost/core/test/e2e-api/admin/posts-legacy.test.js (1)

51-82: Post totals updated to 15; consider reducing reliance on hard-coded indices

The updated expectations (posts.length === 15, last slug html-ipsum, newsletter checks on index 14, feature image on index 13) are consistent with the expanded post fixtures and still validate default ordering and relations correctly.

However, these checks are quite brittle because they depend on the exact array positions. To make the tests more resilient to future fixture changes, you could resolve posts by id/slug instead of index, for example:

-        jsonResponse.posts[14].id.should.eql(testUtils.DataGenerator.Content.posts[0].id);
-        jsonResponse.posts[14].newsletter.id.should.eql(testUtils.DataGenerator.Content.newsletters[0].id);
-        should.not.exist(jsonResponse.posts[14].newsletter_id);
+        const scheduledPost = jsonResponse.posts.find(
+            post => post.id === testUtils.DataGenerator.Content.posts[0].id
+        );
+        should.exist(scheduledPost);
+        scheduledPost.newsletter.id.should.eql(testUtils.DataGenerator.Content.newsletters[0].id);
+        should.not.exist(scheduledPost.newsletter_id);

You could apply a similar pattern for the html-ipsum and feature-image checks if desired.

Also applies to: 113-118

ghost/core/test/integration/url_service.test.js (1)

51-67: URL generator count expectations correctly updated for expanded fixtures

The increased getUrls().length expectations for posts and tags across the three routing setups are consistent with the expanded post/tag fixtures, and the subsequent getUrlByResourceId checks still validate the concrete mappings.

If this file keeps needing tweaks when fixtures grow, you might consider deriving the expected counts from fixture data (e.g., counting posts/tags matching each generator’s filter) instead of hard-coding them, but it’s not essential for this PR.

Also applies to: 152-172, 247-266

ghost/core/test/e2e-api/content/posts.test.js (1)

69-96: Index-based slug/URL/media checks updated for 13‑post dataset

The expanded checks around indices 9 and 11 (including slug, feature image host, canonical URL host, and image src host via cheerio) correctly track the new positions of not-so-short-bit-complex and the kitchen‑sink post in the 13‑post list, and they continue to assert CDN/absolute URL behaviour.

You now assert the slug at index 11 twice:

  • once via fixtureManager.get('posts', 1).slug
  • and again as the literal 'ghostly-kitchen-sink'

To avoid duplicated maintenance if the fixture slug ever changes, you could drop one of these assertions (or keep only the fixture-based one).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68451a6 and 532e035.

⛔ Files ignored due to path filters (10)
  • ghost/core/test/e2e-api/admin/__snapshots__/activity-feed.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/newsletters.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts-bulk.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/search-index.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/snippets.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/users.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/newsletters.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/search-index.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (19)
  • ghost/core/test/e2e-api/admin/activity-feed.test.js (5 hunks)
  • ghost/core/test/e2e-api/admin/newsletters.test.js (12 hunks)
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js (4 hunks)
  • ghost/core/test/e2e-api/admin/search-index.test.js (2 hunks)
  • ghost/core/test/e2e-api/admin/snippets.test.js (2 hunks)
  • ghost/core/test/e2e-api/admin/tags.test.js (2 hunks)
  • ghost/core/test/e2e-api/admin/users.test.js (1 hunks)
  • ghost/core/test/e2e-api/content/authors.test.js (1 hunks)
  • ghost/core/test/e2e-api/content/newsletters.test.js (2 hunks)
  • ghost/core/test/e2e-api/content/posts.test.js (6 hunks)
  • ghost/core/test/e2e-api/content/search-index.test.js (2 hunks)
  • ghost/core/test/e2e-api/content/tags.test.js (4 hunks)
  • ghost/core/test/integration/url_service.test.js (5 hunks)
  • ghost/core/test/legacy/api/admin/posts.test.js (3 hunks)
  • ghost/core/test/legacy/api/content/posts.test.js (6 hunks)
  • ghost/core/test/legacy/api/content/tags.test.js (1 hunks)
  • ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js (1 hunks)
  • ghost/core/test/legacy/models/model_posts.test.js (2 hunks)
  • ghost/core/test/utils/fixtures/data-generator.js (11 hunks)
✅ Files skipped from review due to trivial changes (1)
  • ghost/core/test/e2e-api/content/search-index.test.js
🚧 Files skipped from review as they are similar to previous changes (8)
  • ghost/core/test/e2e-api/admin/search-index.test.js
  • ghost/core/test/legacy/api/admin/posts.test.js
  • ghost/core/test/e2e-api/content/tags.test.js
  • ghost/core/test/legacy/mock-express-style/api-vs-frontend.test.js
  • ghost/core/test/e2e-api/content/newsletters.test.js
  • ghost/core/test/legacy/api/content/posts.test.js
  • ghost/core/test/e2e-api/admin/snippets.test.js
  • ghost/core/test/e2e-api/admin/activity-feed.test.js
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: mike182uk
Repo: TryGhost/Ghost PR: 22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in the Ghost ActivityPub module are covered by tests in the file `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`.
📚 Learning: 2025-11-24T17:29:43.865Z
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-11-24T17:29:43.865Z
Learning: Applies to e2e/**/*.test.ts : Use factory pattern for all test data creation instead of hard-coded data or direct database manipulation

Applied to files:

  • ghost/core/test/e2e-api/content/posts.test.js
📚 Learning: 2025-05-29T10:37:26.369Z
Learnt from: ErisDS
Repo: TryGhost/Ghost PR: 23588
File: ghost/core/test/e2e-api/admin/backup.test.js:136-148
Timestamp: 2025-05-29T10:37:26.369Z
Learning: In the Ghost test framework, when testing CSV exports via the admin API, the response `body` field is empty while the actual CSV data is provided through the `text` field. Tests should use `expectEmptyBody()` and then validate the CSV content via `.expect(({text}) => ...)` - this is not contradictory behavior.

Applied to files:

  • ghost/core/test/e2e-api/content/posts.test.js
  • ghost/core/test/e2e-api/admin/posts-legacy.test.js
📚 Learning: 2025-09-11T07:31:40.433Z
Learnt from: aileen
Repo: TryGhost/Ghost PR: 24879
File: apps/admin-x-settings/src/hooks/useLimiter.tsx:125-125
Timestamp: 2025-09-11T07:31:40.433Z
Learning: In apps/admin-x-settings/src/hooks/useLimiter.tsx, the useMemo dependency array intentionally includes the entire `config` object rather than just `config.hostSettings?.limits` to enforce re-renders when anything in the config changes, particularly for subscription/plan change scenarios.

Applied to files:

  • ghost/core/test/e2e-api/admin/newsletters.test.js
📚 Learning: 2025-08-11T19:37:41.029Z
Learnt from: kevinansfield
Repo: TryGhost/Ghost PR: 24651
File: ghost/core/test/integration/services/q-email-addresses.test.js:138-142
Timestamp: 2025-08-11T19:37:41.029Z
Learning: In Ghost's test suite, prefer explicit cleanup calls (like `configUtils.restore()`) in test teardown even when they might be called by other utilities (like `urlUtils.restore()`), as this improves test readability and prevents issues if test dependencies change in the future.

Applied to files:

  • ghost/core/test/integration/url_service.test.js
🧬 Code graph analysis (4)
ghost/core/test/e2e-api/content/posts.test.js (1)
ghost/core/test/unit/server/data/schema/fixtures/fixture-manager.test.js (1)
  • fixtureManager (9-9)
ghost/core/test/e2e-api/content/authors.test.js (8)
ghost/core/test/e2e-api/admin/activity-feed.test.js (1)
  • assert (4-4)
ghost/core/test/e2e-api/admin/newsletters.test.js (1)
  • assert (1-1)
ghost/core/test/e2e-api/admin/search-index.test.js (1)
  • assert (3-3)
ghost/core/test/e2e-api/admin/users.test.js (1)
  • assert (1-1)
ghost/core/test/e2e-api/content/posts.test.js (1)
  • assert (1-1)
ghost/core/test/e2e-api/content/search-index.test.js (1)
  • assert (1-1)
ghost/core/test/e2e-api/content/tags.test.js (1)
  • assert (1-1)
ghost/core/test/unit/server/services/update-check.test.js (1)
  • assert (6-6)
ghost/core/test/e2e-api/admin/tags.test.js (1)
ghost/core/test/e2e-api/content/tags.test.js (2)
  • config (7-7)
  • should (2-2)
ghost/core/test/e2e-api/admin/newsletters.test.js (1)
ghost/core/test/e2e-api/content/newsletters.test.js (1)
  • newsletterSnapshot (3-8)
🔇 Additional comments (12)
ghost/core/test/e2e-api/admin/users.test.js (1)

101-117: User post-count expectation updated to 10 looks correct

The count.posts: 10 assertion for the owner user is consistent with the expanded fixtures and the increased authored-post counts exercised elsewhere in this PR. No further changes needed here.

ghost/core/test/legacy/api/content/tags.test.js (1)

45-56: Tag list size and pagination total correctly reflect extra tag

Updating the expected tag array length to 5 and pagination.total to 57 aligns with the new tag fixture while keeping pages/limits unchanged. The rest of the count/posts checks remain coherent.

ghost/core/test/e2e-api/content/authors.test.js (1)

52-88: joe‑bloggs post-count assertion updated to match fixtures

The count.posts === 6 expectation for joe-bloggs is consistent with the expanded post fixtures while keeping other author counts unchanged. The helper mustFind still gives clear failure messages.

ghost/core/test/legacy/models/model_posts.test.js (1)

129-135: findPage expectations updated for larger post set

The data.length expectations of 110 for limit: 'all' and 11 on page 2 of the tags:injection filter correctly reflect the two additional posts introduced by the fixtures. The surrounding pagination metadata and flow are unchanged.

Also applies to: 157-169

ghost/core/test/e2e-api/content/posts.test.js (1)

69-71: Snapshot lengths updated to 13 posts across tests

All matchBodySnapshot expectations that construct posts: new Array(13).fill(...) (plain list, formats, field-restricted, author-filtered, includes, and cross-origin) are in sync with the new 13‑post fixture set and keep using the existing matchers (postMatcher / postMatcherShallowIncludes). No further changes needed.

Also applies to: 103-104, 111-113, 176-177, 218-220, 233-235

ghost/core/test/e2e-api/admin/newsletters.test.js (1)

64-64: LGTM! Consistent test updates for expanded fixtures.

All newsletter count expectations have been correctly updated from 3→4 active newsletters (and 4→5 total) to align with the new fixture data. The test logic is preserved correctly, including the scenario at line 534 where the count drops to 3 after archiving a newsletter in the previous test.

Also applies to: 91-91, 327-327, 332-332, 335-335, 346-346, 359-359, 376-376, 383-383, 402-402, 409-409, 433-433, 458-458, 483-483, 503-503, 510-510, 534-534

ghost/core/test/utils/fixtures/data-generator.js (6)

96-216: LGTM! Comprehensive media fixtures for CDN URL testing.

The new posts provide excellent coverage for URL transformation testing across all media types (images, galleries, files, videos, audio) in both Mobiledoc and Lexical formats. The inclusion of embedded snippet content tests nested URL transformations, which is valuable for the stated objective of testing CDN URLs.

Also applies to: 217-592


622-630: LGTM! Tag fixtures extended for image URL testing.

The new tag correctly adds coverage for URL transformations in tag metadata, including feature_image and social media images (og_image, twitter_image).


953-971: LGTM! New newsletter fixture aligns with test expectations.

The fourth active newsletter is properly structured and includes a header_image with the GHOST_URL placeholder for URL transformation testing. This correctly supports the updated test expectations in newsletters.test.js.


1398-1447: LGTM! Snippet fixtures provide comprehensive reusable media content.

The new snippets correctly mirror the media type coverage from the posts, providing test coverage for URL transformations in reusable content blocks. Both Mobiledoc and Lexical formats are properly structured.

Also applies to: 1449-1623


2164-2166: LGTM! Relational data correctly wired for new fixtures.

All relational tables (posts_meta, posts_tags, posts_authors) and array expansions correctly reference the new entity IDs. The posts_meta entries appropriately add og_image and twitter_image for social media URL transformation testing.

Also applies to: 2174-2175, 2292-2303, 2345-2356, 2472-2483, 2600-2601, 2734-2736


2717-2717: Good improvement! Dynamic array indexing.

Replacing the hardcoded modulo value with members.length makes the code more maintainable and prevents potential index errors if the members array size changes in the future.

Also applies to: 2726-2726

@vershwal vershwal requested a review from allouis December 8, 2025 12:35
@vershwal vershwal merged commit d9e0162 into main Dec 10, 2025
39 checks passed
@vershwal vershwal deleted the hitests branch December 10, 2025 07:50
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.

3 participants