Skip to content

Improve content test for videoId field #1656

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

Merged
merged 2 commits into from
Jul 13, 2024

Conversation

fturmel
Copy link
Collaborator

@fturmel fturmel commented Jul 12, 2024

#1655 made me realize that there was an error in the way the video schema was defined, and it was allowing empty videoId to pass the tests.

The check was also updated so that the top-level videoId must be empty or undefined instead of optional when a video is multi-part. It should help avoid confusion and information repetition.

Copy link

netlify bot commented Jul 12, 2024

Deploy Preview for codingtrain ready!

Name Link
🔨 Latest commit a50f243
🔍 Latest deploy log https://app.netlify.com/sites/codingtrain/deploys/6691a8cd9398a300081d1519
😎 Deploy Preview https://deploy-preview-1656--codingtrain.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@shiffman
Copy link
Member

Hi @fturmel thanks again! Am I confused or is there a mistake in this PR where a bunch of videoIds are removed? Perhaps that is leftover from testing the tests themselves?

1 similar comment
@shiffman
Copy link
Member

Hi @fturmel thanks again! Am I confused or is there a mistake in this PR where a bunch of videoIds are removed? Perhaps that is leftover from testing the tests themselves?

@fturmel
Copy link
Collaborator Author

fturmel commented Jul 12, 2024

No it's intended, sorry I wasn't clear. There's a bug fix and an improvement in there:

  • The existing schema validation was supposed to make sure that videoId was required, but the "parts" argument was not destructured from the argument properly. It's basically a Yup library API usage mistake.

  • The top-level videoIds removed are all for multi-part videos and were effectively useless. I added a check in the content tests to require them to be undefined or empty when a "parts" array exist. Currently they were optional but you could still put a YouTube ID in that field even if it did nothing.

@shiffman
Copy link
Member

Ah, I see! Thank you for the clarification. Would it be more clear to remove the field entirely rather than have it as a blank entry?

@fturmel
Copy link
Collaborator Author

fturmel commented Jul 12, 2024

Ah, I see! Thank you for the clarification. Would it be more clear to remove the field entirely rather than have it as a blank entry?

Sure, we can make the check more strict instead of being falsy (which allows undefined, null or empty string). Update incoming.

@fturmel
Copy link
Collaborator Author

fturmel commented Jul 12, 2024

Done, the top-level videoId field cannot be present anymore if the video is multi-part.

@shiffman
Copy link
Member

Fantastic!

@shiffman shiffman merged commit ff9e86a into CodingTrain:main Jul 13, 2024
5 checks passed
@fturmel fturmel deleted the PR/improve-content-testing-videoId branch July 13, 2024 12:41
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.

2 participants