Skip to content

Video preview isssue #30324 #31770

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

Open
wants to merge 7 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

gixid192
Copy link
Contributor

@gixid192 gixid192 commented Jan 20, 2021

Summary

This PR fix the #30324
The error as I understand is caused by not cancelling the video-api request. More on description below.

Description (*)

  1. When making a request to the server. While the request has not been fulfilled yet, the user closes the edit modal and then opens add-new modal.
  2. At the time the request finished, the user is already on the add-new-video modal, so the data from the request now renders on this new modal
  3. The code make sure that it only renders new data in the correct modals/pages.

Fixed Issues (if relevant)

#30324

Manual testing scenarios (*)

  1. Add setTimeout in the ajax's success function (which call _onVimeoLoaded/_onYouTubeLoaded). Keep this timeout long enough to deplay the render function.
  2. Follow the steps in original issue: Add and save new video -> open edit page -> close edit page -> click "Add Video" button to open add-new-video modal

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jan 20, 2021

Hi @gixid192. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Jan 20, 2021
@gixid192
Copy link
Contributor Author

@magento run all tests

@gixid192
Copy link
Contributor Author

@magento run all tests

@gixid192
Copy link
Contributor Author

@magento run all tests

@gixid192
Copy link
Contributor Author

@magento run all tests

@gixid192
Copy link
Contributor Author

@magento run Functional Tests B2B

@danielrussob
Copy link

@magento give me test instance

@magento-deployment-service
Copy link

Hi @danielrussob. Thank you for your request. I'm working on Magento instance for you.

@danielrussob
Copy link

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @danielrussob. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@magento-deployment-service
Copy link

@danielrussob
Copy link

Issue Reproduced on vanilla Magento 2.4

@danielrussob
Copy link

Issued (just as described) are solved on new Magento instance

@@ -1103,6 +1104,7 @@ define([
this._previewImage = null;
}
this._tempPreviewImageData = null;
this._videoUrlWidget.trigger('cancelled_video_information');

Choose a reason for hiding this comment

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

Hello @gixid192 ,
thank you for your contribution.

I have two questions for you:

a. Can you write a test for this PR?
b. I have found a new bug, I tell you a step to reproduce the bug:

b.1. Navigate to Add New Product page in backend
b.2. Open Image And Videos section
b.3. Click on Add Video button
b.4. Enter Vimeo or YouTube video URL in Url field and wait until the Save button is enabled
b.5. Click on Save button
b.6. Click on Add Video Button
b.7. paste URL in Url input, click Title and quickly click on X to close
b.8. Press on Add Video button
b.9. See an Preview Image (bottom left corner) from the previous video

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @danielrussob,

  1. I'm not sure how to write test for this case. Could you suggest some ideas?
  2. Did you try this new case with the code in the PR or the original code? With the PR's code, it stop the render part right after you close X, so there will be no b.8/b.9
    I tried it myself, couldn't reproduce the issue.

Choose a reason for hiding this comment

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

Hi,
for point 2, i have tested it on your PR, if you want we can schedule a chat on slack of Magento Community Engineering
to reproduce the issue (you can found me with name Daniel Russo)

for point 1, see comment of @sivaschenko

Copy link
Contributor Author

@gixid192 gixid192 Jan 27, 2021

Choose a reason for hiding this comment

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

Hi,
So I tried again and reproduced the issue.

There's another ajax in the update image-placeholder:

I made the same approach and it fixed the problem! However, I don't understand the purpose of that _loadRemotePreview function.
The _loadRemotePreview function does 2 things:

  • Send request to server to save the image
  • Only show the preview_image if the request above success.

The thing is those 2 things are not related, it does not take data from the request to show for users (instead the preview_image is taken from video's api). Also, if the request fail, there is no error handle for it (and the preview_image still show)

Should we split this function into 2 small separated ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danielrussob: I updated new code to fix the issue you reported, just write new code, no splitting; kindly have a look when you have time.

If you have options on this split into 2 functions, please let me know.

@sivaschenko
Copy link
Member

@danielrussob @gixid192 I think that MFTF test covering this fix may not be reliable as the fixed behaviour depends on the server response time. I'd advise covering the fix with a javascript jasmine test. https://devdocs.magento.com/guides/v2.4/test/js/jasmine.html

@gixid192
Copy link
Contributor Author

@sivaschenko Thanks for the suggestions, I will try to cover the test, never write testes in Js before 😅

@danielrussob
Copy link

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @danielrussob, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@gixid192
Copy link
Contributor Author

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Component: ProductVideo Priority: P3 May be fixed according to the position in the backlog. Progress: review Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

4 participants