Skip to content

Commit

Permalink
fix menu find
Browse files Browse the repository at this point in the history
  • Loading branch information
caalador committed Oct 14, 2024
1 parent 9604ac6 commit f322b92
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function HelloHilla() {
const [name, setName] = useState("");

return (
<VerticalLayout theme="padding">
<VerticalLayout theme="padding" id={"flow-hilla"}>
<TextField label="Your name for Hilla" onValueChanged={(e) => setName(e.detail.value)} />
<Button onClick = {() => Notification.show(`Hello ${name}` , {
position: 'middle',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
*/
package com.vaadin.platform.react.test;

import java.util.List;
import java.util.Optional;

import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.flow.component.sidenav.testbench.SideNavElement;
import com.vaadin.flow.component.sidenav.testbench.SideNavItemElement;
import com.vaadin.testbench.IPAddress;
import com.vaadin.testbench.parallel.ParallelTest;
import com.vaadin.testbench.parallel.SauceLabsIntegration;
Expand Down Expand Up @@ -92,4 +97,12 @@ protected int getDeploymentPort() {
protected String getDeploymentHostname() {
return hostName;
}

protected Optional<SideNavItemElement> getMenuElement(String label) {
List<SideNavItemElement> items = $(SideNavElement.class).first()
.getItems();
return items.stream()
.filter(item -> item.getLabel().equals(label))
.findFirst();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.vaadin.platform.react.test;

import java.util.List;
import java.util.Optional;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.vaadin.flow.component.button.testbench.ButtonElement;
import com.vaadin.flow.component.sidenav.testbench.SideNavElement;
import com.vaadin.flow.component.sidenav.testbench.SideNavItemElement;

public class FlowInHillaIT extends AbstractPlatformTest{
Expand All @@ -14,14 +19,14 @@ public void flowViewInHillaLayout() {
Assert.assertNotNull(findElement(By.id("hilla")));

// Navigate to Flow view
$(SideNavItemElement.class).withCaption("Flow in hilla").first().click();
getMenuElement("Flow in hilla").get().click();

waitUntil(ExpectedConditions.presenceOfElementLocated(By.id("flow-hilla")));

Assert.assertNull("Showing hilla placeholder even though Flow should be shown", findElement(By.id("placeholder")));

// navigate away from Flow view
$(SideNavItemElement.class).withCaption("React Components").first().click();
getMenuElement("React Components").get().click();

Assert.assertTrue("React components view should be shown", $(ButtonElement.class).id("open-overlay").isDisplayed());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
import com.vaadin.flow.component.sidenav.testbench.SideNavItemElement;

public class HillaInFlowIT extends AbstractPlatformTest{
Expand All @@ -14,14 +15,14 @@ public void hillaViewInFlowLayout() {
waitUntil(ExpectedConditions.presenceOfElementLocated(By.id("flow-main")));

// Navigate to Flow view
$(SideNavItemElement.class).withCaption("Flow in hilla").first().click();
getMenuElement("Hello React in Flow Layout").get().click();

waitUntil(ExpectedConditions.presenceOfElementLocated(By.id("flow-hilla")));

Assert.assertNull("Showing hilla placeholder even though Flow should be shown", findElement(By.id("placeholder")));

// navigate away from Flow view
$(SideNavItemElement.class).withCaption("React Components").first().click();
getMenuElement("Flow Hello").get().click();

Assert.assertTrue("Flow layout should have been rendered", $(HorizontalLayoutElement.class).first().isDisplayed());
}

@Override
Expand Down

0 comments on commit f322b92

Please sign in to comment.