Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to account for the presence of premium modules #2120

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/org/labkey/test/components/domain/DomainFormPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.labkey.test.components.ui.grids.ResponsiveGrid;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.selenium.WebElementWrapper;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
Expand Down Expand Up @@ -531,6 +530,10 @@ public String getPanelAlertText(int index)
return getPanelAlertWebElement(index).getText();
}

public List<String> getPanelAlertTexts()
{
return getWrapper().getTexts(getPanelAlertElements());
}
/**
* There may be an element in the alert that a test will need to interact with so return the alert element and let
* the test find the control it needs.
Expand All @@ -543,19 +546,17 @@ public WebElement getPanelAlertWebElement()

public WebElement getPanelAlertWebElement(int index)
{
try
{
getWrapper().waitFor(() -> BootstrapLocators.infoBanner.existsIn(getDriver()),
"the info alert did not appear as expected", 1000);
}
catch (TimeoutException e)
return getPanelAlertElements().get(index);
}

public List<WebElement> getPanelAlertElements()
{
if (!WebDriverWrapper.waitFor(() -> BootstrapLocators.infoBanner.existsIn(this), 1000))
{
return null;
}

// It would be better to not return a raw WebElement but who knows what the future holds, different alerts
// may show different controls.
return BootstrapLocators.infoBanner.index(index).findElement(this);
return BootstrapLocators.infoBanner.findElements(this);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/tests/SampleTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.assertj.core.api.Assertions;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand Down Expand Up @@ -1357,7 +1358,7 @@ public void testIgnoreReservedFieldNames() throws Exception
DomainFormPanel domainForm = createPage
.getFieldsPanel()
.setInferFieldFile(inferenceFile);
checker().verifyEquals("Reserved field warning not as expected", expectedInfoMsg, domainForm.getPanelAlertText());
checker().verifyThat("Reserved field warning not as expected", domainForm.getPanelAlertTexts(), CoreMatchers.hasItem(expectedInfoMsg));
createPage.clickSave();
DataRegionTable drt = DataRegion(getDriver()).find();
checker().verifyTrue("Sample type not found in list of sample types", drt.getColumnDataAsText("Name").contains(name));
Expand Down
8 changes: 8 additions & 0 deletions src/org/labkey/test/tests/StudyBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.labkey.test.components.ext4.Checkbox;
import org.labkey.test.pages.DatasetPropertiesPage;
import org.labkey.test.pages.admin.ExportFolderPage;
import org.labkey.test.pages.compliance.FolderManagementComplianceTab;
import org.labkey.test.params.FieldDefinition.PhiSelectType;
import org.labkey.test.util.APITestHelper;
import org.labkey.test.util.ApiPermissionsHelper;
Expand Down Expand Up @@ -107,6 +108,13 @@ protected void initializeFolder()
if (_studyHelper.isSpecimenModulePresent())
_containerHelper.enableModule("Specimen");
new ApiPermissionsHelper(this).checkInheritedPermissions();

if (_containerHelper.getAllModules().contains("compliance"))
{
FolderManagementComplianceTab.beginAt(this, getProjectName()).setPhiRolesRequired(true).save();
new ApiPermissionsHelper(getProjectName()).setUserPermissions(getCurrentUser(), "Restricted PHI Reader");
FolderManagementComplianceTab.beginAt(this, getProjectName() + "/" + getFolderName()).setPhiRolesRequired(true).save();
}
}

// Start importing the specimen archive. This can load in the background while executing the first set of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.labkey.test.tests.filecontent;

import org.assertj.core.api.Assertions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -75,11 +76,12 @@ public void testDefaultActions()
BrowserAction.UPLOAD,
BrowserAction.IMPORT_DATA,
BrowserAction.AUDIT_HISTORY,
BrowserAction.ADMIN)
BrowserAction.ADMIN,
BrowserAction.CREATE_RUN)
);

// All icons are present by default
for (BrowserAction action : BrowserAction.values())
for (BrowserAction action : filterActionsForAvailableModules(BrowserAction.values()))
{
assertElementPresent(action.getButtonIconLocator());
if (buttonsWithText.contains(action))
Expand All @@ -106,7 +108,8 @@ public void testEditorActions()
BrowserAction.EDIT_PROPERTIES,
BrowserAction.UPLOAD,
BrowserAction.IMPORT_DATA,
BrowserAction.EMAIL_SETTINGS
BrowserAction.EMAIL_SETTINGS,
BrowserAction.CREATE_RUN
);

stopImpersonatingRole();
Expand All @@ -126,7 +129,8 @@ public void testSubmitterReaderActions()
BrowserAction.EDIT_PROPERTIES,
BrowserAction.UPLOAD,
BrowserAction.IMPORT_DATA,
BrowserAction.EMAIL_SETTINGS
BrowserAction.EMAIL_SETTINGS,
BrowserAction.CREATE_RUN
);

stopImpersonatingRole();
Expand All @@ -146,7 +150,8 @@ public void testAuthorActions()
BrowserAction.EDIT_PROPERTIES,
BrowserAction.UPLOAD,
BrowserAction.IMPORT_DATA,
BrowserAction.EMAIL_SETTINGS
BrowserAction.EMAIL_SETTINGS,
BrowserAction.CREATE_RUN
);

stopImpersonatingRole();
Expand Down Expand Up @@ -251,7 +256,15 @@ public void testActionsWithSpecialCharactersInFileName()

private void assertActionsAvailable(BrowserAction... actions)
{
assertEquals(Arrays.asList(actions), _fileBrowserHelper.getAvailableBrowserActions());
assertEquals(filterActionsForAvailableModules(actions), _fileBrowserHelper.getAvailableBrowserActions());
}

@NotNull
private List<BrowserAction> filterActionsForAvailableModules(BrowserAction[] actions)
{
Set<String> allModules = _containerHelper.getAllModules();
return Arrays.stream(actions)
.filter(action -> allModules.contains(action.getRequiredModule())).toList();
}

private void resetToDefaultToolbar()
Expand Down
13 changes: 12 additions & 1 deletion src/org/labkey/test/util/FileBrowserHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,13 @@ public enum BrowserAction
EMAIL_SETTINGS("envelope", "Email Preferences", "emailPreferences"),
AUDIT_HISTORY("users", "Audit History", "auditLog", true),
ADMIN("cog", "Admin", "customize"),
CREATE_RUN("sitemap", "Create Run", "createRun");
CREATE_RUN("sitemap", "Create Run", "createRun"){
@Override
public String getRequiredModule()
{
return "Provenance";
}
};

private final String _iconName;
private final String _buttonText;
Expand Down Expand Up @@ -771,6 +777,11 @@ public Locator getButtonTextLocator()
{
return button().containing(_buttonText);
}

public String getRequiredModule()
{
return "Core";
}
}

public enum ActionStatus{
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/util/StudyHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public void exportStudy(String folder, boolean zipFile)
_test.clickButton("Export Study");
ExportFolderPage exportFolderPage = new ExportFolderPage(_test.getDriver());

List<String> studyObjects = Arrays.asList("Visit Map", "Cohort Settings", "QC State Settings", "Datasets: Study Dataset Definitions", "Datasets: Study Dataset Data", "Datasets: Assay Dataset Definitions", "Datasets: Assay Dataset Data", "Participant Comment Settings", "Participant Groups", "Protocol Documents");
List<String> studyObjects = Arrays.asList("Visit Map", "Cohort Settings", _test._containerHelper.getAllModules().contains("samplemanagement") ? "Sample Status and QC State Settings" : "QC State Settings", "Datasets: Study Dataset Definitions", "Datasets: Study Dataset Data", "Datasets: Assay Dataset Definitions", "Datasets: Assay Dataset Data", "Participant Comment Settings", "Participant Groups", "Protocol Documents");
if (isSpecimenModuleActive())
{
studyObjects = new ArrayList<>(studyObjects);
Expand Down