-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test components for biologics cross-folder input form actions tests (#…
- Loading branch information
1 parent
1f86123
commit 6eb1d8a
Showing
2 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
src/org/labkey/test/components/react/SelectInputOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package org.labkey.test.components.react; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.labkey.api.collections.CaseInsensitiveHashMap; | ||
import org.labkey.api.collections.CaseInsensitiveMapWrapper; | ||
import org.labkey.api.util.Pair; | ||
import org.labkey.test.Locator; | ||
import org.labkey.test.components.Component; | ||
import org.labkey.test.components.WebDriverComponent; | ||
import org.labkey.test.components.html.Input; | ||
import org.labkey.test.pages.LabKeyPage; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.labkey.test.components.html.Input.Input; | ||
|
||
/* | ||
This component is meant to wrap the verbose options in filteringReactSelect, ReactSelect | ||
*/ | ||
public class SelectInputOption extends WebDriverComponent<SelectInputOption.ElementCache> | ||
{ | ||
private final WebElement _el; | ||
private final WebDriver _driver; | ||
|
||
protected SelectInputOption(WebElement element, WebDriver driver) | ||
{ | ||
_el = element; | ||
_driver = driver; | ||
} | ||
|
||
@Override | ||
public WebElement getComponentElement() | ||
{ | ||
return _el; | ||
} | ||
|
||
@Override | ||
public WebDriver getDriver() | ||
{ | ||
return _driver; | ||
} | ||
|
||
public boolean isFocused() | ||
{ | ||
return getComponentElement().getAttribute("class").contains("select-input__option--is-focused"); | ||
} | ||
|
||
public Map<String, String> getData() | ||
{ | ||
return elementCache().getData(); | ||
} | ||
|
||
@Override | ||
protected ElementCache newElementCache() | ||
{ | ||
return new ElementCache(); | ||
} | ||
|
||
@Override | ||
protected ElementCache elementCache() | ||
{ | ||
return (ElementCache) super.elementCache(); | ||
} | ||
|
||
|
||
protected class ElementCache extends Component<?>.ElementCache | ||
{ | ||
public Locator.XPathLocator text_truncatePairLoc = Locator.tagWithClass("div", "text__truncate"); | ||
|
||
public Map<String, String> getData() | ||
{ | ||
Map<String, String> data = new CaseInsensitiveHashMap<>(); | ||
var elements = text_truncatePairLoc.findElements(this); | ||
for (WebElement el : elements) | ||
{ | ||
WebElement keyEl = Locator.tag("strong").findElement(el); | ||
WebElement valEl = Locator.tag("span").findElement(el); | ||
data.put(StringUtils.stripEnd(keyEl.getText(), ":"), valEl.getText()); | ||
} | ||
return data; | ||
} | ||
|
||
} | ||
|
||
|
||
public static class SelectInputOptionFinder extends WebDriverComponentFinder<SelectInputOption, SelectInputOptionFinder> | ||
{ | ||
private final Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "select-input__option"); | ||
private String _key = null; | ||
private String _value = null; | ||
|
||
public SelectInputOptionFinder(WebDriver driver) | ||
{ | ||
super(driver); | ||
} | ||
|
||
public SelectInputOptionFinder withValue(String key, String value) | ||
{ | ||
_key = key; | ||
_value = value; | ||
return this; | ||
} | ||
|
||
@Override | ||
protected SelectInputOption construct(WebElement el, WebDriver driver) | ||
{ | ||
return new SelectInputOption(el, driver); | ||
} | ||
|
||
|
||
@Override | ||
protected Locator locator() | ||
{ | ||
if (_key != null) | ||
return _baseLocator.withChild(Locator.tagWithClass("div", "text__truncate") | ||
.withChild(Locator.tagWithText("strong",_key)) | ||
.parent() // children are siblings | ||
.withChild(Locator.tagWithAttributeContaining("span", "title", _value))); | ||
else | ||
return _baseLocator; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/org/labkey/test/components/ui/navigation/apps/ChangeTargetFolderDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.labkey.test.components.ui.navigation.apps; | ||
|
||
import org.labkey.test.components.bootstrap.ModalDialog; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
|
||
|
||
public class ChangeTargetFolderDialog extends ModalDialog | ||
{ | ||
private final UpdatesTargetFolder _updatingComponent; | ||
public ChangeTargetFolderDialog(WebDriver driver, UpdatesTargetFolder updatingComponent) | ||
{ | ||
super(new ModalDialogFinder(driver).withTitle("Change projects and reset form?")); | ||
this._updatingComponent = updatingComponent; | ||
} | ||
|
||
|
||
public void clickCancel() | ||
{ | ||
dismiss("Cancel"); | ||
} | ||
|
||
public void clickChangeProjects() | ||
{ | ||
_updatingComponent.doAndWaitForFolderUpdate(()-> | ||
dismiss("Change Projects")); | ||
|
||
} | ||
|
||
|
||
|
||
static public interface UpdatesTargetFolder | ||
{ | ||
void doAndWaitForFolderUpdate(Runnable func); | ||
} | ||
} |