confirm-order-wechat-action.test.mjs
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { describe, it } from 'node:test'
const template = readFileSync(
new URL(
'../../tabWorkOrder/pages/confirmOrder/confirmOrder.wxml',
import.meta.url
),
'utf8'
)
const styles = readFileSync(
new URL(
'../../tabWorkOrder/pages/confirmOrder/confirmOrder.wxss',
import.meta.url
),
'utf8'
)
describe('confirmOrder confirmation action', () => {
it('always renders exactly one confirmation action independent of payment type and role', () => {
const confirmationActions = template.match(/bindtap="next"/g) || []
assert.equal(confirmationActions.length, 1)
assert.match(template, /<view class="btn-box confirm-btn/)
const footer = template.slice(template.indexOf('<view class="btn-box confirm-btn'))
assert.doesNotMatch(footer, /wx:if="\{\{ orderInfo\.selectPayType/)
assert.doesNotMatch(
footer,
/wx:if="\{\{ !perm\.hasPermission\.isSuper\(userInfo\)/
)
})
it('keeps order editing inside the original operator permission gate', () => {
assert.match(
template,
/<block wx:if="\{\{ orderInfo\.status == 1 && !perm\.hasPermission\.isSuper\(userInfo\) && userInfo\.userType == 2 \}\}">\s*<view class="btn text-center change" bindtap="edit">修改<\/view>/
)
assert.equal((template.match(/bindtap="edit"/g) || []).length, 1)
})
it('reserves the bottom safe area and renders a lone action full width', () => {
assert.match(template, /isFullSucreen \? 'isFullSucreenCom' : ''/)
assert.match(
styles,
/\.confirm-btn \.single-confirm-btn \{\s*width: calc\(100% - var\(--fontSize64\)\);\s*\}/
)
})
})