Skip to content

Commit

Permalink
feat: use web components 21.0.0-alpha2, fix tests (#978)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomi Virkki <[email protected]>
  • Loading branch information
web-padawan and tomivirkki authored May 17, 2021
1 parent 4a61d25 commit 4cfbc14
Show file tree
Hide file tree
Showing 68 changed files with 132 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* can be opened at a time.
*/
@Tag("vaadin-accordion")
@NpmPackage(value = "@vaadin/vaadin-accordion", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-accordion", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-accordion/src/vaadin-accordion.js")
public class Accordion extends Component implements HasSize, HasStyle {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* quick and easy way to get a common application layout.
*/
@Tag("vaadin-app-layout")
@NpmPackage(value = "@vaadin/vaadin-app-layout", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-app-layout", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-app-layout/src/vaadin-app-layout.js")
public class AppLayout extends Component implements RouterLayout {
private static final PropertyDescriptor<String, String> primarySectionProperty = PropertyDescriptors
Expand Down Expand Up @@ -265,7 +265,7 @@ private void remove(Component component) {

/**
* Sections in the component that can be used as primary.
*
*
* @see #setPrimarySection(Section)
*/
public enum Section {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* </code>
*/
@Tag("vaadin-drawer-toggle")
@NpmPackage(value = "@vaadin/vaadin-app-layout", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-app-layout", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-app-layout/src/vaadin-drawer-toggle.js")
public class DrawerToggle extends Button {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@Tag("vaadin-avatar")
@JsModule("@vaadin/vaadin-avatar/src/vaadin-avatar.js")
@NpmPackage(value = "@vaadin/vaadin-avatar", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-avatar", version = "21.0.0-alpha2")
public class Avatar extends Component implements HasStyle, HasSize, HasTheme {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*/
@Tag("vaadin-avatar-group")
@JsModule("@vaadin/vaadin-avatar/src/vaadin-avatar-group.js")
@NpmPackage(value = "@vaadin/vaadin-avatar", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-avatar", version = "21.0.0-alpha2")
public class AvatarGroup extends Component
implements HasStyle, HasSize, HasTheme {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* </pre>
*/
@Tag("vaadin-board")
@NpmPackage(value = "@vaadin/vaadin-board", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-board", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-board/vaadin-board.js")
public class Board extends Component
implements HasSize, HasStyle, HasOrderedComponents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* </pre>
*/
@Tag("vaadin-board-row")
@NpmPackage(value = "@vaadin/vaadin-board", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-board", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-board/vaadin-board-row.js")
public class Row extends Component
implements HasStyle, HasSize, HasOrderedComponents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
* </p>
*/
@Tag("vaadin-button")
@NpmPackage(value = "@vaadin/vaadin-button", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-button", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-button/src/vaadin-button.js")
public abstract class GeneratedVaadinButton<R extends GeneratedVaadinButton<R>>
extends Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
import elemental.json.impl.JreJsonFactory;

@Tag("vaadin-chart")
@NpmPackage(value = "@vaadin/vaadin-charts", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-charts", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-charts/src/vaadin-chart.js")
public class Chart extends Component implements HasStyle, HasSize {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
* </p>
*/
@Tag("vaadin-checkbox")
@NpmPackage(value = "@vaadin/vaadin-checkbox", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-checkbox", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-checkbox/src/vaadin-checkbox.js")
public abstract class GeneratedVaadinCheckbox<R extends GeneratedVaadinCheckbox<R, T>, T>
extends AbstractSinglePropertyField<R, T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
* </p>
*/
@Tag("vaadin-checkbox-group")
@NpmPackage(value = "@vaadin/vaadin-checkbox", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-checkbox", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-checkbox/src/vaadin-checkbox-group.js")
public abstract class GeneratedVaadinCheckboxGroup<R extends GeneratedVaadinCheckboxGroup<R, T>, T>
extends AbstractSinglePropertyField<R, T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@
* </p>
*/
@Tag("vaadin-combo-box")
@NpmPackage(value = "@vaadin/vaadin-combo-box", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-combo-box", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-combo-box/src/vaadin-combo-box.js")
@NpmPackage(value = "@vaadin/vaadin-template-renderer", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-template-renderer/src/vaadin-template-renderer.js")
public abstract class GeneratedVaadinComboBox<R extends GeneratedVaadinComboBox<R, T>, T>
extends AbstractSinglePropertyField<R, T>
implements HasStyle, Focusable<R> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Vaadin Ltd
*/
@Tag("vaadin-confirm-dialog")
@NpmPackage(value = "@vaadin/vaadin-confirm-dialog", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-confirm-dialog", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-confirm-dialog/src/vaadin-confirm-dialog.js")
public class ConfirmDialog extends Component
implements HasSize, HasStyle, HasOrderedComponents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@
* </p>
*/
@Tag("vaadin-context-menu")
@NpmPackage(value = "@vaadin/vaadin-context-menu", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-context-menu", version = "21.0.0-alpha2")
@NpmPackage(value = "@vaadin/vaadin-template-renderer", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-context-menu/src/vaadin-context-menu.js")
@JsModule("@vaadin/vaadin-template-renderer/src/vaadin-template-renderer.js")
public abstract class GeneratedVaadinContextMenu<R extends GeneratedVaadinContextMenu<R>>
extends Component implements HasStyle, ClickNotifier<R> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
@SuppressWarnings("serial")
@Tag("vaadin-cookie-consent")
@NpmPackage(value = "@vaadin/vaadin-cookie-consent", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-cookie-consent", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-cookie-consent/src/vaadin-cookie-consent.js")
public class CookieConsent extends Component {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* the bean type
*/
@Tag("vaadin-crud")
@NpmPackage(value = "@vaadin/vaadin-crud", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-crud", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-crud/src/vaadin-crud.js")
@JsModule("@vaadin/vaadin-crud/src/vaadin-crud-edit-column.js")
public class Crud<E> extends Component implements HasSize, HasTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* field value type
*/
@Tag("vaadin-custom-field")
@NpmPackage(value = "@vaadin/vaadin-custom-field", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-custom-field", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-custom-field/src/vaadin-custom-field.js")
public abstract class CustomField<T> extends AbstractField<CustomField<T>, T>
implements HasSize, HasValidation, Focusable<CustomField>, HasHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void testPickerWithValueAndLocaleFromServerSideDifferentCtor() {
for (LogEntry logEntry : getWarningEntries()) {
Assert.assertThat(
"Expected only [Deprecation] warnings in the logs",
logEntry.getMessage(),
CoreMatchers.containsString("HTML Imports"));
logEntry.getMessage(), CoreMatchers.containsString(
"'lit-element' module entrypoint is deprecated."));
Assert.assertThat(logEntry.getMessage(),
CoreMatchers.containsString("deprecated"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
* </p>
*/
@Tag("vaadin-date-picker")
@NpmPackage(value = "@vaadin/vaadin-date-picker", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-date-picker", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-date-picker/src/vaadin-date-picker.js")
public abstract class GeneratedVaadinDatePicker<R extends GeneratedVaadinDatePicker<R, T>, T>
extends AbstractSinglePropertyField<R, T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void validate() {
*
*/
@Tag("vaadin-date-time-picker")
@NpmPackage(value = "@vaadin/vaadin-date-time-picker", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-date-time-picker", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-date-time-picker/src/vaadin-date-time-picker.js")
public class DateTimePicker extends AbstractField<DateTimePicker, LocalDateTime>
implements HasStyle, HasSize, HasTheme, HasValidation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.vaadin.flow.shared.Registration;

@Tag("vaadin-details")
@NpmPackage(value = "@vaadin/vaadin-details", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-details", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-details/src/vaadin-details.js")
public class Details extends Component
implements HasEnabled, HasTheme, HasStyle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
* </p>
*/
@Tag("vaadin-dialog")
@NpmPackage(value = "@vaadin/vaadin-dialog", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-dialog", version = "21.0.0-alpha2")
@NpmPackage(value = "@vaadin/vaadin-template-renderer", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-dialog/src/vaadin-dialog.js")
@JsModule("@vaadin/vaadin-template-renderer/src/vaadin-template-renderer.js")
public abstract class GeneratedVaadinDialog<R extends GeneratedVaadinDialog<R>>
extends Component {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
* </p>
*/
@Tag("vaadin-form-item")
@NpmPackage(value = "@vaadin/vaadin-form-layout", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-form-layout", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-form-layout/src/vaadin-form-item.js")
public abstract class GeneratedVaadinFormItem<R extends GeneratedVaadinFormItem<R>>
extends Component implements HasStyle, ClickNotifier<R> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
* </table>
*/
@Tag("vaadin-form-layout")
@NpmPackage(value = "@vaadin/vaadin-form-layout", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-form-layout", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-form-layout/src/vaadin-form-layout.js")
public abstract class GeneratedVaadinFormLayout<R extends GeneratedVaadinFormLayout<R>>
extends Component implements HasStyle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public void itemCountEstimateGrid_estimateLessThanCurrentRange_estimateNotChange
grid.scrollToRow(1500);
setEstimate(1501);

verifyRows(1501);
verifyRows(1800);

setEstimate(1600);
verifyRows(1600);
setEstimate(1700);
verifyRows(1700);

grid.scrollToRow(1100);
setEstimate(1300);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public void undefinedSizeGrid_switchesToDefinedSize_sizeChanges() {

grid.scrollToRow(500);

int expectedLastItem = 517;
int VIEWPORT_ITEM_CAPACITY = 16;
int expectedLastItem = 500 + VIEWPORT_ITEM_CAPACITY;
Assert.assertEquals(
"Grid should be able to scroll after changing to defined size",
expectedLastItem, grid.getLastVisibleRowIndex());
Expand All @@ -96,7 +97,8 @@ public void undefinedSizeGrid_switchesToDefinedSize_sizeChanges() {
// size has been increased again by default size
doScroll(1000, 1200, 6, 950, 1100);

Assert.assertEquals(999, grid.getLastVisibleRowIndex());
Assert.assertEquals(1000 + VIEWPORT_ITEM_CAPACITY,
grid.getLastVisibleRowIndex());
}

// @Test TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void grid_scrollToEnd() {

Assert.assertEquals(
"Last visible index did not equal last item index after scroll to end.",
1000L, grid.getProperty("lastVisibleIndex"));
1000L, grid.getLastVisibleRowIndex());
}

@Test
Expand All @@ -55,7 +55,7 @@ public void grid_scrollToRow500() {

Assert.assertEquals(
"First visible index did not equal scrollToIndex parameter.",
500L, grid.getProperty("firstVisibleIndex"));
500L, grid.getFirstVisibleRowIndex());
}

@Test
Expand All @@ -66,7 +66,7 @@ public void grid_scrollToEnd_scrollToStart() {

Assert.assertEquals(
"First visible index did not equal 0 after scroll to start.",
0L, grid.getProperty("firstVisibleIndex"));
0L, grid.getFirstVisibleRowIndex());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ public void toStringIsUsedForObjectSerialization() {
// Checks that all header and body cells have text content
List<TestBenchElement> allCellContents = grid
.$("vaadin-grid-cell-content").all();
List<TestBenchElement> headerSlots = grid.$("thead slot").all();
List<TestBenchElement> bodySlots = grid.$("tbody slot").all();
Assert.assertTrue(headerSlots.size() > 0);
Assert.assertTrue(bodySlots.size() > 0);

allCellContents.forEach(vgcc -> {
String slotName = vgcc.getAttribute("slot")
.replace("vaadin-grid-cell-content-", "");
if (Integer.parseInt(slotName) <= 180) {
TestBenchElement slot = vgcc.getPropertyElement("assignedSlot");
if (headerSlots.contains(slot) || bodySlots.contains(slot)) {
Assert.assertTrue(
"A grid cell was expected to have text content but had none.",
StringUtils.isNotBlank(vgcc.getText()));
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,13 @@ private void scroll(GridElement grid, int index) {
}

private void waitUntilCellHasText(WebElement grid, String text) {
waitUntil(driver -> getCells(grid).stream()
.filter(cell -> text.equals(cell.getText())).findFirst()
.isPresent());
waitUntil(driver -> {
List<?> cellContentTexts = (List<?>) getCommandExecutor()
.executeScript(
"return Array.from(arguments[0].querySelectorAll('vaadin-grid-cell-content')).map(cell => cell.textContent)",
grid);
return cellContentTexts.contains(text);
});
}

private void assertRowsSelected(GridElement grid, int first, int last) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ public void gridScrolling() {
waitForElementPresent(By.tagName("vaadin-grid"));
WebElement grid = findElement(By.tagName("vaadin-grid"));

executeScript("arguments[0]._scrollToIndex(1000000);", grid);
executeScript("arguments[0].scrollToIndex(1000000);", grid);

long firstVisible = (long) executeScript(
"return arguments[0]._firstVisibleIndex+arguments[0]._vidxOffset",
grid);
"return arguments[0]._firstVisibleIndex", grid);
Assert.assertEquals(1000000L, firstVisible);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public void keyboard_navigation() {

// Should collapse "Dad 1/1"
new Actions(getDriver()).sendKeys(Keys.SPACE).perform();
// Make sure the "Dad 1/1" still has focus after collapsing (iron-list
// regression)
getTreeGrid().getCell(3, 0).focus();
assertCellTexts(0, 0, "Granddad 0", "Granddad 1", "Dad 1/0", "Dad 1/1",
"Dad 1/2", "Granddad 2");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@
*
*/
@Tag("vaadin-grid")
@NpmPackage(value = "@vaadin/vaadin-grid", version = "20.0.0-beta1")
@NpmPackage(value = "@vaadin/vaadin-grid", version = "21.0.0-alpha2")
@NpmPackage(value = "@vaadin/vaadin-template-renderer", version = "21.0.0-alpha2")
@JsModule("@vaadin/vaadin-grid/src/vaadin-grid.js")
@JsModule("@vaadin/vaadin-grid/src/vaadin-grid-column.js")
@JsModule("@vaadin/vaadin-grid/src/vaadin-grid-sorter.js")
@JsModule("@vaadin/vaadin-checkbox/src/vaadin-checkbox.js")
@JsModule("@vaadin/vaadin-template-renderer/src/vaadin-template-renderer.js")
@JsModule("./flow-component-renderer.js")
@JsModule("./gridConnector.js")
public class Grid<T> extends Component implements HasStyle, HasSize,
Expand Down Expand Up @@ -3425,7 +3427,7 @@ protected static int compareMaybeComparables(Object a, Object b) {
/**
* Sets the bean type this grid is bound to and optionally adds a set of
* columns for each of the bean's properties.
*
*
* The property-values of the bean will be converted to Strings. Full names
* of the properties will be used as the {@link Column#setKey(String) column
* keys} and the property captions will be used as the
Expand All @@ -3442,7 +3444,7 @@ protected static int compareMaybeComparables(Object a, Object b) {
* <p>
* This method can only be called for a newly instanced Grid without any
* beanType or columns set.
*
*
* @param beanType
* the bean type to use, not <code>null</code>
* @param autoCreateColumns
Expand Down
Loading

0 comments on commit 4cfbc14

Please sign in to comment.