Skip to content

Commit

Permalink
schrodinger: export popup panel coverage + test
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Nov 23, 2020
1 parent c528412 commit 2b79761
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 13 deletions.
Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.testing.schrodinger.scenarios;

import com.evolveum.midpoint.schrodinger.component.common.table.Table;
import com.evolveum.midpoint.schrodinger.component.modal.ExportPopupPanel;
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
import com.evolveum.midpoint.testing.schrodinger.AbstractSchrodingerTest;

Expand Down Expand Up @@ -33,7 +35,7 @@ protected List<File> getObjectListToImport(){
CUSTOM_COLUMNS_OBJECT_COLLECTION_KEY_LABELS_FILE);
}

@Test
@Test(priority = 1)
public void test00100checkUserCustomColumns() {
Assert.assertEquals(basicPage.listUsers("Custom columns view")
.table()
Expand All @@ -46,10 +48,9 @@ public void test00100checkUserCustomColumns() {
.findColumnByLabel("Preferred language"), 5, "Preferred language column index doesn't match");
}

@Test
@Test(priority = 2)
public void test00200checkUserCustomColumnsKeyLabels() {
ListUsersPage usersPage = basicPage.listUsers("Custom columns label test");
screenshot("customColumnsLabelsTest");
Assert.assertEquals(usersPage
.table()
.findColumnByLabel("Enable"), 3, "Enable column index doesn't match");
Expand All @@ -60,4 +61,22 @@ public void test00200checkUserCustomColumnsKeyLabels() {
.table()
.findColumnByLabel("Unlink"), 5, "Unlink column index doesn't match");
}

@Test(priority = 3)
public void test00300checkExportColumns() {
ListUsersPage usersPage = basicPage.listUsers("Custom columns view");
Table<ExportPopupPanel<ListUsersPage>> exportTable = usersPage.table()
.clickExportButton()
.table();
screenshot("exportTable");
Assert.assertNotNull(exportTable
.rowByColumnLabel("Column name", "Name (custom)"),
"Name column (in Export popup) doesn't exist,");
Assert.assertNotNull(exportTable
.rowByColumnLabel("Column name", "Role membership"),
"Role membership column (in Export popup) doesn't exist,");
Assert.assertNotNull(exportTable
.rowByColumnLabel("Column name", "Preferred language"),
"Preferred language column (in Export popup) doesn't exist,");
}
}
Expand Up @@ -12,6 +12,11 @@
import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;

import com.evolveum.midpoint.schrodinger.component.modal.ExportPopupPanel;

import com.evolveum.midpoint.schrodinger.util.Utils;

import org.openqa.selenium.By;

import com.evolveum.midpoint.schrodinger.MidPoint;
Expand Down Expand Up @@ -76,16 +81,6 @@ public AssignmentHolderObjectListTable<P, PD> selectAll() {
}

public SelenideElement getToolbarButton(String iconCssClass){
// SelenideElement buttonToolbar = getButtonToolbar();
// SelenideElement buttonElement = null;
// ElementsCollection toolbarButtonsList = buttonToolbar
// .findAll(By.tagName("button"));
// for (SelenideElement button : toolbarButtonsList) {
// SelenideElement iconElement = button.$(By.tagName("i")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S);
// if (iconElement != null && iconElement.exists() && iconElement.getAttribute("class") != null && iconElement.getAttribute("class").contains(iconCssClass)) {
// buttonElement = button;
// }
// }
return getButtonToolbar().$(By.cssSelector(iconCssClass));
}

Expand All @@ -97,6 +92,14 @@ public PD newObjectButtonClickPerformed(String iconCssClass){
return getObjectDetailsPage();
}

public ExportPopupPanel<P> clickExportButton() {
getToolbarButton(".fa.fa-download")
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S)
.click();
Selenide.sleep(2000);
return new ExportPopupPanel<>(getParent(), Utils.getModalWindowSelenideElement());
}

public PD newObjectCollectionButtonClickPerformed(String mainButtonIconCssClass, String objCollectionButtonIconCssClass){
SelenideElement mainButtonElement = getToolbarButton(mainButtonIconCssClass)
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S);
Expand Down
@@ -0,0 +1,41 @@
package com.evolveum.midpoint.schrodinger.component.modal;

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.SelenideElement;

import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.common.table.Table;
import com.evolveum.midpoint.schrodinger.util.Schrodinger;

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

public class ExportPopupPanel<T> extends ModalBox<T> {

public ExportPopupPanel(T parent, SelenideElement parentElement) {
super(parent, parentElement);
}

public Table<ExportPopupPanel<T>> table() {
return new Table<>(this,
getParentElement().$(Schrodinger.bySelfOrDescendantElementAttributeValue("div", "data-s-id", "table",
"style", "float: left; padding-bottom: 5px;"))
.waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S));
}

public ExportPopupPanel<T> setReportName(String reportName) {
getParentElement().$x("//div[@data-s-id='name']").waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S)
.setValue(reportName);
return this;
}

public T exportSelectedColumns() {
$(Schrodinger.byDataId("export")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).click();
return getParent();
}

public T cancel() {
$(Schrodinger.byDataId("cancelButton")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).click();
return getParent();
}

}

0 comments on commit 2b79761

Please sign in to comment.