aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailuresTest.java
blob: 545c9c2e710b084252bba7e4e4f46d5f82708cd7 (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
49
50
51
52
53
54
55
56
57
58
59
60
package com.vaadin.tests.fieldgroup;

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

public class CommitHandlerFailuresTest extends BasicPersonFormTest {

    @Override
    public void setup() throws Exception {
        super.setup();
        openTestURL();
    }

    @Test
    public void testDefaults() {
        assertDefaults();
        assertBeanValuesUnchanged();
    }

    @Test
    public void testUpdatingWithoutCommit() {
        updateFields();
        assertBeanValuesUnchanged();
    }

    @Test
    public void testPreCommitFails() {
        updateFields();

        getPreCommitFailsCheckBox().click();
        assertCommitFails();

        assertBeanValuesUnchanged();
    }

    @Test
    public void testPostCommitFails() {
        updateFields();

        getPostCommitFailsCheckBox().click();
        assertCommitFails();

        assertBeanValuesUnchanged();
    }

    @Test
    public void testDiscard() {
        updateFields();
        assertDiscardResetsFields();
        assertBeanValuesUnchanged();
    }

    private void updateFields() {
        getLastNameArea().sendKeys("Doeve", Keys.ENTER);
        getFirstNameField().sendKeys("Mike", Keys.ENTER);
        getEmailField().sendKeys("me@me.com", Keys.ENTER);
        getAgeField().sendKeys("12", Keys.ENTER);
        getGenderTable().getCell(2, 0).click();
    }
}