Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoPress, Invalid VP URL: Handle case when the URL doesn't contain VP GUID #42237

Open
wants to merge 12 commits into
base: trunk
Choose a base branch
from

Conversation

bogiii
Copy link
Contributor

@bogiii bogiii commented Mar 5, 2025

Fixes #34741

Proposed changes:

  • Handles cases where the entered URL doesn't contain VidePress GUID.
  • The extended approach will try to find the video by filename;
  • Added missing gap between buttons

NOTE: This fix only handles files from the same site since the media search API works in the site context.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

#34741

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Run your sandbox
  • Apply changes from this PR; check for the instructions
  • Upload a video file to your website with the Premium plan
  • Create a new post/page
  • Insert a VideoPress block. Click the Insert From URL link and paste the video's link and submit.
  • Check if Video appears
Screenshot 2025-03-05 at 18 57 49
  • Try entering a wrong URL (for example, url to the image media)
  • Check the the gap between buttons
Before After
Screenshot 2025-03-05 at 19 22 54 Screenshot 2025-03-05 at 19 22 38

@bogiii bogiii self-assigned this Mar 5, 2025
@bogiii bogiii requested a review from a team March 5, 2025 17:58
Copy link
Contributor

github-actions bot commented Mar 5, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/videopress-invalid-url branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/videopress-invalid-url

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Mar 5, 2025
Copy link

jp-launch-control bot commented Mar 5, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/videopress/src/client/block-editor/blocks/video/components/videopress-uploader/index.js 0/104 (0.00%) 0.00% 4 💔
projects/packages/videopress/src/client/lib/url/index.ts 43/63 (68.25%) 0.25% 4 💔

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

@bogiii bogiii marked this pull request as ready for review March 5, 2025 18:32
Copy link
Contributor

@phcp phcp left a comment

Choose a reason for hiding this comment

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

Overall, it works great! I just noted one minor scenario: when passing an invalid URL, it falls back to the first video returned from the endpoint, but in that case, it should display an invalid URL error.

@bogiii
Copy link
Contributor Author

bogiii commented Mar 6, 2025

I just noted one minor scenario: when passing an invalid URL, it falls back to the first video returned from the endpoint, but in that case, it should display an invalid URL error.

It's not 100% true; we are looking for a video by the file name. Eg. example-video.mp4. In that case, if someone just tries a random URL with a file name that doesn't exist, it's going to be a wrong URL warning.

Am I still missing something? @phcp

@phcp
Copy link
Contributor

phcp commented Mar 6, 2025

It's not 100% true; we are looking for a video by the file name. Eg. example-video.mp4. In that case, if someone just tries a random URL with a file name that doesn't exist, it's going to be a wrong URL warning.

It was mostly for cases where getVideoNameFromUrl returns nothing, so the media request goes with an empty search param. For example, removing the file extension causes that, same with typing something random that isn't a URL. In those cases, I think we should display the invalid URL error and not perform the media request.

@bogiii
Copy link
Contributor Author

bogiii commented Mar 7, 2025

It was mostly for cases where getVideoNameFromUrl returns nothing, so the media request goes with an empty search param. For example, removing the file extension causes that, same with typing something random that isn't a URL. In those cases, I think we should display the invalid URL error and not perform the media request.

@phcp, you were right. I've handled the described case. It's ready for re-review.

@bogiii bogiii requested a review from phcp March 7, 2025 18:47
Copy link
Contributor

@phcp phcp left a comment

Choose a reason for hiding this comment

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

Changes are working as expected. Thanks for the fixes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] VideoPress [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Invalid VideoPress URL" when using Insert From URL on WordPress.com sites
3 participants