diff --git a/tests/Feature/AdminDashboardMerchantRevenueRank7dShouldLinkToPlatformOrdersListByMerchantTest.php b/tests/Feature/AdminDashboardMerchantRevenueRank7dShouldLinkToPlatformOrdersListByMerchantTest.php new file mode 100644 index 0000000..42d89d6 --- /dev/null +++ b/tests/Feature/AdminDashboardMerchantRevenueRank7dShouldLinkToPlatformOrdersListByMerchantTest.php @@ -0,0 +1,58 @@ +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); + } +}