Search in sources :

Example 1 with NotificationElement

use of com.vaadin.flow.component.notification.testbench.NotificationElement in project flow by vaadin.

the class FusionFormIT method save_backend_loaded_empty_values_for_required_fields_no_runtime_errors.

@Test
public void save_backend_loaded_empty_values_for_required_fields_no_runtime_errors() {
    ButtonElement loadDataButton = $(ButtonElement.class).id("load-from-endpoint");
    loadDataButton.click();
    ButtonElement saveButton = $(ButtonElement.class).id("save");
    waitUntil(driver -> saveButton.isEnabled());
    saveButton.click();
    NotificationElement notification = $(NotificationElement.class).id("notification");
    Assert.assertNotNull(notification);
    waitUntil(driver -> notification.isOpen());
    Assert.assertTrue(notification.getText().contains("must not be empty"));
    Assert.assertFalse(notification.getText().contains("Expected string but received null"));
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 2 with NotificationElement

use of com.vaadin.flow.component.notification.testbench.NotificationElement in project skeleton-starter-flow-spring by vaadin.

the class MainViewIT method testEnterShowsHelloUserNotificationWhenUserIsNotEmpty.

@Test
public void testEnterShowsHelloUserNotificationWhenUserIsNotEmpty() {
    TextFieldElement textField = $(TextFieldElement.class).waitForFirst();
    textField.setValue("Vaadiner");
    textField.sendKeys(Keys.ENTER);
    $(NotificationElement.class).waitForFirst();
    Assert.assertTrue($(NotificationElement.class).exists());
    NotificationElement notification = $(NotificationElement.class).first();
    Assert.assertEquals("Hello Vaadiner", notification.getText());
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) TextFieldElement(com.vaadin.flow.component.textfield.testbench.TextFieldElement) Test(org.junit.Test)

Example 3 with NotificationElement

use of com.vaadin.flow.component.notification.testbench.NotificationElement in project skeleton-starter-flow-spring by vaadin.

the class MainViewIT method testClickButtonShowsHelloAnonymousUserNotificationWhenUserNameIsEmpty.

@Test
public void testClickButtonShowsHelloAnonymousUserNotificationWhenUserNameIsEmpty() {
    ButtonElement button = $(ButtonElement.class).waitForFirst();
    button.click();
    $(NotificationElement.class).waitForFirst();
    Assert.assertTrue($(NotificationElement.class).exists());
    NotificationElement notification = $(NotificationElement.class).first();
    Assert.assertEquals("Hello anonymous user", notification.getText());
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) Test(org.junit.Test)

Example 4 with NotificationElement

use of com.vaadin.flow.component.notification.testbench.NotificationElement in project skeleton-starter-flow-spring by vaadin.

the class MainViewIT method testClickButtonShowsHelloUserNotificationWhenUserIsNotEmpty.

@Test
public void testClickButtonShowsHelloUserNotificationWhenUserIsNotEmpty() {
    TextFieldElement textField = $(TextFieldElement.class).waitForFirst();
    textField.setValue("Vaadiner");
    $(ButtonElement.class).waitForFirst().click();
    $(NotificationElement.class).waitForFirst();
    Assert.assertTrue($(NotificationElement.class).exists());
    NotificationElement notification = $(NotificationElement.class).first();
    Assert.assertEquals("Hello Vaadiner", notification.getText());
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) TextFieldElement(com.vaadin.flow.component.textfield.testbench.TextFieldElement) Test(org.junit.Test)

Example 5 with NotificationElement

use of com.vaadin.flow.component.notification.testbench.NotificationElement in project flow by vaadin.

the class FusionFormIT method save_empty_values_for_required_fields_no_runtime_errors.

@Test
public void save_empty_values_for_required_fields_no_runtime_errors() {
    ButtonElement saveButton = $(ButtonElement.class).id("save");
    saveButton.click();
    NotificationElement notification = $(NotificationElement.class).id("notification");
    Assert.assertNotNull(notification);
    waitUntil(driver -> notification.isOpen());
    Assert.assertTrue(notification.getText().contains("must not be empty"));
    Assert.assertFalse(notification.getText().contains("Expected string but received a undefined"));
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Aggregations

NotificationElement (com.vaadin.flow.component.notification.testbench.NotificationElement)5 Test (org.junit.Test)5 ButtonElement (com.vaadin.flow.component.button.testbench.ButtonElement)3 TextFieldElement (com.vaadin.flow.component.textfield.testbench.TextFieldElement)2 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)2