Files
compras/tests/Feature/HomeNavigationTest.php

29 lines
1.8 KiB
PHP

<?php
use App\Models\User;
use Inertia\Testing\AssertableInertia as Assert;
test('home is a distinct public entry point without business data', function () {
$this->get('/')->assertOk()->assertInertia(fn (Assert $page) => $page->component('home')->where('auth.user', null)->missing('orders')->missing('receipts')->missing('balances'));
$this->assertGuest();
});
test('each demo area has a dedicated address without exposing operational data', function (string $path, string $screen) {
$this->get($path)->assertOk()->assertInertia(fn (Assert $page) => $page->component('preview/index')->where('initialScreen', $screen)->where('auth.user', null)->missing('orders')->missing('receipts')->missing('movements')->missing('balances'));
})->with([['/consulta', 'overview'], ['/consulta/requisicoes', 'requests'], ['/consulta/fornecedores', 'suppliers'], ['/consulta/cotacoes', 'quotes'], ['/consulta/ordens', 'orders'], ['/consulta/recepcoes', 'receipts'], ['/consulta/stock', 'stock'], ['/consulta/conflitos', 'conflicts'], ['/consulta/aparencia', 'appearance']]);
test('home and public navigation preserve authenticated accounts without exposing identity', function () {
$user = User::factory()->create();
$this->actingAs($user)->get('/')->assertInertia(fn (Assert $page) => $page->where('auth.user', null));
$this->get('/consulta/recepcoes')->assertInertia(fn (Assert $page) => $page->where('auth.user', null));
$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');
});