diff --git a/tests/Feature/EInvoice/PeppolApiTest.php b/tests/Feature/EInvoice/PeppolApiTest.php new file mode 100644 index 0000000000..84832e70de --- /dev/null +++ b/tests/Feature/EInvoice/PeppolApiTest.php @@ -0,0 +1,97 @@ +markTestSkipped('Storecove API key not set'); + } + + $this->makeTestData(); + + $this->withoutMiddleware( + ThrottleRequests::class, + ); + } + + public function testGeneratingToken() + { + config(['ninja.environment' => 'selfhost']); + + /** + * @var \App\Models\CompanyUser $user + */ + $user = $this->user; + + $current = $user->account->e_invoicing_token; + + $this->assertNull($current); + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->post('/api/v1/einvoice/token/update') + ->assertSuccessful() + ; + + $user->refresh(); + + $this->assertNotEquals($current, $user->account->e_invoicing_token); + } + + public function testHealthCheck() + { + config(['ninja.environment' => 'selfhost']); + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->get('/api/v1/einvoice/health_check') + ->assertStatus(status: 422) + ; + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->post('/api/v1/einvoice/token/update') + ->assertSuccessful() + ; + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->get('/api/v1/einvoice/health_check') + ->assertSuccessful() + ; + } +}