Skip to content

Commit

Permalink
Merge pull request #1884 from michalvavrik/feature/fix-grpc-dev-ui-te…
Browse files Browse the repository at this point in the history
…st-on-win

Fix gRPC DEV UI tests on Windows as Vaadin grid is formed differently and we cannot see shadow DOM content
  • Loading branch information
jedla97 authored Jul 10, 2024
2 parents e56f59d + 7c31e59 commit 864e152
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static io.quarkus.test.utils.AwaitilityUtils.untilAsserted;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -34,14 +35,19 @@ public class DevModeGrpcIntegrationReactiveIT {

/**
* Expect streaming service and hello service definition from 'helloworld.proto'
* as well as full generated service names and communication method type (UNARY, CLIENT_STREAMING, ...).
* and communication method type (UNARY, CLIENT_STREAMING, ...).
*/
private static final String[] GRPC_SERVICE_VIEW_EXPECTED_CONTENT = {
"UNARY", "helloworld.Greeter", "io.quarkus.ts.http.advanced.reactive.GrpcService", "SayHello", "SERVER_STREAMING",
"io.quarkus.ts.http.advanced.reactive.GrpcStreamingService", "BIDI_STREAMING", "CLIENT_STREAMING", "ServerStream",
"UNARY", "helloworld.Greeter", "SayHello", "SERVER_STREAMING",
"BIDI_STREAMING", "CLIENT_STREAMING", "ServerStream",
"BidirectionalStream", "ClientStream"
};

private static final String[] GRPC_SERVICE_IMPLEMENTATION_CLASSES = {
"io.quarkus.ts.http.advanced.reactive.GrpcService",
"io.quarkus.ts.http.advanced.reactive.GrpcStreamingService"
};

@DevModeQuarkusApplication(grpc = true)
static final GrpcService app = (GrpcService) new GrpcService() {
@Override
Expand Down Expand Up @@ -79,6 +85,15 @@ public void testGrpcDevUIServicesView() {
for (String text : GRPC_SERVICE_VIEW_EXPECTED_CONTENT) {
assertTrue(grpcSvcView.contains(text), "DevUI gRPC services view is incomplete: " + grpcSvcView);
}
// search for gRPC service implementation classes differently as they are in a shadow root and sometimes
// (like on Windows) they cannot be accessed
for (String implClass : GRPC_SERVICE_IMPLEMENTATION_CLASSES) {
var locator = page.getByText(implClass);
assertNotNull(locator, "DevUI gRPC services view is missing implementation class:" + implClass);
assertNotNull(locator.textContent(), "DevUI gRPC services view is missing implementation class:" + implClass);
assertTrue(locator.textContent().contains(implClass),
"DevUI gRPC services view is missing implementation class:" + implClass);
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static io.quarkus.test.utils.AwaitilityUtils.untilAsserted;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.function.Consumer;
Expand Down Expand Up @@ -32,14 +33,17 @@ public class DevModeGrpcIntegrationIT {
private static final String NAME = "QE";

/**
* Expect streaming service and hello service definition from 'helloworld.proto'
* as well as full generated service names and communication method type (UNARY, CLIENT_STREAMING, ...).
* Expect streaming service and hello service definition from 'helloworld.proto' and communication
* method type (UNARY, CLIENT_STREAMING, ...).
*/
private static final String[] GRPC_SERVICE_VIEW_EXPECTED_CONTENT = {
"helloworld.InterceptedMessage", "io.quarkus.ts.http.advanced.GrpcInterceptorsService", "UNARY",
"helloworld.Greeter", "io.quarkus.ts.http.advanced.GrpcService", "SayHello", "SERVER_STREAMING",
"io.quarkus.ts.http.advanced.GrpcStreamingService", "BIDI_STREAMING", "CLIENT_STREAMING", "ServerStream",
"BidirectionalStream", "ClientStream"
"helloworld.InterceptedMessage", "UNARY", "helloworld.Greeter", "SayHello", "SERVER_STREAMING",
"BIDI_STREAMING", "CLIENT_STREAMING", "ServerStream", "BidirectionalStream", "ClientStream"
};

private static final String[] GRPC_SERVICE_IMPLEMENTATION_CLASSES = {
"io.quarkus.ts.http.advanced.GrpcInterceptorsService", "io.quarkus.ts.http.advanced.GrpcService",
"io.quarkus.ts.http.advanced.GrpcStreamingService"
};

@DevModeQuarkusApplication(grpc = true)
Expand Down Expand Up @@ -75,9 +79,18 @@ public void testGrpcDevUISocket() {
@Test
public void testGrpcDevUIServicesView() {
assertOnGrpcServicePage(page -> {
var grpcSvcView = page.waitForSelector("#page > qwc-grpc-services > vaadin-grid").innerText();
var grpcSvcViewGrid = page.waitForSelector("#page > qwc-grpc-services > vaadin-grid").innerText();
for (String text : GRPC_SERVICE_VIEW_EXPECTED_CONTENT) {
assertTrue(grpcSvcView.contains(text), "DevUI gRPC services view is incomplete: " + grpcSvcView);
assertTrue(grpcSvcViewGrid.contains(text), "DevUI gRPC services view is incomplete: " + grpcSvcViewGrid);
}
// search for gRPC service implementation classes differently as they are in a shadow root and sometimes
// (like on Windows) they cannot be accessed
for (String implClass : GRPC_SERVICE_IMPLEMENTATION_CLASSES) {
var locator = page.getByText(implClass);
assertNotNull(locator, "DevUI gRPC services view is missing implementation class:" + implClass);
assertNotNull(locator.textContent(), "DevUI gRPC services view is missing implementation class:" + implClass);
assertTrue(locator.textContent().contains(implClass),
"DevUI gRPC services view is missing implementation class:" + implClass);
}
});
}
Expand Down

0 comments on commit 864e152

Please sign in to comment.