Skip to content

Fix "A Video is Present" false positive on image filenames containing "youtube"/"vimeo" - #1839

Open
pattonwebz wants to merge 3 commits into
developfrom
william/pro-1229-a-video-is-present-false-positive-on-images-whose-filename
Open

Fix "A Video is Present" false positive on image filenames containing "youtube"/"vimeo"#1839
pattonwebz wants to merge 3 commits into
developfrom
william/pro-1229-a-video-is-present-false-positive-on-images-whose-filename

Conversation

@pattonwebz

@pattonwebz pattonwebz commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • The video_present rule's is_video_detected check matched the keywords youtube, youtu.be, and vimeo against the src attribute of any element hit by the rule's broad selector (video, iframe, object, source, [src]:not(script), [role]), not just embed elements.
  • Since the selector matches any [src] element, a plain <img> whose filename happens to contain one of these words (e.g. a featured image named screenshot-2026-05-21-at-16-53-07-claims-department-youtube.jpg) tripped a false-positive "A Video is Present" warning even though the page has no video/embed at all.
  • Restricts the keyword match to iframe/embed elements, which is where a "youtube"/"vimeo" URL actually indicates an embedded video player.

Fixes PRO-1229.

Test plan

  • Added regression tests in tests/jest/rules/videoElementPresent.test.js for <img> filenames containing "youtube"/"vimeo" — confirmed these fail against the pre-fix code (first commit), then pass after the fix (second commit).
  • Full jest suite: npm run test:jest → 52 suites / 950 tests passing, no regressions.
  • eslint clean on changed files.

Summary by CodeRabbit

  • Bug Fixes
    • Improved embedded video detection so keyword matching applies only to supported embed elements.
    • Reduced false positives where non-video assets (e.g., images) with “YouTube”/“Vimeo” in the filename were incorrectly flagged.
  • Tests
    • Added regression coverage ensuring the video presence check does not flag image assets whose filenames contain “youtube”/“vimeo”.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 775924cd-bb32-4648-ba7b-8382f8396f10

📥 Commits

Reviewing files that changed from the base of the PR and between 69057de and 63a7367.

📒 Files selected for processing (3)
  • .github/workflows/build-plugin-with-ref.yml
  • src/pageScanner/checks/is-video-detected.js
  • tests/jest/rules/videoElementPresent.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/jest/rules/videoElementPresent.test.js
  • src/pageScanner/checks/is-video-detected.js

📝 Walkthrough

Walkthrough

Video keyword detection now applies only to iframe and embed elements, with regression tests for image filenames containing “youtube” or “vimeo”. The Composer workflow also removes the --prefer-offline installation option.

Changes

Video detection refinement

Layer / File(s) Summary
Gate keyword matching and verify image exclusions
src/pageScanner/checks/is-video-detected.js, tests/jest/rules/videoElementPresent.test.js
Keyword matching is limited to iframe and embed elements, with regression cases covering YouTube- and Vimeo-named images.

Composer workflow update

Layer / File(s) Summary
Update Composer installation options
.github/workflows/build-plugin-with-ref.yml
Removes --prefer-offline while retaining the other Composer installation options.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: eliminating video-detection false positives on image filenames containing YouTube/Vimeo terms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 william/pro-1229-a-video-is-present-false-positive-on-images-whose-filename

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/jest/rules/videoElementPresent.test.js (1)

173-187: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the new <embed> path.

The implementation now explicitly supports both iframe and embed, but these tests only exercise iframe positives and image negatives. Add an <embed src="https://player.vimeo.com/video/123"> case with shouldPass: false.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/jest/rules/videoElementPresent.test.js` around lines 173 - 187, Add a
regression case to the video detection test cases covering an <embed> element
with src "https://player.vimeo.com/video/123" and set shouldPass to false,
alongside the existing iframe-positive and image-negative cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/jest/rules/videoElementPresent.test.js`:
- Around line 173-187: Add a regression case to the video detection test cases
covering an <embed> element with src "https://player.vimeo.com/video/123" and
set shouldPass to false, alongside the existing iframe-positive and
image-negative cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6a3cdf5-1d27-4790-ac34-00d418ad480a

📥 Commits

Reviewing files that changed from the base of the PR and between 3959d1e and ffd8e5c.

📒 Files selected for processing (2)
  • src/pageScanner/checks/is-video-detected.js
  • tests/jest/rules/videoElementPresent.test.js

@pattonwebz
pattonwebz force-pushed the william/pro-1229-a-video-is-present-false-positive-on-images-whose-filename branch from ffd8e5c to 69057de Compare July 17, 2026 21:48
Add regression tests for PRO-1229: an <img> whose filename merely
contains "youtube" or "vimeo" (e.g. a screenshot named
screenshot-2026-05-21-at-16-53-07-claims-department-youtube.jpg used
as a featured image) currently trips the video_present rule even
though the page has no video or embed on it.
matchesKeyword in is-video-detected.js was checking the "src"
attribute of any element matched by the rule's broad selector
(video, iframe, object, source, [src]:not(script), [role]) for
substrings like "youtube" or "vimeo". Since the selector includes
any [src] element, this flagged plain <img> tags whose filename
happened to contain one of these words, most commonly a featured
image screenshot named like "...-youtube.jpg".

Restrict the keyword check to iframe/embed elements, which is where
a "youtube"/"vimeo" URL actually indicates an embedded video player.

Fixes PRO-1229.
composer install does not support --prefer-offline (that flag only
exists for composer update/require), so the "Install Composer
dependencies" step in the build-plugin-with-ref workflow fails
immediately with "The --prefer-offline option does not exist."

This is a pre-existing bug on develop from the workflow-caching
optimization merge, unrelated to the video_present fix in this PR,
but it blocks this PR's build job so fixing it here to unblock CI.
@pattonwebz
pattonwebz force-pushed the william/pro-1229-a-video-is-present-false-positive-on-images-whose-filename branch from 69057de to 63a7367 Compare July 17, 2026 21:55
@github-actions

Copy link
Copy Markdown
Contributor

✅ Accessibility Checker build (primary only)

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.

1 participant