125 lines
7.0 KiB
PHP
125 lines
7.0 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) [
|
|
'platform' => '京东账单',
|
|
'occurred_date' => '2026-09-01',
|
|
'store_name' => '测试店铺',
|
|
'online_order_no' => 'ORDER-1',
|
|
'warehouse' => '简尚-崔桥工厂仓',
|
|
'warehouse_short_name' => '崔桥工厂仓',
|
|
'brand' => '测试品牌',
|
|
'category' => '测试类目',
|
|
'supplier_name' => '测试供应商',
|
|
'free_shipping_manufacturer' => true,
|
|
'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_rows' => 7,
|
|
'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('grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr))', $html);
|
|
$this->assertStringContainsString('.product-cost-metric.is-warn .product-cost-metric__action--button', $html);
|
|
$this->assertStringContainsString('商品成本合计', $html);
|
|
$this->assertStringContainsString('待核验成本', $html);
|
|
$this->assertStringContainsString('data-product-cost-metric-card="cost-summary"', $html);
|
|
$this->assertStringContainsString('data-product-cost-summary-open', $html);
|
|
$this->assertStringContainsString('data-product-cost-summary-dialog', $html);
|
|
$this->assertStringContainsString('按发货仓库透视商品数量与商品成本', $html);
|
|
$this->assertStringContainsString('data-product-cost-summary-search', $html);
|
|
$this->assertStringContainsString('data-product-cost-summary-sort="quantity"', $html);
|
|
$this->assertStringContainsString('data-product-cost-summary-sort="cost"', $html);
|
|
$this->assertStringContainsString('data-product-cost-metric-card="pending-summary"', $html);
|
|
$this->assertStringContainsString('data-product-cost-summary="pending_rows">7</span>', $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-filters', $html);
|
|
$this->assertStringContainsString('data-product-cost-pending-export', $html);
|
|
$this->assertMatchesRegularExpression(
|
|
'/<a\s+href="[^"]+"\s+data-product-cost-pending-export/s',
|
|
$html
|
|
);
|
|
$this->assertStringContainsString('.product-cost-pending-dialog__actions a:focus-visible', $html);
|
|
$this->assertStringContainsString("dialog.showModal();\n dialog.focus();", $html);
|
|
$this->assertStringContainsString('待核验类型', $html);
|
|
$this->assertStringContainsString('点击任一明细值可复制', $html);
|
|
$this->assertStringContainsString('data-product-cost-pending-copy-status', $html);
|
|
$this->assertStringContainsString('product-cost-pending-copy-value', $html);
|
|
$this->assertStringContainsString('已复制', $html);
|
|
$this->assertStringContainsString('data-product-cost-pending-refresh', $html);
|
|
$this->assertSame(2, substr_count($html, 'data-product-cost-metric-card='));
|
|
$this->assertStringNotContainsString('product-cost-metric__summary-item', $html);
|
|
$this->assertStringNotContainsString('product-cost-pending-dialog__metrics', $html);
|
|
$this->assertStringNotContainsString('待核验商品数量', $html);
|
|
$this->assertStringNotContainsString('未匹配仓库简称', $html);
|
|
$this->assertStringNotContainsString('明细行数', $html);
|
|
$this->assertStringNotContainsString('已计价商品数量', $html);
|
|
$this->assertStringNotContainsString('线上代发价兜底', $html);
|
|
$this->assertStringNotContainsString('商品资料成本兜底', $html);
|
|
$this->assertStringContainsString('class="product-cost-filter-form"', $html);
|
|
$this->assertStringContainsString('product-cost-columns:v2:', $html);
|
|
$this->assertStringContainsString('搜索当前页数据', $html);
|
|
$this->assertStringContainsString('列设置', $html);
|
|
$this->assertStringContainsString('全部筛选结果', $html);
|
|
$this->assertStringContainsString('当前显示列及顺序', $html);
|
|
$this->assertStringContainsString('id="product-cost-table"', $html);
|
|
$this->assertLessThan(
|
|
strpos($html, 'data-column-key="occurred_date">发生时间'),
|
|
strpos($html, 'data-column-key="platform">平台')
|
|
);
|
|
$this->assertStringContainsString('data-column-key="platform">京东账单</td>', $html);
|
|
$this->assertLessThan(
|
|
strpos($html, 'data-column-key="product_code">商品编码'),
|
|
strpos($html, 'data-column-key="brand">品牌')
|
|
);
|
|
$this->assertStringContainsString('data-column-key="brand">测试品牌</td>', $html);
|
|
$this->assertStringContainsString('data-column-key="category">测试类目</td>', $html);
|
|
$this->assertStringContainsString('data-column-key="supplier_name">测试供应商</td>', $html);
|
|
$this->assertStringContainsString('data-column-key="free_shipping_manufacturer">包邮</td>', $html);
|
|
$this->assertStringContainsString('导出当前筛选结果', $html);
|
|
}
|
|
}
|