test: move demo-rebuild assertion to end of phase A (reseed invalidates earlier fixture)
This commit is contained in:
@@ -116,6 +116,7 @@ const delInv = await api(A, 'GET', '/admin/invites', undefined, T);
|
||||
const invRow = delInv.body?.data?.invites?.find((i) => i.code === delCode);
|
||||
if (invRow) { await api(A, 'POST', '/admin/invites/delete', { id: invRow.id }, T); }
|
||||
|
||||
|
||||
// 个人信息:upsert → get 往返
|
||||
const profileContent = { info: { name: '张三', school: '重庆城市科技学院', major: '网络工程' }, resume: { selfIntro: '热爱安全研究' } };
|
||||
const pUp = await api(A, 'POST', '/api/profile_upsert', { content: profileContent }, T);
|
||||
@@ -164,6 +165,10 @@ ok((await api(A, 'POST', '/auth/register', { username: 'badcode', password: 'pas
|
||||
const reseed = await api(A, 'POST', '/admin/demo-seed', undefined, T);
|
||||
ok(reseed.body?.data?.seeded === false, '重复播种幂等跳过', reseed.body);
|
||||
|
||||
// demo 重建路由(管理员):重置 demo 数据为初始播种态
|
||||
const re2 = await api(A, 'POST', '/admin/demo-rebuild', {}, T);
|
||||
ok(re2.status === 200 && re2.body?.data?.seeded?.footprints === 16, 'demo 重建路由可达', re2.body);
|
||||
|
||||
// ---------- Phase B:同一数据目录「重启」(新模块实例 + 新端口) ----------
|
||||
console.log('\n== Phase B:重启后(持久化 + 不重复播种) ==');
|
||||
process.env.PORT = '8892';
|
||||
|
||||
@@ -226,6 +226,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const remote = await deleteUserCascade(db, target);
|
||||
console.log('[footprints-sync] 用户已删除:', target.username, '(图床文件 ' + remote + ' 个)');
|
||||
return send(200, true, { ok: true, username: target.username, remote_deleted: remote });
|
||||
}
|
||||
|
||||
// 重建演示账号:级联删除现有 demo → 重新注册 → 重新播种
|
||||
if (req.method === 'POST' && route === '/admin/demo-rebuild') {
|
||||
@@ -238,7 +239,6 @@ const server = http.createServer(async (req, res) => {
|
||||
console.log('[footprints-sync] demo 账号已重建:', JSON.stringify(seeded));
|
||||
return send(200, true, { ok: true, seeded });
|
||||
}
|
||||
}
|
||||
|
||||
if (req.method === 'GET' && route === '/admin/invites') {
|
||||
const invites = db.prepare(`
|
||||
|
||||
Reference in New Issue
Block a user