|
| 1 | +/* |
| 2 | + * Copyright 2000-2019 Vaadin Ltd. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package com.vaadin.flow.component.gridpro.test; |
| 17 | + |
| 18 | +import org.junit.Assert; |
| 19 | +import org.junit.Before; |
| 20 | +import org.junit.Test; |
| 21 | + |
| 22 | +import com.vaadin.flow.component.gridpro.testbench.GridProElement; |
| 23 | +import com.vaadin.flow.component.gridpro.testbench.GridTHTDElement; |
| 24 | +import com.vaadin.tests.AbstractComponentIT; |
| 25 | +import com.vaadin.flow.testutil.TestPath; |
| 26 | +import com.vaadin.testbench.TestBenchElement; |
| 27 | + |
| 28 | +@TestPath("gridpro-detach-attach") |
| 29 | +public class GridProDetachAttachIT extends AbstractComponentIT { |
| 30 | + |
| 31 | + private GridProElement grid; |
| 32 | + private TestBenchElement toggleAttachedButton; |
| 33 | + |
| 34 | + @Before |
| 35 | + public void before() { |
| 36 | + open(); |
| 37 | + grid = $(GridProElement.class).first(); |
| 38 | + toggleAttachedButton = $("button").id("toggle-attached"); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void detach_attach_customEditOpens() { |
| 43 | + toggleAttachedButton.click(); |
| 44 | + toggleAttachedButton.click(); |
| 45 | + |
| 46 | + grid = $(GridProElement.class).waitForFirst(); |
| 47 | + assertCellEnterEditModeOnDoubleClick(grid, 0, 0, "vaadin-text-field"); |
| 48 | + } |
| 49 | + |
| 50 | + private void assertCellEnterEditModeOnDoubleClick(GridProElement grid, |
| 51 | + Integer rowIndex, Integer colIndex, String editorTag) { |
| 52 | + GridTHTDElement cell = grid.getCell(rowIndex, colIndex); |
| 53 | + |
| 54 | + // Not in edit mode initially |
| 55 | + Assert.assertFalse(cell.innerHTMLContains(editorTag)); |
| 56 | + |
| 57 | + // Entering edit mode with double click |
| 58 | + executeScript( |
| 59 | + "arguments[0].dispatchEvent(new CustomEvent('dblclick', {composed: true, bubbles: true}));", |
| 60 | + cell); |
| 61 | + Assert.assertTrue(cell.innerHTMLContains(editorTag)); |
| 62 | + // Assert there are no null reference errors |
| 63 | + checkLogsForErrors(); |
| 64 | + } |
| 65 | +} |
0 commit comments