Consolidated custom views e2e tests into flow-based tests#27066
Consolidated custom views e2e tests into flow-based tests#27066
Conversation
Restructured 17 fine-grained tests into 6 flow-based tests that each walk through a complete user journey. Every assertion from the original tests is preserved — create+color+active state, navigation between views, rename+recolor, delete with remainder check, validation error, and persistence after reload.
WalkthroughThe test file for custom views was restructured to reduce complexity and coverage scope. PostFactory usage was removed entirely, with tests now relying only on TagFactory for prerequisites. Multiple nested test groups were collapsed into fewer top-level tests. Assertions were updated to validate sidebar state using 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@e2e/tests/admin/posts/custom-views.test.ts`:
- Around line 37-39: The test currently only asserts the URL contains type=draft
after clicking sidebar.getNavLink('Featured Drafts') but doesn't verify the
restored tag; update the assertion to also check the tag query param or the UI
selected tag filter. Specifically, after await sidebar.getNavLink('Featured
Drafts').click(), add an assertion on page.url() or toHaveURL() that includes
the expected tag query param (e.g., /type=draft.*tag=Featured/) or assert the
tag filter element (the selected tag control accessed via the existing sidebar
or page locators) shows the "Featured" tag is selected so the saved tag is
re-validated.
- Around line 33-39: The test block mixes multiple scenarios (revisit/restore,
navigation activation) in one case — split each scenario into its own test
following "what is tested - expected outcome" lowercase naming and AAA
structure: create separate tests that individually exercise
sidebar.getNavLink('Posts').click() then assert restore behavior, and another
that clicks sidebar.getNavLink('Featured Drafts') and asserts await
expect(page).toHaveURL(/type=draft/) and await
expect(sidebar.getNavLink('Featured
Drafts')).toHaveAttribute('aria-current','page'); ensure each new test only
contains Arrange (setup), Act (single user action like click or delete), and
Assert steps and apply the same refactor for the other ranges (85-93, 122-129,
179-189) so failures don’t block later scenarios.
🪄 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: 6059f15a-f63f-403b-a4ca-47caba9567dd
📒 Files selected for processing (1)
e2e/tests/admin/posts/custom-views.test.ts
| // Navigate away and back — filters should be restored | ||
| await sidebar.getNavLink('Posts').click(); | ||
| await expect(sidebar.getNavLink('Featured Drafts')).not.toHaveAttribute('aria-current', 'page'); | ||
|
|
||
| await sidebar.getNavLink('Featured Drafts').click(); | ||
| await expect(page).toHaveURL(/type=draft/); | ||
| await expect(sidebar.getNavLink('Featured Drafts')).toHaveAttribute('aria-current', 'page'); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Break these follow-on flows into separate tests.
Each of these ranges starts a second scenario after the first one is already asserted: revisit/restore after create, filter-driven activation after click navigation, recolor after rename, and active-view redirect after deleting another view. That makes the later coverage disappear whenever the earlier half fails.
As per coding guidelines, Test names should follow 'what is tested - expected outcome' format in lowercase, with one test = one scenario (never mix multiple scenarios) and Use the AAA (Arrange-Act-Assert) pattern for test structure.
Also applies to: 85-93, 122-129, 179-189
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@e2e/tests/admin/posts/custom-views.test.ts` around lines 33 - 39, The test
block mixes multiple scenarios (revisit/restore, navigation activation) in one
case — split each scenario into its own test following "what is tested -
expected outcome" lowercase naming and AAA structure: create separate tests that
individually exercise sidebar.getNavLink('Posts').click() then assert restore
behavior, and another that clicks sidebar.getNavLink('Featured Drafts') and
asserts await expect(page).toHaveURL(/type=draft/) and await
expect(sidebar.getNavLink('Featured
Drafts')).toHaveAttribute('aria-current','page'); ensure each new test only
contains Arrange (setup), Act (single user action like click or delete), and
Assert steps and apply the same refactor for the other ranges (85-93, 122-129,
179-189) so failures don’t block later scenarios.
| await sidebar.getNavLink('Featured Drafts').click(); | ||
| await expect(page).toHaveURL(/type=draft/); | ||
| await expect(sidebar.getNavLink('Featured Drafts')).toHaveAttribute('aria-current', 'page'); |
There was a problem hiding this comment.
Re-assert the saved tag when returning to the view.
This only proves that type=draft came back. If the Featured tag stops being restored, the test still passes. Assert the tag query param or selected tag filter as well.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@e2e/tests/admin/posts/custom-views.test.ts` around lines 37 - 39, The test
currently only asserts the URL contains type=draft after clicking
sidebar.getNavLink('Featured Drafts') but doesn't verify the restored tag;
update the assertion to also check the tag query param or the UI selected tag
filter. Specifically, after await sidebar.getNavLink('Featured Drafts').click(),
add an assertion on page.url() or toHaveURL() that includes the expected tag
query param (e.g., /type=draft.*tag=Featured/) or assert the tag filter element
(the selected tag control accessed via the existing sidebar or page locators)
shows the "Featured" tag is selected so the saved tag is re-validated.


no ref
Restructured
custom-views.test.tsfrom 17 fine-grained single-assertion tests into 6 flow-based tests that each walk through a complete user journey.Before: 17 tests, each paying full setup cost (create tag, navigate to posts, apply filter, save view) for one assertion.
After: 6 tests that mirror real user journeys:
Every assertion from the original 17 tests is preserved. The file goes from 460 lines to 210 lines.
Test plan