import { expect, test } from "@playwright/test"; import { resolveAlibabaExtendApiKey } from "@/lib/ai/extend/config"; test.describe("image extension provider configuration", () => { test("uses the most recently updated Alibaba image provider key", () => { expect( resolveAlibabaExtendApiKey( [ { apiKey: "older-key", updatedAt: "2026-09-01T00:00:00.000Z" }, { apiKey: "current-key", updatedAt: "2026-09-10T00:00:00.000Z" }, ], "stale-extend-setting-key", ), ).toBe("current-key"); }); test("only falls back to a legacy key when no provider key exists", () => { expect( resolveAlibabaExtendApiKey( [{ apiKey: "", updatedAt: "2026-09-10T00:00:00.000Z" }], "legacy-key", ), ).toBe("legacy-key"); expect(resolveAlibabaExtendApiKey([], "")).toBeNull(); }); });