aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/containers/sqlcontainer/TableQueryWithNonUniqueFirstPrimaryKeyTest.java
blob: 172d83e6458f3fc28d829b5a01352357eb2e518d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.vaadin.tests.containers.sqlcontainer;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class TableQueryWithNonUniqueFirstPrimaryKeyTest extends
        MultiBrowserTest {

    private static final String[] DATA = { "TARUSCIO GIOVANNI",
            "RUSSO GAETANO AUTORICAMBI", "AMORUSO LUIGI SRL", "CARUSO ROCCO",
            "F.LLI RUSSO DI GAETANO RUSSO & C", "RUSSO GIUSEPPE",
            "TRUSCELLI ANTONIO", "CARUSO CALOGERO" };

    @Test
    public void testComboBoxSuggestionsListedCorrectly() throws Exception {
        openTestURL();
        $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox"))
                .sendKeys("rus", Keys.ENTER);

        List<String> result = new ArrayList<String>();

        // pick list items that are shown in suggestion popup
        List<WebElement> elems = findElements(By
                .cssSelector("td[role=\"listitem\"]"));
        Assert.assertEquals("not enough suggestions shown", DATA.length,
                elems.size());

        for (WebElement elem : elems) {
            result.add(elem.getText());
        }

        Assert.assertArrayEquals("popup items not what they should be", DATA,
                result.toArray());

    }
}