@@ -9,11 +9,14 @@ class HttpGatewayTest extends TestCase
9
9
{
10
10
protected HttpGateway $ gateway ;
11
11
12
+ protected string $ renderUrl ;
13
+
12
14
protected function setUp (): void
13
15
{
14
16
parent ::setUp ();
15
17
16
18
$ this ->gateway = new HttpGateway ;
19
+ $ this ->renderUrl = $ this ->gateway ->getUrl ('render ' );
17
20
18
21
Http::preventStrayRequests ();
19
22
}
@@ -46,7 +49,7 @@ public function test_it_uses_the_configured_http_url_when_the_bundle_file_is_det
46
49
]);
47
50
48
51
Http::fake ([
49
- $ this ->gateway -> getHttpUrl () => Http::response (json_encode ([
52
+ $ this ->renderUrl => Http::response (json_encode ([
50
53
'head ' => ['<title>SSR Test</title> ' , '<style></style> ' ],
51
54
'body ' => '<div id="app">SSR Response</div> ' ,
52
55
])),
@@ -69,7 +72,7 @@ public function test_it_uses_the_configured_http_url__when_bundle_file_detection
69
72
]);
70
73
71
74
Http::fake ([
72
- $ this ->gateway -> getHttpUrl () => Http::response (json_encode ([
75
+ $ this ->renderUrl => Http::response (json_encode ([
73
76
'head ' => ['<title>SSR Test</title> ' , '<style></style> ' ],
74
77
'body ' => '<div id="app">SSR Response</div> ' ,
75
78
])),
@@ -91,7 +94,7 @@ public function test_it_returns_null_when_the_http_request_fails()
91
94
]);
92
95
93
96
Http::fake ([
94
- $ this ->gateway -> getHttpUrl () => Http::response (null , 500 ),
97
+ $ this ->renderUrl => Http::response (null , 500 ),
95
98
]);
96
99
97
100
$ 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()
105
108
]);
106
109
107
110
Http::fake ([
108
- $ this ->gateway -> getHttpUrl () => Http::response ('invalid json ' ),
111
+ $ this ->renderUrl => Http::response ('invalid json ' ),
109
112
]);
110
113
111
114
$ this ->assertNull ($ this ->gateway ->dispatch (['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
112
115
}
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
+ }
113
128
}
0 commit comments