feat: connect resource library workflows
This commit is contained in:
48
tests/features/orders/resource-picker-options.test.ts
Normal file
48
tests/features/orders/resource-picker-options.test.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import { mapModelOptions, mapResourceOptions } from "@/features/orders/resource-picker-options";
|
||||
import type { LibraryItemVM } from "@/lib/types/view-models";
|
||||
|
||||
test("prefers backend-backed ids for models when the resource library provides them even without pose", () => {
|
||||
const items: LibraryItemVM[] = [
|
||||
{
|
||||
id: "12",
|
||||
libraryType: "models",
|
||||
name: "Ava Studio",
|
||||
description: "棚拍女模特",
|
||||
previewUri: "https://images.marcusd.me/library/models/ava/thumb.png",
|
||||
tags: ["女装"],
|
||||
isMock: false,
|
||||
backendId: 12,
|
||||
},
|
||||
];
|
||||
|
||||
expect(mapModelOptions(items)).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "12",
|
||||
backendId: 12,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test("prefers backend-backed ids for scene and garment resources when provided", () => {
|
||||
const items: LibraryItemVM[] = [
|
||||
{
|
||||
id: "21",
|
||||
libraryType: "scenes",
|
||||
name: "Loft Window",
|
||||
description: "暖调室内场景",
|
||||
previewUri: "https://images.marcusd.me/library/scenes/loft/thumb.png",
|
||||
tags: ["室内"],
|
||||
isMock: false,
|
||||
backendId: 21,
|
||||
},
|
||||
];
|
||||
|
||||
expect(mapResourceOptions(items)).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "21",
|
||||
backendId: 21,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user