remove companion tests

This commit is contained in:
2026-01-03 15:58:04 +01:00
parent afbe42b0e1
commit e151fe02d0
36 changed files with 10 additions and 5735 deletions

View File

@@ -1,140 +0,0 @@
// @ts-nocheck
/**
* Unit tests for CheckoutConfirmationDialog component.
* Tests the UI rendering and IPC communication for checkout confirmation.
*/
import React from 'react';
import { describe, it, expect, vi, beforeEach, beforeAll } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { act } from 'react';
import { CheckoutConfirmationDialog } from '../../../apps/companion/renderer/components/CheckoutConfirmationDialog';
// Mock window.electronAPI
const mockConfirmCheckout = vi.fn();
describe('CheckoutConfirmationDialog', () => {
beforeAll(() => {
// Set up window.electronAPI mock for all tests
Object.defineProperty(window, 'electronAPI', {
writable: true,
value: {
confirmCheckout: mockConfirmCheckout,
},
});
});
const mockRequest = {
price: '$0.50',
state: 'ready' as const,
sessionMetadata: {
sessionName: 'Test Race',
trackId: 'spa',
carIds: ['porsche_911_gt3_r'],
},
timeoutMs: 60000,
};
beforeEach(() => {
mockConfirmCheckout.mockClear();
});
describe('Rendering', () => {
it('should render dialog with price and session info', () => {
render(<CheckoutConfirmationDialog request={mockRequest} />);
expect(screen.getByText(/Confirm Checkout/i)).toBeInTheDocument();
expect(screen.getByText(/\$0\.50/)).toBeInTheDocument();
expect(screen.getByText(/Test Race/)).toBeInTheDocument();
});
it('should render confirm and cancel buttons', () => {
render(<CheckoutConfirmationDialog request={mockRequest} />);
expect(screen.getByRole('button', { name: /confirm/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /cancel/i })).toBeInTheDocument();
});
it('should display track and car information', () => {
render(<CheckoutConfirmationDialog request={mockRequest} />);
expect(screen.getByText(/spa/i)).toBeInTheDocument();
expect(screen.getByText(/porsche/i)).toBeInTheDocument();
});
it('should show warning when state is insufficient funds', () => {
const insufficientFundsRequest = {
...mockRequest,
state: 'insufficient_funds' as const,
};
render(<CheckoutConfirmationDialog request={insufficientFundsRequest} />);
expect(screen.getByText(/insufficient/i)).toBeInTheDocument();
});
});
describe('IPC Communication', () => {
it('should emit checkout:confirm with "confirmed" when confirm button clicked', () => {
render(<CheckoutConfirmationDialog request={mockRequest} />);
const confirmButton = screen.getByRole('button', { name: /confirm/i });
fireEvent.click(confirmButton);
expect(mockConfirmCheckout).toHaveBeenCalledWith('confirmed');
});
it('should emit checkout:confirm with "cancelled" when cancel button clicked', () => {
render(<CheckoutConfirmationDialog request={mockRequest} />);
const cancelButton = screen.getByRole('button', { name: /cancel/i });
fireEvent.click(cancelButton);
expect(mockConfirmCheckout).toHaveBeenCalledWith('cancelled');
});
it('should emit checkout:confirm with "timeout" when timeout expires', async () => {
vi.useFakeTimers();
const shortTimeoutRequest = {
...mockRequest,
timeoutMs: 1000,
};
render(<CheckoutConfirmationDialog request={shortTimeoutRequest} />);
// Fast-forward time past timeout
vi.advanceTimersByTime(1100);
expect(mockConfirmCheckout).toHaveBeenCalledWith('timeout');
vi.useRealTimers();
});
});
describe('Countdown Timer', () => {
it('should display countdown timer', () => {
render(<CheckoutConfirmationDialog request={mockRequest} />);
expect(screen.getByText(/60/)).toBeInTheDocument();
});
it('should update countdown every second', async () => {
vi.useFakeTimers();
render(<CheckoutConfirmationDialog request={mockRequest} />);
expect(screen.getByText(/60/)).toBeInTheDocument();
await act(async () => {
vi.advanceTimersByTime(1000);
await Promise.resolve();
});
expect(screen.getByText(/59/)).toBeInTheDocument();
vi.useRealTimers();
});
});
});

View File

@@ -1,55 +0,0 @@
// @ts-nocheck
/**
* Unit tests for RaceCreationSuccessScreen component.
* Tests the UI rendering of race creation success result.
*/
import React from 'react';
import { describe, it, expect, beforeEach } from 'vitest';
import { render, screen } from '@testing-library/react';
import { RaceCreationSuccessScreen } from '../../../apps/companion/renderer/components/RaceCreationSuccessScreen';
describe('RaceCreationSuccessScreen', () => {
const mockResult = {
sessionId: 'race-12345',
sessionName: 'Test Race',
trackId: 'spa',
carIds: ['porsche_911_gt3_r'],
finalPrice: '$0.50',
createdAt: new Date('2025-11-25T22:00:00.000Z'),
};
describe('Rendering', () => {
it('should render success message', () => {
render(<RaceCreationSuccessScreen result={mockResult} />);
expect(screen.getByText(/success/i)).toBeInTheDocument();
});
it('should display session information', () => {
render(<RaceCreationSuccessScreen result={mockResult} />);
expect(screen.getByText(/Test Race/)).toBeInTheDocument();
expect(screen.getByText(/race-12345/)).toBeInTheDocument();
});
it('should display track and car information', () => {
render(<RaceCreationSuccessScreen result={mockResult} />);
expect(screen.getByText(/spa/i)).toBeInTheDocument();
expect(screen.getByText(/porsche/i)).toBeInTheDocument();
});
it('should display final price', () => {
render(<RaceCreationSuccessScreen result={mockResult} />);
expect(screen.getByText(/\$0\.50/)).toBeInTheDocument();
});
it('should display creation timestamp', () => {
render(<RaceCreationSuccessScreen result={mockResult} />);
expect(screen.getByText(/2025-11-25/)).toBeInTheDocument();
});
});
});

View File

@@ -1,102 +0,0 @@
// @ts-nocheck
import React from 'react';
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import { SessionProgressMonitor } from '../../../../apps/companion/renderer/components/SessionProgressMonitor';
describe('SessionProgressMonitor', () => {
describe('step display', () => {
it('should display exactly 17 steps', () => {
const progress = {
sessionId: 'test-session-id',
currentStep: 1,
state: 'IN_PROGRESS',
completedSteps: [],
hasError: false,
errorMessage: null
};
render(
<SessionProgressMonitor
sessionId="test-session-id"
progress={progress}
isRunning={true}
/>
);
// Should have exactly 17 step elements
const stepElements = screen.getAllByText(/Navigate to Hosted Racing|Click Create a Race|Fill Race Information|Configure Server Details|Set Admins|Add Admin|Set Time Limits|Set Cars|Add Car|Set Car Classes|Set Track|Add Track|Configure Track Options|Set Time of Day|Configure Weather|Set Race Options|Set Track Conditions/);
expect(stepElements).toHaveLength(17);
});
it('should NOT display "Configure Team Driving" step', () => {
const progress = {
sessionId: 'test-session-id',
currentStep: 1,
state: 'IN_PROGRESS',
completedSteps: [],
hasError: false,
errorMessage: null
};
render(
<SessionProgressMonitor
sessionId="test-session-id"
progress={progress}
isRunning={true}
/>
);
// Should NOT find "Configure Team Driving"
expect(screen.queryByText('Configure Team Driving')).toBeNull();
});
it('should display "Set Track Conditions" as step 17', () => {
const progress = {
sessionId: 'test-session-id',
currentStep: 17,
state: 'IN_PROGRESS',
completedSteps: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
hasError: false,
errorMessage: null
};
render(
<SessionProgressMonitor
sessionId="test-session-id"
progress={progress}
isRunning={true}
/>
);
// Should find "Set Track Conditions" and it should be marked as current
const trackConditionsElement = screen.getByText('Set Track Conditions');
expect(trackConditionsElement).toBeTruthy();
// Verify progress shows 16 / 17 (since we're on step 17 but haven't completed it yet)
expect(screen.getByText(/Progress: 16 \/ 17 steps/)).toBeTruthy();
});
it('should show correct progress count with 17 total steps', () => {
const progress = {
sessionId: 'test-session-id',
currentStep: 5,
state: 'IN_PROGRESS',
completedSteps: [1, 2, 3, 4],
hasError: false,
errorMessage: null
};
render(
<SessionProgressMonitor
sessionId="test-session-id"
progress={progress}
isRunning={true}
/>
);
// Should show "4 / 17 steps"
expect(screen.getByText(/Progress: 4 \/ 17 steps/)).toBeTruthy();
});
});
});