@@ -3,7 +3,7 @@ import { createNodeWebSocket, type NodeWebSocket } from "@hono/node-ws";
33import { bundleRequire } from "bundle-require" ;
44import invariant from "invariant" ;
55import { describe } from "vitest" ;
6- import type { Transport } from "@/client/mod" ;
6+ import type { Encoding , Transport } from "@/client/mod" ;
77import { configureInspectorAccessToken } from "@/inspector/utils" ;
88import { createManagerRouter } from "@/manager/router" ;
99import type { DriverConfig , Registry , RunConfig } from "@/mod" ;
@@ -55,6 +55,8 @@ export interface DriverTestConfig {
5555
5656 transport ?: Transport ;
5757
58+ encoding ?: Encoding ;
59+
5860 clientType : ClientType ;
5961
6062 cleanup ?: ( ) => Promise < void > ;
@@ -78,68 +80,81 @@ export interface DriverDeployOutput {
7880
7981/** Runs all Vitest tests against the provided drivers. */
8082export function runDriverTests (
81- driverTestConfigPartial : Omit < DriverTestConfig , "clientType" | "transport" > ,
83+ driverTestConfigPartial : Omit <
84+ DriverTestConfig ,
85+ "clientType" | "transport" | "encoding"
86+ > ,
8287) {
8388 const clientTypes : ClientType [ ] = driverTestConfigPartial . skip ?. inline
8489 ? [ "http" ]
8590 : [ "http" , "inline" ] ;
8691 for ( const clientType of clientTypes ) {
87- const driverTestConfig : DriverTestConfig = {
88- ...driverTestConfigPartial ,
89- clientType,
90- } ;
91-
9292 describe ( `client type (${ clientType } )` , ( ) => {
93- runActorDriverTests ( driverTestConfig ) ;
94- runManagerDriverTests ( driverTestConfig ) ;
93+ const encodings : Encoding [ ] = [ "bare" , "cbor" , "json" ] ;
9594
96- const transports : Transport [ ] = driverTestConfig . skip ?. sse
97- ? [ "websocket" ]
98- : [ "websocket" , "sse" ] ;
99- for ( const transport of transports ) {
100- describe ( `transport (${ transport } )` , ( ) => {
101- runActorConnTests ( {
102- ...driverTestConfig ,
103- transport,
104- } ) ;
95+ for ( const encoding of encodings ) {
96+ describe ( `encoding (${ encoding } )` , ( ) => {
97+ const driverTestConfig : DriverTestConfig = {
98+ ...driverTestConfigPartial ,
99+ clientType,
100+ encoding,
101+ } ;
105102
106- runActorConnStateTests ( { ...driverTestConfig , transport } ) ;
103+ runActorDriverTests ( driverTestConfig ) ;
104+ runManagerDriverTests ( driverTestConfig ) ;
107105
108- runActorReconnectTests ( { ...driverTestConfig , transport } ) ;
106+ const transports : Transport [ ] = driverTestConfig . skip ?. sse
107+ ? [ "websocket" ]
108+ : [ "websocket" , "sse" ] ;
109+ for ( const transport of transports ) {
110+ describe ( `transport (${ transport } )` , ( ) => {
111+ runActorConnTests ( {
112+ ...driverTestConfig ,
113+ transport,
114+ } ) ;
109115
110- runRequestAccessTests ( { ...driverTestConfig , transport } ) ;
116+ runActorConnStateTests ( { ...driverTestConfig , transport } ) ;
111117
112- runActorDriverTestsWithTransport ( { ...driverTestConfig , transport } ) ;
113- } ) ;
114- }
118+ runActorReconnectTests ( { ...driverTestConfig , transport } ) ;
115119
116- runActorHandleTests ( driverTestConfig ) ;
120+ runRequestAccessTests ( { ... driverTestConfig , transport } ) ;
117121
118- runActionFeaturesTests ( driverTestConfig ) ;
122+ runActorDriverTestsWithTransport ( {
123+ ...driverTestConfig ,
124+ transport,
125+ } ) ;
126+ } ) ;
127+ }
119128
120- runActorVarsTests ( driverTestConfig ) ;
129+ runActorHandleTests ( driverTestConfig ) ;
121130
122- runActorMetadataTests ( driverTestConfig ) ;
131+ runActionFeaturesTests ( driverTestConfig ) ;
123132
124- runActorOnStateChangeTests ( driverTestConfig ) ;
133+ runActorVarsTests ( driverTestConfig ) ;
125134
126- runActorErrorHandlingTests ( driverTestConfig ) ;
135+ runActorMetadataTests ( driverTestConfig ) ;
127136
128- runActorInlineClientTests ( driverTestConfig ) ;
137+ runActorOnStateChangeTests ( driverTestConfig ) ;
129138
130- runRawHttpTests ( driverTestConfig ) ;
139+ runActorErrorHandlingTests ( driverTestConfig ) ;
131140
132- runRawHttpRequestPropertiesTests ( driverTestConfig ) ;
141+ runActorInlineClientTests ( driverTestConfig ) ;
133142
134- runRawWebSocketTests ( driverTestConfig ) ;
143+ runRawHttpTests ( driverTestConfig ) ;
135144
136- // TODO: re-expose this once we can have actor queries on the gateway
137- // runRawHttpDirectRegistryTests(driverTestConfig);
145+ runRawHttpRequestPropertiesTests ( driverTestConfig ) ;
138146
139- // TODO: re-expose this once we can have actor queries on the gateway
140- // runRawWebSocketDirectRegistryTests(driverTestConfig);
147+ runRawWebSocketTests ( driverTestConfig ) ;
141148
142- runActorInspectorTests ( driverTestConfig ) ;
149+ // TODO: re-expose this once we can have actor queries on the gateway
150+ // runRawHttpDirectRegistryTests(driverTestConfig);
151+
152+ // TODO: re-expose this once we can have actor queries on the gateway
153+ // runRawWebSocketDirectRegistryTests(driverTestConfig);
154+
155+ runActorInspectorTests ( driverTestConfig ) ;
156+ } ) ;
157+ }
143158 } ) ;
144159 }
145160}
0 commit comments