Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
110 changes: 98 additions & 12 deletions snd/test/src/org/labkey/test/tests/snd/SNDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.labkey.test.tests.snd;

import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand Down Expand Up @@ -48,6 +49,7 @@
import org.labkey.test.components.snd.PackageViewerResult;
import org.labkey.test.components.snd.ProjectViewerResult;
import org.labkey.test.components.snd.SuperPackageRow;
import org.labkey.test.pages.query.SourceQueryPage;
import org.labkey.test.pages.snd.EditCategoriesPage;
import org.labkey.test.pages.snd.EditPackagePage;
import org.labkey.test.pages.snd.EditProjectPage;
Expand All @@ -56,7 +58,10 @@
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.Maps;
import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SqlserverOnlyTest;
import org.labkey.test.util.StudyHelper;
import org.labkey.test.util.core.webdav.WebDavUploadHelper;
import org.openqa.selenium.WebElement;

Expand Down Expand Up @@ -107,6 +112,7 @@ public class SNDTest extends BaseWebDriverTest implements SqlserverOnlyTest
private static final int TEST_CATEGORY_ID2 = 51;
private static final int TEST_CATEGORY_ID3 = 52;
private static final int TEST_CATEGORY_ID4 = 53;
private static final int TEST_CATEGORY_ID5 = 54;
private static final int TEST_SUPER_PKG_START_ID1 = 130;
private static final int TEST_SUPER_PKG_START_ID2 = 140;
private static final int TEST_SUPER_PKG_START_ID3 = 150;
Expand Down Expand Up @@ -141,6 +147,8 @@ public class SNDTest extends BaseWebDriverTest implements SqlserverOnlyTest
private static final String UITEST_PROJECT_SUBPKG2 = "Vet Comment";
private static final String UITEST_PROJECT_SUBPKG3 = "Ketamine Sedation";

private static final String STUDY_NAME = "Query provisioned snapshot test";

private static final String CREATEDOMAINSAPI ="LABKEY.Domain.create({\n" +
" domainGroup: 'test', \n" +
" domainKind: 'SND', \n" +
Expand Down Expand Up @@ -553,7 +561,12 @@ private static String getPackageWithId(String packageId)
" 'Description': 'Weight', \n"+
" 'Active': true, \n"+
" 'Comment': 'This is a weight' \n"+
" },{ \n"+
" },{ \n" +
" 'CategoryId': " + TEST_CATEGORY_ID5 + " ,\n" +
" 'Description': 'Sodium', \n" +
" 'Active': true, \n" +
" 'Comment': 'This is Sodium' \n" +
" },{ \n"+
" 'CategoryId': " + TEST_CATEGORY_ID4 + ",\n"+
" 'Description': 'Vitals', \n"+
" 'Active': true, \n"+
Expand Down Expand Up @@ -870,16 +883,16 @@ public void checkLinks()
@BeforeClass
public static void setupProject()
{
SNDTest init = (SNDTest) getCurrentTest();

SNDTest init = getCurrentTest();
init.doSetup();
}

private void doSetup()
{
_containerHelper.createProject(getProjectName(), "Collaboration");
goToProjectHome();
_containerHelper.enableModules(Arrays.asList("SND"));
_containerHelper.enableModules(Arrays.asList("SND", "Study"));

_containerHelper.createSubfolder(getProjectName(), getProjectName(), TEST1SUBFOLDER, "Collaboration", new String[]{"SND"});
setupTest1Project();

Expand Down Expand Up @@ -2089,8 +2102,7 @@ public void reviseProjectViaUI() throws Exception
assertFalse("Unassigned package found assigned.", viewPage.isAssignedPackagePresent(UITEST_PROJECT_SUBPKG2));
}

@Test
public void verifyTestFrameworkAPITests()
private void runTestsInAPIFrameWork()
{
log("Launching the Testing framework");
goToProjectHome();
Expand All @@ -2101,11 +2113,10 @@ public void verifyTestFrameworkAPITests()
clickButton("Run tests", 0);
waitForText("Total tests:", 1, WAIT_FOR_PAGE);

log("Verifying no test failed");
assertTextPresent("Complete","Failed tests: 0");
}

private String getPerimissionTableValue(int row, int col)
private String getPermissionTableValue(int row, int col)
{
List<WebElement> els = ((Locator.XPathLocator)getSimpleTableCell(Locator.id("category-security"), row, col)).child("div").child("a").child("input").findElements(getDriver());
if (els.size() > 0)
Expand Down Expand Up @@ -2157,7 +2168,7 @@ public void categoryPermissionsUI() throws Exception
{
if (categories.contains(getTableCellText(Locator.id("category-security"), i, 0)))
{
value = getPerimissionTableValue(i, 1);
value = getPermissionTableValue(i, 1);
assertNotNull(value);
assertTrue(value.equals("None"));
categoryRows.add(i);
Expand All @@ -2169,7 +2180,7 @@ public void categoryPermissionsUI() throws Exception

for (Integer r : categoryRows)
{
value = getPerimissionTableValue(r, 1);
value = getPermissionTableValue(r, 1);
assertNotNull(value);
assertTrue(value.equals("SND Reader"));
}
Expand All @@ -2179,7 +2190,7 @@ public void categoryPermissionsUI() throws Exception

for (int k = 0; k < categoryRows.size(); k++)
{
value = getPerimissionTableValue(categoryRows.get(k), 1);
value = getPermissionTableValue(categoryRows.get(k), 1);
assertNotNull(value);
assertTrue(value.equals("None"));
click(getSimpleTableCell(Locator.id("category-security"), categoryRows.get(k), 1));
Expand All @@ -2190,13 +2201,88 @@ public void categoryPermissionsUI() throws Exception

for (int j = 0; j < categoryRows.size(); j++)
{
value = getPerimissionTableValue(categoryRows.get(j), 1);
value = getPermissionTableValue(categoryRows.get(j), 1);
assertNotNull(value);
assertTrue(value.equals(permissions.get(j)));
}

}

@Test
public void testQueryProvisionedSnapshot()
{
String sourceQueryName = "SND: Source query";
String snapshotName = sourceQueryName + " Snapshot";
String sourceQuery = "SELECT\n" +
"lsid AS _key,\n" +
"SubjectId AS participantid,\n" +
"date,\n" +
"SequenceNum,\n" +
"qcstate,\n" +
"lsid,\n" +
"amount,\n" +
"units,\n" +
"kit_type\n" +
"FROM SND.Categories.Sodium\n";

String updatedSourceQuery = sourceQuery.replace(
"amount,",
"'8976' AS amount,");

log("Enable Allow query based dataset snapshots");
OptionalFeatureHelper.enableOptionalFeature(createDefaultConnection(), "queryBasedDatasets");

log("Run the tests from the framework for set up");
runTestsInAPIFrameWork();

log("Enable study module and create continuous study");
goToProjectHome();
goToManageStudy();
_studyHelper.startCreateStudy()
.setTimepointType(StudyHelper.TimepointType.CONTINUOUS)
.createStudy();

log("Adding dataset webpart");
goToProjectHome();
PortalHelper _portalHelper = new PortalHelper(getDriver());
_portalHelper.addBodyWebPart("Datasets");

log("Create source query from study");
goToSchemaBrowser();
SourceQueryPage querySourcePage = createNewQuery("study", null)
.setName(sourceQueryName)
.setBaseTable("DataSets")
.clickCreate();
querySourcePage.setSource(sourceQuery)
.clickSaveAndFinish();

log("Create the snapshot");
DataRegionTable queryTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("query").waitFor();
queryTable.goToReport("Create Query Snapshot");
checkCheckbox(Locator.name("queryDataset"));
clickButton("Create Snapshot");

log("Verify the dataset snapshot");
goToProjectHome();
clickAndWait(Locator.linkWithText(snapshotName));
DataRegionTable dataRegionTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("Dataset").waitFor();
Assert.assertEquals("Incorrect number of rows", 3, dataRegionTable.getDataRowCount());
Assert.assertEquals("Incorrect column titles", Arrays.asList("ParticipantId", "_key", "date", "amount", "units", "kit_type"),
dataRegionTable.getColumnNames());
Assert.assertEquals("Incorrect value in amount column", Arrays.asList("100", "100", " "), dataRegionTable.getColumnDataAsText("amount"));

log("Edit the source query and verify snapshot is updated");
goToSchemaBrowser();
querySourcePage = editQuerySource("study", sourceQueryName);
querySourcePage.setSource(updatedSourceQuery)
.clickSaveAndFinish();

goToProjectHome();
clickAndWait(Locator.linkWithText(snapshotName));
dataRegionTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("Dataset").waitFor();
Assert.assertEquals("Incorrect value in amount column", Arrays.asList("8976", "8976", "8976"), dataRegionTable.getColumnDataAsText("amount"));
}

private void truncateSndPkg() throws Exception
{
//cleanup - truncate snd.pkgs
Expand Down
2 changes: 1 addition & 1 deletion snd/webapp/snd/test/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
active: true,
repeatable: true,
narrative: 'Sodium: {amount} {units} measured using {kit_type}',
categories: [],
categories: [54],
subPackages: [],
attributes: [
{
Expand Down