PCI Sidebar: Fix multiple contact messages#4097
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughConsolidates credential gating in the Tools tab by moving per-panel Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 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)
src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx (1)
60-149: Add a regression test for the empty-credentials state.This fix depends on a specific UI combination. A sidebar test that asserts the credentials message renders once and the Boost Engagement button stays hidden would help keep it resolved.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx` around lines 60 - 149, Add a regression test that renders the SidebarToolsTab (or the component that contains VerifyCredentials / Boost Engagement) in the empty-credentials state and asserts the credentials message inside VerifyCredentials renders exactly once while the Boost Engagement button (identify by class "boost-engagement" or link text "Boost Engagement") is not present; use the same setup/context providers as the real sidebar (permissions with empty credentials, postId > 0 and isPostTrackable toggled appropriately) and use RTL queries (getByText/ queryByRole or querySelector('.boost-engagement')) to verify the message count and absence of the button so future changes to VerifyCredentials or Boost button visibility are covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx`:
- Around line 60-149: Add a regression test that renders the SidebarToolsTab (or
the component that contains VerifyCredentials / Boost Engagement) in the
empty-credentials state and asserts the credentials message inside
VerifyCredentials renders exactly once while the Boost Engagement button
(identify by class "boost-engagement" or link text "Boost Engagement") is not
present; use the same setup/context providers as the real sidebar (permissions
with empty credentials, postId > 0 and isPostTrackable toggled appropriately)
and use RTL queries (getByText/ queryByRole or
querySelector('.boost-engagement')) to verify the message count and absence of
the button so future changes to VerifyCredentials or Boost button visibility are
covered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e230071a-97b3-45ca-b86f-1795a299119d
⛔ Files ignored due to path filters (2)
build/content-helper/editor-sidebar.asset.phpis excluded by!build/**build/content-helper/editor-sidebar.jsis excluded by!build/**
📒 Files selected for processing (2)
src/content-helper/common/verify-credentials.tsxsrc/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx
Agent-Logs-Url: https://github.com/Parsely/wp-parsely/sessions/087c3a49-1a10-4e35-a546-4d04a150b6ed Co-authored-by: acicovic <23142906+acicovic@users.noreply.github.com>
Fix failing E2E tests for PR #4097
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/e2e/utils.ts`:
- Around line 85-98: The current logic treats a 3s wait failure on
relatedPostsButton as "panel absent", which misroutes selectors in slow CI;
replace the timeout-based visibility fallback by explicitly detecting
presence/visibility of relatedPostsButton (e.g., use relatedPostsButton.count()
or relatedPostsButton.isVisible() without a short hard timeout) and only if it
truly does not exist proceed to the tab-level selector; if it exists, call
setSidebarPanelExpanded(page, 'Related Posts', true) and then use
page.locator('.wp-parsely-content-helper div.components-panel__body.is-opened '
+ selector).textContent(), otherwise use
page.locator('.wp-parsely-content-helper ' + selector).textContent(); ensure you
remove the .waitFor(..., timeout: 3000).then(...).catch(...) branch and base
routing solely on the existence check of relatedPostsButton/selector.
🪄 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: 9f7b82e5-f3f5-4e2a-955b-4c6cf54964e9
📒 Files selected for processing (2)
tests/e2e/specs/content-helper/top-bar-icon.spec.tstests/e2e/utils.ts
…-contact-messages" (d85018a)
Summary
When no Parse.ly credentials are configured, each panel in the Tools tab independently rendered the "Contact us" credentials message. This was inconsistent with the Performance tab, which shows the message once for the whole tab. The fix lifts the credential gate to the tab level, matching the established pattern, and also moves the "Boost Engagement" button inside the gate since it has no utility without credentials.
As a side effect, the
VerifyCredentialscomponent'schildrenprop type was broadened fromReact.JSX.Element|JSX.Element[]toReact.ReactNodeto correctly support conditional rendering at the wrapper level.Before
<VerifyCredentials>, causing the "Contact us / wp-parsely options" message to appear once per expanded panel (up to 4 times).After
<VerifyCredentials>wraps all Tools tab content, showing the message exactly once — consistent with the Performance tab.Screenshots
Summary by CodeRabbit
Refactor
Tests