import { describe, expect, it } from 'vitest'
import { BaseProjectSchema, BaseTaskSchema } from '../business/base-entities'
import {
  makeInitializationState,
  makeOrganizationModel,
  makeProject,
  makeTask,
  makeUserProfile,
  TEST_ORGS,
  TEST_USERS
} from './published'

describe('published test-utils factories', () => {
  it('creates schema-validated base entities with overrides', () => {
    const project = makeProject({ name: 'Custom Project', metadata: { source: 'test' } })
    const task = makeTask({ projectId: project.id, status: 'done' })

    expect(BaseProjectSchema.parse(project)).toMatchObject({
      name: 'Custom Project',
      metadata: { source: 'test' }
    })
    expect(BaseTaskSchema.parse(task)).toMatchObject({
      projectId: project.id,
      status: 'done'
    })
  })

  it('creates organization model and initialization fixtures', () => {
    const model = makeOrganizationModel({
      branding: { organizationName: 'Test Brand' }
    })
    const profile = makeUserProfile({ id: TEST_USERS.admin.id, email: TEST_USERS.admin.email })
    const state = makeInitializationState({ profile, organizationReady: false, allReady: false })

    expect(model.branding.organizationName).toBe('Test Brand')
    expect(state.profile?.email).toBe(TEST_USERS.admin.email)
    expect(state.organizationReady).toBe(false)
  })

  it('promotes existing fixture surface through the public barrel', () => {
    expect(TEST_USERS.admin.email).toBe('admin@test.com')
    expect(TEST_ORGS.acme.name).toBe('Acme Corp')
  })
})
