Files
danyang-match/tests/miniapp/matchmaker_progress_behavior_test.cjs
T
WorkBuddy 3c2b967274
CI/CD Pipeline / UI Contracts (source-structure gates) (push) Canceled after 0s
CI/CD Pipeline / E2E (live stack) (push) Canceled after 0s
CI/CD Pipeline / Backend Build & Test (push) Canceled after 0s
CI/CD Pipeline / Admin Web Build (push) Canceled after 0s
CI/CD Pipeline / Mini Program Compile Check (push) Canceled after 0s
CI/CD Pipeline / Migration Validation (push) Canceled after 0s
CI/CD Pipeline / Test Shell Guard (Phase 23 Gate) (push) Canceled after 0s
release: freeze 2026-10-15 validated release baseline
2026-10-15 09:47:31 +08:00

36 lines
1.4 KiB
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const vm = require('node:vm');
const path = require('node:path');
(async () => {
let page;
let status = 'waiting_user';
const requests = [];
vm.runInNewContext(fs.readFileSync(path.join(__dirname, '../../miniapp/pages/matchmaker-progress/matchmaker-progress.js'), 'utf8'), {
Page: definition => { page = definition; },
wx: { getStorageSync: () => 'test-token', showToast: () => {} },
require: name => name.endsWith('/api') ? {
get: async url => {
requests.push(url);
assert.equal(url, '/matchmaker/services');
return [{ id: 'other', status: 'completed' }, { id: 'demo-service', status }];
},
} : { matchmakerService: { confirmService: async id => {
assert.equal(id, 'demo-service');
status = 'in_service';
} } },
});
page.setData = values => Object.assign(page.data, values);
await page.loadService('demo-service');
assert.equal(page.data.service.id, 'demo-service');
await page.onConfirmService();
assert.equal(page.data.service.status, 'in_service');
assert.equal(page.data.confirming, false);
assert.equal(requests.length, 2);
await page.loadService('missing');
assert.equal(page.data.service, null);
assert.equal(page.data.loading, false);
console.log('PASS: 本人列表定位、确认后刷新及缺失服务处理');
})().catch(error => { console.error(error); process.exitCode = 1; });