Skip to content

Commit 5ea4590

Browse files
ENGCOM-6134: [ProductVideo] Validating the Product Video Url #25090
2 parents 647424e + 8c8b7f6 commit 5ea4590

8 files changed

+158
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminAssertVideoNoValidationErrorActionGroup">
12+
<arguments>
13+
<argument name="inputName" type="string"/>
14+
</arguments>
15+
16+
<dontSeeElement selector="{{AdminProductNewVideoSection.errorElement(inputName)}}"
17+
stepKey="seeElementValidationError"/>
18+
</actionGroup>
19+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminFillProductVideoFieldActionGroup">
12+
<arguments>
13+
<argument name="input" type="string"/>
14+
<argument name="value" type="string"/>
15+
</arguments>
16+
17+
<fillField selector="{{input}}" userInput="{{value}}" stepKey="fillVideoField"/>
18+
</actionGroup>
19+
</actionGroups>
20+
21+
22+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminGetVideoInformationActionGroup">
12+
<click selector="{{AdminProductNewVideoSection.getVideoInformationButton}}" stepKey="getVideoInformation"/>
13+
</actionGroup>
14+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminOpenProductVideoModalActionGroup">
12+
<scrollTo selector="{{AdminProductImagesSection.productImagesToggle}}" x="0" y="-100" stepKey="scrollToArea"/>
13+
<conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductVideoSection"/>
14+
<waitForElementVisible selector="{{AdminProductImagesSection.addVideoButton}}" stepKey="waitForAddVideoButtonVisible" time="30"/>
15+
<click selector="{{AdminProductImagesSection.addVideoButton}}" stepKey="addVideo"/>
16+
<waitForElementVisible selector=".modal-slide.mage-new-video-dialog.form-inline._show" stepKey="waitForUrlElementVisibleslide" time="30"/>
17+
<waitForElementVisible selector="{{AdminProductNewVideoSection.videoUrlTextField}}" stepKey="waitForUrlElementVisible" time="60"/>
18+
</actionGroup>
19+
</actionGroups>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminVideoValidationErrorActionGroup">
12+
<arguments>
13+
<argument name="inputName" type="string"/>
14+
<argument name="errorMessage" type="string" defaultValue="This is a required field."/>
15+
</arguments>
16+
17+
<see selector="{{AdminProductNewVideoSection.errorElement(inputName)}}" userInput="{{errorMessage}}"
18+
stepKey="seeElementValidationError"/>
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/ProductVideo/Test/Mftf/Section/AdminProductNewVideoSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<element name="saveButton" type="button" selector=".action-primary.video-create-button" timeout="30"/>
1313
<element name="saveButtonDisabled" type="text" selector="//button[@class='action-primary video-create-button' and @disabled='disabled']"/>
1414
<element name="cancelButton" type="button" selector=".video-cancel-button" timeout="30"/>
15+
<element name="getVideoInformationButton" type="button" selector="#new_video_get"/>
1516
<element name="videoUrlTextField" type="input" selector="#video_url"/>
1617
<element name="videoTitleTextField" type="input" selector="#video_title"/>
1718
<element name="videoDescriptionTextField" type="input" selector="#video_description"/>
@@ -20,5 +21,6 @@
2021
<element name="swatchCheckbox" type="checkbox" selector="#video_swatch_image"/>
2122
<element name="thumbnailCheckbox" type="checkbox" selector="#video_thumbnail"/>
2223
<element name="hideFromProductPageCheckbox" type="checkbox" selector="#new_video_disabled"/>
24+
<element name="errorElement" type="text" selector="#{{inputName}}-error" parameterized="true" />
2325
</section>
2426
</sections>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminValidateUrlOnGetVideoInformationTest">
12+
<annotations>
13+
<stories value="Admin validates the url when getting video information"/>
14+
<title value="Admin validates the url when getting video information"/>
15+
<description value="Testing for a required video url when getting video information"/>
16+
<severity value="CRITICAL"/>
17+
<group value="ProductVideo"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
21+
<createData entity="ProductVideoYoutubeApiKeyConfig" stepKey="setStoreConfig"/>
22+
</before>
23+
<after>
24+
<createData entity="DefaultProductVideoConfig" stepKey="setStoreDefaultConfig"/>
25+
<actionGroup ref="logout" stepKey="logout"/>
26+
</after>
27+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndexPage"/>
28+
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateProduct">
29+
<argument name="product" value="SimpleProduct"/>
30+
</actionGroup>
31+
<actionGroup ref="AdminOpenProductVideoModalActionGroup" stepKey="openAddProductVideoModal"/>
32+
<actionGroup ref="AdminGetVideoInformationActionGroup" stepKey="clickOnGetVideoInformation"/>
33+
<actionGroup ref="AssertAdminVideoValidationErrorActionGroup" stepKey="seeUrlValidationMessage">
34+
<argument name="inputName" value="video_url"/>
35+
</actionGroup>
36+
<actionGroup ref="AdminFillProductVideoFieldActionGroup" stepKey="fillVideoUrlField">
37+
<argument name="input" value="{{AdminProductNewVideoSection.videoUrlTextField}}"/>
38+
<argument name="value" value="{{mftfTestProductVideo.videoUrl}}"/>
39+
</actionGroup>
40+
<actionGroup ref="AdminGetVideoInformationActionGroup" stepKey="clickOnGetVideoInformation2"/>
41+
<actionGroup ref="AdminAssertVideoNoValidationErrorActionGroup" stepKey="dontSeeUrlValidationMessage">
42+
<argument name="inputName" value="video_url"/>
43+
</actionGroup>
44+
</test>
45+
</tests>

app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,15 @@ define([
282282
* @private
283283
*/
284284
_onGetVideoInformationClick: function () {
285-
this._onlyVideoPlayer = false;
286-
this._isEditPage = false;
287-
this._videoUrlWidget.trigger('update_video_information');
285+
var videoForm = this.element.find(this._videoFormSelector);
286+
287+
videoForm.validation();
288+
289+
if (this.element.find(this._videoUrlSelector).valid()) {
290+
this._onlyVideoPlayer = false;
291+
this._isEditPage = false;
292+
this._videoUrlWidget.trigger('update_video_information');
293+
}
288294
},
289295

290296
/**
@@ -299,6 +305,14 @@ define([
299305
* @private
300306
*/
301307
_onGetVideoInformationStartRequest: function () {
308+
var videoForm = this.element.find(this._videoFormSelector);
309+
310+
try {
311+
videoForm.validation('clearError');
312+
} catch (e) {
313+
// Do nothing
314+
}
315+
302316
this._videoRequestComplete = false;
303317
},
304318

0 commit comments

Comments
 (0)