mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-10 02:16:45 +08:00
* fix(runtimes): preserve custom profile base runtime identity Co-authored-by: multica-agent <[email protected]> * fix(runtimes): pass both url params to the profile identity test TestUpdateRuntimeProfile_RejectsIdentityChange nested two withURLParam calls. That helper installs a fresh chi route context each time and does not copy what is already there, so the outer call for profileId dropped id: the handler answered 400 "workspace_id is required" and never reached the immutability check the test exists to cover. Use withURLParams, which carries existing params forward and is what the rest of this file already uses. Co-authored-by: multica-agent <[email protected]> * fix(runtimes): name a runtime target the same way on every surface The base-runtime picker spelled Oh-My-Pi with an inline ternary, so it was the only place that used the product name. The catalog row, both detail headers, the base-runtime detail row and the locked chip in the form kept rendering the stored id under `capitalize` — a user picked "Oh-My-Pi" and the next screen, and the saved profile, said "Omp". Move the name into runtimeTypeLabel next to the target whitelist and read it from every surface. profileRuntimeType replaces the repeated runtime_type ?? protocol_family fallback. Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: multica-agent <[email protected]> Co-authored-by: Bohan-J <[email protected]>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, it, expect } from "vitest";
|
|
import { RuntimeProfileSchema } from "./schemas";
|
|
import { parseWithFallback } from "./schema";
|
|
const profile = {
|
|
id: "p",
|
|
workspace_id: "ws",
|
|
display_name: "Custom",
|
|
protocol_family: "pi",
|
|
command_name: "wrapper",
|
|
};
|
|
describe("runtime profile response compatibility", () => {
|
|
it("defaults old or malformed identities to the protocol", () => {
|
|
for (const runtime_type of [undefined, null, 42, ""]) {
|
|
expect(
|
|
RuntimeProfileSchema.parse({ ...profile, runtime_type }).runtime_type,
|
|
).toBe("pi");
|
|
}
|
|
});
|
|
it("preserves runtime identities including future targets", () => {
|
|
for (const runtime_type of ["omp", "future-runtime"]) {
|
|
expect(
|
|
RuntimeProfileSchema.parse({ ...profile, runtime_type }).runtime_type,
|
|
).toBe(runtime_type);
|
|
}
|
|
});
|
|
it("uses a safe fallback for malformed responses", () => {
|
|
expect(
|
|
parseWithFallback(
|
|
{ ...profile, command_name: 42 },
|
|
RuntimeProfileSchema,
|
|
null,
|
|
{ endpoint: "runtimeProfile" },
|
|
),
|
|
).toBeNull();
|
|
});
|
|
});
|