123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package com.vaadin.v7.tests.components.grid.basicfeatures.server;
-
- import com.vaadin.testbench.elements.ButtonElement;
- import com.vaadin.testbench.elements.GridElement;
- import com.vaadin.testbench.parallel.TestCategory;
- import com.vaadin.tests.tb3.SingleBrowserTest;
- import org.junit.Assert;
- import org.junit.Test;
- import org.openqa.selenium.By;
-
- @TestCategory("grid")
- public class GridIndexedContainerInsertSelectTest extends SingleBrowserTest {
-
- @Override
- public void setup() throws Exception {
-
- super.setup();
- openTestURL();
- waitForElementPresent(By.className("v-grid"));
- }
-
- /**
- * Test asserting that issue
- * https://github.com/vaadin/framework/issues/11477 is fixed.
- */
- @Test
- public void test_insertRowAfterSelected_newRowIsSelected() {
- openTestURL();
-
- // Assert that first row is already selected when ui loaded
- Assert.assertTrue(
- "First row should be selected to continue with the test!",
- isRowSelected(0));
-
- // Add new row after the selected one
- $(ButtonElement.class).first().click();
-
- // Assert that the new row is added correctly
- Assert.assertEquals("Item 4",
- $(GridElement.class).first().getRow(1).getCell(0).getText());
-
- // Assert that the new added row is selected
- Assert.assertTrue("Newly inserted row should be selected!",
- isRowSelected(1));
-
- // Select row at index 2
- $(GridElement.class).first().getRow(2).click();
-
- // Add new row after the selected one
- $(ButtonElement.class).first().click();
-
- // Assert that the new row is added correctly
- Assert.assertEquals("Item 5",
- $(GridElement.class).first().getRow(3).getCell(0).getText());
-
- // Assert that the new added row is selected
- Assert.assertTrue("Newly inserted row should be selected!",
- isRowSelected(3));
-
- }
-
- protected boolean isRowSelected(int index) {
- return $(GridElement.class).first().getRow(index).isSelected();
- }
-
- }
|