Files
order_site/apps/frontend/tests/order-service-layout.test.ts
T

58 lines
2.3 KiB
TypeScript

import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
test('订单服务单商品提交按钮固定在一屏底部并预留手机安全区', async () => {
const [page, styles] = await Promise.all([
readFile(new URL('../src/pages/public/OrderServicePage.tsx', import.meta.url), 'utf8'),
readFile(new URL('../src/styles/client/collect.css', import.meta.url), 'utf8'),
])
assert.ok(page.includes('const hasFixedSubmit = !ageGateOpen && pendingItems.length === 1'))
assert.ok(page.includes('fixedSubmit={hasFixedSubmit}'))
assert.ok(page.includes('is-viewport-fixed'))
assert.ok(styles.includes('.collect-link-page.has-fixed-submit'))
assert.match(styles, /\.collect-link-actions\.is-viewport-fixed\s*\{[^}]*position:\s*fixed;/s)
assert.ok(styles.includes('env(safe-area-inset-bottom, 0px)'))
assert.ok(styles.includes('calc(100vw - 48px)'))
assert.match(
styles,
/\.collect-link-actions\.is-viewport-fixed\s*\{[^}]*background:\s*transparent;/s,
)
assert.match(
styles,
/\.collect-link-actions\.is-viewport-fixed \.ant-btn\s*\{[^}]*background:\s*#ff6a00;/s,
)
assert.match(
styles,
/\.collect-link-actions\.is-viewport-fixed \.ant-btn:not\(:disabled\):hover[\s\S]*background:\s*#ff6a00;/s,
)
})
test('多商品待补资料时保留逐商品按钮,避免固定按钮互相覆盖', async () => {
const page = await readFile(
new URL('../src/pages/public/OrderServicePage.tsx', import.meta.url),
'utf8',
)
assert.ok(page.includes('pendingItems.length === 1'))
assert.ok(page.includes('fixedSubmit={hasFixedSubmit}'))
assert.ok(page.includes('className={`collect-link-actions${fixedSubmit'))
})
test('未成年提示正文独立滚动,底部操作按钮始终可见', async () => {
const styles = await readFile(
new URL('../src/styles/client/collect.css', import.meta.url),
'utf8',
)
assert.match(
styles,
/\.order-service-age-gate \.ant-modal-body\s*\{[^}]*flex:\s*1 1 0;[^}]*max-height:\s*max\(96px, calc\(100dvh - 230px\)\);[^}]*overflow-y:\s*auto;/s,
)
assert.match(
styles,
/\.order-service-age-gate \.ant-modal-footer\s*\{[^}]*flex:\s*none;[^}]*border-top:/s,
)
assert.ok(styles.includes('.order-service-age-gate .ant-modal-body::-webkit-scrollbar-thumb'))
})