Skip to content

Commit

Permalink
Add partial selenium tests implementation for Video component
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Negrusa committed Jul 9, 2021
1 parent 51447af commit 2324f9f
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 1 deletion.
Expand Up @@ -78,7 +78,7 @@
fieldDescription="Textual alternative of the meaning or function of the image, for visually impaired readers."
fieldLabel="Alternative Text"
name="./alt"
required="{Boolean}true"
required="{Boolean}false"
wrapperClass="cmp-image--editor-alt"/>
</items>
</column>
Expand Down
@@ -0,0 +1,54 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2021 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

package com.adobe.cq.wcm.core.components.it.seljup.components.video;

import com.adobe.cq.testing.selenium.pagewidgets.coral.CoralCheckbox;

import static com.codeborne.selenide.Selenide.$$;

public class VideoEditDialog {
private static String loopEnabled = ".cmp-video__editor coral-checkbox[name='./loopEnabled']";
private static String hideControl = ".cmp-video__editor coral-checkbox[name='./hideControl']";
private static String autoplayEnabled = ".cmp-video__editor coral-checkbox[name='./autoplayEnabled']";

public void openVideoTab() {
$$(".cmp-video__editor coral-tab").get(0).click();
}

public void openPosterTab() {
$$(".cmp-video__editor coral-tab").get(1).click();
}

public void openPropertiesTab() {
$$(".cmp-video__editor coral-tab").get(2).click();
}

public void clickLoopEnabled() {
CoralCheckbox checkbox = new CoralCheckbox(loopEnabled);
checkbox.click();
}

public void clickHideControl() {
CoralCheckbox checkbox = new CoralCheckbox(hideControl);
checkbox.click();
}

public void clickAutoplayEnabled() {
CoralCheckbox checkbox = new CoralCheckbox(autoplayEnabled);
checkbox.click();
}
}
@@ -0,0 +1,31 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2021 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

package com.adobe.cq.wcm.core.components.it.seljup.components.video.v1;

import com.adobe.cq.testing.selenium.pagewidgets.common.BaseComponent;
import com.adobe.cq.wcm.core.components.it.seljup.components.video.VideoEditDialog;

public class Video extends BaseComponent {

public Video() {
super(".cmp-video");
}

public VideoEditDialog getEditDialog() {
return new VideoEditDialog();
}
}
@@ -0,0 +1,91 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2021 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

package com.adobe.cq.wcm.core.components.it.seljup.tests.video.v1;

import com.adobe.cq.testing.selenium.pageobject.EditorPage;
import com.adobe.cq.testing.selenium.pageobject.PageEditorPage;
import com.adobe.cq.wcm.core.components.it.seljup.AuthorBaseUITest;
import com.adobe.cq.wcm.core.components.it.seljup.components.video.VideoEditDialog;
import com.adobe.cq.wcm.core.components.it.seljup.components.video.v1.Video;
import com.adobe.cq.wcm.core.components.it.seljup.constant.CoreComponentConstants;
import com.adobe.cq.wcm.core.components.it.seljup.util.Commons;
import org.apache.http.HttpStatus;
import org.apache.sling.testing.clients.ClientException;
import org.junit.jupiter.api.*;

import java.util.concurrent.TimeoutException;

import static com.codeborne.selenide.Selenide.$;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag("group2")
public class VideoIT extends AuthorBaseUITest {

private static String componentName = "video";

private String proxyComponentPath;

protected String testPage;
protected EditorPage editorPage;
protected Video video;
protected String cmpPath;
protected String videoRT;

private void setupResources() {
videoRT = Commons.rtVideo_v1;
}

protected void setup() throws ClientException {
testPage = authorClient.createPage("testPage", "Test Page", rootPage, defaultPageTemplate, 200, 201).getSlingPath();
proxyComponentPath = Commons.creatProxyComponent(adminClient, videoRT, "Proxy Video", componentName);
addPathtoComponentPolicy(responsiveGridPath, proxyComponentPath);
cmpPath = Commons.addComponent(adminClient, proxyComponentPath,testPage + Commons.relParentCompPath, componentName, null);
editorPage = new PageEditorPage(testPage);
editorPage.open();
video = new Video();
}

@BeforeEach
public void setupBefore() throws Exception {
setupResources();
setup();
}

@AfterEach
public void cleanup() throws ClientException, InterruptedException {
Commons.deleteProxyComponent(adminClient, proxyComponentPath);
authorClient.deletePageWithRetry(testPage, true,false, CoreComponentConstants.TIMEOUT_TIME_MS, CoreComponentConstants.RETRY_TIME_INTERVAL, HttpStatus.SC_OK);
}

@Test
@DisplayName("Test: Add video component")
public void testAddVideo() throws InterruptedException {
VideoEditDialog editDialog = video.getEditDialog();
Thread.sleep(4000);
}

@Test
@DisplayName("Test: Check video boxes")
public void testCheckBoxes() throws InterruptedException, TimeoutException {
Commons.openEditDialog(editorPage, cmpPath);
VideoEditDialog editDialog = video.getEditDialog();
editDialog.openPropertiesTab();
editDialog.clickLoopEnabled();
Commons.saveConfigureDialog();
assertTrue($(".cmp-video video").getAttribute("loop").equals(""), "loop is set");
}
}
Expand Up @@ -117,6 +117,8 @@ public class Commons {
public static String rtCarousel_v1 = "core/wcm/components/carousel/v1/carousel";
// tabs component
public static String rtTabs_v1 = "core/wcm/components/tabs/v1/tabs";
// video component
public static String rtVideo_v1 = "core/wcm/components/video/v1/video";
// content fragment component
public static String rtContentFragment_v1 = "core/wcm/components/contentfragment/v1/contentfragment";
// content fragment list component
Expand Down

0 comments on commit 2324f9f

Please sign in to comment.