Skip to content

Commit 40aba3f

Browse files
author
Yaroslav Onischenko
committed
Merge remote-tracking branch 'origin/MAGETWO-51526' into develop
2 parents adc1c6e + 9ac3ebf commit 40aba3f

File tree

17 files changed

+579
-162
lines changed

17 files changed

+579
-162
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ define([
373373
var url = this.options.saveRemoteVideoUrl,
374374
self = this;
375375

376+
this._getPreviewImage().attr('src', sourceUrl).hide();
376377
this._blockActionButtons(true, true);
377378
$.ajax({
378379
url: url,
@@ -628,7 +629,7 @@ define([
628629
* @private
629630
*/
630631
_create: function () {
631-
var imgs = this.element.closest(this.options.videoSelector).data('images') || [],
632+
var imgs = _.values(this.element.closest(this.options.videoSelector).data('images')) || [],
632633
widget,
633634
uploader,
634635
tmp,
@@ -697,7 +698,7 @@ define([
697698
roles.prop('disabled', false);
698699
file = widget.element.find('#file_name').val();
699700
widget._onGetVideoInformationEditClick();
700-
modalTitleElement = widget.element.closest('.mage-new-video-dialog .modal-title');
701+
modalTitleElement = modal.find('.modal-title');
701702

702703
if (!file) {
703704
widget._blockActionButtons(true);

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ class View extends AbstractConfigureBlock
189189
*/
190190
protected $baseImage = '[data-gallery-role="gallery"] img.fotorama__img.fotorama__img';
191191

192+
/**
193+
* Video Container selector
194+
*
195+
* @var string
196+
*/
197+
private $videoContainer = 'div.fotorama-video-container';
198+
192199
/**
193200
* Get block price.
194201
*
@@ -553,4 +560,14 @@ public function closeFullImage()
553560
{
554561
$this->browser->find($this->fullImageClose, Locator::SELECTOR_CSS)->click();
555562
}
563+
564+
/**
565+
* Check is video is visible on product page
566+
*
567+
* @return bool
568+
*/
569+
public function isVideoVisible()
570+
{
571+
return $this->_rootElement->find($this->videoContainer)->isVisible();
572+
}
556573
}

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/Images/VideoDialog.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class VideoDialog extends Form
4949
*/
5050
protected $screenshotPreview = '#new_video_screenshot_preview + img';
5151

52+
/**
53+
* Video Player CSS Selector
54+
*
55+
* @var string
56+
*/
57+
private $videoPlayer = '#new-video div.video-player-container';
58+
5259
/**
5360
* Close button CSS selector.
5461
*
@@ -74,6 +81,7 @@ public function clickSaveButton()
7481
*/
7582
public function clickEditButton()
7683
{
84+
$this->waitForElementNotDisabled($this->editButton);
7785
$this->_rootElement->find($this->editButton)->click();
7886
return $this;
7987
}
@@ -116,11 +124,29 @@ public function fillForm(array $data)
116124
$this->_fill($videoFill);
117125
$this->_rootElement->find($this->getVideoButton)->click();
118126
$this->waitForElementVisible($this->screenshotPreview);
127+
$this->waitForElementVisible($this->videoPlayer);
119128
}
120129
$this->_fill($data);
121130
return $this;
122131
}
123132

133+
/**
134+
* Wait for element is not disabled in the block
135+
*
136+
* @param string $selector
137+
* @param string $strategy
138+
* @return bool|null
139+
*/
140+
public function waitForElementNotDisabled($selector, $strategy = Locator::SELECTOR_CSS)
141+
{
142+
$browser = $this->browser;
143+
return $browser->waitUntil(
144+
function () use ($browser, $selector, $strategy) {
145+
$element = $browser->find($selector, $strategy);
146+
return $element->isDisabled() == false ? true : null;
147+
}
148+
);
149+
}
124150

125151
/**
126152
* Gets video info

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
*/
1515
class ImagesAndVideos extends Tab
1616
{
17+
/**
18+
* Order Id of first video
19+
*
20+
* @var int
21+
*/
22+
private $firstVideoId = 0;
23+
1724
/**
1825
* Add video button CSS locator.
1926
*
@@ -189,7 +196,7 @@ public function getFieldsData($tabFields = null, SimpleElement $element = null)
189196
protected function getImageSelector($id)
190197
{
191198
++$id;
192-
return $this->imageItem . ':nth-child(' . $id . ') .draggable-handle';
199+
return $this->imageItem . ':nth-child(' . $id . ') .product-image-wrapper';
193200
}
194201

195202
/**
@@ -221,7 +228,17 @@ protected function clickVideo($id)
221228
*/
222229
public function clickFirstVideo()
223230
{
224-
$this->_rootElement->find($this->getImageSelector(0))->click();
231+
$this->_rootElement->find($this->getImageSelector($this->firstVideoId))->click();
225232
return $this;
226233
}
234+
235+
/**
236+
* Delete first video in a product
237+
*
238+
* @return void
239+
*/
240+
public function deleteFirstVideo()
241+
{
242+
$this->deleteVideo($this->firstVideoId);
243+
}
227244
}

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertGetVideoInfoDataIsCorrect.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Mtf\Fixture\InjectableFixture;
1010
use Magento\Mtf\Constraint\AbstractAssertForm;
11+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
1112
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
1213

1314
/**
@@ -18,18 +19,21 @@ class AssertGetVideoInfoDataIsCorrect extends AbstractAssertForm
1819
/**
1920
* Assert that video data received from external service is correct.
2021
*
22+
* @param CatalogProductIndex $productGrid
2123
* @param CatalogProductEdit $editProductPage
22-
* @param InjectableFixture $initialProduct
24+
* @param InjectableFixture $product
2325
* @param array $video
2426
* @return void
2527
*/
2628
public function processAssert(
29+
CatalogProductIndex $productGrid,
2730
CatalogProductEdit $editProductPage,
28-
InjectableFixture $initialProduct,
31+
InjectableFixture $product,
2932
array $video
3033
) {
34+
$productGrid->open();
35+
$productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
3136

32-
$editProductPage->open(['id' => $initialProduct->getId()]);
3337
$editProductPage->getProductForm()->openSection('images-and-videos');
3438
$imagesTab = $editProductPage->getProductForm()->getSection('images-and-videos');
3539
$result = $imagesTab->clickFirstVideo()->getVideoDialog()->validate($video);

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertNoVideoCategoryView.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ class AssertNoVideoCategoryView extends AbstractConstraint
2222
*
2323
* @param CmsIndex $cmsIndex
2424
* @param CatalogCategoryView $catalogCategoryView
25-
* @param InjectableFixture $initialProduct
26-
* @return void
25+
* @param InjectableFixture $product
2726
*/
2827
public function processAssert(
2928
CmsIndex $cmsIndex,
3029
CatalogCategoryView $catalogCategoryView,
31-
InjectableFixture $initialProduct
30+
InjectableFixture $product
3231
) {
3332
$cmsIndex->open();
34-
$cmsIndex->getTopmenu()->selectCategoryByName($initialProduct->getCategoryIds()[0]);
35-
$src = $catalogCategoryView->getListProductBlock()->getProductItem($initialProduct)->getBaseImageSource();
33+
$cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
34+
$src = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getBaseImageSource();
3635
\PHPUnit_Framework_Assert::assertTrue(
3736
strpos($src, '/placeholder/') !== false,
3837
'Product image is displayed on category view when it should not.'

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertNoVideoProductView.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\ProductVideo\Test\Constraint;
88

9-
109
use Magento\Catalog\Test\Page\Product\CatalogProductView;
1110
use Magento\Mtf\Constraint\AbstractConstraint;
1211
use Magento\Mtf\Client\BrowserInterface;
@@ -22,17 +21,16 @@ class AssertNoVideoProductView extends AbstractConstraint
2221
*
2322
* @param BrowserInterface $browser
2423
* @param CatalogProductView $catalogProductView
25-
* @param InjectableFixture $initialProduct
24+
* @param InjectableFixture $product
2625
*/
2726
public function processAssert(
2827
BrowserInterface $browser,
2928
CatalogProductView $catalogProductView,
30-
InjectableFixture $initialProduct
29+
InjectableFixture $product
3130
) {
32-
$browser->open($_ENV['app_frontend_url'] . $initialProduct->getUrlKey() . '.html');
33-
$catalogProductView->getViewBlock()->isGalleryVisible();
31+
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
3432
\PHPUnit_Framework_Assert::assertFalse(
35-
$catalogProductView->getViewBlock()->isGalleryVisible(),
33+
$catalogProductView->getViewBlock()->isVideoVisible(),
3634
'Product video is displayed on product view when it should not.'
3735
);
3836
}

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertVideoCategoryView.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ class AssertVideoCategoryView extends AbstractConstraint
2121
*
2222
* @param CmsIndex $cmsIndex
2323
* @param CatalogCategoryView $catalogCategoryView
24-
* @param InjectableFixture $initialProduct
24+
* @param InjectableFixture $product
2525
* @return void
2626
*/
2727
public function processAssert(
2828
CmsIndex $cmsIndex,
2929
CatalogCategoryView $catalogCategoryView,
30-
InjectableFixture $initialProduct
30+
InjectableFixture $product
3131
) {
3232
$cmsIndex->open();
33-
$cmsIndex->getTopmenu()->selectCategoryByName($initialProduct->getCategoryIds()[0]);
34-
$src = $catalogCategoryView->getListProductBlock()->getProductItem($initialProduct)->getBaseImageSource();
33+
$cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
34+
$src = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getBaseImageSource();
3535
\PHPUnit_Framework_Assert::assertFalse(
3636
strpos($src, '/placeholder/') !== false,
3737
'Video preview image is not displayed on category view when it should.'

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertVideoProductView.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ class AssertVideoProductView extends AbstractConstraint
2626
public function processAssert(
2727
BrowserInterface $browser,
2828
CatalogProductView $catalogProductView,
29-
InjectableFixture $initialProduct
29+
InjectableFixture $product
3030
) {
31-
$browser->open($_ENV['app_frontend_url'] . $initialProduct->getUrlKey() . '.html');
32-
$catalogProductView->getViewBlock()->isGalleryVisible();
31+
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
3332
\PHPUnit_Framework_Assert::assertTrue(
34-
$catalogProductView->getViewBlock()->isGalleryVisible(),
33+
$catalogProductView->getViewBlock()->isVideoVisible(),
3534
'Product video is not displayed on product view when it should.'
3635
);
3736
}

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Repository/CatalogProductSimple.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,11 @@
3333
<field name="category_ids" xsi:type="array">
3434
<item name="dataset" xsi:type="string">default_subcategory</item>
3535
</field>
36-
<field name="image" xsi:type="string">/v/i/video_test.jpg</field>
37-
<field name="small_image" xsi:type="string">/v/i/video_test.jpg</field>
38-
<field name="swatch_image" xsi:type="string">/v/i/video_test.jpg</field>
39-
<field name="thumbnail" xsi:type="string">/v/i/video_test.jpg</field>
4036
<field name="media_gallery" xsi:type="array">
4137
<item name="images" xsi:type="array">
4238
<item name="0" xsi:type="array">
43-
<item name="position" xsi:type="number">1</item>
44-
<item name="media_type" xsi:type="string">external-video</item>
45-
<item name="file" xsi:type="string">/v/i/video_test.jpg</item>
4639
<item name="video_url" xsi:type="string">https://youtu.be/bpOSxM0rNPM</item>
4740
<item name="video_title" xsi:type="string">Some title</item>
48-
<item name="label" xsi:type="string">image1</item>
4941
</item>
5042
</item>
5143
</field>
@@ -76,19 +68,11 @@
7668
<field name="category_ids" xsi:type="array">
7769
<item name="dataset" xsi:type="string">default_subcategory</item>
7870
</field>
79-
<field name="image" xsi:type="string">/v/i/video_test.jpg</field>
80-
<field name="small_image" xsi:type="string">/v/i/video_test.jpg</field>
81-
<field name="swatch_image" xsi:type="string">/v/i/video_test.jpg</field>
82-
<field name="thumbnail" xsi:type="string">/v/i/video_test.jpg</field>
8371
<field name="media_gallery" xsi:type="array">
8472
<item name="images" xsi:type="array">
8573
<item name="0" xsi:type="array">
86-
<item name="position" xsi:type="number">1</item>
87-
<item name="media_type" xsi:type="string">external-video</item>
88-
<item name="file" xsi:type="string">/v/i/video_test.jpg</item>
8974
<item name="video_url" xsi:type="string">https://vimeo.com/16342611</item>
9075
<item name="video_title" xsi:type="string">Some title</item>
91-
<item name="label" xsi:type="string">image1</item>
9276
</item>
9377
</item>
9478
</field>

0 commit comments

Comments
 (0)