/* * Deterministic seed for the REST smoke test. * Run against the local Mongo used by the dev Meteor server, e.g.: * docker exec -i tcef-mongo32 mongo fuegos < smoke/seed.js * * It resets the collections the REST API reads/writes to a fixed, known state * so that endpoint responses are reproducible across Meteor upgrade escalas. * Only test-owned documents are touched. */ // --- Fixed identifiers (24-hex ObjectIds) ------------------------------- var FIRE_A = ObjectId('a0000000000000000000000a'); var FIRE_B = ObjectId('b0000000000000000000000b'); var ARCHIVE_FIRE = ObjectId('c0000000000000000000000c'); var MOBILE_TOKEN = 'smoke-mobile-token'; // Madrid-ish coordinates var LAT = 40.41; var LON = -3.70; var WHEN = ISODate('2024-01-01T00:00:00.000Z'); var WHEN_B = ISODate('2024-01-02T00:00:00.000Z'); // later, so last-fire-detected is deterministic var FIXED = ISODate('2024-01-01T00:00:00.000Z'); // --- activefires -------------------------------------------------------- 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: '2024-01-01', acq_time: '00:00', 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: '2024-01-01', acq_time: '00:05', 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' }); // --- fires (archive) — must match the sealed fire used by mobile/falsepositive db.fires.deleteMany({}); db.fires.insertOne({ _id: ARCHIVE_FIRE, ourid: { type: 'Point', coordinates: [LON, LAT] }, lat: LAT, lon: LON, type: 'viirs', when: WHEN, scan: 0.5, track: 0.4, address: 'Madrid, Spain', createdAt: FIXED, updatedAt: FIXED }); db.fires.createIndex({ ourid: '2dsphere' }); // --- falsePositives / industries: empty so "real fire" counting is stable db.falsePositives.deleteMany({}); db.industries.deleteMany({}); db.industries.createIndex({ geo: '2dsphere' }); // --- subscriptions: clean; index for geo queries db.subscriptions.deleteMany({}); db.subscriptions.createIndex({ geo: '2dsphere' }); // --- siteSettings consumed by status endpoints -------------------------- db.siteSettings.deleteMany({ name: { $in: ['last-fire-check', 'subs-public-union', 'subs-public-union-bounds'] } }); db.siteSettings.insertMany([ { _id: ObjectId('51e00000000000000000000c'), name: 'last-fire-check', value: FIXED, createdAt: FIXED, updatedAt: FIXED }, { _id: ObjectId('51e0000000000000000000a1'), name: 'subs-public-union', value: JSON.stringify({ type: 'Feature', geometry: { type: 'MultiPolygon', coordinates: [[[[LON - 1, LAT - 1], [LON + 1, LAT - 1], [LON + 1, LAT + 1], [LON - 1, LAT + 1], [LON - 1, LAT - 1]]]] } }), createdAt: FIXED, updatedAt: FIXED }, { _id: ObjectId('51e0000000000000000000b2'), name: 'subs-public-union-bounds', value: JSON.stringify({ ne: { lat: LAT + 1, lon: LON + 1 }, sw: { lat: LAT - 1, lon: LON - 1 } }), createdAt: FIXED, updatedAt: FIXED } ]); // --- users: remove any previous smoke user so mobile/users creates fresh db.users.deleteMany({ fireBaseToken: MOBILE_TOKEN }); print('seed OK: activefires=' + db.activefires.count() + ' fires=' + db.fires.count() + ' siteSettings=' + db.siteSettings.count({ name: /fire|union/ }));