test(frontend): comprehensive test coverage improvements and bug fixes
- Raise coverage thresholds to 90% statements/lines/functions, 85% branches - Add comprehensive tests for ProjectDashboard, ProjectWizard, and all wizard steps - Add tests for issue management: IssueDetailPanel, BulkActions, IssueFilters - Expand IssueTable tests with keyboard navigation, dropdown menu, edge cases - Add useIssues hook tests covering all mutations and optimistic updates - Expand eventStore tests with selector hooks and additional scenarios - Expand useProjectEvents tests with error recovery, ping events, edge cases - Add PriorityBadge, StatusBadge, SyncStatusIndicator fallback branch tests - Add constants.test.ts for comprehensive constant validation Bug fixes: - Fix false positive rollback test to properly verify onMutate context setup - Replace deprecated substr() with substring() in mock helpers - Fix type errors: ProjectComplexity, ClientMode enum values - Fix unused imports and variables across test files - Fix @ts-expect-error directives and method override signatures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
193
frontend/tests/features/issues/constants.test.ts
Normal file
193
frontend/tests/features/issues/constants.test.ts
Normal file
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
* Issue Constants Tests
|
||||
*
|
||||
* Tests for issue-related constants and helper functions.
|
||||
*/
|
||||
|
||||
import {
|
||||
STATUS_CONFIG,
|
||||
PRIORITY_CONFIG,
|
||||
STATUS_TRANSITIONS,
|
||||
STATUS_ORDER,
|
||||
PRIORITY_ORDER,
|
||||
SYNC_STATUS_CONFIG,
|
||||
DEFAULT_PAGE_SIZE,
|
||||
MAX_BULK_SELECTION,
|
||||
getAvailableTransitions,
|
||||
getPrimaryTransition,
|
||||
} from '@/features/issues/constants';
|
||||
import type { IssueStatus } from '@/features/issues/types';
|
||||
|
||||
describe('Issue Constants', () => {
|
||||
describe('STATUS_CONFIG', () => {
|
||||
it('has configuration for all statuses', () => {
|
||||
expect(STATUS_CONFIG.open).toBeDefined();
|
||||
expect(STATUS_CONFIG.in_progress).toBeDefined();
|
||||
expect(STATUS_CONFIG.in_review).toBeDefined();
|
||||
expect(STATUS_CONFIG.blocked).toBeDefined();
|
||||
expect(STATUS_CONFIG.closed).toBeDefined();
|
||||
});
|
||||
|
||||
it('each status has label and color', () => {
|
||||
Object.values(STATUS_CONFIG).forEach((config) => {
|
||||
expect(config.label).toBeDefined();
|
||||
expect(config.color).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('PRIORITY_CONFIG', () => {
|
||||
it('has configuration for all priorities', () => {
|
||||
expect(PRIORITY_CONFIG.critical).toBeDefined();
|
||||
expect(PRIORITY_CONFIG.high).toBeDefined();
|
||||
expect(PRIORITY_CONFIG.medium).toBeDefined();
|
||||
expect(PRIORITY_CONFIG.low).toBeDefined();
|
||||
});
|
||||
|
||||
it('each priority has label and color', () => {
|
||||
Object.values(PRIORITY_CONFIG).forEach((config) => {
|
||||
expect(config.label).toBeDefined();
|
||||
expect(config.color).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('STATUS_TRANSITIONS', () => {
|
||||
it('contains expected transitions', () => {
|
||||
expect(STATUS_TRANSITIONS.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('each transition has from, to, and label', () => {
|
||||
STATUS_TRANSITIONS.forEach((transition) => {
|
||||
expect(transition.from).toBeDefined();
|
||||
expect(transition.to).toBeDefined();
|
||||
expect(transition.label).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAvailableTransitions', () => {
|
||||
it('returns transitions for open status', () => {
|
||||
const transitions = getAvailableTransitions('open');
|
||||
expect(transitions.length).toBeGreaterThan(0);
|
||||
expect(transitions.every((t) => t.from === 'open')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns transitions for in_progress status', () => {
|
||||
const transitions = getAvailableTransitions('in_progress');
|
||||
expect(transitions.length).toBeGreaterThan(0);
|
||||
expect(transitions.every((t) => t.from === 'in_progress')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns transitions for in_review status', () => {
|
||||
const transitions = getAvailableTransitions('in_review');
|
||||
expect(transitions.length).toBeGreaterThan(0);
|
||||
expect(transitions.every((t) => t.from === 'in_review')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns transitions for blocked status', () => {
|
||||
const transitions = getAvailableTransitions('blocked');
|
||||
expect(transitions.length).toBeGreaterThan(0);
|
||||
expect(transitions.every((t) => t.from === 'blocked')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns transitions for closed status', () => {
|
||||
const transitions = getAvailableTransitions('closed');
|
||||
expect(transitions.length).toBeGreaterThan(0);
|
||||
expect(transitions.every((t) => t.from === 'closed')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns empty array for unknown status', () => {
|
||||
const transitions = getAvailableTransitions('unknown' as IssueStatus);
|
||||
expect(transitions).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPrimaryTransition', () => {
|
||||
it('returns first transition for open status', () => {
|
||||
const transition = getPrimaryTransition('open');
|
||||
expect(transition).toBeDefined();
|
||||
expect(transition?.from).toBe('open');
|
||||
});
|
||||
|
||||
it('returns first transition for in_progress status', () => {
|
||||
const transition = getPrimaryTransition('in_progress');
|
||||
expect(transition).toBeDefined();
|
||||
expect(transition?.from).toBe('in_progress');
|
||||
});
|
||||
|
||||
it('returns first transition for in_review status', () => {
|
||||
const transition = getPrimaryTransition('in_review');
|
||||
expect(transition).toBeDefined();
|
||||
expect(transition?.from).toBe('in_review');
|
||||
});
|
||||
|
||||
it('returns first transition for blocked status', () => {
|
||||
const transition = getPrimaryTransition('blocked');
|
||||
expect(transition).toBeDefined();
|
||||
expect(transition?.from).toBe('blocked');
|
||||
});
|
||||
|
||||
it('returns first transition for closed status', () => {
|
||||
const transition = getPrimaryTransition('closed');
|
||||
expect(transition).toBeDefined();
|
||||
expect(transition?.from).toBe('closed');
|
||||
});
|
||||
|
||||
it('returns undefined for unknown status', () => {
|
||||
const transition = getPrimaryTransition('unknown' as IssueStatus);
|
||||
expect(transition).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('STATUS_ORDER', () => {
|
||||
it('contains all statuses in order', () => {
|
||||
expect(STATUS_ORDER).toContain('open');
|
||||
expect(STATUS_ORDER).toContain('in_progress');
|
||||
expect(STATUS_ORDER).toContain('in_review');
|
||||
expect(STATUS_ORDER).toContain('blocked');
|
||||
expect(STATUS_ORDER).toContain('closed');
|
||||
});
|
||||
|
||||
it('has correct length', () => {
|
||||
expect(STATUS_ORDER.length).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PRIORITY_ORDER', () => {
|
||||
it('contains all priorities in order', () => {
|
||||
expect(PRIORITY_ORDER).toContain('critical');
|
||||
expect(PRIORITY_ORDER).toContain('high');
|
||||
expect(PRIORITY_ORDER).toContain('medium');
|
||||
expect(PRIORITY_ORDER).toContain('low');
|
||||
});
|
||||
|
||||
it('has correct length', () => {
|
||||
expect(PRIORITY_ORDER.length).toBe(4);
|
||||
});
|
||||
|
||||
it('has correct order (critical first, low last)', () => {
|
||||
expect(PRIORITY_ORDER[0]).toBe('critical');
|
||||
expect(PRIORITY_ORDER[PRIORITY_ORDER.length - 1]).toBe('low');
|
||||
});
|
||||
});
|
||||
|
||||
describe('SYNC_STATUS_CONFIG', () => {
|
||||
it('has configuration for all sync statuses', () => {
|
||||
expect(SYNC_STATUS_CONFIG.synced).toBeDefined();
|
||||
expect(SYNC_STATUS_CONFIG.pending).toBeDefined();
|
||||
expect(SYNC_STATUS_CONFIG.conflict).toBeDefined();
|
||||
expect(SYNC_STATUS_CONFIG.error).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pagination and Bulk Constants', () => {
|
||||
it('DEFAULT_PAGE_SIZE is a positive number', () => {
|
||||
expect(DEFAULT_PAGE_SIZE).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('MAX_BULK_SELECTION is a positive number', () => {
|
||||
expect(MAX_BULK_SELECTION).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user