refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,75 @@
<?php
namespace Tests\Api\Settings;
use Tests\ApiTestCase;
use App\Models\Instance\AuditLog;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiAuditLogControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureAuditLog = [
'id',
'object',
'author' => [
'name',
],
'action',
'objects',
'audited_at',
'created_at',
'updated_at',
];
/** @test */
public function it_gets_a_list_of_audit_logs()
{
$user = $this->signin();
factory(AuditLog::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/logs');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonStructureAuditLog],
]);
$this->assertCount(
10,
$response->decodeResponseJson()['data']
);
$response->assertJsonFragment([
'total' => 10,
'current_page' => 1,
]);
}
/** @test */
public function it_is_possible_to_get_audit_logs_and_limit_query_and_paginate()
{
$user = $this->signin();
factory(AuditLog::class, 10)->create([
'account_id' => $user->account_id,
]);
$response = $this->json('GET', '/api/logs?limit=1&page=2');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonStructureAuditLog],
]);
$response->assertJsonFragment([
'total' => 10,
'per_page' => 1,
'current_page' => 2,
]);
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Tests\Api\Settings;
use Tests\ApiTestCase;
use App\Models\Settings\Term;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiComplianceControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureCompliance = [
'id',
'object',
'term_version',
'term_content',
'privacy_version',
'privacy_content',
'created_at',
'updated_at',
];
/** @test */
public function it_gets_a_list_of_terms()
{
$term = factory(Term::class, 10)->create([
'term_version' => rand(1, 100),
'term_content' => 'dummy data',
'privacy_version' => rand(1, 100),
'privacy_content' => 'dummy data',
]);
$response = $this->json('GET', '/api/compliance/');
$response->assertStatus(200);
$this->assertCount(
Term::get()->count(),
$response->decodeResponseJson()['data']
);
$response->assertJsonFragment([
'total' => Term::get()->count(),
'current_page' => 1,
]);
$response->assertJsonStructure([
'data' => [
'*' => $this->jsonStructureCompliance,
],
]);
}
/** @test */
public function it_gets_a_single_term()
{
$term = factory(Term::class)->create([
'term_version' => rand(1, 100),
'term_content' => 'dummy data',
'privacy_version' => rand(1, 100),
'privacy_content' => 'dummy data',
]);
$response = $this->json('GET', '/api/compliance/'.$term->id);
$response->assertStatus(200);
$response->assertJsonFragment([
'id' => $term->id,
'object' => 'term',
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureCompliance,
]);
}
/** @test */
public function it_doesnt_get_a_single_term()
{
$response = $this->json('GET', '/api/compliance/3');
$response->assertStatus(404);
$response->assertJsonFragment([
'message' => 'The resource has not been found',
'error_code' => 31,
]);
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Tests\Api\Settings;
use Tests\ApiTestCase;
use App\Models\Settings\Currency;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiCurrencyControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureCurrency = [
'id',
'object',
'iso',
'name',
'symbol',
];
/** @test */
public function it_gets_all_the_currencies()
{
// in theory the currencies table is seeded by the initial script
$response = $this->json('GET', '/api/currencies/');
$response->assertStatus(200);
$this->assertCount(
15,
$response->decodeResponseJson()['data']
);
$response->assertJsonFragment([
'total' => 153,
'current_page' => 1,
]);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonStructureCurrency],
]);
}
/** @test */
public function it_gets_one_currency()
{
$currency = factory(Currency::class)->create([]);
$response = $this->json('GET', '/api/currencies/'.$currency->id);
$response->assertStatus(200);
$response->assertJsonFragment([
'id' => $currency->id,
'object' => 'currency',
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureCurrency,
]);
}
/** @test */
public function it_gets_a_currency_that_is_invalid()
{
$response = $this->json('GET', '/api/currencies/0');
$this->expectNotFound($response);
}
}