feat: 新增现场日历并将四类日历的起止地改为选填,以支持现场派车记录。

This commit is contained in:
wuzilong committed 2026-10-30 11:58:48 +08:00
1 parent 0453e90000
commit cd99b040aa
15 files changed
+172 -31

No files matched your search

@@ -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()