Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Provide an IT test to click Vaadin button inside Grid via space
Browse files Browse the repository at this point in the history
IT verification test for #37.
Closes #37.
  • Loading branch information
Denis Anisimov committed Jun 7, 2018
1 parent ce4b48e commit cdd9887
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2000-2017 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.flow.component.grid.it;

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

import com.vaadin.flow.testutil.AbstractComponentIT;
import com.vaadin.flow.testutil.TestPath;

@TestPath("vaadin-button-inside-grid")
public class ButtonInGridIT extends AbstractComponentIT {

@Test
public void pressButtonUsingKeyboard() {
open();

WebElement firstCell = findElements(
By.tagName("vaadin-grid-cell-content")).stream()
.filter(cell -> cell.getText().equals("Show item"))
.findFirst().get();

WebElement vaadinButton = firstCell
.findElement(By.tagName("vaadin-button"));
vaadinButton.sendKeys(Keys.SPACE);

WebElement info = findElement(By.id("info"));
Assert.assertEquals("foo", info.getText());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2017 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.flow.component.grid.it;

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.theme.NoTheme;

@Route("vaadin-button-inside-grid")
@NoTheme
public class ButtonInGridPage extends Div {

public ButtonInGridPage() {
Grid<String> grid = new Grid<>();
grid.setId("grid");

Div div = new Div();
div.setId("info");

grid.addComponentColumn(item -> new Button("Show item", evt -> {
div.setText(item);
})).setHeader("Click to see an item");

grid.setItems("foo", "bar");
add(grid, div);
}
}

0 comments on commit cdd9887

Please sign in to comment.