feat(portal): Co-Lite labels only filter on Translations

On by default. The portal server sends its own label codes to the new
search; unchecking lists every label as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-02 14:55:56 +08:00
1 parent d2cbc3c227
commit 918f5fa2b2
12 files changed
+70 -8

No files matched your search

@@ -5,6 +5,7 @@ vi.mock("@/app/lib/server/mobileApi", () => ({ callMobileApi: mocks.callMobileAp
vi.mock("@/app/lib/server/session", () => ({ getToken: mocks.getToken }));
import { GET, POST, PUT } from "./route";
import { DEFAULT_MESSAGES } from "@/app/lib/i18n/defaultMessages";
type Req = Parameters<typeof GET>[0];
const req = (url: string, init?: RequestInit) => new Request(url, init) as unknown as Req;
@@ -29,6 +30,24 @@ describe("/api/messages", () => {
`/api/admin/messages?searchKey=${encodeURIComponent("线索")}&missingLocale=zh_CN&page=0&size=20`, { token: "jwt" });
});
it("own=1 searches the portal's own label codes, built on the server", async () => {
await GET(req("http://localhost/api/messages?own=1&searchKey=lead&missingLocale=zh_CN&page=2&size=50&codes=Evil"), ctx());
expect(mocks.callMobileApi).toHaveBeenCalledWith("/api/admin/messages/search", {
method: "POST",
body: { searchKey: "lead", missingLocale: "zh_CN", page: 2, size: 50, codes: Object.keys(DEFAULT_MESSAGES) },
token: "jwt",
});
});
it("own=1 without filters sends page defaults and no empty filters", async () => {
await GET(req("http://localhost/api/messages?own=1"), ctx());
expect(mocks.callMobileApi).toHaveBeenCalledWith("/api/admin/messages/search", {
method: "POST",
body: { page: 0, size: 20, codes: Object.keys(DEFAULT_MESSAGES) },
token: "jwt",
});
});
it("forwards detail and export reads", async () => {
await GET(req("http://localhost/api/messages/7"), ctx(["7"]));
expect(mocks.callMobileApi).toHaveBeenLastCalledWith("/api/admin/messages/7", { token: "jwt" });