import { describe, it, expect } from "vitest";
import {
  RecordingTracer,
  RecordingLogger,
} from "@repo/core-testing/instrumentation";
import { MockSiteSettingsRepository } from "@/infrastructure/repositories/site-settings.repository.mock";

// Mock repo also wraps in spans.
describe("MockSiteSettingsRepository emits spans", () => {
  it("getSiteSettings emits one span with op='repository'", async () => {
    const tracer = new RecordingTracer();
    const logger = new RecordingLogger();
    const repo = new MockSiteSettingsRepository(tracer, logger);
    await repo.getSiteSettings();
    expect(tracer.spans).toHaveLength(1);
    expect(tracer.spans[0]).toMatchObject({
      name: "site-settings.getSiteSettings",
      op: "repository",
    });
    expect(tracer.spans[0]!.attributes.found).toBe(true);
  });
});
