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

Commit

Permalink
IT test for flow bug #4444, #4438 (#291)
Browse files Browse the repository at this point in the history
* IT test for flow bug #4444

* Add one more test to check that #4438 is fixed.
  • Loading branch information
Denis authored Aug 1, 2018
1 parent e428fca commit aff9356
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2018 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 com.vaadin.flow.testutil.AbstractComponentIT;
import com.vaadin.flow.testutil.TestPath;

@TestPath("refresh-invisible-grid")
public class RefreshAndMakeVisibleGridIT extends AbstractComponentIT {

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

findElement(By.id("refresh")).click();
checkLogsForErrors();

boolean hasFooCell = $("vaadin-grid-cell-content").all().stream()
.anyMatch(element -> "foo".equals(element.getText()));

Assert.assertTrue(
"Grid has no 'foo' cell after making it visible and refresh data provider",
hasFooCell);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2000-2018 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 java.util.ArrayList;

import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.NativeButton;
import com.vaadin.flow.data.provider.ListDataProvider;
import com.vaadin.flow.function.ValueProvider;
import com.vaadin.flow.router.Route;

@Route("refresh-invisible-grid")
public class RefreshAndMakeVisibleGridPage extends Div {

private Grid<String> grid;
private ListDataProvider<String> dataProvider;

public RefreshAndMakeVisibleGridPage() {
grid = new Grid<>();
dataProvider = new ListDataProvider<>(new ArrayList<>());
grid.setDataProvider(dataProvider);
grid.setVisible(false);
grid.addColumn(ValueProvider.identity()).setHeader("Name");

NativeButton button = new NativeButton("Make grid visible", event -> {
dataProvider.getItems().clear();
dataProvider.getItems().add("foo");
dataProvider.refreshAll();
grid.setVisible(true);
});

button.setId("refresh");

add(grid, button);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2000-2018 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 com.vaadin.flow.testutil.AbstractComponentIT;
import com.vaadin.flow.testutil.TestPath;

@TestPath("select-invisible-grid")
public class SelectAndMakeVisibleIT extends AbstractComponentIT {

@Test
public void selectRowAndMakeGridVisible() throws InterruptedException {
open();

findElement(By.id("select")).click();
checkLogsForErrors();

Long selectedLength = (Long) getCommandExecutor().executeScript(
"return arguments[0].selectedItems.length;",
findElement(By.tagName("vaadin-grid")));
Assert.assertEquals("Unexpected number of selected items", 1l,
selectedLength.longValue());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2018 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.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.NativeButton;
import com.vaadin.flow.function.ValueProvider;
import com.vaadin.flow.router.Route;

@Route("select-invisible-grid")
public class SelectAndMakeVisiblePage extends Div {

public SelectAndMakeVisiblePage() {
Grid<String> grid = new Grid<>();
grid.setItems("foo", "bar");
grid.setVisible(false);
grid.addColumn(ValueProvider.identity()).setHeader("Name");

NativeButton button = new NativeButton("Make grid visible", event -> {
grid.setVisible(true);
grid.getSelectionModel().select("foo");
});

button.setId("select");

add(grid, button);
}
}

0 comments on commit aff9356

Please sign in to comment.