CaiWuXiTong/tests/Feature/Business/ProductCostPageLayoutTest.php
chenxi 6fd059ae98 商品成本:增加待核验明细弹框
待核验成本卡片增加明细弹框,按当前筛选分页展示单价或仓库未匹配行,修复后刷新即可移除。
2026-10-25 19:03:46 +08:00

81 lines
3.9 KiB
PHP

<?php
namespace Tests\Feature\Business;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\URL;
use Tests\TestCase;
class ProductCostPageLayoutTest extends TestCase
{
public function test_product_cost_page_uses_performance_detail_style_modules(): void
{
URL::defaults(['company_id' => 1]);
$row = (object) [
'occurred_date' => '2026-09-01',
'store_name' => '测试店铺',
'online_order_no' => 'ORDER-1',
'warehouse' => '简尚-崔桥工厂仓',
'warehouse_short_name' => '崔桥工厂仓',
'product_code' => 'SKU-1',
'product_quantity' => 1,
'unit_price' => 10,
'product_cost' => 10,
];
$html = view('business.pages.financial-operations.product-costs', [
'section' => ['slug' => 'financial-operations'],
'page' => ['slug' => 'product-costs'],
'productCostRows' => new LengthAwarePaginator([$row], 1, 25, 1, ['path' => '/product-costs']),
'productCostFilters' => [
'month' => '2026-09',
'platform' => '',
'store_name' => '',
'online_order_no' => '',
'product_code' => '',
'warehouse_short_name' => '',
],
'productCostSummary' => [
'rows' => 1,
'quantity_total' => 1,
'cost_total' => 10,
'pending_cost_rows' => 0,
'pending_cost_quantity' => 0,
'fallback_price_rows' => 0,
'catalog_price_rows' => 0,
'missing_warehouse_rows' => 0,
],
'productCostMonths' => ['2026-09'],
'productCostPlatforms' => ['抖音'],
'productCostWarehouses' => ['崔桥工厂仓'],
'productCostError' => null,
])->render();
$this->assertStringContainsString('product-cost-head', $html);
$this->assertStringContainsString('共享镜像', $html);
$this->assertStringContainsString('成本指标', $html);
$this->assertStringContainsString('口径说明', $html);
$this->assertStringContainsString('商品成本合计', $html);
$this->assertStringContainsString('待核验成本', $html);
$this->assertStringContainsString('待核验商品数量', $html);
$this->assertStringContainsString('未匹配仓库简称', $html);
$this->assertStringContainsString('data-product-cost-metric-card="pending-summary"', $html);
$this->assertStringContainsString('data-product-cost-pending-open', $html);
$this->assertStringContainsString('data-product-cost-pending-dialog', $html);
$this->assertStringContainsString('待核验成本明细', $html);
$this->assertStringContainsString('data-product-cost-pending-refresh', $html);
$this->assertSame(2, substr_count($html, 'data-product-cost-metric-card='));
$this->assertSame(3, substr_count($html, 'class="product-cost-metric__summary-item"'));
$this->assertStringNotContainsString('明细行数', $html);
$this->assertStringNotContainsString('已计价商品数量', $html);
$this->assertStringNotContainsString('线上代发价兜底', $html);
$this->assertStringNotContainsString('商品资料成本兜底', $html);
$this->assertStringContainsString('class="product-cost-filter-form"', $html);
$this->assertStringContainsString('搜索当前页数据', $html);
$this->assertStringContainsString('列设置', $html);
$this->assertStringContainsString('全部筛选结果', $html);
$this->assertStringContainsString('当前显示列及顺序', $html);
$this->assertStringContainsString('id="product-cost-table"', $html);
$this->assertStringContainsString('导出当前筛选结果', $html);
}
}