Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -1,15 +1,27 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { hostAgentUpdateLabel, hostAgentUpdateMessage, hostAgentUpdatesEnabled, type HostInventory } from '../../src/lib/hosts.js';
|
||||
import {
|
||||
hostAgentUpdateLabel,
|
||||
hostAgentUpdateMessage,
|
||||
hostAgentUpdatesEnabled,
|
||||
type HostInventory
|
||||
} from '../../src/lib/hosts.js';
|
||||
|
||||
const installed: HostInventory = {
|
||||
agentVersion: '1.2.0', capabilities: ['host.decommission', 'agent.update'],
|
||||
agentUpdate: { enabled: true, state: 'current', currentVersion: '1.2.0', checkedAt: '2026-10-04T12:00:00Z' }
|
||||
agentVersion: '1.2.0',
|
||||
capabilities: ['host.decommission', 'agent.update'],
|
||||
agentUpdate: {
|
||||
enabled: true,
|
||||
state: 'current',
|
||||
currentVersion: '1.2.0',
|
||||
checkedAt: '2026-10-04T12:00:00Z'
|
||||
}
|
||||
};
|
||||
|
||||
describe('host automatic update status', () => {
|
||||
it('requires the installed updater capability instead of inferring setup from agent version', () => {
|
||||
for (const inventory of [
|
||||
{}, { agentVersion: '1.2.0' },
|
||||
{},
|
||||
{ agentVersion: '1.2.0' },
|
||||
{ ...installed, capabilities: ['host.decommission'] },
|
||||
{ ...installed, agentUpdate: { ...installed.agentUpdate!, enabled: false } }
|
||||
]) {
|
||||
@@ -22,27 +34,60 @@ describe('host automatic update status', () => {
|
||||
});
|
||||
|
||||
it('does not claim an unchecked fresh installation has verified the latest release', () => {
|
||||
const fresh = { ...installed, agentUpdate: { ...installed.agentUpdate!, checkedAt: undefined } };
|
||||
const fresh = {
|
||||
...installed,
|
||||
agentUpdate: { ...installed.agentUpdate!, checkedAt: undefined }
|
||||
};
|
||||
expect(hostAgentUpdateLabel(fresh)).toBe('Awaiting first check');
|
||||
expect(hostAgentUpdateMessage(fresh)).toContain('will check');
|
||||
expect(hostAgentUpdateMessage(installed)).toContain('last check');
|
||||
});
|
||||
|
||||
it('distinguishes a deferred check from a failed update without assuming every hold is an active operation', () => {
|
||||
const deferred = { ...installed, agentUpdate: { ...installed.agentUpdate!, state: 'deferred' as const, targetVersion: '1.3.0' } };
|
||||
const deferred = {
|
||||
...installed,
|
||||
agentUpdate: {
|
||||
...installed.agentUpdate!,
|
||||
state: 'deferred' as const,
|
||||
targetVersion: '1.3.0'
|
||||
}
|
||||
};
|
||||
expect(hostAgentUpdateLabel(deferred)).toBe('Deferred');
|
||||
expect(hostAgentUpdateMessage(deferred)).toContain('reported condition to clear');
|
||||
expect(hostAgentUpdateMessage(deferred)).toContain('checks again automatically');
|
||||
const failed = { ...installed, agentUpdate: { ...installed.agentUpdate!, state: 'failed' as const, error: 'Checksum mismatch' } };
|
||||
const failed = {
|
||||
...installed,
|
||||
agentUpdate: {
|
||||
...installed.agentUpdate!,
|
||||
state: 'failed' as const,
|
||||
error: 'Checksum mismatch'
|
||||
}
|
||||
};
|
||||
expect(hostAgentUpdateLabel(failed)).toBe('Needs attention');
|
||||
expect(hostAgentUpdateMessage(failed)).toContain('did not complete');
|
||||
});
|
||||
|
||||
it('describes connection verification until the updater confirms success', () => {
|
||||
const updating = { ...installed, agentUpdate: { ...installed.agentUpdate!, state: 'updating' as const, targetVersion: '1.3.0' } };
|
||||
const updating = {
|
||||
...installed,
|
||||
agentUpdate: {
|
||||
...installed.agentUpdate!,
|
||||
state: 'updating' as const,
|
||||
targetVersion: '1.3.0'
|
||||
}
|
||||
};
|
||||
expect(hostAgentUpdateLabel(updating)).toBe('Updating');
|
||||
expect(hostAgentUpdateMessage(updating)).toContain('checking that the new process connects');
|
||||
const updated = { ...installed, agentUpdate: { ...installed.agentUpdate!, state: 'updated' as const, currentVersion: '1.3.0' } };
|
||||
expect(hostAgentUpdateMessage(updating)).toContain(
|
||||
'checking that the new process connects'
|
||||
);
|
||||
const updated = {
|
||||
...installed,
|
||||
agentUpdate: {
|
||||
...installed.agentUpdate!,
|
||||
state: 'updated' as const,
|
||||
currentVersion: '1.3.0'
|
||||
}
|
||||
};
|
||||
expect(hostAgentUpdateLabel(updated)).toBe('Updated');
|
||||
expect(hostAgentUpdateMessage(updated)).toContain('connected successfully');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user