|
|
@@ -2,8 +2,12 @@ import assert from 'node:assert/strict'
|
|
|
import { describe, it } from 'node:test'
|
|
|
import type { Plan, PlanStopProduct } from '@/api/pl'
|
|
|
import {
|
|
|
+ buildPlPlanListSpanMethod,
|
|
|
flattenPlanArchivePairRows,
|
|
|
- matchLoadProduct
|
|
|
+ flattenPlanListRows,
|
|
|
+ matchLoadProduct,
|
|
|
+ PL_DELIVERY_SPAN_PROPS,
|
|
|
+ PL_PLAN_SPAN_PROPS
|
|
|
} from './pl-plan-list-display-rows'
|
|
|
|
|
|
function sp(partial: Partial<PlanStopProduct> & Pick<PlanStopProduct, 'productId'>): PlanStopProduct {
|
|
|
@@ -93,3 +97,95 @@ describe('flattenPlanArchivePairRows product rows', () => {
|
|
|
assert.equal(rows[0].deliveryRowSpan, 1)
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+describe('buildPlPlanListSpanMethod two-level', () => {
|
|
|
+ it('merges plan and delivery columns independently', () => {
|
|
|
+ const rows = flattenPlanArchivePairRows([samplePlan()])
|
|
|
+ const span = buildPlPlanListSpanMethod()
|
|
|
+ const planFirst = span({
|
|
|
+ row: rows[0],
|
|
|
+ column: { property: 'loadCustomer' },
|
|
|
+ rowIndex: 0,
|
|
|
+ columnIndex: 0
|
|
|
+ })
|
|
|
+ assert.deepEqual(planFirst, { rowspan: 3, colspan: 1 })
|
|
|
+ const planSecond = span({
|
|
|
+ row: rows[1],
|
|
|
+ column: { property: 'loadCustomer' },
|
|
|
+ rowIndex: 1,
|
|
|
+ columnIndex: 0
|
|
|
+ })
|
|
|
+ assert.deepEqual(planSecond, { rowspan: 0, colspan: 0 })
|
|
|
+ const delFirst = span({
|
|
|
+ row: rows[0],
|
|
|
+ column: { property: 'deliveryCustomer' },
|
|
|
+ rowIndex: 0,
|
|
|
+ columnIndex: 0
|
|
|
+ })
|
|
|
+ assert.deepEqual(delFirst, { rowspan: 2, colspan: 1 })
|
|
|
+ const delThird = span({
|
|
|
+ row: rows[2],
|
|
|
+ column: { property: 'deliveryCustomer' },
|
|
|
+ rowIndex: 2,
|
|
|
+ columnIndex: 0
|
|
|
+ })
|
|
|
+ assert.deepEqual(delThird, { rowspan: 1, colspan: 1 })
|
|
|
+ const leaf = span({
|
|
|
+ row: rows[0],
|
|
|
+ column: { property: 'productName' },
|
|
|
+ rowIndex: 0,
|
|
|
+ columnIndex: 0
|
|
|
+ })
|
|
|
+ assert.equal(leaf, undefined)
|
|
|
+ const sel = span({
|
|
|
+ row: rows[0],
|
|
|
+ column: { type: 'selection' },
|
|
|
+ rowIndex: 0,
|
|
|
+ columnIndex: 0
|
|
|
+ })
|
|
|
+ assert.deepEqual(sel, { rowspan: 3, colspan: 1 })
|
|
|
+ assert.equal(PL_PLAN_SPAN_PROPS.has('loadAddressTime'), true)
|
|
|
+ assert.equal(PL_DELIVERY_SPAN_PROPS.has('deliveryContract'), true)
|
|
|
+ })
|
|
|
+
|
|
|
+ it('non-pair rows merge only plan columns by planRowSpan', () => {
|
|
|
+ const rows = flattenPlanListRows([samplePlan()])
|
|
|
+ const span = buildPlPlanListSpanMethod([], 3)
|
|
|
+ assert.deepEqual(
|
|
|
+ span({
|
|
|
+ row: rows[0],
|
|
|
+ column: { property: 'planDate' },
|
|
|
+ rowIndex: 0,
|
|
|
+ columnIndex: 0
|
|
|
+ }),
|
|
|
+ { rowspan: 3, colspan: 1 }
|
|
|
+ )
|
|
|
+ assert.deepEqual(
|
|
|
+ span({
|
|
|
+ row: rows[1],
|
|
|
+ column: { property: 'planDate' },
|
|
|
+ rowIndex: 1,
|
|
|
+ columnIndex: 0
|
|
|
+ }),
|
|
|
+ { rowspan: 0, colspan: 0 }
|
|
|
+ )
|
|
|
+ assert.equal(
|
|
|
+ span({
|
|
|
+ row: rows[1],
|
|
|
+ column: { property: 'deliveryCustomer' },
|
|
|
+ rowIndex: 1,
|
|
|
+ columnIndex: 0
|
|
|
+ }),
|
|
|
+ undefined
|
|
|
+ )
|
|
|
+ assert.equal(
|
|
|
+ span({
|
|
|
+ row: rows[2],
|
|
|
+ column: { property: 'deliveryContract' },
|
|
|
+ rowIndex: 2,
|
|
|
+ columnIndex: 0
|
|
|
+ }),
|
|
|
+ undefined
|
|
|
+ )
|
|
|
+ })
|
|
|
+})
|