Dormant import honors dry (it wrote rows even with dry: true); e2e 125/125

Not deployed: ships with the go-live deploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 10:06:15 -06:00
parent cf0da5044a
commit 0e508312c9
2 changed files with 4 additions and 1 deletions
+2
View File
@@ -248,6 +248,8 @@ async function main() {
for (const [from, to] of [['/?oldmember', '/memberone'], ['/index.php?oldmember', '/memberone'], ['/splashpg.php?r=oldmember', '/memberone'], ['/lcp.php?r=oldmember', '/memberone'], ['/join.php?r=oldmember', '/memberone'], ['/login.php', '/my'], ['/faq.php', '/guides/faq'], ['/whatever.php', '/'], ['/?oldtwo', '/membertwo'], ['/?OLDTWO', '/membertwo'], ['/?dup', '/'], ['/?nobody', '/']]) {
const x = await fetch(BASE + from, { redirect: 'manual' }); ok(x.status === 301 && x.headers.get('location') === to, 'old link ' + from + ' -> ' + to, x.headers.get('location'));
}
{ const dr = await admin('/api/admin/dormant', { dry: true, packets: [{ oldId: '10010', oldUsername: 'oldm2', hubId: 'h_' + '2'.repeat(16), name: 'Team Build Machine', url: 'https://teambuildmachine.example.com/oldm2', added: '2022-04-21' }] });
const st = await admin('/api/admin/status'); ok(dr.dry && dr.created === 1 && st.packets.dormant === 0, 'dormant import dry run counts and writes nothing', [dr, st.packets]); }
r = await admin('/api/admin/dormant', { packets: [{ oldId: '10010', oldUsername: 'oldm2', hubId: 'h_' + '2'.repeat(16), name: 'Team Build Machine', url: 'https://teambuildmachine.example.com/oldm2', added: '2022-04-21' }, { oldId: 'x', hubId: 'h_1', name: 'bad', url: 'nope' }] });
ok(r.created === 1 && r.skipped === 1, 'dormant import: 1 created, a bad row skipped', r);
const my2 = await cM2.get('/api/my'); const dm = my2.j.dormant && my2.j.dormant[0];
+2 -1
View File
@@ -598,7 +598,8 @@ const server = http.createServer(async (req, res) => {
if (!/^\d{1,9}$/.test(oldId) || !/^h_[0-9a-f]{16}$/.test(hubId) || store.packets().some(x => x.old && x.old.oldId === oldId)) { skipped++; continue; }
const name = cleanText(r.name, C.packet.name).slice(0, C.packet.name); const url = String(r.url || '').trim().slice(0, 500);
if (name.length < 2 || !/^https?:\/\//i.test(url)) { skipped++; continue; }
store.addPacket({ owner: '', ownerName: null, status: 'dormant', stage: 'sprouting', name, url: '', desc: '', old: { oldId, oldUsername: String(r.oldUsername || '').slice(0, 40), hubId, url, added: String(r.added || '').slice(0, 10) } }); created++;
if (!b.dry) store.addPacket({ owner: '', ownerName: null, status: 'dormant', stage: 'sprouting', name, url: '', desc: '', old: { oldId, oldUsername: String(r.oldUsername || '').slice(0, 40), hubId, url, added: String(r.added || '').slice(0, 10) } });
created++; // with dry: counted, nothing written (it used to write anyway)
}
return json(res, 200, { ok: true, created, skipped, dry: !!b.dry });
}