32 lines
1.7 KiB
PHP
32 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
|
|
test('visual consultation is accessible without authentication', function (string $path, string $component) {
|
|
$this->get($path)->assertOk()->assertInertia(fn (Assert $page) => $page
|
|
->component($component)
|
|
->where('auth.user', null)
|
|
->missing('suppliers')->missing('requisitions')->missing('documents')
|
|
->missing('adoptions')->missing('policies')->missing('recommendations'));
|
|
$this->assertGuest();
|
|
})->with([['/consulta', 'preview/index'], ['/proposta/qualificacao', 'preview/qualification'], ['/proposta/admissao', 'preview/admission'], ['/proposta/recomendacao', 'preview/recommendation']]);
|
|
|
|
test('preview does not expose authenticated account data or log it out', function () {
|
|
$user = User::factory()->create();
|
|
$this->actingAs($user)->get('/consulta')->assertOk()->assertInertia(fn (Assert $page) => $page->where('auth.user', null));
|
|
$this->get('/proposta/recomendacao')->assertOk()->assertInertia(fn (Assert $page) => $page->where('auth.user', null)->missing('recommendations')->missing('policies')->missing('documents'));
|
|
$this->assertAuthenticatedAs($user);
|
|
});
|
|
|
|
test('consultation creates no business access or mutation endpoint', function () {
|
|
$this->get('/consulta')->assertOk();
|
|
foreach (['/dashboard', '/fornecedores', '/cotacoes', '/conflitos'] as $path) {
|
|
$this->get($path)->assertRedirect('/login');
|
|
}
|
|
$this->post('/fornecedores', ['name' => 'Tentativa pública'])->assertRedirect('/login');
|
|
$this->post('/consulta', [])->assertStatus(405);
|
|
$this->post('/proposta/recomendacao', [])->assertStatus(405);
|
|
expect(User::query()->count())->toBe(0);
|
|
});
|