// @vitest-environment node

import { readFile } from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";

describe("donor monthly history", () => {
  it("uses orphan transfers instead of sponsor payments", async () => {
    const page = await readFile(
      path.join(process.cwd(), "src/app/donor/orphans/[id]/page.tsx"),
      "utf8"
    );

    expect(page).toContain('.from("orphan_transfers")');
    expect(page).not.toContain('.eq("sponsor_id", profile.id)');
    expect(page).not.toContain('.from("sponsor_monthly_payments")');
    expect(page.match(/سجل دفعاتك الشهرية/g)).toHaveLength(1);
  });
});
