Skip to content

Commit 2f0a53c

Browse files
Update test code to match React-based plate designer (#2967)
#### Rationale The test needs to be updated to the new DOM from the React reimplementation of the plate designer. #### Related Pull Requests - LabKey/platform#7623 #### Changes - Update to new DOM - Consolidate more in PlateDesignerPage
1 parent 60f490f commit 2f0a53c

5 files changed

Lines changed: 66 additions & 62 deletions

File tree

src/org/labkey/test/pages/assay/plate/PlateDesignerPage.java

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.openqa.selenium.WebDriver;
99
import org.openqa.selenium.WebElement;
1010
import org.openqa.selenium.interactions.Actions;
11+
import org.openqa.selenium.support.ui.Select;
1112

1213
import java.util.HashMap;
1314
import java.util.Map;
@@ -37,55 +38,65 @@ public void createWellGroup(String type, String name)
3738
{
3839
selectTypeTab(type);
3940

40-
WebElement nameField = Locator.tagWithName("input", "wellGroupName")
41-
.withAttribute("data-type", type)
42-
.findElement(getDriver());
43-
setFormElement(nameField, name);
44-
fireEvent(nameField, SeleniumEvent.change);
41+
// Wait for the create row to be visible (canAdd must be true for this type)
42+
WebElement newNameInput = Locator.css(".group-types-panel__new-name-input")
43+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
44+
45+
if ("input".equalsIgnoreCase(newNameInput.getTagName()))
46+
{
47+
setFormElement(newNameInput, name);
48+
}
49+
else
50+
{
51+
new Select(newNameInput).selectByVisibleText(name);
52+
}
53+
4554
clickButton("Create", 0);
46-
waitForElement(Locator.tagContainingText("label", name));
55+
waitForElement(Locator.css(".group-types-panel__group-name").withText(name));
4756
}
4857

4958
public void selectTypeTab(String name)
5059
{
51-
Locator.tagWithClass("div", "gwt-Label").withText(name).waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT).click();
60+
Locator.css(".group-types-panel__tab").withText(name)
61+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT).click();
62+
}
63+
64+
public void selectGroup(String name)
65+
{
66+
Locator.css(".group-types-panel__group-name").withText(name)
67+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT).click();
5268
}
5369

5470
public void selectWellsForWellgroup(String type, String wellGroup, String startLocation, String endLocation)
5571
{
5672
selectTypeTab(type);
57-
waitForElement(Locator.tagWithText("label", wellGroup));
5873

59-
Locator start = Locator.css(".Cell-"+startLocation);
60-
Locator end = Locator.css(".Cell-"+endLocation);
61-
if (wellGroup != null & !"".equals(wellGroup))
74+
if (wellGroup != null && !wellGroup.isEmpty())
6275
{
63-
if (!getText(Locator.css(".gwt-TabBarItem-selected")).equals(type))
64-
{
65-
Locator.css(".gwt-Label").withText(type).findElement(getDriver()).click();
66-
//want for switch
67-
}
68-
if (!isChecked(Locator.xpath("//input[@name='wellGroup' and following-sibling::label[text()='"+wellGroup+"']]")))
69-
click(Locator.xpath("//input[@name='wellGroup' and following-sibling::label[text()='"+wellGroup+"']]"));
70-
if (!getAttribute(start, "style").contains("rgb(255, 255, 255)"))
71-
click(start);
72-
}
73-
else
74-
{
75-
Locator.tagWithClass("*", "gwt-Label").withText(type).findElement(getDriver()).click();
76-
//select no group in order to clear area
76+
selectGroup(wellGroup);
7777
}
78-
WebElement fromEl = start.findElement(getDriver());
79-
WebElement toEl = end.findElement(getDriver());
78+
79+
// Cells are <td> elements with aria-label matching the location (e.g. "A1" or "A1: Specimen 1")
80+
WebElement fromEl = Locator.css(".template-grid__cell[aria-label^='" + startLocation + "']")
81+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
82+
WebElement toEl = Locator.css(".template-grid__cell[aria-label^='" + endLocation + "']")
83+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
8084

8185
Actions builder = new Actions(getDriver());
8286
builder.clickAndHold(fromEl).moveToElement(toEl).release().build().perform();
8387
}
8488

89+
public void setWellGroupProperty(String propertyKey, String value)
90+
{
91+
WebElement input = Locator.tag("input").withAttribute("aria-label", propertyKey)
92+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
93+
setFormElement(input, value);
94+
}
95+
8596
public void setName(String name)
8697
{
87-
Locator nameField = Locator.id("templateName");
88-
waitForElement(nameField, WAIT_FOR_JAVASCRIPT);
98+
WebElement nameField = Locator.css(".plate-template-designer__name-input")
99+
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
89100
setFormElement(nameField, name);
90101
fireEvent(nameField, SeleniumEvent.change);
91102
}
@@ -100,13 +111,18 @@ public void save()
100111
clickButton("Save", 0);
101112
}
102113

114+
public void cancel()
115+
{
116+
clickButton("Cancel");
117+
}
118+
103119
@Override
104120
protected ElementCache newElementCache()
105121
{
106122
return new ElementCache();
107123
}
108124

109-
protected class ElementCache extends LabKeyPage.ElementCache
125+
protected class ElementCache extends LabKeyPage<?>.ElementCache
110126
{
111127
}
112128

src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ protected void createTemplate()
467467
plateDesigner.selectTypeTab("CONTROL");
468468

469469
clickButton("Create", 0);
470-
waitForElement(Locator.tagWithText("label", "Background Wells"));
470+
waitForElement(Locator.tagWithText("span", "Background Wells"));
471471

472472
plateDesigner.selectWellsForWellgroup("CONTROL", "Background Wells", "A1", "B3");
473473
plateDesigner.selectWellsForWellgroup("CONTROL", "Background Wells", "C4", "D6");

src/org/labkey/test/tests/nab/NabAssayTest.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,28 +210,22 @@ public void runUITests()
210210
.setAssayType("NAb")
211211
.setTemplateType("single-plate")));
212212

213-
setFormElement(Locator.inputById("templateName"), PLATE_TEMPLATE_NAME);
213+
PlateDesignerPage designerPage = new PlateDesignerPage(getDriver());
214+
designerPage.setName(PLATE_TEMPLATE_NAME);
215+
designerPage.selectTypeTab("SPECIMEN");
214216

215-
// select the specimen wellgroup tab
216-
click(Locator.tagWithText("div", "SPECIMEN"));
217+
designerPage.selectGroup("Specimen 1");
218+
designerPage.setWellGroupProperty("ReverseDilutionDirection", "true");
217219

218-
// select the first specimen group
219-
click(Locator.tagWithText("label", "Specimen 1"));
220-
// set reversed dilution direction to true:
221-
setFormElement(Locator.inputById("property-ReverseDilutionDirection"), "true");
220+
designerPage.selectGroup("Specimen 2");
221+
designerPage.setWellGroupProperty("ReverseDilutionDirection", "false");
222222

223-
// select the second specimen group
224-
click(Locator.tagWithText("label", "Specimen 2"));
225-
// set reversed dilution direction to false:
226-
setFormElement(Locator.inputById("property-ReverseDilutionDirection"), "false");
227-
228-
// select the third specimen group
229-
click(Locator.tagWithText("label", "Specimen 3"));
223+
designerPage.selectGroup("Specimen 3");
230224
// set reversed dilution direction to a nonsense value:
231-
setFormElement(Locator.inputById("property-ReverseDilutionDirection"), "invalid boolean value");
225+
designerPage.setWellGroupProperty("ReverseDilutionDirection", "invalid boolean value");
232226

233227
// note that we're intentionally leaving the fourth and fifth direction specifiers null, which should default to 'false'
234-
clickButton("Save & Close");
228+
designerPage.saveAndClose();
235229

236230
assertTextPresent(PLATE_TEMPLATE_NAME, "NAb: 5 specimens in duplicate");
237231

src/org/labkey/test/tests/nab/NabHighThroughputAssayTest.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,9 @@ protected void doInit()
8888
.setAssayType("NAb")
8989
.setTemplateType("high-throughput (single plate dilution)")));
9090

91-
Locator.IdLocator nameField = Locator.id("templateName");
92-
waitForElement(nameField, WAIT_FOR_JAVASCRIPT);
93-
setFormElement(nameField, PLATE_TEMPLATE_NAME);
94-
fireEvent(nameField, SeleniumEvent.change);
95-
96-
clickButton("Save & Close");
91+
PlateDesignerPage designerPage = new PlateDesignerPage(getDriver());
92+
designerPage.setName(PLATE_TEMPLATE_NAME);
93+
designerPage.saveAndClose();
9794
assertTextPresent(PLATE_TEMPLATE_NAME);
9895

9996
// create the cross plate dilution template
@@ -103,11 +100,9 @@ protected void doInit()
103100
.setAssayType("NAb")
104101
.setTemplateType("high-throughput (cross plate dilution)")));
105102

106-
waitForElement(nameField, WAIT_FOR_JAVASCRIPT);
107-
setFormElement(nameField, CPD_PLATE_TEMPLATE_NAME);
108-
fireEvent(nameField, SeleniumEvent.change);
109-
110-
clickButton("Save & Close");
103+
designerPage = new PlateDesignerPage(getDriver());
104+
designerPage.setName(CPD_PLATE_TEMPLATE_NAME);
105+
designerPage.saveAndClose();
111106
assertTextPresent(CPD_PLATE_TEMPLATE_NAME);
112107

113108
_containerHelper.createSubfolder(getProjectName(), TEST_ASSAY_FLDR_NAB);

src/org/labkey/test/tests/nab/NabMultiVirusPlateTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ private void doCreateSteps()
111111
.setAssayType("NAb")
112112
.setTemplateType("multi-virus plate")));
113113

114-
waitForElement(Locator.xpath("//input[@id='templateName']"), WAIT_FOR_JAVASCRIPT);
115-
setFormElement(Locator.xpath("//input[@id='templateName']"), PLATE_TEMPLATE_NAME);
116-
117-
clickButton("Save & Close");
114+
PlateDesignerPage designerPage = new PlateDesignerPage(getDriver());
115+
designerPage.setName(PLATE_TEMPLATE_NAME);
116+
designerPage.saveAndClose();
118117

119118
goToProjectHome();
120119

0 commit comments

Comments
 (0)