diff --git a/tests/e2e/Controllers/ScheduledNodeControllerTest.php b/tests/e2e/Controllers/ScheduledNodeControllerTest.php index 085a6d8..0a7c57e 100644 --- a/tests/e2e/Controllers/ScheduledNodeControllerTest.php +++ b/tests/e2e/Controllers/ScheduledNodeControllerTest.php @@ -225,4 +225,28 @@ class ScheduledNodeControllerTest extends TestCase $body = json_decode((string) $response->getBody(), true); $this->assertEquals([], $body); } + + public function test_returns_404_when_use_case_throws_domain_exception(): void + { + $unknownUser = new User( + id: 999, + email: new EmailAddress('ghost@test.com'), + passwordHash: '', + isAdmin: false, + ); + + $response = $this->controller->getScheduledNodes( + $this->makeRequest('2025-01-02', $unknownUser), + new Response(), + $this->getTodaysSchedule, + ); + + $this->assertEquals(404, $response->getStatusCode()); + $body = json_decode((string) $response->getBody(), true); + $this->assertArrayHasKey('error', $body); + $this->assertEquals( + 'User with id: 999 doesnt exist', + $body['error'] + ); + } }