diff --git a/resources/views/peptideSummary.html b/resources/views/peptideSummary.html index 0f62a3e87..19a97e173 100644 --- a/resources/views/peptideSummary.html +++ b/resources/views/peptideSummary.html @@ -2,6 +2,7 @@ .date-picker-container { display: none; margin-top: 10px; + margin-bottom: 10px; } .legend-container { @@ -78,6 +79,7 @@ +
   No outliers
@@ -87,7 +89,6 @@
Loading... -
@@ -328,8 +329,16 @@ const endDateVal = document.getElementById('ps-end-date').value; if (!startDateVal || !endDateVal) { - alert('Please select both start and end dates.'); $('#fom-loading').hide(); + $('#fom-error').text('Please select both start and end dates.').show(); + return; + } + + const parsedStart = new Date(startDateVal); + const parsedEnd = new Date(endDateVal); + if (parsedStart.getTime() > parsedEnd.getTime()) { + $('#fom-loading').hide(); + $('#fom-error').text('Please choose a start date that is before the end date.').show(); return; } diff --git a/test/src/org/labkey/test/components/targetedms/PeptideSummaryWebPart.java b/test/src/org/labkey/test/components/targetedms/PeptideSummaryWebPart.java index 2403e087a..a51e1e6eb 100644 --- a/test/src/org/labkey/test/components/targetedms/PeptideSummaryWebPart.java +++ b/test/src/org/labkey/test/components/targetedms/PeptideSummaryWebPart.java @@ -38,21 +38,51 @@ public PeptideSummaryWebPart setDateRange(HeatmapDateRange value) public PeptideSummaryWebPart setStartDate(String value) { - elementCache().startDate.set(value); + if (value != null) + { + elementCache().startDate.set(value); + } + else + { + elementCache().startDate.clear(); + } return this; } public PeptideSummaryWebPart setEndDate(String value) { - elementCache().endDate.set(value); + if (value != null) + { + elementCache().endDate.set(value); + } + else + { + elementCache().endDate.clear(); + } return this; } + public String getStartDate() + { + return elementCache().startDate.get(); + } + + public String getEndDate() + { + return elementCache().endDate.get(); + } + public PeptideSummaryWebPart apply() { doAndWaitForElementToRefresh(() -> elementCache().applyButton.findElement(this).click(), elementCache().heatmapLoc, getWrapper().defaultWaitForPage); + return this; + } + public PeptideSummaryWebPart applyExpectingError(String error) + { + elementCache().applyButton.findElement(this).click(); + getWrapper().assertTextPresent(error); return this; } diff --git a/test/src/org/labkey/test/components/targetedms/QCPlotsWebPart.java b/test/src/org/labkey/test/components/targetedms/QCPlotsWebPart.java index 89ce88806..962d63384 100644 --- a/test/src/org/labkey/test/components/targetedms/QCPlotsWebPart.java +++ b/test/src/org/labkey/test/components/targetedms/QCPlotsWebPart.java @@ -678,6 +678,7 @@ public String toString() public enum DateRangeOffset { ALL(0, "All dates"), + LAST_7_DAYS(180, "Last 7 days"), LAST_180_DAYS(180, "Last 180 days"), CUSTOM(-1, "Custom range"); diff --git a/test/src/org/labkey/test/tests/targetedms/TargetedMSPeptideSummaryHeatmapTest.java b/test/src/org/labkey/test/tests/targetedms/TargetedMSPeptideSummaryHeatmapTest.java index 8c89ebdd3..39be75157 100644 --- a/test/src/org/labkey/test/tests/targetedms/TargetedMSPeptideSummaryHeatmapTest.java +++ b/test/src/org/labkey/test/tests/targetedms/TargetedMSPeptideSummaryHeatmapTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.labkey.test.BaseWebDriverTest; +import org.labkey.test.Locator; import org.labkey.test.components.targetedms.PeptideSummaryWebPart; import org.labkey.test.components.targetedms.QCPlotsWebPart; import org.labkey.test.pages.panoramapremium.ConfigureMetricsUIPage; @@ -14,6 +15,8 @@ import java.util.Arrays; import java.util.List; +import static org.junit.Assert.assertEquals; + @Category({}) @BaseWebDriverTest.ClassTimeout(minutes = 5) public class TargetedMSPeptideSummaryHeatmapTest extends TargetedMSTest @@ -61,13 +64,57 @@ public void testHeatMapColorAndValues() .clickSave(); clickPortalTab(PEPTIDE_MOLECULE_SUMMARY); - PeptideSummaryWebPart peptideSummaryHeatMap = new PeptideSummaryWebPart(getDriver()); - Assert.assertEquals("Incorrect outlier count", "2", - peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.FWHM).getText()); - Assert.assertEquals("Incorrect total replicate count", "47", peptideSummaryHeatMap.getTotalReplicateCount().trim()); + verifyDataAllDates(); log("Verify data range: " + PeptideSummaryWebPart.HeatmapDateRange.Last_7_Days); + PeptideSummaryWebPart peptideSummaryHeatMap = new PeptideSummaryWebPart(getDriver()); peptideSummaryHeatMap.setDateRange(PeptideSummaryWebPart.HeatmapDateRange.Last_7_Days); + verifyDataLast7Days(); + + // Go back to the dashboard and make sure the date range matches + goToProjectHome(); + qcPlotsWebPart = new PanoramaDashboard(this).getQcPlotsWebPart(); + qcPlotsWebPart.waitForReady(); + assertEquals("Date Range Offset not set to default value", QCPlotsWebPart.DateRangeOffset.LAST_7_DAYS, qcPlotsWebPart.getCurrentDateRangeOffset()); + qcPlotsWebPart.filterQCPlots("2013-08-10", "2013-08-15", 7); + + // Now navigate through the link instead of the custom tab and webpart + waitAndClickAndWait(Locator.linkContainingText("View all 47 replicates")); + // Make sure the custom date range matches the other plot's + peptideSummaryHeatMap = new PeptideSummaryWebPart(getDriver()); + assertEquals("2013-08-10", peptideSummaryHeatMap.getStartDate()); + assertEquals("2013-08-15", peptideSummaryHeatMap.getEndDate()); + + log("Verify invalid date combos produce helpful errors"); + peptideSummaryHeatMap.setCustomDateRange("2013-08-15", "2013-08-01"); + peptideSummaryHeatMap.applyExpectingError("Please choose a start date that is before the end date."); + peptideSummaryHeatMap.setCustomDateRange(null, "2013-08-01"); + peptideSummaryHeatMap.applyExpectingError("Please select both start and end dates."); + + log("Verify Custom date range"); + peptideSummaryHeatMap.setCustomDateRange("2013-08-01", "2013-08-15"); + peptideSummaryHeatMap.apply(); + verifyDataCustomRange(peptideSummaryHeatMap); + + log("Verify Custom -> standard -> custom toggling"); + peptideSummaryHeatMap.setDateRange(PeptideSummaryWebPart.HeatmapDateRange.Last_7_Days); + verifyDataLast7Days(); + + peptideSummaryHeatMap.setDateRange(PeptideSummaryWebPart.HeatmapDateRange.Custom_Range); + assertEquals("2013-08-01", peptideSummaryHeatMap.getStartDate()); + assertEquals("2013-08-15", peptideSummaryHeatMap.getEndDate()); + verifyDataCustomRange(peptideSummaryHeatMap); + } + + private static void verifyDataCustomRange(PeptideSummaryWebPart peptideSummaryHeatMap) + { + Assert.assertEquals("Incorrect outlier count for " + QCPlotsWebPart.MetricType.PRECURSOR_AREA, "11", + peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.PRECURSOR_AREA).getText()); + } + + private void verifyDataLast7Days() + { + PeptideSummaryWebPart peptideSummaryHeatMap = new PeptideSummaryWebPart(getDriver()); Assert.assertEquals("Incorrect outlier count for " + QCPlotsWebPart.MetricType.FWHM, "1", peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.FWHM).getText()); @@ -76,13 +123,15 @@ public void testHeatMapColorAndValues() peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.PRECURSOR_AREA).getCssValue("background-color")); Assert.assertEquals("Incorrect heatmap color for lightest red", "rgb(255, 245, 245)", peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.FWHM).getCssValue("background-color")); + } - log("Verify Custom date range"); - peptideSummaryHeatMap.setCustomDateRange("2013-08-01", "2013-08-15"); - log("hitting apply button"); - peptideSummaryHeatMap.apply(); - Assert.assertEquals("Incorrect outlier count for " + QCPlotsWebPart.MetricType.PRECURSOR_AREA, "11", - peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.PRECURSOR_AREA).getText()); + private void verifyDataAllDates() + { + PeptideSummaryWebPart peptideSummaryHeatMap = new PeptideSummaryWebPart(getDriver()); + Assert.assertEquals("Incorrect outlier count", "2", + peptideSummaryHeatMap.getCellElement(1, QCPlotsWebPart.MetricType.FWHM).getText()); + assertTextPresent("Total Ion Chromatogram Area", "VYVEELKPTPEGDLEILLQK", "++, 1,157.1330"); + Assert.assertEquals("Incorrect total replicate count", "47", peptideSummaryHeatMap.getTotalReplicateCount().trim()); } @Test