import { TaskWorklogService } from './task-worklog.service';

describe('TaskWorklogService append writes', () => {
  it('appends task worklogs as relational evidence rows', async () => {
    const prisma = {
      taskWorklog: {
        create: jest.fn().mockResolvedValue({ id: 'wl-1' }),
        deleteMany: jest.fn(),
        findMany: jest.fn(),
      },
    };
    const service = new TaskWorklogService(prisma as any);

    await service.create({
      taskId: 'task-1',
      userId: 'member-1',
      date: '2026-07-08',
      hours: 2,
      workContent: '补充日报',
      versionId: 'version-1',
    });

    expect(prisma.taskWorklog.create).toHaveBeenCalledWith({
      data: expect.objectContaining({
        sourceType: 'dev_task',
        sourceId: 'task-1',
        sourceVersionId: 'version-1',
        versionId: 'version-1',
        userId: 'member-1',
        workDate: new Date('2026-07-08T00:00:00.000Z'),
        hours: 2,
        content: '补充日报',
      }),
    });
  });
});
