|
1 |
/**
|
|
2 |
* Copyright (C) 2020 EDIT
|
|
3 |
* European Distributed Institute of Taxonomy
|
|
4 |
* http://www.e-taxonomy.eu
|
|
5 |
*
|
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms.
|
|
8 |
*/
|
|
9 |
package eu.etaxonomy.dataportal.selenium.tests.reference;
|
|
10 |
|
|
11 |
import java.io.IOException;
|
|
12 |
import java.util.List;
|
|
13 |
import java.util.Optional;
|
|
14 |
import java.util.UUID;
|
|
15 |
|
|
16 |
import org.apache.commons.lang3.StringUtils;
|
|
17 |
import org.apache.log4j.Level;
|
|
18 |
import org.apache.log4j.Logger;
|
|
19 |
import org.junit.Before;
|
|
20 |
import org.junit.Test;
|
|
21 |
import org.openqa.selenium.By;
|
|
22 |
import org.openqa.selenium.WebElement;
|
|
23 |
|
|
24 |
import eu.etaxonomy.dataportal.DataPortalSite;
|
|
25 |
import eu.etaxonomy.dataportal.DrupalVars;
|
|
26 |
import eu.etaxonomy.dataportal.elements.LinkElement;
|
|
27 |
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
|
|
28 |
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
|
|
29 |
import eu.etaxonomy.dataportal.pages.TaxonPage;
|
|
30 |
import eu.etaxonomy.drush.DrushExecuter;
|
|
31 |
import eu.etaxonomy.drush.DrushExecutionFailure;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* @author a.kohlbecker
|
|
35 |
* @since Aug 11, 2020
|
|
36 |
*/
|
|
37 |
@DataPortalContexts( { DataPortalSite.reference })
|
|
38 |
public class SpecimenTableViewTest extends CdmDataPortalTestBase {
|
|
39 |
|
|
40 |
/**
|
|
41 |
*
|
|
42 |
*/
|
|
43 |
private static final String STEP_DONE_IMAGE = "modules/cdm_dataportal/images/step_done.gif";
|
|
44 |
|
|
45 |
public static final Logger logger = Logger.getLogger(DrushExecuter.class);
|
|
46 |
|
|
47 |
private static final UUID glenodinium_apiculatum_t = UUID.fromString("d245083e-3bda-435f-9bb3-bdc2249ff23c");
|
|
48 |
|
|
49 |
TaxonPage p = null;
|
|
50 |
|
|
51 |
@Before
|
|
52 |
public void switchToView() throws IOException, InterruptedException, DrushExecutionFailure {
|
|
53 |
Logger.getLogger(DrushExecuter.class).setLevel(Level.DEBUG);
|
|
54 |
setDrupalVar(DrupalVars.CDM_DATAPORTAL_TAXONPAGE_TABS, "1");
|
|
55 |
setDrupalVar(DrupalVars.CDM_SPECIMEN_LIST_VIEW_MODE, "derivate_table");
|
|
56 |
p = new TaxonPage(driver, getContext(), glenodinium_apiculatum_t, "specimens");
|
|
57 |
}
|
|
58 |
|
|
59 |
@Test
|
|
60 |
public void testPageTitle() {
|
|
61 |
assertEquals(getContext().prepareTitle("Glenodinium apiculatum"), p.getTitle());
|
|
62 |
}
|
|
63 |
|
|
64 |
@Test
|
|
65 |
public void testPageTab() {
|
|
66 |
Optional<LinkElement> activeTab = p.getActivePrimaryTab();
|
|
67 |
assertTrue(activeTab.isPresent());
|
|
68 |
assertEquals("Specimens\n(active tab)", activeTab.get().getText());
|
|
69 |
}
|
|
70 |
|
|
71 |
@Test
|
|
72 |
public void testTableHaders() {
|
|
73 |
|
|
74 |
WebElement specimensTable = p.getDataPortalContent().getElement().findElement(By.cssSelector("#derivate_hierarchy_table"));
|
|
75 |
List<WebElement> headerRows = specimensTable.findElements(By.cssSelector("tr th"));
|
|
76 |
// Country Date Collector + collecting number Herbaria Type Scan Derivatives
|
|
77 |
// first row is empty, this is the "expand row"
|
|
78 |
assertEquals("Country", headerRows.get(1).getText());
|
|
79 |
assertEquals("Date", headerRows.get(2).getText());
|
|
80 |
assertEquals("Collector + collecting number", headerRows.get(3).getText());
|
|
81 |
assertEquals("Herbaria", headerRows.get(4).getText());
|
|
82 |
assertEquals("Type", headerRows.get(5).getText());
|
|
83 |
assertEquals("Scan", headerRows.get(6).getText());
|
|
84 |
assertEquals("Derivatives", headerRows.get(7).getText());
|
|
85 |
|
|
86 |
}
|
|
87 |
|
|
88 |
@Test
|
|
89 |
public void testTable() {
|
|
90 |
|
|
91 |
WebElement specimensTable = p.getDataPortalContent().getElement().findElement(By.cssSelector("#derivate_hierarchy_table"));
|
|
92 |
|
|
93 |
List<WebElement> rows = specimensTable.findElements(By.cssSelector("tr"));
|
|
94 |
assertEquals(5, rows.size());
|
|
95 |
// expected rows:
|
|
96 |
// 0: header row
|
|
97 |
// 1: summary row
|
|
98 |
// 2: detail row
|
|
99 |
// 3: summary row
|
|
100 |
// 4: detail row
|
|
101 |
|
|
102 |
// summary row 1
|
|
103 |
int rowId = 1;
|
|
104 |
assertTrue(rows.get(rowId).getAttribute("class").contains("summary_row"));
|
|
105 |
List<WebElement> cells = rows.get(rowId).findElements(By.tagName("td"));
|
|
106 |
assertEquals("Germany", cells.get(1).getText());
|
|
107 |
assertEquals("1835-04-02", cells.get(2).getText());
|
|
108 |
assertEquals("", cells.get(3).getText());
|
|
109 |
// all other empty, TODO check if this is correct or if some data is being missed here
|
|
110 |
|
|
111 |
// details row 1
|
|
112 |
rowId = 2;
|
|
113 |
assertTrue(rows.get(rowId).getAttribute("class").contains("detail_row"));
|
|
114 |
assertEquals("Should be initially invisible", "none", rows.get(rowId).getCssValue("display"));
|
|
115 |
rows.get(rowId - 1).click();
|
|
116 |
assertEquals("The click should make it visible", "table-row", rows.get(rowId).getCssValue("display"));
|
|
117 |
cells = rows.get(rowId).findElements(By.tagName("td"));
|
|
118 |
String detailsText = cells.get(1).getText();
|
|
119 |
String[] detailsLines = StringUtils.split(detailsText, "\n");
|
|
120 |
assertEquals(1, detailsLines.length);
|
|
121 |
assertEquals("Citation: Germany, Berlin, 2 Apr 1835. (BHUPM 671)", detailsLines[0]);
|
|
122 |
|
|
123 |
// summary row 1
|
|
124 |
rowId = 3;
|
|
125 |
assertTrue(rows.get(rowId).getAttribute("class").contains("summary_row"));
|
|
126 |
cells = rows.get(rowId).findElements(By.tagName("td"));
|
|
127 |
assertEquals("Germany", cells.get(1).getText());
|
|
128 |
assertEquals("2016-03-28", cells.get(2).getText());
|
|
129 |
assertEquals("Ehrenberg, C.G. D047", cells.get(3).getText());
|
|
130 |
assertEquals("CEDiT, M", cells.get(4).getText());
|
|
131 |
assertTrue(cells.get(5).findElement(By.tagName("img")).getAttribute("src")
|
|
132 |
.endsWith(STEP_DONE_IMAGE));
|
|
133 |
assertTrue(cells.get(6).findElement(By.tagName("img")).getAttribute("src")
|
|
134 |
.endsWith(STEP_DONE_IMAGE));
|
|
135 |
|
|
136 |
// details row 1
|
|
137 |
rowId = 4;
|
|
138 |
assertTrue(rows.get(rowId).getAttribute("class").contains("detail_row"));
|
|
139 |
assertEquals("Should be initially invisible", "none", rows.get(rowId).getCssValue("display"));
|
|
140 |
rows.get(rowId - 1).click();
|
|
141 |
assertEquals("The click should make it visible", "table-row", rows.get(rowId).getCssValue("display"));
|
|
142 |
cells = rows.get(rowId).findElements(By.tagName("td"));
|
|
143 |
detailsText = cells.get(1).getText();
|
|
144 |
detailsLines = StringUtils.split(detailsText, "\n");
|
|
145 |
assertEquals(6, detailsLines.length);
|
|
146 |
assertEquals("Citation: Germany, Berlin, alt. 165 m, 52°31'1.2\"N, 13°21'E (WGS84), 28 Mar 2016, Ehrenberg D047. (M M-0289351, CEDiT 2017E68)", detailsLines[0]);
|
|
147 |
assertEquals("Specimen summary: M (M-0289351)", detailsLines[1]);
|
|
148 |
assertEquals("Preferred stable URI: http://herbarium.bgbm.org/object/B400042045", detailsLines[2]);
|
|
149 |
assertEquals("Isolectotype of Glenodinium apiculatum Ehrenb.", detailsLines[3]);
|
|
150 |
assertEquals("Specimen summary: CEDiT (2017E68)", detailsLines[4]);
|
|
151 |
assertEquals("Epitype of Glenodinium apiculatum Ehrenb. Specimen Scans: CEDiT (2017E68)", detailsLines[5]);
|
|
152 |
}
|
|
153 |
|
|
154 |
}
|
ref #7685 test for compressed specimen table implemented, test data not yet complete