Skip to content

PCI Sidebar: Fix multiple contact messages#4097

Merged
acicovic merged 7 commits into
developfrom
fix/pci-sidebar-multiple-contact-messages
Mar 30, 2026
Merged

PCI Sidebar: Fix multiple contact messages#4097
acicovic merged 7 commits into
developfrom
fix/pci-sidebar-multiple-contact-messages

Conversation

@acicovic
Copy link
Copy Markdown
Collaborator

@acicovic acicovic commented Mar 26, 2026

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 VerifyCredentials component's children prop type was broadened from React.JSX.Element|JSX.Element[] to React.ReactNode to correctly support conditional rendering at the wrapper level.

Before

  • The Tools tab wrapped each panel's content individually in <VerifyCredentials>, causing the "Contact us / wp-parsely options" message to appear once per expanded panel (up to 4 times).
  • The "Boost Engagement" button was rendered outside any credentials check and appeared below the repeated messages.
  • Behaviour was inconsistent with the Performance tab.

After

  • A single <VerifyCredentials> wraps all Tools tab content, showing the message exactly once — consistent with the Performance tab.
  • The "Boost Engagement" button is hidden alongside the panels when credentials are absent.

Screenshots

Before After
image image

Summary by CodeRabbit

  • Refactor

    • Broadened a component prop to accept a wider range of React children.
    • Consolidated credential gating into a single wrapper around the tool panels for simpler structure.
  • Tests

    • Added a reusable sidebar/tab message helper and updated end-to-end tests to use it, simplifying sidebar visibility handling and message retrieval.

@acicovic acicovic added this to the 3.22.1 milestone Mar 26, 2026
@acicovic acicovic self-assigned this Mar 26, 2026
@acicovic acicovic requested a review from a team as a code owner March 26, 2026 18:49
@acicovic acicovic added Changelog: Fixed PR to be added under the changelog's "Fixed" section Feature: PCI Ticket/PR related to Content Intelligence labels Mar 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e4f1f43-781c-4ff5-9509-c75b896b7bb4

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd45ce and b395fdf.

📒 Files selected for processing (1)
  • tests/e2e/utils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/utils.ts

📝 Walkthrough

Walkthrough

Consolidates credential gating in the Tools tab by moving per-panel <VerifyCredentials> wrappers into a single outer wrapper that also gates the Boost Engagement button, widens VerifyCredentials's children prop type to React.ReactNode, and adds a test helper to read sidebar/tab messages.

Changes

Cohort / File(s) Summary
VerifyCredentials Type
src/content-helper/common/verify-credentials.tsx
Changed VerifyCredentialsProps.children from React.JSX.Element | JSX.Element[] to React.ReactNode.
Sidebar Tools Tab Restructuring
src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx
Removed per-panel <VerifyCredentials> wrappers; added a single outer <VerifyCredentials> that wraps Title Suggestions, Excerpt Suggestions, Smart Linking, Related Posts panels and the Boost Engagement button.
E2E tests & utils
tests/e2e/specs/content-helper/top-bar-icon.spec.ts, tests/e2e/utils.ts
Added getSidebarPanelOrTabMessage(page, selector) in utils.ts; updated getRelatedPostsMessage to delegate to it; tests now use the new helper instead of manually expanding a panel and reading a specific opened-panel selector.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • vaurdan
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'PCI Sidebar: Fix multiple contact messages' clearly and specifically summarizes the main change — fixing the issue of multiple credential messages in the Tools tab.
Description check ✅ Passed The PR description is comprehensive, covering summary, motivation, before/after comparison, screenshots, and linked issues. All required template sections are addressed.
Linked Issues check ✅ Passed The PR successfully addresses all requirements from issue #4096: single credential gate at tab level, consistent with Performance tab behavior, and Boost Engagement button hidden without credentials.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives. The type broadening of VerifyCredentials.children and E2E test updates are necessary supporting changes for the main fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pci-sidebar-multiple-contact-messages

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
Copy Markdown
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.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9555c42 and bb8b681.

⛔ Files ignored due to path filters (2)
  • build/content-helper/editor-sidebar.asset.php is excluded by !build/**
  • build/content-helper/editor-sidebar.js is excluded by !build/**
📒 Files selected for processing (2)
  • src/content-helper/common/verify-credentials.tsx
  • src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx

@acicovic
Copy link
Copy Markdown
Collaborator Author

@copilot, can you understand why E2E tests fail here (they pass for me locally), and propose a fix? It shouldn't break any functionality, and the tests should pass without compromising their quality.

Name the PR that you'll be opening "Fix failing E2E tests for PR #4097".

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

@acicovic I've opened a new pull request, #4098, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between bb8b681 and 1fd45ce.

📒 Files selected for processing (2)
  • tests/e2e/specs/content-helper/top-bar-icon.spec.ts
  • tests/e2e/utils.ts

Comment thread tests/e2e/utils.ts Outdated
@acicovic acicovic merged commit d85018a into develop Mar 30, 2026
37 checks passed
@acicovic acicovic deleted the fix/pci-sidebar-multiple-contact-messages branch March 30, 2026 07:28
github-actions Bot added a commit that referenced this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Fixed PR to be added under the changelog's "Fixed" section Feature: PCI Ticket/PR related to Content Intelligence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PCI Sidebar: Fix multiple contact messages

2 participants