From 933aabae3bf4a81d4125dcc077aea7f173bbae3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 13:58:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98=E8=B6=8B=E5=8A=BF=E8=BF=B7=E4=BD=A0=E5=9B=BE=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=97=A5=E6=9C=9F=E9=93=BE=E6=8E=A5=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sShouldHaveLinkWhenDateLinkPresentTest.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Feature/AdminDashboardPlatformOrderTrend7dMiniChartBarsShouldHaveLinkWhenDateLinkPresentTest.php diff --git a/tests/Feature/AdminDashboardPlatformOrderTrend7dMiniChartBarsShouldHaveLinkWhenDateLinkPresentTest.php b/tests/Feature/AdminDashboardPlatformOrderTrend7dMiniChartBarsShouldHaveLinkWhenDateLinkPresentTest.php new file mode 100644 index 0000000..0066ac7 --- /dev/null +++ b/tests/Feature/AdminDashboardPlatformOrderTrend7dMiniChartBarsShouldHaveLinkWhenDateLinkPresentTest.php @@ -0,0 +1,71 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_trend_mini_chart_should_reuse_table_date_links(): void + { + Cache::flush(); + + $this->loginAsPlatformAdmin(); + + $merchantId = (int) Merchant::query()->value('id'); + $platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id'); + + $d3 = now()->subDays(3)->format('Y-m-d'); + + $po = PlatformOrder::query()->create([ + 'merchant_id' => $merchantId, + 'plan_id' => null, + 'site_subscription_id' => null, + 'created_by_admin_id' => $platformAdminId ?: null, + 'order_no' => 'PO_TREND_CHART_LINK_D3', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'paid', + 'payable_amount' => 10, + 'paid_amount' => 10, + ]); + + PlatformOrder::query()->where('id', $po->id)->update([ + 'created_at' => now()->subDays(3)->startOfDay(), + 'updated_at' => now()->subDays(3)->startOfDay(), + ]); + + Cache::flush(); + + $res = $this->get('/admin'); + $res->assertOk(); + + // 迷你图表的链接不是 SSR 输出(由 JS 渐进增强渲染), + // 但它依赖下方表格中的日期链接口径,因此这里至少做“表格日期链接存在”护栏。 + // 若未来有人把表格链接删掉/改成非 ,迷你图表将失去跳转能力。 + $res->assertSee('data-role="platform-order-trend-7d"', false); + $res->assertSee('data-role="platform-order-trend-7d-chart"', false); + + // 日期列应为可点击链接 + $res->assertSee('>' . $d3 . '', false); + $res->assertSee('created_from=' . $d3, false); + $res->assertSee('created_to=' . $d3, false); + } +}