chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { __doubaoTestUtils } from "./doubao";
|
||||
import { __doubaoTestUtils } from './doubao'
|
||||
|
||||
const {
|
||||
buildSourceItem,
|
||||
@@ -8,44 +8,55 @@ const {
|
||||
isNonCitationAssetDomain,
|
||||
isNonCitationAssetUrl,
|
||||
parseDoubaoStreamBody,
|
||||
} = __doubaoTestUtils;
|
||||
} = __doubaoTestUtils
|
||||
|
||||
describe("doubao adapter helpers", () => {
|
||||
it("filters byteimg and bytednsdoc asset CDN links from source items", () => {
|
||||
expect(isNonCitationAssetDomain("p3-spider-image-sign.byteimg.com")).toBe(true);
|
||||
expect(isNonCitationAssetDomain("lf3-static.bytednsdoc.com")).toBe(true);
|
||||
expect(isNonCitationAssetUrl("https://p11-spider-image-sign.byteimg.com/obj/logo.png")).toBe(true);
|
||||
expect(isNonCitationAssetUrl("https://m.sohu.com/a/1012750625_122649842/")).toBe(false);
|
||||
describe('doubao adapter helpers', () => {
|
||||
it('filters byteimg and bytednsdoc asset CDN links from source items', () => {
|
||||
expect(isNonCitationAssetDomain('p3-spider-image-sign.byteimg.com')).toBe(true)
|
||||
expect(isNonCitationAssetDomain('lf3-static.bytednsdoc.com')).toBe(true)
|
||||
expect(isNonCitationAssetUrl('https://p11-spider-image-sign.byteimg.com/obj/logo.png')).toBe(
|
||||
true,
|
||||
)
|
||||
expect(isNonCitationAssetUrl('https://m.sohu.com/a/1012750625_122649842/')).toBe(false)
|
||||
|
||||
expect(buildSourceItem({
|
||||
url: "https://p3-spider-image-sign.byteimg.com/img/logo.jpeg",
|
||||
title: "logo",
|
||||
site_name: "byteimg.com",
|
||||
})).toBeNull();
|
||||
expect(buildSourceItem({
|
||||
url: "https://example.com/article",
|
||||
title: "真实来源",
|
||||
})).toMatchObject({
|
||||
url: "https://example.com/article",
|
||||
host: "example.com",
|
||||
});
|
||||
});
|
||||
expect(
|
||||
buildSourceItem({
|
||||
url: 'https://p3-spider-image-sign.byteimg.com/img/logo.jpeg',
|
||||
title: 'logo',
|
||||
site_name: 'byteimg.com',
|
||||
}),
|
||||
).toBeNull()
|
||||
expect(
|
||||
buildSourceItem({
|
||||
url: 'https://example.com/article',
|
||||
title: '真实来源',
|
||||
}),
|
||||
).toMatchObject({
|
||||
url: 'https://example.com/article',
|
||||
host: 'example.com',
|
||||
})
|
||||
})
|
||||
|
||||
it("dedupes and drops asset CDN links parsed from Doubao streams", () => {
|
||||
it('dedupes and drops asset CDN links parsed from Doubao streams', () => {
|
||||
const body = [
|
||||
"event: STREAM_CHUNK",
|
||||
"data: {\"references\":[{\"url\":\"https://p11-spider-image-sign.byteimg.com/logo.jpeg\",\"title\":\"logo\"},{\"url\":\"https://m.sohu.com/a/1012750625_122649842/\",\"title\":\"真实来源\"}],\"text_block\":{\"text\":\"回答\"}}",
|
||||
"",
|
||||
"",
|
||||
].join("\n");
|
||||
'event: STREAM_CHUNK',
|
||||
'data: {"references":[{"url":"https://p11-spider-image-sign.byteimg.com/logo.jpeg","title":"logo"},{"url":"https://m.sohu.com/a/1012750625_122649842/","title":"真实来源"}],"text_block":{"text":"回答"}}',
|
||||
'',
|
||||
'',
|
||||
].join('\n')
|
||||
|
||||
const summary = parseDoubaoStreamBody(body);
|
||||
expect(summary.search_results).toHaveLength(1);
|
||||
expect(summary.search_results[0]?.url).toBe("https://m.sohu.com/a/1012750625_122649842/");
|
||||
const summary = parseDoubaoStreamBody(body)
|
||||
expect(summary.search_results).toHaveLength(1)
|
||||
expect(summary.search_results[0]?.url).toBe('https://m.sohu.com/a/1012750625_122649842/')
|
||||
|
||||
expect(dedupeSourceItems([
|
||||
{ url: "https://static.bytednsdoc.com/logo.png", normalized_url: "https://static.bytednsdoc.com/logo.png" },
|
||||
{ url: "https://example.com/a", normalized_url: "https://example.com/a" },
|
||||
])).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
expect(
|
||||
dedupeSourceItems([
|
||||
{
|
||||
url: 'https://static.bytednsdoc.com/logo.png',
|
||||
normalized_url: 'https://static.bytednsdoc.com/logo.png',
|
||||
},
|
||||
{ url: 'https://example.com/a', normalized_url: 'https://example.com/a' },
|
||||
]),
|
||||
).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user