Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b679e12
feat: Implement RedminePool class with unit tests
anatolyshipitz Jun 3, 2025
67eefc5
refactor: Improve RedminePool test structure and type safety
anatolyshipitz Jun 3, 2025
82062f3
fix: Enhance error handling in RedminePool class and tests
anatolyshipitz Jun 3, 2025
8f92d90
feat: Implement Redmine repository
anatolyshipitz Jun 4, 2025
c107265
fix: Update SQL query for time entries in Redmine integration
anatolyshipitz Jun 4, 2025
b49ce63
test: Add unit tests for RedmineRepository and RedmineService
anatolyshipitz Jun 4, 2025
683be91
Merge branch 'main' into feat/redmine-service
anatolyshipitz Jun 4, 2025
7875d77
Rename RedmineService and associated components to TargetUnitService
anatolyshipitz Jun 4, 2025
81ca5b0
Refactor ProjectUnit to TargetUnit across the codebase
anatolyshipitz Jun 4, 2025
f448f6e
Refactor method names from getProjectUnits to getTargetUnits in Targe…
anatolyshipitz Jun 5, 2025
a43ccf8
Merge branch 'main' into feat/redmine-service
anatolyshipitz Jun 5, 2025
d7e2c90
chore: Simplify TargetUnitRepository
anatolyshipitz Jun 5, 2025
1117c36
refactor: Update SQL query formatting in TargetUnit queries
anatolyshipitz Jun 5, 2025
f723157
fix: Remove console error logging in TargetUnitRepository
anatolyshipitz Jun 5, 2025
b698473
refactor: Simplify mapRowToTargetUnit method in TargetUnitRepository
anatolyshipitz Jun 5, 2025
88c6809
refactor: Remove TargetUnitService and its tests
anatolyshipitz Jun 5, 2025
35368da
feat: Implement TargetUnitService and its tests
anatolyshipitz Jun 5, 2025
1d9bbd1
Merge branch 'main' into feat/target-unit-service
anatolyshipitz Jun 5, 2025
9e733e2
Merge branch 'main' into feat/target-unit-service
anatolyshipitz Jun 6, 2025
6a7a358
Merge branch 'main' into feat/target-unit-service
anatolyshipitz Jun 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions workers/main/src/services/TargetUnit/TargetUnitService.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { afterEach, beforeEach, describe, expect, it, Mock, vi } from 'vitest';

import { TargetUnit } from '../../common/types';
import { TargetUnitService } from './TargetUnitService';

const createTargetUnit = (overrides: Partial<TargetUnit> = {}): TargetUnit => ({
group_id: 1,
group_name: 'Group',
project_id: 2,
project_name: 'Project',
user_id: 3,
username: 'User',
spent_on: '2024-06-01',
total_hours: 8,
...overrides,
});

const createMockRepo = () => ({
getTargetUnits: vi.fn(),
});

describe('TargetUnitService', () => {
let mockRepo: { getTargetUnits: Mock };
let service: TargetUnitService;

beforeEach(() => {
mockRepo = createMockRepo();
service = new TargetUnitService(mockRepo);
});

afterEach(() => {
vi.clearAllMocks();
});

it('should return project units from the repository', async () => {
const units = [createTargetUnit()];

mockRepo.getTargetUnits.mockResolvedValueOnce(units);

const result = await service.getTargetUnits();

expect(result).toEqual(units);
expect(mockRepo.getTargetUnits).toHaveBeenCalledTimes(1);
});
});
10 changes: 10 additions & 0 deletions workers/main/src/services/TargetUnit/TargetUnitService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { TargetUnit } from '../../common/types';
import { ITargetUnitRepository } from './ITargetUnitRepository';

export class TargetUnitService {
constructor(private repo: ITargetUnitRepository) {}

async getTargetUnits(): Promise<TargetUnit[]> {
return this.repo.getTargetUnits();
}
}