This repository has been archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IT test for flow bug #4444, #4438 (#291)
* 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
Showing
4 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/test/java/com/vaadin/flow/component/grid/it/RefreshAndMakeVisibleGridIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/com/vaadin/flow/component/grid/it/RefreshAndMakeVisibleGridPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/test/java/com/vaadin/flow/component/grid/it/SelectAndMakeVisibleIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/com/vaadin/flow/component/grid/it/SelectAndMakeVisiblePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |