working companion prototype

This commit is contained in:
2025-11-24 23:32:36 +01:00
parent e7978024d7
commit e2bea9a126
175 changed files with 23227 additions and 3519 deletions

View File

@@ -130,7 +130,7 @@ describe('AutomationSession Entity', () => {
);
});
it('should stop at step 18 (safety checkpoint)', () => {
it('should stop at step 17 (safety checkpoint)', () => {
const session = AutomationSession.create({
sessionName: 'Test Race',
trackId: 'spa',
@@ -138,12 +138,12 @@ describe('AutomationSession Entity', () => {
});
session.start();
// Advance through all steps to 18
for (let i = 2; i <= 18; i++) {
// Advance through all steps to 17
for (let i = 2; i <= 17; i++) {
session.transitionToStep(StepId.create(i));
}
expect(session.currentStep.value).toBe(18);
expect(session.currentStep.value).toBe(17);
expect(session.state.isStoppedAtStep18()).toBe(true);
expect(session.completedAt).toBeDefined();
});
@@ -252,8 +252,8 @@ describe('AutomationSession Entity', () => {
});
session.start();
// Advance to step 18
for (let i = 2; i <= 18; i++) {
// Advance to step 17
for (let i = 2; i <= 17; i++) {
session.transitionToStep(StepId.create(i));
}
@@ -351,8 +351,8 @@ describe('AutomationSession Entity', () => {
});
session.start();
// Advance to step 18
for (let i = 2; i <= 18; i++) {
// Advance to step 17
for (let i = 2; i <= 17; i++) {
session.transitionToStep(StepId.create(i));
}

View File

@@ -129,16 +129,16 @@ describe('StepTransitionValidator Service', () => {
});
describe('shouldStopAtStep18', () => {
it('should return true when transitioning to step 18', () => {
const nextStep = StepId.create(18);
it('should return true when transitioning to step 17 (final step)', () => {
const nextStep = StepId.create(17);
const shouldStop = StepTransitionValidator.shouldStopAtStep18(nextStep);
expect(shouldStop).toBe(true);
});
it('should return false for steps before 18', () => {
const nextStep = StepId.create(17);
it('should return false for steps before 17', () => {
const nextStep = StepId.create(16);
const shouldStop = StepTransitionValidator.shouldStopAtStep18(nextStep);
@@ -171,8 +171,8 @@ describe('StepTransitionValidator Service', () => {
expect(description).toBe('Add Admin (Modal)');
});
it('should return description for step 18 (final)', () => {
const step = StepId.create(18);
it('should return description for step 17 (final)', () => {
const step = StepId.create(17);
const description = StepTransitionValidator.getStepDescription(step);
@@ -195,7 +195,7 @@ describe('StepTransitionValidator Service', () => {
const state = SessionState.create('IN_PROGRESS');
let currentStep = StepId.create(1);
for (let i = 2; i <= 18; i++) {
for (let i = 2; i <= 17; i++) {
const nextStep = StepId.create(i);
const result = StepTransitionValidator.canTransition(currentStep, nextStep, state);

View File

@@ -8,21 +8,21 @@ describe('StepId Value Object', () => {
expect(stepId.value).toBe(1);
});
it('should create a valid StepId for step 18', () => {
const stepId = StepId.create(18);
expect(stepId.value).toBe(18);
it('should create a valid StepId for step 17', () => {
const stepId = StepId.create(17);
expect(stepId.value).toBe(17);
});
it('should throw error for step 0 (below minimum)', () => {
expect(() => StepId.create(0)).toThrow('StepId must be between 1 and 18');
expect(() => StepId.create(0)).toThrow('StepId must be between 1 and 17');
});
it('should throw error for step 19 (above maximum)', () => {
expect(() => StepId.create(19)).toThrow('StepId must be between 1 and 18');
it('should throw error for step 18 (above maximum)', () => {
expect(() => StepId.create(18)).toThrow('StepId must be between 1 and 17');
});
it('should throw error for negative step', () => {
expect(() => StepId.create(-1)).toThrow('StepId must be between 1 and 18');
expect(() => StepId.create(-1)).toThrow('StepId must be between 1 and 17');
});
it('should throw error for non-integer step', () => {
@@ -67,13 +67,13 @@ describe('StepId Value Object', () => {
});
describe('isFinalStep', () => {
it('should return true for step 18', () => {
const stepId = StepId.create(18);
it('should return true for step 17', () => {
const stepId = StepId.create(17);
expect(stepId.isFinalStep()).toBe(true);
});
it('should return false for step 17', () => {
const stepId = StepId.create(17);
it('should return false for step 16', () => {
const stepId = StepId.create(16);
expect(stepId.isFinalStep()).toBe(false);
});
@@ -90,14 +90,14 @@ describe('StepId Value Object', () => {
expect(nextStep.value).toBe(2);
});
it('should return next step for step 17', () => {
const stepId = StepId.create(17);
it('should return next step for step 16', () => {
const stepId = StepId.create(16);
const nextStep = stepId.next();
expect(nextStep.value).toBe(18);
expect(nextStep.value).toBe(17);
});
it('should throw error when calling next on step 18', () => {
const stepId = StepId.create(18);
it('should throw error when calling next on step 17', () => {
const stepId = StepId.create(17);
expect(() => stepId.next()).toThrow('Cannot advance beyond final step');
});
});

View File

@@ -52,13 +52,13 @@ describe('AutomationConfig', () => {
expect(mode).toBe('test');
});
it('should return production mode when NODE_ENV=development', () => {
it('should return development mode when NODE_ENV=development', () => {
process.env.NODE_ENV = 'development';
delete process.env.AUTOMATION_MODE;
const mode = getAutomationMode();
expect(mode).toBe('production');
expect(mode).toBe('development');
});
});
@@ -128,7 +128,7 @@ describe('AutomationConfig', () => {
const config = loadAutomationConfig();
expect(config.nutJs?.windowTitle).toBe('iRacing');
expect(config.nutJs?.templatePath).toBe('./resources/templates');
expect(config.nutJs?.templatePath).toBe('./resources/templates/iracing');
expect(config.nutJs?.confidence).toBe(0.9);
});