Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+28 -5
View File
@@ -1,15 +1,38 @@
import { describe, expect, it } from 'vitest';
import { validateInventory } from '../../src/lib/server/hosts/index.js';
const update = { enabled: true, state: 'updated', currentVersion: '1.2.0', targetVersion: '1.2.0', checkedAt: '2026-10-04T12:00:00Z' };
const update = {
enabled: true,
state: 'updated',
currentVersion: '1.2.0',
targetVersion: '1.2.0',
checkedAt: '2026-10-04T12:00:00Z'
};
describe('agent update inventory', () => {
it('accepts legacy inventory and only publishes recognized update display fields', () => {
expect(validateInventory({ protocolVersion: 1 })).toEqual({ protocolVersion: 1 });
expect(validateInventory({ agentUpdate: { ...update, credential: 'private', journal: { backups: 'local-path' } } }).agentUpdate).toEqual(update);
expect(
validateInventory({
agentUpdate: {
...update,
credential: 'private',
journal: { backups: 'local-path' }
}
}).agentUpdate
).toEqual(update);
});
it.each([null, [], 'updated', { ...update, enabled: 'yes' }, { ...update, state: '<script>' },
{ ...update, currentVersion: {} }, { ...update, targetVersion: 'invalid' }, { ...update, checkedAt: 'invalid' },
{ ...update, error: {} }, { ...update, error: 'x'.repeat(2001) }])('rejects invalid update metadata %j', agentUpdate => {
it.each([
null,
[],
'updated',
{ ...update, enabled: 'yes' },
{ ...update, state: '<script>' },
{ ...update, currentVersion: {} },
{ ...update, targetVersion: 'invalid' },
{ ...update, checkedAt: 'invalid' },
{ ...update, error: {} },
{ ...update, error: 'x'.repeat(2001) }
])('rejects invalid update metadata %j', (agentUpdate) => {
expect(() => validateInventory({ agentUpdate })).toThrow('Invalid agent update inventory');
});
});