import {
  claimForCharge,
  createOrder,
  markPaid,
  type NewOrder,
} from '@platform-modules/commerce-orders'
import { describe, it } from 'vitest'
import type { CheckoutDeps } from './types.js'

describe('deps-tx-assignability', () => {
  it('CheckoutDeps tx passes createOrder/claimForCharge/markPaid', async () => {
  async function exerciseCheckoutDeps(deps: CheckoutDeps): Promise<void> {
    if (false as boolean) {
      const fakeNewOrder = {
        idempotencyKey: 'idem-1',
        buyerRef: { userId: '00000000-0000-4000-8000-000000000001' },
        currency: 'ILS',
        priceMode: 'exclusive',
        subtotal: 1000n,
        tax: 180n,
        discount: 0n,
        total: 1180n,
        lines: [],
        splits: [],
      } satisfies NewOrder

      const orderId = '00000000-0000-4000-8000-000000000002'

      await deps.db.transaction(async (tx) => {
        await createOrder(tx, fakeNewOrder)
        await claimForCharge(tx, orderId)
        await markPaid(tx, orderId, 'pi_test')
      })
    }
  }

    await exerciseCheckoutDeps({
      fulfillment: {} as CheckoutDeps['fulfillment'],
    } as CheckoutDeps)
  })
})
