CaiWuXiTong/tests/Feature/Business/NegativeAlertPagesTest.php
苏木 3eba7507cb feat: 调整负数预警导航与子页面
将供应商和快递负数预警统一放到应付款项下的负数预警入口,并移除供应商对账中的旧入口。
Co-authored-by: 苏木 <594326199@qq.com>
Co-committed-by: 苏木 <594326199@qq.com>
2026-10-28 11:26:20 +08:00

78 lines
2.6 KiB
PHP

<?php
namespace Tests\Feature\Business;
use App\Listeners\Menu\ShowInAdmin;
use App\Models\Auth\Permission;
use App\Utilities\BusinessNavigation;
use Tests\Feature\FeatureTestCase;
class NegativeAlertPagesTest extends FeatureTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail()
);
}
public function test_negative_alerts_is_a_payables_section_with_two_children(): void
{
$navigation = collect(BusinessNavigation::all())->keyBy('slug');
$alertSection = $navigation->get('negative-alerts');
$this->assertNotNull($alertSection);
$this->assertSame('负数预警', $alertSection['title']);
$this->assertSame(
['supplier-negative-alert', 'courier-negative-alert'],
array_column($alertSection['pages'], 'slug'),
);
$this->assertNotContains(
'supplier-negative-alert',
array_column($navigation->get('supplier-reconciliation')['pages'], 'slug'),
);
$grouped = ShowInAdmin::groupPayables(BusinessNavigation::all());
$payables = collect($grouped)->firstWhere('slug', 'payable-items');
$this->assertSame('negative-alerts', $payables['sections'][0]['slug']);
}
public function test_supplier_and_courier_negative_alert_pages_render_as_tabs(): void
{
$this->loginAs()
->get(route('business.pages.show', [
'section' => 'negative-alerts',
'page' => 'supplier-negative-alert',
]))
->assertOk()
->assertSeeText('供应商负数预警')
->assertSeeText('快递负数预警')
->assertSeeText('供应商负数判定口径待确认')
->assertSeeText('待接入');
$this->loginAs()
->get(route('business.pages.show', [
'section' => 'negative-alerts',
'page' => 'courier-negative-alert',
]))
->assertOk()
->assertSeeText('供应商负数预警')
->assertSeeText('快递负数预警')
->assertSeeText('快递负数判定口径待确认')
->assertSeeText('待接入');
}
public function test_supplier_negative_alert_route_no_longer_renders_under_supplier_reconciliation(): void
{
$this->withExceptionHandling()
->loginAs()
->get(route('business.pages.show', [
'section' => 'supplier-reconciliation',
'page' => 'supplier-negative-alert',
]))
->assertRedirect();
}
}