| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
-
- namespace Tests\Feature;
-
- use App\Http\Controllers\LegalController;
- use Inertia\Testing\AssertableInertia as Assert;
- use Tests\TestCase;
-
- class LegalPagesTest extends TestCase
- {
- public function test_visitors_can_read_the_privacy_policy()
- {
- config([
- 'legal.operator' => 'Mirfalah Sdn Bhd',
- 'legal.registration' => '202601234567',
- 'legal.email' => 'privacy@example.com',
- ]);
-
- $this->get(route('privacy'))
- ->assertOk()
- ->assertInertia(fn (Assert $page) => $page
- ->component('legal/privacy')
- ->where('operator', 'Mirfalah Sdn Bhd')
- ->where('registration', '202601234567')
- ->where('email', 'privacy@example.com')
- ->where('updated', '22 November 2026')
- ->has('aiCompanies'));
- }
-
- public function test_visitors_can_read_the_terms()
- {
- $this->get(route('terms'))
- ->assertOk()
- ->assertInertia(fn (Assert $page) => $page
- ->component('legal/terms')
- ->where('trialDays', 14));
- }
-
- public function test_the_pages_name_the_ai_companies_the_tasks_use_now()
- {
- config([
- 'ai.tasks.generate.provider' => 'claude',
- 'ai.tasks.edit.provider' => 'deepseek',
- ]);
-
- $this->assertSame([
- ['name' => 'Anthropic', 'country' => 'the United States'],
- ['name' => 'DeepSeek', 'country' => 'China'],
- ], LegalController::aiCompanies());
-
- // After switching every task to one provider, only that company is named.
- config(['ai.tasks.edit.provider' => 'claude']);
-
- $this->assertSame([
- ['name' => 'Anthropic', 'country' => 'the United States'],
- ], LegalController::aiCompanies());
- }
-
- public function test_every_real_ai_provider_has_a_company_for_the_legal_pages()
- {
- $providers = array_diff(array_keys(config('ai.providers')), ['fake']);
-
- foreach ($providers as $provider) {
- $this->assertNotNull(
- config("legal.ai_companies.{$provider}"),
- "Add the company behind the \"{$provider}\" AI provider to config/legal.php, so the privacy policy names it.",
- );
- }
- }
-
- public function test_the_sign_up_page_works_with_its_links_to_the_terms()
- {
- $this->get(route('register'))->assertOk();
- }
- }
|