/* * Deterministic seed for the browser e2e suite (mongosh script). * * ⚠️ DESTRUCTIVE: it empties the collections it seeds. It is only ever meant for * the throwaway Mongo of docker-compose.e2e.yml (or a local scratch one). Never * point it at staging or production — that is what e2e/seed.sh guards against. * * mongosh --host localhost:27021 fuegos e2e/seed.js * * The subscriptions collection is deliberately NOT seeded: the whole point of * the zone spec is to create one through the UI and watch the union appear. */ var FIRE_A = ObjectId('e2e0000000000000000000a1'); var FIRE_B = ObjectId('e2e0000000000000000000b2'); // Madrid, so a zone created around the map's default view sees them. var LAT = 40.41; var LON = -3.70; var WHEN = ISODate('2026-07-30T05:30:00.000Z'); var WHEN_B = ISODate('2026-07-30T06:30:00.000Z'); var FIXED = ISODate('2026-07-30T00:00:00.000Z'); db.activefires.deleteMany({}); db.activefires.insertMany([ { _id: FIRE_A, ourid: { type: 'Point', coordinates: [LON, LAT] }, lat: LAT, lon: LON, type: 'viirs', when: WHEN, scan: 0.5, track: 0.4, acq_date: '2026-07-30', acq_time: '05:30', satellite: 'N', confidence: 50, version: '1.0NRT', frp: 4.3, daynight: 'N', bright_ti4: 330.2, bright_ti5: 291, createdAt: FIXED, updatedAt: FIXED }, { _id: FIRE_B, ourid: { type: 'Point', coordinates: [LON + 0.02, LAT + 0.02] }, lat: LAT + 0.02, lon: LON + 0.02, type: 'viirs', when: WHEN_B, scan: 0.5, track: 0.4, acq_date: '2026-07-30', acq_time: '06:30', satellite: 'N', confidence: 60, version: '1.0NRT', frp: 6.1, daynight: 'N', bright_ti4: 331.0, bright_ti5: 292, createdAt: FIXED, updatedAt: FIXED } ]); db.activefires.createIndex({ ourid: '2dsphere' }); db.activefiresunion.deleteMany({}); db.activefiresunion.createIndex({ shape: '2dsphere' }); db.comments.deleteMany({}); db.falsePositives.deleteMany({}); db.industries.deleteMany({}); // Anything left over from a previous run of the suite: users it created, their // zones, and the stored union computed from them. db.subscriptions.deleteMany({}); db.users.deleteMany({ 'emails.address': /^e2e\+/ }); db.siteSettings.deleteMany({ name: /^subs-(public|private)-union/ }); db.siteSettings.deleteMany({ name: 'subs-union-count' }); print('e2e seed OK: ' + db.activefires.countDocuments({}) + ' active fires, 0 subscriptions');