Project

General

Profile

« Previous | Next » 

Revision 8c3d9651

Added by Andreas Kohlbecker over 3 years ago

ref #7685 test for compressed specimen table implemented, test data not yet complete

View differences:

modules/cdm_dataportal/includes/occurrences.inc
1014 1014
}
1015 1015

  
1016 1016
/**
1017
 * Creates the drupal render array for the table showing all derivatives which
1017
 * Composes a compressed derivate table showing all derivatives which
1018 1018
 * stem from a common gathering event.
1019 1019
 *
1020 1020
 * @param $field_unit_uuids array
......
1023 1023
 * @return array
1024 1024
 *  A drupal render array for a table
1025 1025
 *
1026
 * @see CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TABLE
1027
 *
1026 1028
 * @ingroup compose
1027 1029
 */
1028 1030

  
......
1624 1626

  
1625 1627

  
1626 1628
/**
1627
 * Composes a BOTTOM-UP-SPECIMEN-TABLE
1629
 * Composes a BOTTOM-UP-SPECIMEN-TABLE for the view mode
1630
 * CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE
1631
 *
1628 1632
 * @param $specimensOrObservations
1629 1633
 * @return array
1630 1634
 *  A drupal render array with the following keys:
......
1632 1636
 *   - 'pager'
1633 1637
 *
1634 1638
 * @ingroup Compose
1639
 * @see CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE
1635 1640
 */
1636 1641
function compose_specimens_table_bottom_up($specimensOrObservations)
1637 1642
{
src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java
13 13
import java.util.List;
14 14
import java.util.Map;
15 15
import java.util.Map.Entry;
16
import java.util.Optional;
16 17
import java.util.concurrent.TimeUnit;
17 18
import java.util.regex.Matcher;
18 19
import java.util.regex.Pattern;
......
416 417
        return tabs;
417 418
    }
418 419

  
420
    /**
421
     * @return the active primary tab
422
     */
423
    public Optional<LinkElement> getActivePrimaryTab() {
424
        List<LinkElement> primaryTabs = getPrimaryTabs();
425
        return primaryTabs.stream()
426
                .filter(we -> we.getClassAttributes().stream().anyMatch(ca -> ca.equals("active")))
427
                .findFirst();
428

  
429
    }
430

  
419 431
    /**
420 432
     * Provides access to the the CDM specific main content <code>div</code> element.
421 433
     *
src/main/java/eu/etaxonomy/dataportal/pages/TaxonPage.java
89 89
        return statusEls;
90 90
    }
91 91

  
92

  
92 93
}
src/test/java/eu/etaxonomy/dataportal/selenium/tests/reference/SpecimenTableViewTest.java
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
}
src/test/java/eu/etaxonomy/dataportal/selenium/tests/reference/SpecimensTreeViewTest.java
54 54
    }
55 55

  
56 56
    @Test
57
    //@Ignore
58 57
    public void test1() throws MalformedURLException {
59 58
        TaxonPage p = new TaxonPage(driver, getContext(), glenodinium_apiculatum_t, "specimens");
60 59
        WebElement specimensTable = p.getDataPortalContent().getElement().findElement(By.cssSelector("#specimens table.derivate_tree"));

Also available in: Unified diff