Subscriptions: add renewal CTA on expiry governance view

This commit is contained in:
萝卜
2026-03-15 01:03:50 +00:00
parent f3f89e9492
commit 09cb6e9c6d
2 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminSiteSubscriptionIndexExpiryGovernanceRenewalCtaTest 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_expiry_view_should_show_create_renewal_order_cta_with_back_to_self(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/site-subscriptions?expiry=expiring_7d&merchant_id=2&plan_id=3');
$res->assertOk();
$res->assertSee('创建续费订单(当前集合)');
// CTA 应带上当前筛选 merchant_id/plan_id并且 back 回到当前列表selfWithoutBack
$res->assertSee('href="/admin/platform-orders/create?order_type=renewal&merchant_id=2&plan_id=3&back=%2Fadmin%2Fsite-subscriptions%3Fexpiry%3Dexpiring_7d%26merchant_id%3D2%26plan_id%3D3"', false);
// 链接不应出现 &amp;(只检查该 CTA 的 href 文本中不含 &amp;
$html = (string) $res->getContent();
preg_match('/href="([^"]+)"[^>]*>创建续费订单(当前集合)<\/a>/', $html, $m);
$ctaHref = (string) ($m[1] ?? '');
$this->assertNotSame('', $ctaHref);
$this->assertStringNotContainsString('&amp;', $ctaHref);
}
public function test_non_expiry_view_should_not_show_renewal_cta(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/site-subscriptions?status=activated');
$res->assertOk();
$res->assertDontSee('创建续费订单(当前集合)');
}
}