Files
streamline/control-server/test/meego_link_detection.test.ts
2026-11-16 17:26:44 -08:00

54 lines
2.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// MUST be first: sets DATABASE_URL before db_client is evaluated.
import "./setup_env";
import { test, expect, describe } from "bun:test";
import { extractLinksFromBlob } from "../src/meego";
/**
* `extractLinksFromBlob` 是「粘贴内容里有没有工单链接」的唯一判据,它决定
* `/api/import` 走哪条路:
*
* - 认出链接 → 逐条按工单导入。平台取工单的「Bug端分类」,**表单里选的平台不生效**。
* - 一条都没认出 → 整段文字当一条 bug 建单,表单选的平台 / 产品生效。
*
* 所以这条判据宽一个 URL,用户就会看到一件莫名其妙的事。
*
* 2026-10-26 的真实事故:在「一句话建单」里粘了一段描述 + 一个 Figma 设计稿链接,
* 后端把 Figma 链接当成了工单 —— `parseMeegoLink` 对任何 URL 都取最后一段当工单 id,
* 于是 Figma 的 file token 成了「工单号」。这个假工单没有「Bug端分类」,关键词分类器
* 默认猜 android,而用户选的是 iOS + 只支持 iOS 的 Notes 产品,于是整条被 skip,
* 原因显示「Product Notes does not support android」。用户看到一张「未新增 · 1 条
* 被跳过」的表,原因跟粘进去的东西毫无关系。
*
* 这里钉两件事:非工单链接(设计稿 / 文档 / 视图)**不能**被当成 ticket;真正的
* 工作项详情链接照旧要认出来。
*/
describe("extractLinksFromBlob · 只认真正的工作项详情链接", () => {
test("Figma / 飞书文档 / Meego 视图链接都不是工单", () => {
expect(extractLinksFromBlob("https://www.figma.com/design/tizyEsa8lhnaeJnbPgcvvi/")).toEqual([]);
expect(extractLinksFromBlob("https://bytedance.us.larkoffice.com/docx/XFLEdHT7BoS0dCxSvG0ukKj9sbe")).toEqual([]);
// 视图链接的 host 是 Meego,但它不是一个工作项,取不出单条工单。
expect(extractLinksFromBlob("https://meego.larkoffice.com/tiktok/issueView/Rrn5z70Dg?node=65142759")).toEqual([]);
});
test("一句话 + Figma 链接:不认链接,走纯文本建单", () => {
const text = [
"验证下餐厅 bot 中灵感卡和对比卡的 UI 设计,并修复问题。",
"仓库分支是 notes/feature/restaurant-radar,需要开启 ppe_rest_bot 环境。",
"设计稿 https://www.figma.com/design/tizyEsa8lhnaeJnbPgcvvi/",
].join("\n");
expect(extractLinksFromBlob(text)).toEqual([]);
});
test("真正的工作项链接照旧认出来(含 query string 与行内位置)", () => {
const a = "https://meego.larkoffice.com/tiktok/issue/detail/7328764565";
const b = "https://meego.larkoffice.com/tiktok_live/issue/detail/7356610293?parentUrl=x";
const text = `第一个问题 ${a}\n第二个问题 ${b}`;
expect(extractLinksFromBlob(text)).toEqual([a, b]);
});
test("裸数字仍然不算工单(没有 project/type,取不出来)", () => {
expect(extractLinksFromBlob("1 2 3 12345 7328764565")).toEqual([]);
});
});