workspace-source-contract.test.mjs 1.18 KB
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, it } from 'node:test'

const testDir = path.dirname(fileURLToPath(import.meta.url))
const projectRoot = path.resolve(testDir, '../..')

describe('工作台新增工单源码契约', () => {
  it('菜单使用独立图片地址并直接打开收款方式弹窗', async () => {
    const [pageSource, templateSource] = await Promise.all([
      readFile(
        path.join(projectRoot, 'pages/tab/workspace/workspace.js'),
        'utf8'
      ),
      readFile(
        path.join(projectRoot, 'pages/tab/workspace/workspace.wxml'),
        'utf8'
      )
    ])

    assert.match(pageSource, /name:\s*["']新增工单["']/)
    assert.match(
      pageSource,
      /const WORK_ORDER_ICON_URL\s*=\s*\n\s*"https:\/\/img02\.glsx\.com\.cn\/weapp\/resource\/dj-car-boutique-work-wechat\/upgrade\/create_newworkorder\.png"/
    )
    assert.match(pageSource, /iconUrl:/)
    assert.match(pageSource, /openWorkOrderPrompt/)
    assert.match(templateSource, /item\.iconUrl\s*\|\|/)
    assert.match(templateSource, /<order-prompt-pop/)
  })
})