Skip to content

fix: use useClipboard hook in CodeBlockComponent to fix clipboard on non-secure contexts#28003

Open
harsh-vador wants to merge 1 commit intomainfrom
fix-service-doc-panel-copy
Open

fix: use useClipboard hook in CodeBlockComponent to fix clipboard on non-secure contexts#28003
harsh-vador wants to merge 1 commit intomainfrom
fix-service-doc-panel-copy

Conversation

@harsh-vador
Copy link
Copy Markdown
Contributor

Describe your changes:

Summary

  • CodeBlockComponent used navigator.clipboard.writeText() directly with a silent catch — on http:// (AUT/non-secure context) window.isSecureContext is false, the write silently fails, setCopied never fires, and E2E tests see an empty clipboard
  • Replaced the manual clipboard + timer logic with the existing useClipboard hook (same pattern as CopyLinkButton) which has a document.execCommand fallback for non-secure contexts
  • Fixed copyAndGetClipboardText Playwright utility: replaced fixed 300ms wait + textarea paste hack with a sentinel-based expect.poll — writes a known sentinel before clicking, polls navigator.clipboard.readText() until the value changes, eliminating races from pre-populated clipboard or slow async writes
  • Updated ServiceDocPanel.test.tsx: added window.isSecureContext = true mock, removed timer implementation-detail tests (now owned by useClipboard hook), kept behavioral assertions
Screen.Recording.2026-05-09.at.1.20.53.AM.mov
Screenshot 2026-05-09 at 1 33 17 AM

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

N/A — small change.

Tests:

Use cases covered

Unit tests

Backend integration tests

Ingestion integration tests

Playwright (UI) tests

Manual testing performed

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

@harsh-vador harsh-vador self-assigned this May 8, 2026
@harsh-vador harsh-vador requested a review from a team as a code owner May 8, 2026 20:03
@harsh-vador harsh-vador added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch labels May 8, 2026
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented May 8, 2026

Code Review ✅ Approved

Replaces manual clipboard handling with the useClipboard hook in CodeBlockComponent to support non-secure contexts. Includes a robust sentinel-based expect.poll utility to eliminate race conditions in E2E tests.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 62%
62.32% (64262/103105) 42.92% (34839/81164) 45.73% (10256/22427)

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

🟡 Playwright Results — all passed (17 flaky)

✅ 4068 passed · ❌ 0 failed · 🟡 17 flaky · ⏭️ 86 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 298 0 1 4
🟡 Shard 2 760 0 8 8
🟡 Shard 3 777 0 4 7
🟡 Shard 4 789 0 1 18
✅ Shard 5 709 0 0 41
🟡 Shard 6 735 0 3 8
🟡 17 flaky test(s) (passed on retry)
  • Pages/AuditLogs.spec.ts › should apply both User and EntityType filters simultaneously (shard 1, 2 retries)
  • Features/ActivityAPI.spec.ts › Activity event shows the actor who made the change (shard 2, 1 retry)
  • Features/BulkEditEntity.spec.ts › Database (shard 2, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Keyboard Delete selection (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should start term as Draft when glossary has reviewers (shard 2, 1 retry)
  • Features/KnowledgeCenter.spec.ts › Article mentions in description should working for Knowledge Center (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Features/UserProfileOnlineStatus.spec.ts › Should show online status badge on user profile for active users (shard 3, 1 retry)
  • Features/Workflows/WorkflowOssRestrictions.spec.ts › add-event-filter-button is enabled in OSS (shard 3, 1 retry)
  • Flow/ObservabilityAlerts.spec.ts › Alert operations for a user with and without permissions (shard 3, 2 retries)
  • Pages/CustomProperties.spec.ts › Should display custom properties for apiCollection in right panel (shard 4, 1 retry)
  • Pages/Glossary.spec.ts › Glossary Term Update in Glossary Page should persist tree (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/ODCSImportExport.spec.ts › Verify SLA mapping from ODCS to OpenMetadata format (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

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

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant