Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -1,23 +1,72 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { provisioningQueueStatus, provisioningWarnings } from '../../src/lib/ui/provisioning-queue.js';
|
||||
import {
|
||||
provisioningQueueStatus,
|
||||
provisioningWarnings
|
||||
} from '../../src/lib/ui/provisioning-queue.js';
|
||||
|
||||
it('distinguishes capacity, occupancy, recovery and verification without inventing errors', () => {
|
||||
const row = { action: 'restart' as const, state: 'waiting', stage: 'Waiting' };
|
||||
expect(provisioningQueueStatus({ ...row, waitCode: 'restart-capacity' })).toMatchObject({ label: 'Queued for restart', tone: 'neutral', group: 'queued' });
|
||||
expect(provisioningQueueStatus({ ...row, stage: 'Queued to restart; waiting for another server to recover' })).toMatchObject({ group: 'queued' });
|
||||
expect(provisioningQueueStatus({ ...row, stage: 'Waiting for 3 player(s) to leave.' })).toMatchObject({ label: 'Waiting for empty lobby', group: 'waiting' });
|
||||
expect(provisioningQueueStatus({ ...row, stage: 'Waiting for a fresh local player count.' })).toMatchObject({ label: 'Checking lobby occupancy' });
|
||||
expect(provisioningQueueStatus({ ...row, waitCode: 'operation-conflict' })).toMatchObject({ label: 'Waiting for another operation' });
|
||||
expect(provisioningQueueStatus({ ...row, state: 'awaiting-health', waitCode: 'native-host', stage: 'Waiting for container readiness: starting' })).toMatchObject({ label: 'Verifying health', group: 'verifying' });
|
||||
expect(provisioningQueueStatus({ ...row, state: 'running', waitCode: 'native-host', stage: 'Waiting for startup capacity.' })).toMatchObject({ label: 'Waiting for capacity', group: 'queued' });
|
||||
expect(provisioningQueueStatus({ ...row, phase: 'cleanup' })).toMatchObject({ label: 'Cleaning up', group: 'running' });
|
||||
expect(provisioningQueueStatus({ ...row, waitCode: 'restart-capacity' })).toMatchObject({
|
||||
label: 'Queued for restart',
|
||||
tone: 'neutral',
|
||||
group: 'queued'
|
||||
});
|
||||
expect(
|
||||
provisioningQueueStatus({
|
||||
...row,
|
||||
stage: 'Queued to restart; waiting for another server to recover'
|
||||
})
|
||||
).toMatchObject({ group: 'queued' });
|
||||
expect(
|
||||
provisioningQueueStatus({ ...row, stage: 'Waiting for 3 player(s) to leave.' })
|
||||
).toMatchObject({ label: 'Waiting for empty lobby', group: 'waiting' });
|
||||
expect(
|
||||
provisioningQueueStatus({ ...row, stage: 'Waiting for a fresh local player count.' })
|
||||
).toMatchObject({ label: 'Checking lobby occupancy' });
|
||||
expect(provisioningQueueStatus({ ...row, waitCode: 'operation-conflict' })).toMatchObject({
|
||||
label: 'Waiting for another operation'
|
||||
});
|
||||
expect(
|
||||
provisioningQueueStatus({
|
||||
...row,
|
||||
state: 'awaiting-health',
|
||||
waitCode: 'native-host',
|
||||
stage: 'Waiting for container readiness: starting'
|
||||
})
|
||||
).toMatchObject({ label: 'Verifying health', group: 'verifying' });
|
||||
expect(
|
||||
provisioningQueueStatus({
|
||||
...row,
|
||||
state: 'running',
|
||||
waitCode: 'native-host',
|
||||
stage: 'Waiting for startup capacity.'
|
||||
})
|
||||
).toMatchObject({ label: 'Waiting for capacity', group: 'queued' });
|
||||
expect(provisioningQueueStatus({ ...row, phase: 'cleanup' })).toMatchObject({
|
||||
label: 'Cleaning up',
|
||||
group: 'running'
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps recorded terminal outcomes ahead of leftover progress and blockers', () => {
|
||||
const row = { action: 'restart' as const, state: 'done', stage: 'Old waiting text', waitCode: 'restart-capacity', phase: 'cleanup' };
|
||||
const row = {
|
||||
action: 'restart' as const,
|
||||
state: 'done',
|
||||
stage: 'Old waiting text',
|
||||
waitCode: 'restart-capacity',
|
||||
phase: 'cleanup'
|
||||
};
|
||||
expect(provisioningQueueStatus(row)).toMatchObject({ label: 'Complete', group: 'complete' });
|
||||
expect(provisioningQueueStatus({ ...row, state: 'failed' })).toMatchObject({ label: 'Failed', tone: 'danger', group: 'attention' });
|
||||
expect(provisioningQueueStatus({ ...row, state: 'cancelled' })).toMatchObject({ label: 'Cancelled', group: 'cancelled', tone: 'neutral' });
|
||||
expect(provisioningQueueStatus({ ...row, state: 'failed' })).toMatchObject({
|
||||
label: 'Failed',
|
||||
tone: 'danger',
|
||||
group: 'attention'
|
||||
});
|
||||
expect(provisioningQueueStatus({ ...row, state: 'cancelled' })).toMatchObject({
|
||||
label: 'Cancelled',
|
||||
group: 'cancelled',
|
||||
tone: 'neutral'
|
||||
});
|
||||
});
|
||||
|
||||
it('only displays strings from recorded warning arrays', () => {
|
||||
|
||||
Reference in New Issue
Block a user