CaiWuXiTong/tests/Feature/Business/KukaReconciliationPageTest.php
chenxi 8b46486b87 feat(顾家对账): 按工作簿子表补充各页签表头 (#1276)
按工作簿4子表名补充顾家对账各页签表头;无对应工作表的两个对账单页签保持占位。`n`n验证:页面测试 2 个、49 条断言通过。
2026-11-19 16:25:14 +08:00

94 lines
4.3 KiB
PHP

<?php
namespace Tests\Feature\Business;
use Tests\Feature\FeatureTestCase;
class KukaReconciliationPageTest extends FeatureTestCase
{
public function test_renders_all_kuka_reconciliation_tabs_with_the_first_tab_active(): void
{
$response = $this->loginAs()
->get(route('business.pages.show', [
'section' => 'posting-data',
'page' => 'kuka-reconciliation',
]))
->assertOk()
->assertSeeText('顾家对账')
->assertSeeText('顾家过账数据')
->assertSeeText('TOC订单')
->assertSeeText('灵珊虚拟过账')
->assertSeeText('顾家ERP商品导入')
->assertSeeText('开票填写模板-货物-灵珊')
->assertSeeText('库存管理模板')
->assertSeeText('灵珊对账单')
->assertSeeText('欧伯娜对账单')
->assertSee('data-kuka-reconciliation-tabs', false)
->assertSee('data-kuka-reconciliation-panel="posting-data"', false)
->assertSee('data-kuka-reconciliation-panel="oberna-statement"', false)
->assertSee('id="kuka-reconciliation-tab-posting-data"', false)
->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false)
->assertSee('data-kuka-reconciliation-template="顾家过账数据"', false)
->assertSee('data-kuka-reconciliation-template="TOC订单"', false)
->assertSee('data-kuka-reconciliation-template="灵珊虚拟过账"', false)
->assertSee('data-kuka-reconciliation-template="顾家ERP商品导入"', false)
->assertSee('data-kuka-reconciliation-template="开票填写模板-货物-灵珊"', false)
->assertSee('data-kuka-reconciliation-template="库存管理模版"', false)
->assertSeeText('供货商金额')
->assertSeeText('装载号')
->assertSeeText('nationalSubsidySubject')
->assertSeeText('提交人电话(手机)')
->assertSeeText('toElsAccount')
->assertSeeText('实际可用库存数量')
->assertSeeText('灵珊对账单页面已建立')
->assertSeeText('欧伯娜对账单页面已建立');
$html = $response->getContent();
$this->assertSame([
'posting-data' => 7,
'toc-orders' => 6,
'lingshan-virtual-posting' => 16,
'erp-product-import' => 34,
'invoice-entry-template' => 20,
'inventory-management-template' => 28,
], [
'posting-data' => $this->headerCount($html, 'posting-data'),
'toc-orders' => $this->headerCount($html, 'toc-orders'),
'lingshan-virtual-posting' => $this->headerCount($html, 'lingshan-virtual-posting'),
'erp-product-import' => $this->headerCount($html, 'erp-product-import'),
'invoice-entry-template' => $this->headerCount($html, 'invoice-entry-template'),
'inventory-management-template' => $this->headerCount($html, 'inventory-management-template'),
]);
}
public function test_kuka_reconciliation_tab_can_open_directly_from_the_url(): void
{
$this->loginAs()
->get(route('business.pages.show', [
'section' => 'posting-data',
'page' => 'kuka-reconciliation',
'reconciliation_view' => 'toc-orders',
]))
->assertOk()
->assertSee('id="kuka-reconciliation-tab-toc-orders"', false)
->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false)
->assertSee('data-kuka-reconciliation-panel="toc-orders"', false)
->assertSee('data-kuka-reconciliation-template="TOC订单"', false)
->assertSeeText('订单号')
->assertSeeText('发货数量');
}
private function headerCount(string $html, string $slug): int
{
$panelStart = strpos($html, 'data-kuka-reconciliation-panel="'.$slug.'"');
$this->assertNotFalse($panelStart);
$panelEnd = strpos($html, '</section>', $panelStart);
$this->assertNotFalse($panelEnd);
$panel = substr($html, $panelStart, $panelEnd - $panelStart);
preg_match_all('/<th scope="col">/', $panel, $matches);
return count($matches[0]);
}
}