|
|
|
|
@ -16,7 +16,7 @@ process.env.RUNTIME_CONFIG_FILE = temporaryRuntime;
|
|
|
|
|
process.env.EZO_MODE = 'demo';
|
|
|
|
|
|
|
|
|
|
const { app, HISTORY_FILES } = require('../api/server');
|
|
|
|
|
const { collectReadings } = require('../api/acquisition-service');
|
|
|
|
|
const { collectReadings, publishReading } = require('../api/acquisition-service');
|
|
|
|
|
|
|
|
|
|
let server;
|
|
|
|
|
let baseUrl;
|
|
|
|
|
@ -140,6 +140,20 @@ test('demo acquisition writes live JSON and CSV files', async () => {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('hardware null readings are marked offline and not appended as zero', async () => {
|
|
|
|
|
const timestamp = new Date().toISOString();
|
|
|
|
|
const csvPath = path.join(temporaryLogs, 'ph.csv');
|
|
|
|
|
fs.rmSync(csvPath, { force: true });
|
|
|
|
|
|
|
|
|
|
const online = await publishReading('ph', null, timestamp, 'hardware');
|
|
|
|
|
const data = JSON.parse(fs.readFileSync(path.join(temporaryData, 'EZOPH.json')));
|
|
|
|
|
|
|
|
|
|
assert.equal(online, false);
|
|
|
|
|
assert.equal(data.online, false);
|
|
|
|
|
assert.equal(data.error, 'Lectura no disponible');
|
|
|
|
|
assert.equal(fs.existsSync(csvPath), false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('clears historical CSV files and preserves headers', async () => {
|
|
|
|
|
for (const name of Object.keys(HISTORY_FILES)) {
|
|
|
|
|
fs.writeFileSync(path.join(temporaryLogs, `${name}.csv`), 'old,data\n1,2\n');
|
|
|
|
|
|