Files
ForgeFlow/tests/audit-service.test.mjs
NuklearRabbit 4ad698c4eb Release ForgeFlow 0.8.1
Add advanced Git and deployment workflows, secure backups and auditing, live Gitea integration, desktop notifications, connection validation, and the premium responsive UX refresh.
2026-07-26 00:42:17 +02:00

26 lines
1.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import os from 'node:os';
import path from 'node:path';
import fs from 'node:fs/promises';
import auditModule from '../src/main/audit-service.cjs';
const { AuditService } = auditModule;
test('audit service appends ordered records and exports CSV', async (t) => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'forgeflow-audit-'));
t.after(() => fs.rm(root, { recursive: true, force: true }));
const audit = new AuditService({ userDataPath: root, appInfo: { version: 'test' } });
await Promise.all([
audit.append('deployment.requested', { repository: 'owner/app', sha: 'a'.repeat(40), note: 'Release, wave 1' }),
audit.append('deployment.completed', { repository: 'owner/app', result: 'success' })
]);
const entries = await audit.list();
assert.equal(entries.length, 2);
assert.equal(entries[0].event, 'deployment.completed');
const destination = path.join(root, 'audit.csv');
const result = await audit.exportTo(destination, 'csv');
assert.equal(result.count, 2);
assert.match(await fs.readFile(destination, 'utf8'), /"Release, wave 1"/);
});