Skip to content

Commit 9f13f7e

Browse files
author
Sebastian Benjamin
committed
Add CSV download test
1 parent 6151f49 commit 9f13f7e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

jbrowse/test/src/org/labkey/test/tests/external/labModules/JBrowseTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.labkey.test.tests.external.labModules;
1717

18+
import au.com.bytecode.opencsv.CSVReader;
1819
import org.apache.commons.lang3.StringUtils;
1920
import org.apache.commons.lang3.tuple.Pair;
2021
import org.json.JSONArray;
@@ -50,6 +51,7 @@
5051
import org.openqa.selenium.support.Color;
5152

5253
import java.io.File;
54+
import java.io.FileReader;
5355
import java.io.IOException;
5456
import java.util.List;
5557
import java.util.Map;
@@ -1896,6 +1898,40 @@ private void testLuceneSearchUI(String sessionId)
18961898
waitAndClick(Locator.tagWithClass("button", "filter-form-select-button"));
18971899
waitForElement(Locator.tagWithText("span", "0.029"));
18981900

1901+
// Test the CSV export on this discrete case prior to clearing -- there should be 2 rows
1902+
File downloadCSV = doAndWaitForDownload(() -> clickButton("Export CSV", 0));
1903+
try (FileReader fileReader = new FileReader(downloadCSV))
1904+
{
1905+
CSVReader csvReader = new CSVReader(fileReader);
1906+
String[] line = csvReader.readNext();
1907+
Assert.assertArrayEquals(new String[] {
1908+
"contig", "start", "end", "ref", "alt", "genomicPosition",
1909+
"nCalled", "fractionHet", "variableSamples", "homozygousVarSamples",
1910+
"nHomVar", "nHet", "AF", "AC", "CADD_PH", "CLN_ALLELE", "OMIMD", "IMPACT"
1911+
}, line);
1912+
line = csvReader.readNext();
1913+
Assert.assertArrayEquals(new String[] {
1914+
"1", "2", "2", "A", "T", "2", "1523", "0.9268293",
1915+
"m00004,m00013,m00029,m00101,m00391,m00435,m00458,m00598,m00610,m00789,m00801,m00816,m00969,m02168," +
1916+
"m02169,m02179,m02225,m02230,m02280,m02324,m02344,m02369,m02391,m03592,m03655,m03667,m03669," +
1917+
"m03684,m03694,m05192,m05264,m05270,m05273,m05550,m05551,m05557,m05622,m05640,m05658,m05659," +
1918+
"m05660,m05662,m05666,m05668,m05669,m05671,m05672,m05673,m05675,m05795,m05812,m05834,m05855," +
1919+
"m05861,m05895,m06088,m06969,m06970,m06985,m06986,m06988,m06993,m07003,m07006,m07007,m07025," +
1920+
"m07034,m07037,m07045,m07409,m07418,m07426,m07438,m07446,m07458,m07489,m07495,m07513,m07863," +
1921+
"m07929,m07951,m07952",
1922+
"m03694,m05671,m05672,m06970,m06993,m07951",
1923+
"6", "76", "0.029", "88", "7.292", "", "", "HIGH"
1924+
}, line);
1925+
line = csvReader.readNext();
1926+
Assert.assertArrayEquals(new String[] {
1927+
"1","5336","5336","A","G","5336","1524","1.0","m05373","","0","1","3.281E-4","1","2.868","","","MODERATE"
1928+
}, line);
1929+
}
1930+
catch (Exception e)
1931+
{
1932+
Assert.fail();
1933+
}
1934+
18991935
clearFilterDialog("IMPACT equals HIGH,MODERATE");
19001936

19011937
testLuceneColumnSerialization(sessionId);

0 commit comments

Comments
 (0)