@@ -8,6 +8,7 @@ import * as Fiber from "effect/Fiber";
88import * as Option from "effect/Option" ;
99import * as Scope from "effect/Scope" ;
1010import * as Stream from "effect/Stream" ;
11+ import * as TestClock from "effect/testing/TestClock" ;
1112import * as AcpErrors from "effect-acp/errors" ;
1213import type * as AcpSchema from "effect-acp/compat" ;
1314
@@ -62,6 +63,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
6263 const authenticated = yield * Deferred . make < void , AcpErrors . AcpError > ( ) ;
6364 const discovered = yield * Deferred . make < void , AcpErrors . AcpError > ( ) ;
6465 const closed = yield * Deferred . make < void > ( ) ;
66+ const authenticateCalled = yield * Deferred . make < void > ( ) ;
6567 const events : string [ ] = [ ] ;
6668 let receiveAuthorizationUrl :
6769 | ( ( url : string ) => Effect . Effect < void , AcpErrors . AcpError > )
@@ -92,6 +94,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
9294 start : ( ) =>
9395 Effect . gen ( function * ( ) {
9496 events . push ( "authenticate" ) ;
97+ yield * Deferred . succeed ( authenticateCalled , undefined ) ;
9598 if ( options . interactive !== false && input . onAuthorizationUrl ) {
9699 for ( const url of options . authorizationUrls ?? [ authorizationUrl ] ) {
97100 yield * input . onAuthorizationUrl ( url ) ;
@@ -129,6 +132,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
129132 authenticated,
130133 discovered,
131134 closed,
135+ authenticateCalled,
132136 events,
133137 catalog : ( ) => catalog ,
134138 forwarded : ( ) => forwarded ,
@@ -254,6 +258,38 @@ it.layer(NodeServices.layer)("AntigravityAuth", (it) => {
254258 } ) ,
255259 ) ;
256260
261+ it . effect ( "tells the user when the agent cannot reach Google" , ( ) =>
262+ Effect . gen ( function * ( ) {
263+ const harness = yield * makeHarness ( { interactive : false } ) ;
264+ yield * harness . auth . controller . start ( owner ) ;
265+ yield * Deferred . await ( harness . authenticateCalled ) ;
266+
267+ yield * TestClock . adjust ( "30 seconds" ) ;
268+ const stalled = yield * harness . auth . controller . subscribe ( owner ) . pipe (
269+ Stream . filter ( ( state ) => state . message ?. includes ( "Broken IPv6" ) === true ) ,
270+ Stream . runHead ,
271+ Effect . map ( Option . getOrThrow ) ,
272+ ) ;
273+ assert . equal ( stalled . phase , "starting" ) ;
274+
275+ yield * TestClock . adjust ( "270 seconds" ) ;
276+ const failed = yield * phase ( harness . auth , "failed" ) ;
277+ assert . include ( failed . message ?? "" , "could not reach Google" ) ;
278+ } ) ,
279+ ) ;
280+
281+ it . effect ( "keeps the expired message once the Google link was shown" , ( ) =>
282+ Effect . gen ( function * ( ) {
283+ const harness = yield * makeHarness ( ) ;
284+ yield * harness . auth . controller . start ( owner ) ;
285+ yield * phase ( harness . auth , "waiting" ) ;
286+
287+ yield * TestClock . adjust ( "300 seconds" ) ;
288+ const failed = yield * phase ( harness . auth , "failed" ) ;
289+ assert . equal ( failed . message , "Google sign-in expired. Start sign-in again." ) ;
290+ } ) ,
291+ ) ;
292+
257293 it . effect ( "accepts direct local or cached completion without a callback RPC" , ( ) =>
258294 Effect . gen ( function * ( ) {
259295 const harness = yield * makeHarness ( { interactive : false } ) ;
0 commit comments