@@ -9,11 +9,14 @@ class HttpGatewayTest extends TestCase
99{
1010 protected HttpGateway $ gateway ;
1111
12+ protected string $ renderUrl ;
13+
1214 protected function setUp (): void
1315 {
1416 parent ::setUp ();
1517
1618 $ this ->gateway = new HttpGateway ;
19+ $ this ->renderUrl = $ this ->gateway ->getUrl ('render ' );
1720
1821 Http::preventStrayRequests ();
1922 }
@@ -46,7 +49,7 @@ public function test_it_uses_the_configured_http_url_when_the_bundle_file_is_det
4649 ]);
4750
4851 Http::fake ([
49- $ this ->gateway -> getHttpUrl () => Http::response (json_encode ([
52+ $ this ->renderUrl => Http::response (json_encode ([
5053 'head ' => ['<title>SSR Test</title> ' , '<style></style> ' ],
5154 'body ' => '<div id="app">SSR Response</div> ' ,
5255 ])),
@@ -69,7 +72,7 @@ public function test_it_uses_the_configured_http_url__when_bundle_file_detection
6972 ]);
7073
7174 Http::fake ([
72- $ this ->gateway -> getHttpUrl () => Http::response (json_encode ([
75+ $ this ->renderUrl => Http::response (json_encode ([
7376 'head ' => ['<title>SSR Test</title> ' , '<style></style> ' ],
7477 'body ' => '<div id="app">SSR Response</div> ' ,
7578 ])),
@@ -91,7 +94,7 @@ public function test_it_returns_null_when_the_http_request_fails()
9194 ]);
9295
9396 Http::fake ([
94- $ this ->gateway -> getHttpUrl () => Http::response (null , 500 ),
97+ $ this ->renderUrl => Http::response (null , 500 ),
9598 ]);
9699
97100 $ this ->assertNull ($ this ->gateway ->dispatch (['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
@@ -105,9 +108,21 @@ public function test_it_returns_null_when_invalid_json_is_returned()
105108 ]);
106109
107110 Http::fake ([
108- $ this ->gateway -> getHttpUrl () => Http::response ('invalid json ' ),
111+ $ this ->renderUrl => Http::response ('invalid json ' ),
109112 ]);
110113
111114 $ this ->assertNull ($ this ->gateway ->dispatch (['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
112115 }
116+
117+ public function test_health_check_the_ssr_server ()
118+ {
119+ Http::fake ([
120+ $ this ->gateway ->getUrl ('health ' ) => Http::sequence ()
121+ ->push (status: 200 )
122+ ->push (status: 500 ),
123+ ]);
124+
125+ $ this ->assertTrue ($ this ->gateway ->isHealthy ());
126+ $ this ->assertFalse ($ this ->gateway ->isHealthy ());
127+ }
113128}
0 commit comments