astrbot_plugin_imagestudio/frontend/tests/workflow-profile-card-wiring.test.mjs

33 行
1.6 KiB
JavaScript

import assert from "node:assert/strict"
import { readFile } from "node:fs/promises"
import test from "node:test"
const appPath = new URL("../standalone-web/src/App.vue", import.meta.url)
const endpointsPath = new URL("../shared/api/endpoints.ts", import.meta.url)
test("finalizes a detailed workflow through the atomic profile-card endpoint", async () => {
const [app, endpoints] = await Promise.all([
readFile(appPath, "utf8"),
readFile(endpointsPath, "utf8"),
])
const start = app.indexOf("async function archiveSelectedWorkflowFinal()")
const end = app.indexOf("async function changeSelectedWorkflowLifecycle", start)
assert.notEqual(start, -1)
assert.notEqual(end, -1)
const finalizeFunction = app.slice(start, end)
assert.match(finalizeFunction, /endpoints\.workflowFinalizeCard\(workflowId\)/)
assert.doesNotMatch(finalizeFunction, /endpoints\.workflowHistory/)
assert.doesNotMatch(finalizeFunction, /endpoints\.nodeComplete/)
assert.doesNotMatch(finalizeFunction, /putJson<ProfileWorkflow>/)
assert.match(app, /avatar: selectedImageFor\("headshot"\)/)
assert.match(app, /persona_image: selectedImageFor\("design_sheet", "turnaround"\)/)
assert.match(app, /standing: selectedImageFor\("full_body"\)/)
assert.match(app, /pv: selectedImageFor\("style_lock"\)/)
assert.match(finalizeFunction, /idempotency_key:/)
assert.match(finalizeFunction, /persona_document:/)
assert.match(finalizeFunction, /branch_name: branchName/)
assert.match(finalizeFunction, /endpoints\.profileCards\(profile\.profileId\)/)
assert.match(finalizeFunction, /loadBackendQuickProfiles\(\)/)
assert.match(endpoints, /workflowFinalizeCard:/)
})