test(admin-dashboard): merchant revenue rank links to merchant order list

This commit is contained in:
萝卜
2026-03-16 17:24:12 +08:00
parent ce7f957d70
commit ed739eb97f

View File

@@ -0,0 +1,58 @@
<?php
namespace Tests\Feature;
use App\Models\Admin;
use App\Models\Merchant;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminDashboardMerchantRevenueRank7dShouldLinkToPlatformOrdersListByMerchantTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_dashboard_merchant_revenue_rank_7d_should_link_to_platform_orders_list_by_merchant(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id');
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => null,
'site_subscription_id' => null,
'created_by_admin_id' => $platformAdminId ?: null,
'order_no' => 'PO_DASH_RANK_LINK_0001',
'order_type' => 'new_purchase',
'status' => 'pending',
'payment_status' => 'paid',
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now(),
'meta' => [],
]);
$res = $this->get('/admin');
$res->assertOk();
$res->assertSee($merchant->name, false);
// 断言 Top5 站点链接能带 merchant_id 与 created_from/to近7天
$res->assertSee('merchant_id=' . (int) $merchant->id, false);
$res->assertSee('created_from=', false);
$res->assertSee('created_to=', false);
$res->assertSee('/admin/platform-orders?', false);
}
}