aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/ui/RefreshUITest.java
blob: db42bc71f87f74bec6253694d20550c4c3cec1b3 (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
46
47
48
package com.vaadin.tests.components.ui;

import com.vaadin.testbench.elements.ButtonElement;
import org.junit.Test;

import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

import static org.junit.Assert.assertEquals;

public class RefreshUITest extends MultiBrowserTest {

    @Test
    public void testUIRefresh_viewNotRecreated() {
        openTestURL();
        assertEquals("The Label content is not matching",
                "This is instance no 1",
                $(LabelElement.class).first().getText());

        // Reload the page; UI.refresh should be invoked
        reloadPage();
        assertEquals("The Label content is not matching",
                "This is instance no 1",
                $(LabelElement.class).first().getText());
    }

    @Test
    public void testViewNotRecreatedAfterNavigation() {
        openTestURL();
        assertEquals("This is instance no 1",
                $(LabelElement.class).first().getText());

        // Reload the page; UI.refresh should be invoked
        reloadPage();
        assertEquals("This is instance no 1",
                $(LabelElement.class).first().getText());

        // now open the other view using the navigator
        $(ButtonElement.class).first().click();
        assertEquals("This is otherview instance no 1",
                $(LabelElement.class).first().getText());

        // Reload the page; UI.refresh should be invoked
        reloadPage();
        assertEquals("This is otherview instance no 1",
                $(LabelElement.class).first().getText());
    }
}