feat(admin-js): auto open receipt details for payment/refund hashes
This commit is contained in:
@@ -55,8 +55,13 @@
|
||||
}
|
||||
|
||||
var h = String(window.location.hash || '');
|
||||
if (h === '#add-payment-receipt') {
|
||||
var d = qs('details#add-payment-receipt');
|
||||
var map = {
|
||||
'#add-payment-receipt': 'details#add-payment-receipt',
|
||||
'#refund-receipts': 'details#add-refund-receipt',
|
||||
};
|
||||
|
||||
if (map[h]) {
|
||||
var d = qs(map[h]);
|
||||
if (d) {
|
||||
d.open = true;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ class AdminJsShouldAutoOpenAddPaymentReceiptDetailsWhenHashPresentTest extends T
|
||||
$js = (string) file_get_contents(public_path('js/admin.js'));
|
||||
|
||||
// 护栏:当 hash 为 #add-payment-receipt 时,应自动展开 details#add-payment-receipt。
|
||||
$this->assertStringContainsString("h === '#add-payment-receipt'", $js);
|
||||
$this->assertStringContainsString("qs('details#add-payment-receipt')", $js);
|
||||
$this->assertStringContainsString("'#add-payment-receipt': 'details#add-payment-receipt'", $js);
|
||||
$this->assertStringContainsString('if (map[h])', $js);
|
||||
$this->assertStringContainsString('d.open = true', $js);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminJsShouldAutoOpenRefundReceiptDetailsWhenHashPresentTest extends TestCase
|
||||
{
|
||||
public function test_admin_js_should_auto_open_refund_receipt_details_when_hash_present(): void
|
||||
{
|
||||
$js = (string) file_get_contents(public_path('js/admin.js'));
|
||||
|
||||
// 护栏:当 hash 为 #refund-receipts 时,应自动展开 details#add-refund-receipt(追加退款记录面板)。
|
||||
$this->assertStringContainsString("'#refund-receipts': 'details#add-refund-receipt'", $js);
|
||||
$this->assertStringContainsString('if (map[h])', $js);
|
||||
$this->assertStringContainsString('d.open = true', $js);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user