Files
compras/tests/Feature/HomeNavigationTest.php
T
nala 47649bd46c
tests / ci (push) Canceled after 0s
commit compras1 3011
2026-11-30 09:33:36 +02:00

32 lines
2.0 KiB
PHP

<?php
use App\Models\User;
use Inertia\Testing\AssertableInertia as Assert;
test('application entry directs guests to login and keeps presentation without business data', function () {
$this->get('/')->assertRedirect('/login');
$this->get('/apresentacao')->assertOk()->assertInertia(fn (Assert $page) => $page->component('home')->where('auth.user', null)->missing('orders')->missing('receipts')->missing('balances'));
$this->assertGuest();
});
test('old presentation addresses lead to real authenticated functionality', function (string $path, string $destination) {
$this->get($path)->assertRedirect($destination);
$this->get($destination)->assertRedirect('/login');
})->with([['/consulta', '/dashboard'], ['/consulta/requisicoes', '/requisicoes'], ['/consulta/fornecedores', '/fornecedores'], ['/consulta/cotacoes', '/requisicoes'], ['/consulta/ordens', '/ordens'], ['/consulta/recepcoes', '/recepcoes'], ['/consulta/stock', '/stock'], ['/consulta/conflitos', '/conflitos'], ['/consulta/aparencia', '/settings/appearance'], ['/proposta/principal', '/dashboard'], ['/proposta/qualificacao', '/requisicoes'], ['/proposta/admissao', '/requisicoes'], ['/proposta/recomendacao', '/requisicoes'], ['/consulta?ecra=invoices', '/facturas']]);
test('home and public navigation preserve authenticated accounts without exposing identity', function () {
$user = User::factory()->create();
$this->actingAs($user)->get('/')->assertRedirect('/dashboard');
$this->get('/apresentacao')->assertInertia(fn (Assert $page) => $page->where('auth.user', null));
$this->get('/consulta/recepcoes')->assertRedirect('/recepcoes');
$this->assertAuthenticatedAs($user);
});
test('public receiving and stock demos provide no mutation endpoints', function () {
$this->post('/consulta/recepcoes', [])->assertStatus(405);
$this->post('/consulta/stock', [])->assertStatus(405);
$this->get('/consulta/desconhecido')->assertNotFound();
$this->get('/recepcoes')->assertRedirect('/login');
$this->get('/stock')->assertRedirect('/login');
});