mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix(cli): label the batch asset-import RENDER_FAILED with the images endpoint
Review feedback on #2358: the batch-miss RENDER_FAILED in runAssetImportMany (asset.ts) throws the same typed error as client.ts's single-node renderNode, but wasn't labeled — so cli_error.endpoint would silently come back undefined for the flow that most heavily exercises /v1/images.
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
runAssetImportMany,
|
||||
type AssetImportDeps,
|
||||
} from "./asset.js";
|
||||
import type { FigmaClient } from "@hyperframes/core/figma";
|
||||
import { FigmaClientError, type FigmaClient } from "@hyperframes/core/figma";
|
||||
|
||||
const dirs: string[] = [];
|
||||
function scratch(): string {
|
||||
@@ -179,6 +179,24 @@ describe("runAssetImport", () => {
|
||||
expect(new Set(results.map((r) => r.record.id)).size).toBe(3);
|
||||
});
|
||||
|
||||
it("labels a batch-miss RENDER_FAILED with the images endpoint (telemetry parity with client.ts)", async () => {
|
||||
const dir = scratch();
|
||||
const missClient = fakeClient({
|
||||
renderNodes: (fileKey, nodeIds) =>
|
||||
Promise.resolve(nodeIds.map((nodeId) => ({ nodeId, url: null, ext: "png" }))),
|
||||
});
|
||||
const err = await runAssetImportMany(
|
||||
["KEY:1-2"],
|
||||
{ format: "png" },
|
||||
deps(dir, { client: missClient }),
|
||||
).catch((e: unknown) => e);
|
||||
expect(err).toBeInstanceOf(FigmaClientError);
|
||||
if (err instanceof FigmaClientError) {
|
||||
expect(err.code).toBe("RENDER_FAILED");
|
||||
expect(err.endpoint).toBe("images");
|
||||
}
|
||||
});
|
||||
|
||||
it("gatherAssetRefs splits bare comma-joined ids but keeps URLs whole", () => {
|
||||
// bare tokens comma-split
|
||||
expect(gatherAssetRefs(["KEY:1-2,KEY:3-4"])).toEqual(["KEY:1-2", "KEY:3-4"]);
|
||||
|
||||
@@ -209,6 +209,8 @@ export async function runAssetImportMany(
|
||||
throw new FigmaClientError(
|
||||
"RENDER_FAILED",
|
||||
`figma could not render node ${nodeId} as ${opts.format}`,
|
||||
undefined,
|
||||
"images",
|
||||
);
|
||||
slots[i] = await freezeAndRecord(
|
||||
fileKey,
|
||||
|
||||
Reference in New Issue
Block a user