mvysny / karibu-testing

Vaadin Server-Side Browserless Containerless Unit Testing
Apache License 2.0
111 stars 14 forks source link

Connector can only be initialized for an attached Grid error when switching between routes #93

Closed nbabb closed 2 years ago

nbabb commented 2 years ago

It seems that the first page we load (with a disabled AbstractCompositeField that contains a Grid) works fine, but when we navigate away from this page to another page the error is thrown. When doing the same thing in the live application it does not appear to be an issue.

Seems the call to getUI() is returning null in the case where we are navigating away from a page with a disabled Grid contained by an AbstractCompositeField.

image

Stacktrace is

Caused by: java.lang.IllegalStateException: Connector can only be initialized for an attached Grid
    at com.vaadin.flow.component.grid.Grid.lambda$initConnector$2(Grid.java:1388)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at com.vaadin.flow.component.grid.Grid.initConnector(Grid.java:1388)
    at com.vaadin.flow.component.grid.Grid$GridArrayUpdaterImpl.initialize(Grid.java:1141)
    at com.vaadin.flow.data.provider.DataCommunicator.lambda$requestFlush$7258256f$1(DataCommunicator.java:1054)
    at com.vaadin.flow.internal.StateTree.lambda$runExecutionsBeforeClientResponse$2(StateTree.java:392)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at com.vaadin.flow.internal.StateTree.runExecutionsBeforeClientResponse(StateTree.java:389)
    at com.github.mvysny.kaributesting.v10.MockVaadin.clientRoundtrip(MockVaadin.kt:266)
    at com.github.mvysny.kaributesting.v10.TestingLifecycleHook$DefaultImpls.awaitBeforeLookup(TestingLifecycleHook.kt:38)
    at com.github.mvysny.kaributesting.v10.TestingLifecycleHook$Companion$default$1.awaitBeforeLookup(TestingLifecycleHook.kt:105)
    at com.github.mvysny.kaributesting.v10.LocatorKt.find(Locator.kt:190)
    at com.github.mvysny.kaributesting.v10.LocatorKt._find(Locator.kt:143)
    at com.github.mvysny.kaributesting.v10.LocatorKt._get(Locator.kt:111)
    at com.github.mvysny.kaributesting.v10.LocatorKt._get(Locator.kt:134)
mvysny commented 2 years ago

Hi, thank you for letting me know. The test case is a bit complex; could you please post a simple test code which reproduces the issue?

mvysny commented 2 years ago

Closing as inactive, please feel free to reopen if a sample project is available