Skip to content

Conversation

9larsons
Copy link
Contributor

@9larsons 9larsons commented Oct 9, 2025

ref ecb0f3d

  • updated tags tests to improve resiliency

A few tests were failing locally. Specifically, the save action was occurring too quickly for the remaining actions in some tests.

@github-actions github-actions bot added the community [triage] Community features and bugs label Oct 9, 2025
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

TagEditorPage: save() now waits for the save button to enter "running" then "success" states after clicking save. TagsPage: added a pageGotoOptions import and a new async goto(url?: string, options?: pageGotoOptions) method that calls super.goto and then waits for the page to fully load; waitForPageToFullyLoad was simplified to wait for navigation with domcontentloaded (removed previous DOM/content visibility racing checks). Tests: reused a cached newTagRow element in multiple assertions, adjusted waits after delete flows to explicitly wait for page content visibility, and replaced one editor navigation with a direct page.goto('/ghost/#/tags/unknown'); other whitespace/navigation tweaks only.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Reduced flakiness of tags e2e tests” succinctly and accurately captures the primary change of improving test reliability for the tags end-to-end suite, directly reflecting the synchronization and wait enhancements introduced.
Description Check ✅ Passed The description references the relevant commit, explains that tags e2e tests were updated to improve resiliency, and notes the root cause of flakiness, demonstrating clear alignment with the actual changes in the tests and helpers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 less-flake-tag-tests

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f67248a and 44df7f3.

📒 Files selected for processing (2)
  • e2e/helpers/pages/admin/tags/TagEditorPage.ts (2 hunks)
  • e2e/helpers/pages/admin/tags/TagsPage.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
e2e/helpers/pages/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/helpers/pages/**/*.ts: Follow ADR-0002 (use Page Objects) and keep page objects in helpers/pages/
Expose locators in page objects as public readonly when used with assertions in tests
Use semantic action method names in page objects (e.g., login()) rather than click* details
Use waitFor() for guards in page objects; never use expect() inside page objects
Do not place assertions in page objects

Files:

  • e2e/helpers/pages/admin/tags/TagsPage.ts
  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
e2e/{tests,helpers/pages}/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/{tests,helpers/pages}/**/*.ts: Use only semantic locators (getByRole/getByLabel/getByText); fallback to data-testid; never use CSS/XPath/nth-child/class names
Do not use hard-coded waits (waitForTimeout)
Do not use networkidle in waits

Files:

  • e2e/helpers/pages/admin/tags/TagsPage.ts
  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
e2e/**

📄 CodeRabbit inference engine (AGENTS.md)

End-to-end tests should live under the e2e/ directory (Playwright-based)

Files:

  • e2e/helpers/pages/admin/tags/TagsPage.ts
  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
🧠 Learnings (2)
📚 Learning: 2025-10-08T14:20:28.632Z
Learnt from: CR
PR: TryGhost/Ghost#0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-10-08T14:20:28.632Z
Learning: Applies to e2e/{tests,helpers/pages}/**/*.ts : Do not use networkidle in waits

Applied to files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
📚 Learning: 2025-10-08T14:20:28.632Z
Learnt from: CR
PR: TryGhost/Ghost#0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-10-08T14:20:28.632Z
Learning: Applies to e2e/{tests,helpers/pages}/**/*.ts : Do not use hard-coded waits (waitForTimeout)

Applied to files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
🧬 Code graph analysis (1)
e2e/helpers/pages/admin/tags/TagsPage.ts (1)
e2e/helpers/pages/BasePage.ts (1)
  • pageGotoOptions (5-9)
⏰ 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). (4)
  • GitHub Check: Inspect Docker Image
  • GitHub Check: E2E Tests (Shard 2/2)
  • GitHub Check: E2E Tests (Shard 1/2)
  • GitHub Check: Unit tests (Node 22.13.1)
🔇 Additional comments (3)
e2e/helpers/pages/admin/tags/TagEditorPage.ts (1)

64-70: LGTM! Excellent fix for the networkidle violation.

The new state-based synchronization approach correctly waits for the save button to transition through "running" and "success" states, eliminating the previous networkidle violation while providing deterministic waits. This directly addresses the PR objective of reducing flakiness.

e2e/helpers/pages/admin/tags/TagsPage.ts (2)

53-56: LGTM! Clean navigation helper.

The goto() override properly extends parent navigation by adding page-specific load waits, improving test reliability. The pattern is clean and follows page object best practices.


58-60: LGTM! Simplified and compliant.

The streamlined implementation correctly uses domcontentloaded instead of networkidle, adhering to coding guidelines while maintaining proper page load synchronization.


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
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3be542a and c7fa053.

📒 Files selected for processing (3)
  • e2e/helpers/pages/admin/tags/TagEditorPage.ts (1 hunks)
  • e2e/helpers/pages/admin/tags/TagsPage.ts (2 hunks)
  • e2e/tests/admin/tags/editor.test.ts (6 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
e2e/helpers/pages/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/helpers/pages/**/*.ts: Follow ADR-0002 (use Page Objects) and keep page objects in helpers/pages/
Expose locators in page objects as public readonly when used with assertions in tests
Use semantic action method names in page objects (e.g., login()) rather than click* details
Use waitFor() for guards in page objects; never use expect() inside page objects
Do not place assertions in page objects

Files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
  • e2e/helpers/pages/admin/tags/TagsPage.ts
e2e/{tests,helpers/pages}/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/{tests,helpers/pages}/**/*.ts: Use only semantic locators (getByRole/getByLabel/getByText); fallback to data-testid; never use CSS/XPath/nth-child/class names
Do not use hard-coded waits (waitForTimeout)
Do not use networkidle in waits

Files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
  • e2e/helpers/pages/admin/tags/TagsPage.ts
  • e2e/tests/admin/tags/editor.test.ts
e2e/**

📄 CodeRabbit inference engine (AGENTS.md)

End-to-end tests should live under the e2e/ directory (Playwright-based)

Files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
  • e2e/helpers/pages/admin/tags/TagsPage.ts
  • e2e/tests/admin/tags/editor.test.ts
e2e/tests/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/tests/**/*.ts: Follow ADR-0001 (AAA pattern) in all test files
Test suite titles should follow: 'Ghost Admin - Feature' or 'Ghost Public - Feature'
Test names should be 'what is tested - expected outcome' in lowercase
One test equals one scenario; do not mix multiple scenarios in a single test
Keep all assertions in test files (not in page objects)
Use the Factory Pattern for all test data via data-factory (e.g., createPostFactory)
Do not include multiple scenarios in a single test
Do not perform manual login in tests (auto-auth via fixture)

Files:

  • e2e/tests/admin/tags/editor.test.ts
e2e/tests/admin/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

Admin area end-to-end tests should reside under tests/admin/

Files:

  • e2e/tests/admin/tags/editor.test.ts
🧬 Code graph analysis (2)
e2e/helpers/pages/admin/tags/TagsPage.ts (1)
e2e/helpers/pages/BasePage.ts (1)
  • pageGotoOptions (5-9)
e2e/tests/admin/tags/editor.test.ts (2)
e2e/helpers/pages/admin/tags/TagsPage.ts (1)
  • TagsPage (5-67)
e2e/helpers/pages/admin/tags/TagEditorPage.ts (1)
  • TagEditorPage (4-82)
⏰ 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). (2)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Build & Push
🔇 Additional comments (5)
e2e/helpers/pages/admin/tags/TagsPage.ts (1)

53-66: LGTM! Well-structured synchronization improvements.

The new goto method properly delegates to the base implementation and ensures a full page load before proceeding. The enhanced waitForPageToFullyLoad method uses domcontentloaded (which complies with guidelines), verifies content visibility, and elegantly handles both populated and empty states via Promise.race. This should significantly reduce test flakiness.

e2e/tests/admin/tags/editor.test.ts (4)

15-18: LGTM! Element caching reduces flakiness.

Storing the newTagRow element and reusing it for multiple assertions is a good practice that prevents stale element issues and reduces repeated DOM queries.


41-43: LGTM! Consistent element caching pattern.

Same beneficial element caching pattern applied here as in the earlier test.


77-77: LGTM! Improved synchronization in delete flows.

The updated wait patterns properly ensure the page is fully loaded after delete operations, which should reduce timing-related flakiness.

Also applies to: 93-94


109-109: LGTM! Direct navigation for 404 test is appropriate.

Using page.goto directly for the non-existent tag test is cleaner than going through the page object, as the intent is to trigger a 404 response rather than simulate user navigation.

Copy link
Collaborator

cmraible commented Oct 9, 2025

Can confirm this has addressed the flakiness locally. I've got a few small tweaks to make, I'll just push them here in a few if you don't mind?

Copy link

axolo-co bot commented Oct 9, 2025

9larsons commented:
Have at it!

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)
e2e/helpers/pages/admin/tags/TagEditorPage.ts (1)

1-1: Remove unused expect import.

The expect import is not used in this file and should be removed. Additionally, per the coding guidelines, page objects should not use expect() for assertions.

As per coding guidelines.

Apply this diff to remove the unused import:

-import {expect, Locator, Page} from '@playwright/test';
+import {Locator, Page} from '@playwright/test';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7fa053 and f67248a.

📒 Files selected for processing (1)
  • e2e/helpers/pages/admin/tags/TagEditorPage.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
e2e/helpers/pages/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/helpers/pages/**/*.ts: Follow ADR-0002 (use Page Objects) and keep page objects in helpers/pages/
Expose locators in page objects as public readonly when used with assertions in tests
Use semantic action method names in page objects (e.g., login()) rather than click* details
Use waitFor() for guards in page objects; never use expect() inside page objects
Do not place assertions in page objects

Files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
e2e/{tests,helpers/pages}/**/*.ts

📄 CodeRabbit inference engine (e2e/AGENTS.md)

e2e/{tests,helpers/pages}/**/*.ts: Use only semantic locators (getByRole/getByLabel/getByText); fallback to data-testid; never use CSS/XPath/nth-child/class names
Do not use hard-coded waits (waitForTimeout)
Do not use networkidle in waits

Files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
e2e/**

📄 CodeRabbit inference engine (AGENTS.md)

End-to-end tests should live under the e2e/ directory (Playwright-based)

Files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
🧠 Learnings (3)
📚 Learning: 2025-10-08T14:20:28.632Z
Learnt from: CR
PR: TryGhost/Ghost#0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-10-08T14:20:28.632Z
Learning: Applies to e2e/{tests,helpers/pages}/**/*.ts : Do not use networkidle in waits

Applied to files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
📚 Learning: 2025-10-08T14:20:28.632Z
Learnt from: CR
PR: TryGhost/Ghost#0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-10-08T14:20:28.632Z
Learning: Applies to e2e/{tests,helpers/pages}/**/*.ts : Do not use hard-coded waits (waitForTimeout)

Applied to files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
📚 Learning: 2025-10-08T14:20:28.632Z
Learnt from: CR
PR: TryGhost/Ghost#0
File: e2e/AGENTS.md:0-0
Timestamp: 2025-10-08T14:20:28.632Z
Learning: Applies to e2e/helpers/pages/**/*.ts : Expose locators in page objects as public readonly when used with assertions in tests

Applied to files:

  • e2e/helpers/pages/admin/tags/TagEditorPage.ts
🪛 ESLint
e2e/helpers/pages/admin/tags/TagEditorPage.ts

[error] 1-1: 'expect' is defined but never used.

(@typescript-eslint/no-unused-vars)

⏰ 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). (2)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Build & Push
🔇 Additional comments (1)
e2e/helpers/pages/admin/tags/TagEditorPage.ts (1)

64-70: Excellent improvement to save synchronization!

The new implementation properly waits for the save button to transition through "running" and "success" states, which is a much more robust approach than the previous networkidle wait. This directly addresses the flakiness issues mentioned in the PR objectives and follows the coding guidelines by using waitFor() guards instead of prohibited patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community [triage] Community features and bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants