mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
Merge pull request #13688 from SivanCola/fix/skill-spec-info-key
fix(studio): key each skill metadata row / 技能元数据行补上 key
This commit is contained in:
2 files changed
+37
-1
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { Fragment } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { SkillEntry } from "../port/port";
|
||||
|
||||
@@ -12,7 +13,7 @@ export function SkillSpecInfo({ sk }: { sk: SkillEntry }) {
|
||||
<dl>
|
||||
{sk.license && <><dt>{t("许可")}</dt><dd>{sk.license}</dd></>}
|
||||
{sk.compatibility && <><dt>{t("运行要求")}</dt><dd>{sk.compatibility}</dd></>}
|
||||
{meta.map(([key, value]) => <><dt key={`${key}-k`}>{key}</dt><dd key={`${key}-v`}>{value}</dd></>)}
|
||||
{meta.map(([key, value]) => <Fragment key={key}><dt>{key}</dt><dd>{value}</dd></Fragment>)}
|
||||
</dl>
|
||||
</details>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// @vitest-environment jsdom
|
||||
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
||||
import { cleanup, render } from "@testing-library/react";
|
||||
import "./testkit";
|
||||
import { boot, STORAGE } from "../i18n";
|
||||
import type { SkillEntry } from "../port/port";
|
||||
import { SkillSpecInfo } from "./SkillSpecInfo";
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.setItem(STORAGE, "zh");
|
||||
boot();
|
||||
});
|
||||
afterEach(cleanup);
|
||||
|
||||
// The metadata rows are an array, so every rendered item needs its own key.
|
||||
// The shorthand fragment cannot carry one, and React warns about it at mount.
|
||||
// This guard lives in its own file because React reports that warning once per
|
||||
// component: sharing a worker with another metadata render would leave the spy
|
||||
// silent even when the key is missing.
|
||||
it("keys each metadata row, so React does not warn about the list", () => {
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
try {
|
||||
const sk: SkillEntry = {
|
||||
name: "pdf-processing", slashName: "pdf-processing", enabled: true,
|
||||
metadata: { author: "example-org", version: "1.0" },
|
||||
};
|
||||
render(<SkillSpecInfo sk={sk} />);
|
||||
const keyWarnings = error.mock.calls.filter(
|
||||
([first]) => typeof first === "string" && first.includes('unique "key" prop'),
|
||||
);
|
||||
expect(keyWarnings).toEqual([]);
|
||||
} finally {
|
||||
error.mockRestore();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user