diff --git a/src/org/labkey/test/components/SaveChartDialog.java b/src/org/labkey/test/components/SaveChartDialog.java index 1b4e47613f..0b371e9b27 100644 --- a/src/org/labkey/test/components/SaveChartDialog.java +++ b/src/org/labkey/test/components/SaveChartDialog.java @@ -17,6 +17,7 @@ import org.labkey.test.Locator; import org.labkey.test.WebDriverWrapper; +import org.labkey.test.components.ext4.Checkbox; import org.labkey.test.components.ext4.RadioButton; import org.labkey.test.components.ext4.Window; import org.labkey.test.pages.TimeChartWizard; @@ -24,6 +25,8 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; +import static org.labkey.test.components.ext4.Checkbox.Ext4Checkbox; + public class SaveChartDialog extends Window { private static final Locator DIALOG_LOC = Locator.byClass("chart-wizard-dialog").append(Locator.byClass("save-chart-panel")); @@ -99,6 +102,12 @@ public SaveChartDialog setViewableBy(ViewableBy visibility) return this; } + public SaveChartDialog setInherit(boolean checked) + { + elementCache().inheritCheckbox.set(checked); + return this; + } + public TimeChartWizard clickCancel() { clickButton("Cancel", true); @@ -152,6 +161,7 @@ protected class Elements extends Window.ElementCache private final RadioButton autoThumbnail = new RadioButton.RadioButtonFinder().withLabel("Auto-generate").findWhenNeeded(this); private final RadioButton allReaders = new RadioButton.RadioButtonFinder().withLabel("All readers").findWhenNeeded(this); private final RadioButton onlyMe = new RadioButton.RadioButtonFinder().withLabel("Only me").findWhenNeeded(this); + private final Checkbox inheritCheckbox = Ext4Checkbox().withLabel("Make this report available in child folders").findWhenNeeded(this); } public enum ViewableBy diff --git a/src/org/labkey/test/components/react/QueryChartDialog.java b/src/org/labkey/test/components/react/QueryChartDialog.java index 6e8431cd64..d471cf8b4f 100644 --- a/src/org/labkey/test/components/react/QueryChartDialog.java +++ b/src/org/labkey/test/components/react/QueryChartDialog.java @@ -54,6 +54,17 @@ public boolean getShared() return elementCache().sharedCheckbox.get(); } + public QueryChartDialog setInheritable(boolean checked) + { + elementCache().inheritableCheckbox.set(checked); + return this; + } + + public boolean getInheritable() + { + return elementCache().inheritableCheckbox.get(); + } + // field selects public QueryChartDialog clearFieldValue(String fieldLabel) @@ -321,6 +332,7 @@ protected class ElementCache extends ModalDialog.ElementCache { final Input nameInput = Input(Locator.input("name"), getDriver()).findWhenNeeded(this); final Checkbox sharedCheckbox = Checkbox.Checkbox(Locator.input("shared")).findWhenNeeded(this); + final Checkbox inheritableCheckbox = Checkbox.Checkbox(Locator.input("inheritable")).findWhenNeeded(this); Locator.XPathLocator chartBuilderType = Locator.tagWithClass("div", "chart-builder-type"); diff --git a/src/org/labkey/test/tests/DataReportsTest.java b/src/org/labkey/test/tests/DataReportsTest.java index cfb20e3b66..9f3f390269 100644 --- a/src/org/labkey/test/tests/DataReportsTest.java +++ b/src/org/labkey/test/tests/DataReportsTest.java @@ -311,9 +311,7 @@ public void doAdvancedViewTest() // Note: Enabling this feature flag requires a server restart if (TestProperties.isPrimaryUserAppAdmin() || !OptionalFeatureHelper.isOptionalFeatureEnabled(createDefaultConnection(), "enableExternalReport")) { - BootstrapMenu reportMenu = dataRegion.getReportMenu(); - reportMenu.expand(); - List menuItems = getTexts(reportMenu.findVisibleMenuItems()); + List menuItems = dataRegion.getHeaderMenuOptions("Charts / Reports"); assertThat("App admin shouldn't be able to create an advanced report.", menuItems, not(hasItem(create_advanced_report))); assertThat("Sanity check failed. Check menu text for advanced report.", menuItems, hasItem("Create Chart")); // Site admins can still navigate to the externalReport page. It isn't functional though, so skipping this check @@ -509,6 +507,18 @@ public void doRReportsTest() // TODO: Issue 36040: Unable to download PDF for R report run as pipeline job // verifyReportPdfDownload("study", 4500d); + + // delete report and then verify audit events + deleteReport(R_SCRIPTS[0]); + goToSchemaBrowser(); + viewQueryData("auditLog", "ReportEvent"); + DataRegionTable table = new DataRegionTable("query", this); + table.setFilter("ReportName", "Equals", R_SCRIPTS[0]); + assertEquals("Number of audit events for report not as expected", 3, table.getDataRowCount()); + assertEquals("Report name for audit events not as expected", List.of(R_SCRIPTS[0], R_SCRIPTS[0], R_SCRIPTS[0]), table.getColumnDataAsText("ReportName")); + assertEquals("Report key for audit events not as expected", List.of("study/DEM-1", "study/DEM-1", "study/DEM-1"), table.getColumnDataAsText("ReportKey")); + assertEquals("Report type for audit events not as expected", List.of("Study.rReport", "Study.rReport", "Study.rReport"), table.getColumnDataAsText("ReportType")); + assertEquals("Report comment for audit events not as expected", List.of("Report deleted", "Report updated", "Report created"), table.getColumnDataAsText("Comment")); } private void verifyReportPdfDownload(String schema, double expectedSize) diff --git a/src/org/labkey/test/tests/visualization/BarPlotTest.java b/src/org/labkey/test/tests/visualization/BarPlotTest.java index 484ec09989..40c667ae9f 100644 --- a/src/org/labkey/test/tests/visualization/BarPlotTest.java +++ b/src/org/labkey/test/tests/visualization/BarPlotTest.java @@ -27,6 +27,7 @@ import org.labkey.test.components.ChartTypeDialog; import org.labkey.test.components.ColumnChartRegion; import org.labkey.test.components.LookAndFeelBarPlot; +import org.labkey.test.components.SaveChartDialog; import org.labkey.test.pages.TimeChartWizard; import org.labkey.test.util.DataRegionTable; import org.labkey.test.util.LabKeyExpectedConditions; @@ -35,6 +36,10 @@ import java.net.URL; import java.net.URLEncoder; import java.nio.charset.Charset; +import java.util.List; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; @Category({Daily.class, Reports.class, Charting.class, Hosting.class}) @BaseWebDriverTest.ClassTimeout(minutes = 8) @@ -73,6 +78,7 @@ protected LookAndFeelBarPlot clickChartLayoutButton() protected void testPlots() { doBasicBarPlotTest(); + doInheritedPlotTest(); doGroupedBarPlotTest(); doColumnPlotClickThrough(); doExportOfBarPlot(); @@ -173,6 +179,53 @@ private void doBasicBarPlotTest() savePlot(BAR_PLOT_SAVE_NAME, "This is a bar plot from the simple bar plot test."); } + @LogMethod + private void doInheritedPlotTest() + { + String chartName = "InheritedPlotTest"; + String subfolderName = chartName + "Folder"; + String SVG_TEXT = "normal\n0\n0.1\n0.2\n0.3\n0.4\n0.5\n0.6\n0.7\n0.8\n0.9\n1\nContainers\nType"; + + goToProjectHome(); + clickFolder(getFolderName()); + + // create a bar chart on a schema/query that is shared across folders + ChartTypeDialog chartTypeDialog = clickAddChart("core", "Containers"); + TimeChartWizard chartWizard = chartTypeDialog.setXAxis("Type").clickApply(); + SaveChartDialog saveChartDialog = chartWizard.clickSave(); + saveChartDialog.setReportName(chartName); + saveChartDialog.clickSave(); + assertSVG(SVG_TEXT); + + // create subfolder and initially verify that the chart is not inherited + _containerHelper.createSubfolder(getProjectName() + "/" + getFolderName(), subfolderName, "Collaboration"); + clickFolder(subfolderName); + goToSchemaBrowser(); + viewQueryData("core", "Containers"); + DataRegionTable table = new DataRegionTable("query", this); + List menuItems = table.getHeaderMenuOptions("Charts / Reports"); + assertFalse("Report should not be visible in subfolder", menuItems.contains(chartName)); + + // verify that the chart is inherited when the inherit flag is set + clickFolder(getFolderName()); + goToChart(chartName); + chartWizard = openSavedPlotInEditMode(chartName); + saveChartDialog = chartWizard.clickSaveAs(); + saveChartDialog.setReportName(chartName + "_Inherited"); + saveChartDialog.setInherit(true); + saveChartDialog.clickSave(); + + clickFolder(subfolderName); + goToSchemaBrowser(); + viewQueryData("core", "Containers"); + table = new DataRegionTable("query", this); + menuItems = table.getHeaderMenuOptions("Charts / Reports"); + assertFalse("Report should not be visible in subfolder", menuItems.contains(chartName)); + assertTrue("Inherited report should be visible in subfolder", menuItems.contains(chartName + "_Inherited")); + table.goToReport(chartName + "_Inherited"); + assertSVG(SVG_TEXT); + } + @LogMethod private void doGroupedBarPlotTest() { @@ -292,12 +345,17 @@ private void doExportOfBarPlot() final String EXPORTED_SCRIPT_CHECK_YAXIS = "Sum of " + BP_DIASTOLIC; log("Validate that export of the bar plot works."); + goToChart(BAR_PLOT_SAVE_NAME); + export(EXPORTED_SCRIPT_CHECK_TYPE, EXPORTED_SCRIPT_CHECK_XAXIS, EXPORTED_SCRIPT_CHECK_YAXIS); + } + + private void goToChart(String chartName) + { goToProjectHome(); clickFolder(getFolderName()); clickTab("Clinical and Assay Data"); - waitForElement(Locator.linkWithText(BAR_PLOT_SAVE_NAME)); - clickAndWait(Locator.linkWithText(BAR_PLOT_SAVE_NAME), WAIT_FOR_PAGE); - export(EXPORTED_SCRIPT_CHECK_TYPE, EXPORTED_SCRIPT_CHECK_XAXIS, EXPORTED_SCRIPT_CHECK_YAXIS); + waitForElement(Locator.linkWithText(chartName)); + clickAndWait(Locator.linkWithText(chartName), WAIT_FOR_PAGE); } @LogMethod