Made fake automations database more realistic#27779
Conversation
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
WalkthroughThe 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
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/server/services/automations/temporary-fake-database.js (1)
27-42: ⚡ Quick win
fakeLexicalis 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
📒 Files selected for processing (1)
ghost/core/core/server/services/automations/temporary-fake-database.js
ref https://linear.app/ghost/issue/NY-1260
towards https://linear.app/ghost/issue/NY-1265
Several improvements:
email_design_setting_idset