MotorSignal-App/docs/qa-2026-10-01/auth.cleanup.mjs

17 lines
1.1 KiB
JavaScript

// Run only after every browser/device owner has released these demo fixtures.
import {writeFileSync} from 'node:fs';
const project='demo-motorsignal-qa';
const results=[];
for(const [service,url] of [
['auth',`http://127.0.0.1:9099/emulator/v1/projects/${project}/accounts`],
['firestore',`http://127.0.0.1:8088/emulator/v1/projects/${project}/databases/(default)/documents`],
]){
const response=await fetch(url,{method:'DELETE'});
results.push({service,status:response.status,success:response.ok});
if(!response.ok)throw Error(`${service} cleanup failed (${response.status})`);
}
const check=await fetch(`http://127.0.0.1:9099/identitytoolkit.googleapis.com/v1/projects/${project}/accounts:batchGet`);
if(check.ok){const data=await check.json();results.push({service:'auth-verification',remainingUsers:(data.users??[]).length});if((data.users??[]).length)throw Error('Accounts remain');}
writeFileSync(new URL('auth.cleanup-results.json',import.meta.url),JSON.stringify({project,executedAt:new Date().toISOString(),results},null,2));
console.log(JSON.stringify(results));