close
Skip to content

Made fake automations database more realistic#27779

Merged
EvanHahn merged 1 commit intomainfrom
automations-temporary-fake-database-more-realistic
May 8, 2026
Merged

Made fake automations database more realistic#27779
EvanHahn merged 1 commit intomainfrom
automations-temporary-fake-database-more-realistic

Conversation

@EvanHahn
Copy link
Copy Markdown
Contributor

@EvanHahn EvanHahn commented May 7, 2026

ref https://linear.app/ghost/issue/NY-1260
towards https://linear.app/ghost/issue/NY-1265

Several improvements:

  • Uses more realistic IDs across the board
  • Revisions now have email_design_setting_id set
  • Uses TEXT timestamps, matching what we do in the real database
  • Attach more realistic Lexical data
  • Uses prepared statements that are easier to read/edit
  • API now exists to get a singleton, or create a new database from scratch

ref https://linear.app/ghost/issue/NY-1260
towards https://linear.app/ghost/issue/NY-1265

Several improvements:

- Uses more realistic IDs across the board
- Revisions now have `email_design_setting_id` set
- Uses TEXT timestamps, matching what we do in the real database
- Attach more realistic Lexical data
- Uses prepared statements that are easier to read/edit
- API now exists to get a singleton, or create a new database from
  scratch
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

Walkthrough

The temporary automations database module was refactored from hard-coded test fixtures to dynamically generated test data with deferred initialization. The schema now includes automation_runs and automation_run_steps tables with text-based timestamps. ID and timestamp generation logic was moved to runtime helpers, and seed data is now constructed programmatically via prepared statements, populating two automations with four actions each, revisions, and edge relationships. The export pattern changed from eager initialization to a cached lazy getter that enforces development environment access and throws IncorrectUsageError if accessed outside development mode.

Possibly related PRs

  • TryGhost/Ghost#27733: Directly modifies the same temporary automations database module and exported interfaces.

Suggested reviewers

  • cmraible
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Made fake automations database more realistic' directly and clearly summarizes the main change: improving the realism of the temporary fake automations database used in development.
Description check ✅ Passed The description provides detailed context about improvements made to the fake automations database, including specific enhancements like realistic IDs, TEXT timestamps, Lexical data, and API changes, all directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 automations-temporary-fake-database-more-realistic

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.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
ghost/core/core/server/services/automations/temporary-fake-database.js (1)

27-42: ⚡ Quick win

fakeLexical is missing standard Lexical node fields — may cause rendering failures in development.

The paragraph and text nodes omit several properties that Lexical (and Ghost's Lexical-to-HTML serializer) typically expects on every node. If any real Lexical processing code encounters this payload during development testing, it could throw or produce unexpected output.

Standard required fields:

  • Paragraph node: direction, format, indent, version
  • Text node: detail, format, mode, style, version
✨ Proposed fix with complete Lexical node shape
     const fakeLexical = JSON.stringify({
         root: {
             children: [{
                 type: 'paragraph',
+                direction: 'ltr',
+                format: '',
+                indent: 0,
+                version: 1,
                 children: [{
                     type: 'text',
-                    text: 'Lorem ipsum.'
+                    text: 'Lorem ipsum.',
+                    detail: 0,
+                    format: 0,
+                    mode: 'normal',
+                    style: '',
+                    version: 1
                 }]
             }],
             direction: null,
             format: '',
             indent: 0,
             type: 'root',
             version: 1
         }
     });
🤖 Prompt for 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.

In `@ghost/core/core/server/services/automations/temporary-fake-database.js`
around lines 27 - 42, fakeLexical currently builds Lexical JSON with paragraph
and text nodes missing required node fields which can break serializers; update
the fakeLexical object (the constant named fakeLexical) so the paragraph node
includes direction, format, indent, version and the text node includes detail,
format, mode, style, version (and keep existing type/text fields) to match
standard Lexical node shape used by Ghost's Lexical-to-HTML serializer; ensure
the final value remains JSON.stringify(...) of the fully populated root object.
🤖 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.

Nitpick comments:
In `@ghost/core/core/server/services/automations/temporary-fake-database.js`:
- Around line 27-42: fakeLexical currently builds Lexical JSON with paragraph
and text nodes missing required node fields which can break serializers; update
the fakeLexical object (the constant named fakeLexical) so the paragraph node
includes direction, format, indent, version and the text node includes detail,
format, mode, style, version (and keep existing type/text fields) to match
standard Lexical node shape used by Ghost's Lexical-to-HTML serializer; ensure
the final value remains JSON.stringify(...) of the fully populated root object.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 17b71856-6b4f-4d6a-ad22-303bad3b8c17

📥 Commits

Reviewing files that changed from the base of the PR and between e1cd50f and 1ceecfc.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/automations/temporary-fake-database.js

@EvanHahn EvanHahn merged commit 61763f7 into main May 8, 2026
44 checks passed
@EvanHahn EvanHahn deleted the automations-temporary-fake-database-more-realistic branch May 8, 2026 12:19
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.

2 participants