Skip to content

Commit

Permalink
Added an IT for the long-polling push case
Browse files Browse the repository at this point in the history
  • Loading branch information
gilberto-torrezan committed Jul 16, 2018
1 parent c8a30cb commit ef557a6
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.uitest.ui;

import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.NativeButton;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.page.Push;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.shared.ui.Transport;

/**
* Class for reproducing the bug https://github.com/vaadin/flow/issues/4353
*/
@Route("com.vaadin.flow.uitest.ui.LongPollingPushView")
@Push(transport = Transport.LONG_POLLING)
public class LongPollingPushView extends AbstractDivView {

public LongPollingPushView() {
Div parent = new Div();
Span child = new Span("Some text");
child.setId("child");
parent.add(child);
add(parent);
parent.setVisible(false);

NativeButton visibility = new NativeButton("Toggle visibility",
e -> parent.setVisible(!parent.isVisible()));
visibility.setId("visibility");
add(visibility);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.uitest.ui;

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

import com.vaadin.flow.testutil.ChromeBrowserTest;

public class LongPollingPushIT extends ChromeBrowserTest {

@Test
public void openPage_thereAreNoErrorsInTheConsole() {
open();
checkLogsForErrors();

waitForElementNotPresent(By.id("child"));

WebElement button = findElement(By.id("visibility"));
button.click();

waitForElementPresent(By.id("child"));

WebElement span = findElement(By.id("child"));
Assert.assertEquals("Some text", span.getText());
checkLogsForErrors();
}

}

0 comments on commit ef557a6

Please sign in to comment.