Skip to content

fix: improve visibility checks and remove unnecessary load state…#8037

Merged
mikeallisonJS merged 3 commits intomainfrom
00-00-MA-fix-e2e-timeouts-waitforloadstate
Oct 22, 2025
Merged

fix: improve visibility checks and remove unnecessary load state…#8037
mikeallisonJS merged 3 commits intomainfrom
00-00-MA-fix-e2e-timeouts-waitforloadstate

Conversation

@mikeallisonJS
Copy link
Collaborator

@mikeallisonJS mikeallisonJS commented Oct 21, 2025

… waits in journey and card level actions

Summary by CodeRabbit

  • Tests
    • Improved automated test reliability by replacing generic load waits with explicit visibility checks for specific UI elements.
    • Made selectors more precise and adjusted element-targeting order to match current page structure and handle shifting elements.
    • Removed redundant waits and extended timeouts for complex interactions to reduce flakiness.
    • Strengthened navigation steps with more robust locators and viewport assertions for content visibility.

@mikeallisonJS mikeallisonJS requested a review from tanflem October 21, 2025 21:24
@mikeallisonJS mikeallisonJS self-assigned this Oct 21, 2025
@mikeallisonJS mikeallisonJS changed the title refactor: improve visibility checks and remove unnecessary load state… fix: improve visibility checks and remove unnecessary load state… Oct 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

Replaces generic page load-state waits with explicit visibility waits and more specific locators for journey card/button/frame interactions in E2E page objects and tests; updates element targeting order (.first() → .last()) and refines error-handling flows and click timing.

Changes

Cohort / File(s) Summary
Card-level action helpers
apps/journeys-admin-e2e/src/pages/card-level-actions.ts
Replaced load-state waits with explicit visibility waits for card image containers and background-image elements; added scoped frame locators; changed some targets from .first() to .last(); removed redundant waitForLoadState('load'); adjusted catch blocks and forceful click/timeouts.
Journey page helpers
apps/journeys-admin-e2e/src/pages/journey-page.ts
Replaced waitForLoadState('load') with visibility waits for specific UI elements (custom journey button, overlay image container within frame); increased timeouts (60–150s) before interactions.
E2E navigation/spec
apps/journeys-e2e/src/e2e/journeys.spec.ts
Replaced raw anchor click with an href/role-based locator and explicit visibility wait for the "Fact or Fiction" entry; preserved subsequent navigation assertions while improving locator stability.
Manifest
package.json
Listed as part of the diff (no exported/public signature changes detected).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as E2E Test
    participant PageObj as Page Object
    participant Frame as Browser Frame
    participant Element as UI Element

    Note over Test,PageObj #D6EAF8: High-level test action triggers page-object method
    Test->>PageObj: clickOnJourneyCard()/clickCreateCustomJourney()
    PageObj->>Frame: locate frame -> wait for specific element visible (timeout)
    Frame->>Element: overlay-image / background-image becomes visible
    PageObj->>Element: click (force/with timeout)
    Element-->>PageObj: click result / navigation
    PageObj-->>Test: return
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • kiran-redhat
  • tataihono

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix: improve visibility checks and remove unnecessary load state…" is directly related to the main changes in the changeset. The raw summary confirms that the PR replaces generic waitForLoadState calls with explicit visibility waits and targeted element locators across card-level actions, journey pages, and e2e tests. The title accurately captures both key objectives: improving visibility checks and removing unnecessary load state waits. The phrasing is concise and specific enough for a teammate to understand the primary focus when scanning the history.
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 00-00-MA-fix-e2e-timeouts-waitforloadstate

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 90e7600 and c9d46d1.

📒 Files selected for processing (1)
  • apps/journeys-e2e/src/e2e/journeys.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/journeys-e2e/src/e2e/journeys.spec.ts
⏰ 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). (3)
  • GitHub Check: Deploy Preview (journeys, 8037/merge, pull_request, 22)
  • GitHub Check: Deploy Preview (journeys-admin, 8037/merge, pull_request, 22)
  • GitHub Check: lint (22)

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.

@nx-cloud
Copy link

nx-cloud bot commented Oct 21, 2025

View your CI Pipeline Execution ↗ for commit c9d46d1

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 40s View ↗
nx run journeys-e2e:e2e ✅ Succeeded 16s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 10s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
nx run-many --target=deploy --projects=journeys ✅ Succeeded 43s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 12s View ↗
nx run-many --target=deploy --projects=journeys... ✅ Succeeded 53s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-22 16:22:46 UTC

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)
apps/journeys-admin-e2e/src/pages/journey-page.ts (1)

246-253: Remove redundant visibility check.

Lines 246-248 and 249-253 both wait for the same button to be visible with the same 150-second timeout. The waitFor() call already ensures the element is visible, making the subsequent expect().toBeVisible() redundant.

Apply this diff to remove the redundancy:

     await this.page
       .locator('div[data-testid="JourneysAdminContainedIconButton"] button')
       .waitFor({ state: 'visible', timeout: 150000 })
-    await expect(
-      this.page.locator(
-        'div[data-testid="JourneysAdminContainedIconButton"] button'
-      )
-    ).toBeVisible({ timeout: 150000 })
apps/journeys-admin-e2e/src/pages/card-level-actions.ts (1)

199-206: Remove redundant visibility check.

Lines 200-202 and 203-205 both wait for the same StrategyItem button to be visible with the same timeout. The waitFor() call already ensures visibility, making the subsequent expect().toBeVisible() redundant.

Apply this diff to remove the redundancy:

+  async waitUntilJourneyCardLoaded() {
     await this.page
       .locator('div[data-testid="StrategyItem"] button')
       .waitFor({ state: 'visible', timeout: sixtySecondsTimeout })
-    await expect(
-      this.page.locator('div[data-testid="StrategyItem"] button')
-    ).toBeVisible({ timeout: sixtySecondsTimeout })
   }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6ca6437 and 0c9daf9.

📒 Files selected for processing (3)
  • apps/journeys-admin-e2e/src/pages/card-level-actions.ts (2 hunks)
  • apps/journeys-admin-e2e/src/pages/journey-page.ts (2 hunks)
  • apps/journeys-e2e/src/e2e/journeys.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names.
Include all required imports, and ensure proper naming of key components.

Files:

  • apps/journeys-admin-e2e/src/pages/journey-page.ts
  • apps/journeys-admin-e2e/src/pages/card-level-actions.ts
  • apps/journeys-e2e/src/e2e/journeys.spec.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

Define a type if possible.

Files:

  • apps/journeys-admin-e2e/src/pages/journey-page.ts
  • apps/journeys-admin-e2e/src/pages/card-level-actions.ts
  • apps/journeys-e2e/src/e2e/journeys.spec.ts
apps/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/apps.mdc)

apps/**/*.{js,jsx,ts,tsx}: Always use MUI over HTML elements; avoid using CSS or tags.
Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.

Files:

  • apps/journeys-admin-e2e/src/pages/journey-page.ts
  • apps/journeys-admin-e2e/src/pages/card-level-actions.ts
  • apps/journeys-e2e/src/e2e/journeys.spec.ts
⏰ 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). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
apps/journeys-admin-e2e/src/pages/journey-page.ts (1)

1076-1088: LGTM! Improved synchronization for frame interactions.

The explicit visibility wait for the frame element before clicking ensures reliable interaction with nested iframe content, which is more robust than relying on generic load-state waits.

apps/journeys-e2e/src/e2e/journeys.spec.ts (2)

8-11: LGTM! Robust role-based locator improves test reliability.

Using getByRole with an explicit visibility wait is more resilient than direct selectors and aligns with accessibility best practices. This change improves test stability by ensuring the element is ready before interaction.


15-18: LGTM! Granular assertions improve test diagnostics.

Splitting the assertions provides clearer test feedback when failures occur, making it easier to identify which specific element is missing or not visible.

apps/journeys-admin-e2e/src/pages/card-level-actions.ts (3)

31-42: LGTM! Explicit visibility wait improves reliability.

Adding the visibility wait before clicking the card overlay ensures the frame content is fully loaded and interactive, which is more reliable than depending on generic page load states.


44-59: LGTM! Targeted selector for video card interactions.

The more specific selector targeting the background-image within the overlay is appropriate for video cards, and the explicit visibility wait ensures the element is ready before the forced click.


478-516: Verify the intentional change from .first() to .last() for element targeting.

This method uses .last() when selecting elements for deletion (lines 492, 509). While using .last() can avoid index shifting as elements are removed from the DOM, I cannot independently verify whether this represents a change from .first() or confirm the intended behavior. Additionally, the test that calls this method (Video - create, update & delete in card-level-actions.spec.ts) is marked as test.skip, so this code path is currently not actively tested.

Please confirm:

  • Whether this represents a change from .first() to .last()
  • That the deletion order is correct for your test scenarios and doesn't cause unintended side effects

@github-actions github-actions bot temporarily deployed to Preview - journeys October 21, 2025 21:31 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin October 21, 2025 21:31 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Thu Oct 23 05:19:03 NZDT 2025

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Thu Oct 23 05:18:48 NZDT 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)
apps/journeys-e2e/src/e2e/journeys.spec.ts (1)

18-18: Consider consolidating viewport assertions.

The separate assertion for JourneysTypography is clear but creates sequential viewport checks. If both elements must be visible together, consider combining them.

If consolidation is preferred:

  await expect(
    page.getByRole('heading', { name: 'Fact or Fiction' })
  ).toBeInViewport()
- await expect(page.getByTestId('JourneysTypography')).toBeInViewport()
+ await expect.soft(page.getByTestId('JourneysTypography')).toBeInViewport()

Or use Promise.all() for parallel checks:

await Promise.all([
  expect(page.getByRole('heading', { name: 'Fact or Fiction' })).toBeInViewport(),
  expect(page.getByTestId('JourneysTypography')).toBeInViewport()
])

However, keeping them separate provides clearer failure messages, so this is purely a performance micro-optimization.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0c9daf9 and 90e7600.

📒 Files selected for processing (1)
  • apps/journeys-e2e/src/e2e/journeys.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names.
Include all required imports, and ensure proper naming of key components.

Files:

  • apps/journeys-e2e/src/e2e/journeys.spec.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

Define a type if possible.

Files:

  • apps/journeys-e2e/src/e2e/journeys.spec.ts
apps/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/apps.mdc)

apps/**/*.{js,jsx,ts,tsx}: Always use MUI over HTML elements; avoid using CSS or tags.
Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.

Files:

  • apps/journeys-e2e/src/e2e/journeys.spec.ts
🧬 Code graph analysis (1)
apps/journeys-e2e/src/e2e/journeys.spec.ts (1)
apps/journeys-admin-e2e/src/fixtures/authenticated.ts (1)
  • expect (15-15)
⏰ 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). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/journeys-e2e/src/e2e/journeys.spec.ts (2)

15-17: Excellent use of semantic role-based selector.

Using getByRole('heading', { name: 'Fact or Fiction' }) is more accessible and follows Playwright best practices for semantic element targeting.


8-11: Explicit visibility wait improves test reliability.

The change from a generic load state wait to an explicit visibility wait on the href-based locator a[href="/fact-or-fiction"] is a solid improvement. Code search confirms this selector is unique in the codebase with no duplicates.

@github-actions github-actions bot temporarily deployed to Preview - journeys-admin October 21, 2025 23:17 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys October 21, 2025 23:17 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin October 22, 2025 16:15 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys October 22, 2025 16:15 Inactive
@mikeallisonJS mikeallisonJS added this pull request to the merge queue Oct 22, 2025
Merged via the queue into main with commit f602fe9 Oct 22, 2025
27 checks passed
@mikeallisonJS mikeallisonJS deleted the 00-00-MA-fix-e2e-timeouts-waitforloadstate branch October 22, 2025 16:29
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