Skip to content

Commit f6e26ae

Browse files
committed
PB-425: Update Video Alignment MFTF Video Tests
- Updating tests, data, action groups, and sections for video alignment
1 parent 5282c1c commit f6e26ae

File tree

4 files changed

+204
-277
lines changed

4 files changed

+204
-277
lines changed

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeVideoActionGroup.xml

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,75 +50,90 @@
5050
<actualResult type="variable">ratioDifference</actualResult>
5151
</assertLessThanOrEqual>
5252
</actionGroup>
53-
<actionGroup name="validateVideoWithOnlyVideoUrl">
53+
<actionGroup name="validateVideoUrl">
54+
<annotations>
55+
<description>Validates that the video's url in the video content type.</description>
56+
</annotations>
5457
<arguments>
55-
<argument name="page" defaultValue=""/>
58+
<argument name="page" defaultValue="VideoOnStage"/>
5659
<argument name="index" defaultValue="1" type="string"/>
57-
<argument name="url" defaultValue=""/>
58-
<!-- This is 2 because the width and the height may both have fractions that could round by a maximum of 1 for each which makes the maximum 2-->
60+
<argument name="url" defaultValue="PageBuilderVideoUrl_YouTube"/>
5961
<argument name="acceptableOffset" defaultValue="2" type="string"/>
6062
</arguments>
61-
<waitForElementVisible selector="{{page.base(index)}}" stepKey="waitForElement"/>
62-
<waitForElementVisible selector="{{page.source(index, url.renderedValue)}}" stepKey="waitForUrl"/>
63-
<waitForElementVisible selector="{{page.noWidth(index)}}" stepKey="waitForWidth"/>
64-
<comment userInput="Validate Aspect Ratio" stepKey="commentValidateAspectRatio"/>
65-
<executeJS function="return window.calculatedHeight = parseInt(getComputedStyle(document.evaluate(&quot;{{page.iframe(index)}}&quot;,document.body).iterateNext()).width) / 16 * 9" stepKey="calculatedHeight"/>
66-
<executeJS function="return window.actualHeight = parseInt(getComputedStyle(document.evaluate(&quot;{{page.iframe(index)}}&quot;,document.body).iterateNext()).height)" stepKey="actualHeight"/>
67-
<executeJS function="return Math.abs(window.calculatedHeight - window.actualHeight)" stepKey="ratioDifference"/>
68-
<assertLessThanOrEqual stepKey="assertRatio">
69-
<expectedResult type="int">{{acceptableOffset}}</expectedResult>
70-
<actualResult type="variable">ratioDifference</actualResult>
71-
</assertLessThanOrEqual>
72-
<grabAttributeFrom selector="{{page.iframe(index)}}" userInput="src" stepKey="videoSrc"/>
73-
<assertNotContains stepKey="assertNoAutoplay">
74-
<expectedResult type="string">autoplay</expectedResult>
75-
<actualResult type="variable">$videoSrc</actualResult>
76-
</assertNotContains>
63+
<waitForElementVisible selector="{{page.videoElement(index)}}" stepKey="waitForVideoElement"/>
64+
<waitForElementVisible selector="{{page.videoUrl(index, url.renderedValue)}}" stepKey="waitForVideoUrl"/>
7765
</actionGroup>
78-
<actionGroup name="validateVideoWithOnlyVideoUrlMp4">
66+
<actionGroup name="validateVideoAspectRatio">
67+
<annotations>
68+
<description>Validates that the video's aspect ratio in the video content type.</description>
69+
</annotations>
7970
<arguments>
80-
<argument name="page" defaultValue=""/>
71+
<argument name="page" defaultValue="VideoOnStage"/>
8172
<argument name="index" defaultValue="1" type="string"/>
82-
<argument name="url" defaultValue=""/>
83-
<!-- This is 2 because the width and the height may both have fractions that could round by a maximum of 1 for each which makes the maximum 2-->
8473
<argument name="acceptableOffset" defaultValue="2" type="string"/>
8574
</arguments>
86-
<waitForElementVisible selector="{{page.base(index)}}" stepKey="waitForElement"/>
87-
<waitForElementVisible selector="{{page.sourceVideo(index, url.renderedValue)}}" stepKey="waitForUrl"/>
88-
<waitForElementVisible selector="{{page.noWidth(index)}}" stepKey="waitForWidth"/>
89-
<comment userInput="Validate Aspect Ratio" stepKey="commentValidateAspectRatio"/>
90-
<executeJS function="return window.calculatedHeight = parseInt(getComputedStyle(document.evaluate(&quot;{{page.video(index)}}&quot;,document.body).iterateNext()).width) / 16 * 9" stepKey="calculatedHeight"/>
91-
<executeJS function="return window.actualHeight = parseInt(getComputedStyle(document.evaluate(&quot;{{page.video(index)}}&quot;,document.body).iterateNext()).height)" stepKey="actualHeight"/>
75+
<waitForPageLoad stepKey="waitForPageLoad"/>
76+
<waitForElementVisible selector="{{page.videoElement(index)}}" stepKey="waitForVideoElement"/>
77+
<executeJS function="return window.calculatedHeight = parseInt(getComputedStyle(document.evaluate(&quot;{{page.videoElement(index)}}&quot;,document.body).iterateNext()).width) / 16 * 9" stepKey="calculatedHeight"/>
78+
<executeJS function="return window.actualHeight = parseInt(getComputedStyle(document.evaluate(&quot;{{page.videoElement(index)}}&quot;,document.body).iterateNext()).height)" stepKey="actualHeight"/>
9279
<executeJS function="return Math.abs(window.calculatedHeight - window.actualHeight)" stepKey="ratioDifference"/>
9380
<assertLessThanOrEqual stepKey="assertRatio">
9481
<expectedResult type="int">{{acceptableOffset}}</expectedResult>
9582
<actualResult type="variable">ratioDifference</actualResult>
9683
</assertLessThanOrEqual>
97-
<waitForElementNotVisible selector="{{page.videoAutoplay(index)}}" stepKey="assertNoAutoplay"/>
84+
</actionGroup>
85+
<actionGroup name="validateVideoAutoPlay">
86+
<annotations>
87+
<description>Validates that the video content type has the autoplay attributes.</description>
88+
</annotations>
89+
<arguments>
90+
<argument name="page" defaultValue="VideoOnStage"/>
91+
<argument name="index" defaultValue="1" type="string"/>
92+
</arguments>
93+
<waitForPageLoad stepKey="waitForPageLoad"/>
94+
<waitForElementVisible selector="{{page.videoElement(index)}}" stepKey="waitForVideoElement"/>
95+
<waitForElementVisible selector="{{page.videoAutoplay(index)}}" stepKey="waitForVideoAutoplay"/>
96+
<grabAttributeFrom selector="{{page.videoElement(index)}}" userInput="src" stepKey="videoSrc"/>
97+
<assertContains stepKey="assertAutoplay">
98+
<expectedResult type="string">autoplay=1</expectedResult>
99+
<actualResult type="variable">$videoSrc</actualResult>
100+
</assertContains>
101+
</actionGroup>
102+
<actionGroup name="validateVideoNoAutoPlay" extends="validateVideoAutoPlay">
103+
<annotations>
104+
<description>Validates that the video content type does not have the autoplay attributes.</description>
105+
</annotations>
106+
<waitForElementVisible selector="{{page.videoNoAutoplay(index)}}" stepKey="waitForVideoAutoplay"/>
107+
<assertNotContains stepKey="assertAutoplay">
108+
<expectedResult type="string">autoplay</expectedResult>
109+
<actualResult type="variable">$videoSrc</actualResult>
110+
</assertNotContains>
98111
</actionGroup>
99112
<actionGroup name="validateVideoPlaying">
100113
<annotations>
101-
<description>Validates that the video content type is playing.</description>
114+
<description>Validates that the video content type is playing. Only works with videos that play in an iframe.</description>
102115
</annotations>
103116
<arguments>
104117
<argument name="page" defaultValue="VideoOnStage"/>
105-
<argument name="url" defaultValue="PageBuilderVideoUrl_Empty"/>
106118
<argument name="index" defaultValue="1" type="string"/>
107119
</arguments>
108120
<waitForPageLoad stepKey="waitForPageLoad"/>
109-
<waitForElementVisible selector="{{page.videoElement(index)}}" stepKey="waitForVideoVisible"/>
110-
<executeJS function="document.querySelector('[data-element=\'video\']').id = 'video-iframe'" stepKey="setIframeId"/>
111-
<switchToIFrame userInput="video-iframe" stepKey="switchToVideoIframe"/>
112-
<waitForElementVisible selector="{{page.iframePlaying(index)}}" stepKey="seeIframePlaying"/>
121+
<waitForElementVisible selector="{{page.videoElement(index)}}" stepKey="waitForVideoElement"/>
122+
<executeJS function="document.querySelectorAll('{{page.videoElementCss}}')[{{index}}-1].id = 'video-iframe'" stepKey="setIframeId"/>
123+
<switchToIFrame selector="video-iframe" stepKey="switchToVideoIframe"/>
124+
<waitForElementVisible selector="{{page.iframePlaying}}" stepKey="seeIframePlaying"/>
113125
<switchToIFrame stepKey="switchBackFromIframe"/>
114126
</actionGroup>
115127
<actionGroup name="validateVideoNotAutoplaying" extends="validateVideoPlaying">
116128
<annotations>
117-
<description>Validates that the video content type is not autoplaying.</description>
129+
<description>Validates that the video content type is not autoplaying. Only works with videos that play in an iframe.</description>
118130
</annotations>
119-
<waitForElementVisible selector="{{page.iframeNotAutoplaying(index)}}" stepKey="seeIframePlaying"/>
131+
<waitForElementVisible selector="{{page.iframeNotAutoplaying}}" stepKey="seeIframePlaying"/>
120132
</actionGroup>
121133
<actionGroup name="validateEmptyVideoStage">
134+
<annotations>
135+
<description>Validates that the video content type on the stage in admin is empty.</description>
136+
</annotations>
122137
<arguments>
123138
<argument name="index" defaultValue="1" type="string"/>
124139
</arguments>

app/code/Magento/PageBuilder/Test/Mftf/Data/VideoData.xml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
1111
<!-- URL -->
12-
<entity name="PageBuilderVideoUrl_Default" type="pagebuilder_video_url_property">
12+
<entity name="PageBuilderVideoUrl_Default" type="pagebuilder_video_url_property" deprecated="Use PageBuilderVideoUrl_Empty instead">
1313
<data key="name">Video URL</data>
1414
<data key="section">general</data>
1515
<data key="fieldName">video_source</data>
1616
<data key="text">Video</data>
1717
</entity>
18-
<entity name="PageBuilderVideoUrl_YouTube" type="pagebuilder_video_url_property">
18+
<entity name="PageBuilderVideoUrl_Empty" type="pagebuilder_video_url_property">
1919
<data key="name">Video URL</data>
2020
<data key="section">general</data>
2121
<data key="fieldName">video_source</data>
22-
<data key="value">https://www.youtube.com/embed/slOtnjsbff0</data>
23-
<data key="renderedValue">https://www.youtube.com/embed/slOtnjsbff0</data>
22+
<data key="value"/>
23+
<data key="text">Video</data>
24+
<data key="tooltipText">Video URLs can be links to videos on YouTube or Vimeo, or HTTP(S) links to files with valid video extensions (we recommend .mp4)</data>
2425
</entity>
2526
<entity name="PageBuilder_InvalidVideoURL_Text" type="pagebuilder_video_url_property">
2627
<data key="name">Video URL</data>
@@ -36,19 +37,19 @@
3637
<data key="value">&lt;iframe width=&quot;1280&quot; height=&quot;720&quot; src=&quot;https://www.youtube.com/embed/bLXEUP6vKEk"&gt;&lt;/iframe&gt;</data>
3738
<data key="errorMessage">Please enter a valid video URL. Valid URLs have a video file extension (.mp4, .webm, .ogv) or links to videos on YouTube or Vimeo.</data>
3839
</entity>
39-
<entity name="PageBuilderVideoUrl_NonEmbedded" type="pagebuilder_video_url_property">
40+
<entity name="PageBuilderVideoUrl_YouTube" type="pagebuilder_video_url_property">
4041
<data key="name">Video URL</data>
4142
<data key="section">general</data>
4243
<data key="fieldName">video_source</data>
43-
<data key="value">https://www.youtube.com/watch?v=slOtnjsbff0</data>
44+
<data key="value">https://www.youtube.com/embed/slOtnjsbff0</data>
4445
<data key="renderedValue">https://www.youtube.com/embed/slOtnjsbff0</data>
4546
</entity>
46-
<entity name="PageBuilderVideoUrl_Empty" type="pagebuilder_video_url_property">
47+
<entity name="PageBuilderVideoUrl_NonEmbedded" type="pagebuilder_video_url_property">
4748
<data key="name">Video URL</data>
4849
<data key="section">general</data>
4950
<data key="fieldName">video_source</data>
50-
<data key="value"/>
51-
<data key="tooltipText">Video URLs can be links to videos on YouTube or Vimeo, or HTTP(S) links to files with valid video extensions (we recommend .mp4)</data>
51+
<data key="value">https://www.youtube.com/watch?v=slOtnjsbff0</data>
52+
<data key="renderedValue">https://www.youtube.com/embed/slOtnjsbff0</data>
5253
</entity>
5354
<entity name="PageBuilderVideoUrl_YouTube_Insecure" type="pagebuilder_video_url_property">
5455
<data key="name">Video URL</data>
@@ -95,6 +96,12 @@
9596
<data key="height">320px</data>
9697
</entity>
9798
<!-- Width -->
99+
<entity name="PageBuilderVideoWidth_Empty" type="pagebuilder_video_width_property">
100+
<data key="name">Maximum Width</data>
101+
<data key="section">general</data>
102+
<data key="fieldName">max_width</data>
103+
<data key="value"/>
104+
</entity>
98105
<entity name="PageBuilderVideoWidth_500" type="pagebuilder_video_width_property">
99106
<data key="name">Maximum Width</data>
100107
<data key="section">general</data>

0 commit comments

Comments
 (0)