Skip to content

Commit

Permalink
Merge pull request #1147 from phac-nml/fix-flaky-ui-tests
Browse files Browse the repository at this point in the history
Fix flaky ui tests
  • Loading branch information
joshsadam authored Dec 16, 2021
2 parents aa18fa6 + 8fb6261 commit 88e8067
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/webapp/resources/js/apis/projects/user-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const BASE_URL = setBaseUrl(`/ajax/projects/groups`);
export async function removeUserGroupFromProject({ projectId, groupId }) {
const params = new URLSearchParams({ projectId, groupId });
try {
const { data } = axios.delete(`${BASE_URL}?${params.toString()}`);
const { data } = await axios.delete(`${BASE_URL}?${params.toString()}`);
return Promise.resolve(data);
} catch (e) {
return Promise.reject(e.response.data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -318,7 +320,18 @@ public void filterSamples(String searchStr) {
* Gets provenance for file selected
*/
public void getFileProvenance(int fileNum) {
WebDriverWait wait = new WebDriverWait(driver, 2);
WebElement firstTool = null;

if (toolList.size() > 0) {
firstTool = toolList.get(0);
}

files.get(fileNum).click();

if (firstTool != null) {
wait.until(ExpectedConditions.invisibilityOf(firstTool));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.springframework.web.util.UriUtils;

import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage;

Expand Down Expand Up @@ -52,9 +53,9 @@ public NcbiExportPage(WebDriver driver) {
public static NcbiExportPage goTo(WebDriver driver, Long projectId, Collection<Long> sampleIds) {

StringJoiner stringJoiner = new StringJoiner("&");
sampleIds.forEach(s -> stringJoiner.add("ids[]=" + s.toString()));
sampleIds.forEach(s -> stringJoiner.add(UriUtils.encodeQuery("ids[]=" + s.toString(), "UTF-8")));

String url = "/projects/" + projectId + "/export/ncbi?" + stringJoiner.toString();
String url = "projects/" + projectId + "/export/ncbi?" + stringJoiner.toString();
get(driver, url);
return PageFactory.initElements(driver, NcbiExportPage.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,17 @@ public boolean allFieldsTemplateIsDefault() {
return defaultTag.size() == 1;
}

public void setDefaultTemplate() {
WebElement newDefaultTemplate = metadataTemplateRow.get(0);
WebElement setDefaultTemplate = newDefaultTemplate.findElement(By.className("t-t-set-default-button"));
setDefaultTemplate.click();
public void setDefaultTemplate(String name) {
WebElement templateRow = null;
for (WebElement row : metadataTemplateRow) {
String text = row.findElement(By.className("t-t-name")).getText();
if (text.equalsIgnoreCase(name)) {
templateRow = row;
break;
}
}
WebElement setDefaultTemplateBtn = templateRow.findElement(By.className("t-t-set-default-button"));
setDefaultTemplateBtn.click();
}

public boolean removeButtonIsDisabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public void testAdminProjectMetadata() {
page.getNumberOfMetadataTemplates());

// Set the first template as the default for the project which is the template created above
page.setDefaultTemplate();
page.setDefaultTemplate(newTemplateName);
// The remove button for the default template should be disabled.
page.removeButtonIsDisabled();

// The all fields template shouldn't be the default as we set the new template created above as the default
Assert.assertFalse(page.allFieldsTemplateIsDefault());

// The current default template
page.gotoTemplate("An awesome name");
page.gotoTemplate(newTemplateName);
Assert.assertTrue(page.defaultTemplateTagVisible());

page.gotoMetadataTemplates();
Expand Down

0 comments on commit 88e8067

Please sign in to comment.