CaiWuXiTong/tests/Feature/Business/ZhongcaiReconciliationPlatformTest.php
2026-09-01 13:11:09 +08:00

87 lines
3.1 KiB
PHP

<?php
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use App\Models\StoreReceivables\StoreZhongcaiReconciliation;
use Tests\Feature\FeatureTestCase;
class ZhongcaiReconciliationPlatformTest extends FeatureTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail()
);
}
public function testReconciliationPageProvidesPlatformTabsForCurrentPageRows(): void
{
foreach ([
['platform' => '京东商城', 'order' => 'JD-TEST-001'],
['platform' => '抖音小店', 'order' => 'DY-TEST-001'],
['platform' => '天猫旗舰店', 'order' => 'TM-TEST-001'],
['platform' => '拼多多店铺', 'order' => 'PDD-TEST-001'],
['platform' => '淘宝店铺', 'order' => 'TB-TEST-001'],
['platform' => '京喜店铺', 'order' => 'JX-TEST-001'],
] as $row) {
StoreZhongcaiReconciliation::create([
'company_id' => $this->company->id,
'bill_date' => '2026-08-01',
'planting_order_no' => $row['order'],
'responsible_platform' => $row['platform'],
]);
}
$response = $this->loginAs()->get(route('business.pages.show', [
'section' => 'store-receivables',
'page' => 'zhongcai-reconciliation',
]));
$response
->assertOk()
->assertSee('平台筛选', false)
->assertSee('>京东<', false)
->assertSee('>抖音<', false)
->assertSee('>天猫<', false)
->assertSee('>拼多多<', false)
->assertSee('>淘宝<', false)
->assertSee('>京喜<', false)
->assertDontSee('>全部<', false)
->assertSee('data-platform="jd"', false)
->assertSee('data-platform="douyin"', false)
->assertSee('data-platform="tmall"', false)
->assertSee('data-platform="pdd"', false)
->assertSee('data-platform="taobao"', false)
->assertSee('data-platform="jingxi"', false)
->assertSee('JD-TEST-001')
->assertSee('DY-TEST-001')
->assertSee('TM-TEST-001')
->assertSee('PDD-TEST-001')
->assertSee('TB-TEST-001')
->assertSee('JX-TEST-001');
}
public function testReconciliationPageShowsPlatformSpecificEmptyState(): void
{
StoreZhongcaiReconciliation::create([
'company_id' => $this->company->id,
'bill_date' => '2026-08-01',
'planting_order_no' => 'JD-TEST-002',
'responsible_platform' => '京东',
]);
$response = $this->loginAs()->get(route('business.pages.show', [
'section' => 'store-receivables',
'page' => 'zhongcai-reconciliation',
]));
$response
->assertOk()
->assertSee('当前页暂无抖音平台数据', false)
->assertSee('当前页暂无天猫平台数据', false);
}
}