65 行
3.7 KiB
TypeScript
65 行
3.7 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const MP_ROOT = path.resolve('m:/2026项目/CRMmp/mpuniapp');
|
|
const pagesJsonPath = path.join(MP_ROOT, 'pages.json');
|
|
const profileUvuePath = path.join(MP_ROOT, 'pages/owner/profile/index.uvue');
|
|
const cardHomeUtsPath = path.join(MP_ROOT, 'pages/owner/card/useCardHome.uts');
|
|
|
|
test('1. pages.json TabBar 信息架构纯正性审查 (工作台、名片、雷达、潜客、我的 5 栏标准)', () => {
|
|
assert.ok(fs.existsSync(pagesJsonPath), 'pages.json 必须存在');
|
|
const content = fs.readFileSync(pagesJsonPath, 'utf-8');
|
|
const config = JSON.parse(content);
|
|
|
|
const tabBarList = config.tabBar?.list || [];
|
|
assert.equal(tabBarList.length, 5, 'TabBar 应当精确包含 5 个核心工作台 Tab');
|
|
|
|
// 验证不包含微官网 pages/portal/index
|
|
const hasPortalInTabBar = tabBarList.some((item: any) => item.pagePath === 'pages/portal/index');
|
|
assert.equal(hasPortalInTabBar, false, '微官网 pages/portal/index 严禁作为 TabBar 常驻项,应作为独立落地页');
|
|
|
|
// 验证 5 个 Tab 顺序与路由
|
|
assert.equal(tabBarList[0].pagePath, 'pages/owner/workplace/index', 'TabBar 第 1 项必须是工作台');
|
|
assert.equal(tabBarList[0].text, '工作台');
|
|
|
|
assert.equal(tabBarList[1].pagePath, 'pages/owner/card/index', 'TabBar 第 2 项必须是名片');
|
|
assert.equal(tabBarList[1].text, '名片');
|
|
|
|
assert.equal(tabBarList[2].pagePath, 'pages/owner/radar', 'TabBar 第 3 项必须是雷达');
|
|
assert.equal(tabBarList[2].text, '雷达');
|
|
|
|
assert.equal(tabBarList[3].pagePath, 'pages/owner/leads', 'TabBar 第 4 项必须是潜客');
|
|
assert.equal(tabBarList[3].text, '潜客');
|
|
|
|
assert.equal(tabBarList[4].pagePath, 'pages/owner/profile/index', 'TabBar 第 5 项必须是我的');
|
|
assert.equal(tabBarList[4].text, '我的');
|
|
|
|
// 验证 pages[0] 首屏页面为工作台首页
|
|
assert.equal(config.pages[0].path, 'pages/owner/workplace/index', '应用首屏 pages[0] 应设为工作台首页');
|
|
|
|
// 验证微官网依然保留在 pages 路由列表中供扫码和独立预览访问
|
|
const hasPortalInPages = config.pages.some((item: any) => item.path === 'pages/portal/index');
|
|
assert.equal(hasPortalInPages, true, '微官网 pages/portal/index 必须保留在 pages 列表中供独立沉浸访问');
|
|
});
|
|
|
|
test('2. profile/index.uvue 的 openPage 导航守卫与新 TabBar 保持 100% 一致', () => {
|
|
const content = fs.readFileSync(profileUvuePath, 'utf-8');
|
|
|
|
// 验证 tabPages 数组不包含 portal/index,且包含 5 个工作台管理页
|
|
assert.ok(content.includes("'/pages/owner/workplace/index'"), 'tabPages 必须包含 /pages/owner/workplace/index');
|
|
assert.ok(content.includes("'/pages/owner/card/index'"), 'tabPages 必须包含 /pages/owner/card/index');
|
|
assert.ok(content.includes("'/pages/owner/radar'"), 'tabPages 必须包含 /pages/owner/radar');
|
|
assert.ok(content.includes("'/pages/owner/leads'"), 'tabPages 必须包含 /pages/owner/leads');
|
|
assert.ok(content.includes("'/pages/owner/profile/index'"), 'tabPages 必须包含 /pages/owner/profile/index');
|
|
assert.equal(content.includes("'/pages/portal/index'"), false, 'tabPages 严禁包含 /pages/portal/index,微官网应通过 uni.navigateTo 打开');
|
|
});
|
|
|
|
test('3. useCardHome.uts 中的 buildPortalPreviewUrl 保持对微官网的独立全屏预览能力', () => {
|
|
const content = fs.readFileSync(cardHomeUtsPath, 'utf-8');
|
|
assert.ok(content.includes('buildPortalPreviewUrl'), '必须包含 buildPortalPreviewUrl');
|
|
assert.ok(content.includes('openCardPreview'), '必须包含 openCardPreview');
|
|
assert.ok(content.includes('/pages/portal/index'), '预览链接必须指向微官网 /pages/portal/index');
|
|
});
|