promptTemplateTelemetry.test.ts 865 B

1234567891011121314151617181920212223242526
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. buildPromptTemplateClickTelemetryPayload,
  4. PROMPT_TEMPLATE_CLICK_EVENT_NAME,
  5. } from "@/lib/promptTemplateTelemetry.js";
  6. describe("prompt template click telemetry", () => {
  7. it("builds the shared click payload with a stable template id and full localized prompt", () => {
  8. expect(
  9. buildPromptTemplateClickTelemetryPayload({
  10. templateId: "weekly-summary",
  11. templateName: "周报总结",
  12. templatePrompt: "请总结最近一周的工作进展。",
  13. }),
  14. ).toEqual({
  15. elementName: PROMPT_TEMPLATE_CLICK_EVENT_NAME,
  16. eventRegion: "app.session",
  17. eventType: "ck",
  18. eventText: "周报总结",
  19. eventExtraDetail: {
  20. template_id: "weekly-summary",
  21. template_prompt: "请总结最近一周的工作进展。",
  22. },
  23. });
  24. });
  25. });