feat: 新增现场日历并将四类日历的起止地改为选填,以支持现场派车记录。
This commit is contained in:
1 parent
0453e90000
commit
cd99b040aa
15 files changed
+172
-31
No files matched your search
@@ -107,8 +107,22 @@ test('同一车辆按创建时间正序,复制时排在一起且每条换行',
|
||||
])
|
||||
assert.equal(text.startsWith('2026-10-28'), true)
|
||||
})
|
||||
test('表单拒绝空白、无效日期,保留手写起止地', () => {
|
||||
assert.equal(validateManualDraft({ ...row('1'), origin: ' ' }), '请填写始发地')
|
||||
test('表单允许起止地留空,仍拒绝无效日期和超长地址', () => {
|
||||
for (const calendarKind of ['acid', 'alkali', 'other', 'site'] as const) {
|
||||
for (const addresses of [
|
||||
{ origin: '', destination: '云栋' },
|
||||
{ origin: '山峡', destination: '' },
|
||||
{ origin: ' ', destination: ' ' }
|
||||
]) {
|
||||
assert.equal(validateManualDraft({ ...row('1'), calendarKind, ...addresses }), '')
|
||||
}
|
||||
}
|
||||
for (const field of ['origin', 'destination']) {
|
||||
assert.equal(
|
||||
validateManualDraft({ ...row('1'), [field]: '地'.repeat(256) }),
|
||||
'始发地和目的地最多255个字符'
|
||||
)
|
||||
}
|
||||
assert.equal(
|
||||
validateManualDraft({ ...row('1'), dispatchDate: '2026-02-30' }),
|
||||
'请选择有效的派车日期'
|
||||
@@ -118,7 +132,9 @@ test('表单拒绝空白、无效日期,保留手写起止地', () => {
|
||||
test('数量是可空文本,复制逐条展示,日汇总仍只计车次', () => {
|
||||
const tons = { ...row('1'), quantity: '32.50' }
|
||||
const blank = { ...row('2'), quantity: ' ' }
|
||||
const day = manualCalendarDays([tons, blank], '2026-10').find((item) => item.date === '2026-10-26')!
|
||||
const day = manualCalendarDays([tons, blank], '2026-10').find(
|
||||
(item) => item.date === '2026-10-26'
|
||||
)!
|
||||
assert.deepEqual(day.products[0], { id: 'p1', name: '液碱', count: 2 })
|
||||
const text = manualCopyText('2026-10-26', [tons, blank])
|
||||
assert.match(text, /液碱 32\.50吨 山峡 → 云栋/)
|
||||
@@ -130,8 +146,5 @@ test('数量是可空文本,复制逐条展示,日汇总仍只计车次', ()
|
||||
validateManualDraft({ ...row('1'), quantity: '12.345' }),
|
||||
'数量须为数字,最多两位小数'
|
||||
)
|
||||
assert.equal(
|
||||
validateManualDraft({ ...row('1'), quantity: '1吨' }),
|
||||
'数量须为数字,最多两位小数'
|
||||
)
|
||||
assert.equal(validateManualDraft({ ...row('1'), quantity: '1吨' }), '数量须为数字,最多两位小数')
|
||||
})
|
||||
@@ -2,7 +2,13 @@ import assert from 'node:assert/strict'
|
||||
import { chromium } from 'playwright'
|
||||
const browser = await chromium.launch({ headless: true, channel: 'chrome' })
|
||||
try {
|
||||
for (const mobile of [false, true]) {
|
||||
for (const { mobile, kind, title } of [
|
||||
{ mobile: false, kind: 'acid', title: '酸派车日历' },
|
||||
{ mobile: false, kind: 'alkali', title: '碱派车日历' },
|
||||
{ mobile: false, kind: 'other', title: '其他日历' },
|
||||
{ mobile: false, kind: 'site', title: '现场日历' },
|
||||
{ mobile: true, kind: 'acid', title: '酸派车日历' }
|
||||
]) {
|
||||
const context = await browser.newContext({
|
||||
permissions: ['clipboard-read', 'clipboard-write'],
|
||||
viewport: mobile ? { width: 375, height: 812 } : { width: 1440, height: 1000 }
|
||||
@@ -132,6 +138,13 @@ try {
|
||||
console.log('PAGE', await page.locator('body').innerText(), errors)
|
||||
throw e
|
||||
})
|
||||
if (!mobile) {
|
||||
assert.deepEqual(
|
||||
await page.locator('.dispatch-calendar-tabs [role="tab"]').allTextContents(),
|
||||
['酸派车日历', '碱派车日历', '其他日历', '现场日历', '实际派车信息']
|
||||
)
|
||||
}
|
||||
await page.getByRole('tab', { name: title, exact: true }).click()
|
||||
if (mobile) {
|
||||
await page.getByLabel('查看月份', { exact: true }).click()
|
||||
const popup = page.locator('.mp-calendar-date-picker:visible')
|
||||
@@ -175,6 +188,15 @@ try {
|
||||
await editor.getByRole('combobox', { name: '产品名称', exact: true }).click()
|
||||
await page.getByRole('option', { name: '液碱', exact: true }).click()
|
||||
}
|
||||
// 起止地留空也应保存成功,编辑后仍可补填。
|
||||
await editor.getByRole('button', { name: '保存', exact: true }).click()
|
||||
await editor.waitFor({ state: 'hidden' })
|
||||
assert.equal(rows.length, 1)
|
||||
assert.equal(rows[0].origin, '')
|
||||
assert.equal(rows[0].destination, '')
|
||||
assert.equal(rows[0].calendarKind, kind)
|
||||
await page.locator('[data-testid="manual-record"]').first().click()
|
||||
await page.getByRole('button', { name: '编辑', exact: true }).click()
|
||||
await editor.getByPlaceholder('请输入始发地').fill('山峡')
|
||||
await editor.getByPlaceholder('请输入目的地').fill('云栋')
|
||||
failSave = true
|
||||
@@ -184,10 +206,11 @@ try {
|
||||
await editor.getByRole('button', { name: '保存', exact: true }).click()
|
||||
await editor.waitFor({ state: 'hidden' })
|
||||
assert.equal(rows.length, 1)
|
||||
assert.equal(rows[0].calendarKind, kind)
|
||||
const card = page.locator('[data-testid="manual-record"]').first()
|
||||
await card.waitFor()
|
||||
await page.screenshot({
|
||||
path: `/tmp/manual-calendar-${mobile ? 'mobile' : 'web'}.png`,
|
||||
path: `/tmp/manual-calendar-${mobile ? 'mobile' : 'web'}-${kind}.png`,
|
||||
fullPage: false
|
||||
})
|
||||
assert.match(await card.innerText(), /山峡 → 云栋/)
|
||||
@@ -197,7 +220,7 @@ try {
|
||||
.click()
|
||||
assert.match(
|
||||
await page.evaluate(() => navigator.clipboard.readText()),
|
||||
/皖H12345.*液碱.*山峡 → 云栋/
|
||||
/皖H12345.*液碱.*山峡 → 云栋/s
|
||||
)
|
||||
|
||||
await card.click()
|
||||
@@ -213,7 +236,7 @@ try {
|
||||
assert.equal(rows.length, 0)
|
||||
failLoad = true
|
||||
await page.getByRole('tab', { name: '实际派车信息', exact: true }).click()
|
||||
await page.getByRole('tab', { name: '酸派车日历', exact: true }).click()
|
||||
await page.getByRole('tab', { name: title, exact: true }).click()
|
||||
await page.getByText('派车日历加载失败,请重试', { exact: false }).first().waitFor()
|
||||
await page.getByRole('button', { name: '重试', exact: true }).click()
|
||||
await page
|
||||
@@ -240,10 +263,10 @@ try {
|
||||
origin: '山峡',
|
||||
destination: '云栋',
|
||||
remark: '',
|
||||
calendarKind: 'acid'
|
||||
calendarKind: kind
|
||||
}
|
||||
]
|
||||
await page.getByRole('tab', { name: '酸派车日历', exact: true }).click()
|
||||
await page.getByRole('tab', { name: title, exact: true }).click()
|
||||
await page.locator('[data-testid="manual-record"]').first().waitFor()
|
||||
assert.equal(await page.getByRole('button', { name: '新增派车计划', exact: true }).count(), 0)
|
||||
await page.locator('[data-testid="manual-record"]').first().click()
|
||||
@@ -251,7 +274,7 @@ try {
|
||||
assert.equal(await page.getByRole('button', { name: '删除', exact: true }).count(), 0)
|
||||
assert.deepEqual(errors, [])
|
||||
await context.close()
|
||||
console.log(mobile ? 'mobile CRUD passed' : 'web CRUD passed')
|
||||
console.log(`${mobile ? 'mobile' : 'web'} ${kind} CRUD passed`)
|
||||
}
|
||||
} finally {
|
||||
await browser.close()
|
||||
|
||||
Reference in new issue
Block a user