aa96143754
Apply repo-wide Prettier/lint normalization across admin-web, desktop-client and ops-web: single quotes, no semicolons, trailing commas, consistent line wrapping, and import ordering. Also drop an unused brand-logo import in DesktopShell.vue. No behavior changes — formatting only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
vi.mock('../../../../../packages/publisher-platforms/src/toutiao', () => ({
|
|
publishToutiaoArticle: vi.fn(async () => ({
|
|
success: true,
|
|
status: 'success',
|
|
articleId: 'pgc-1',
|
|
mediaName: '头条号测试账号',
|
|
externalManageUrl: 'https://mp.toutiao.com/profile_v4/index',
|
|
externalArticleUrl: 'https://www.toutiao.com/article/pgc-1/',
|
|
message: '头条号发布成功。',
|
|
})),
|
|
}))
|
|
|
|
vi.mock('./media-image', () => ({
|
|
fetchImageAssetBlob: vi.fn(async () => ({
|
|
blob: new Blob(['image'], { type: 'image/png' }),
|
|
width: 1,
|
|
height: 1,
|
|
fileName: 'image.png',
|
|
})),
|
|
}))
|
|
|
|
import { publishToutiaoArticle } from '../../../../../packages/publisher-platforms/src/toutiao'
|
|
import { fetchImageAssetBlob } from './media-image'
|
|
import { toutiaoAdapter } from './toutiao'
|
|
|
|
describe('toutiao adapter', () => {
|
|
it('fetches relative public assets through the desktop asset pipeline before platform upload', async () => {
|
|
const result = await toutiaoAdapter.publish(
|
|
{
|
|
taskId: 'task-1',
|
|
accountId: 'account-1',
|
|
session: {} as never,
|
|
view: null,
|
|
playwright: null,
|
|
signal: new AbortController().signal,
|
|
phase: 'initial',
|
|
reportProgress: vi.fn(),
|
|
article: {
|
|
article_id: 889,
|
|
title: '2026年室内门锁怎么选?五款高适配产品参考',
|
|
html_content: null,
|
|
markdown_content:
|
|
'<p class="article-editor-image article-editor-image--center" align="center"><img src="/api/public/assets/body-token" alt="" /></p>',
|
|
cover_asset_url: '/api/public/assets/cover-token',
|
|
},
|
|
},
|
|
{},
|
|
)
|
|
|
|
expect(result.status).toBe('succeeded')
|
|
expect(publishToutiaoArticle).toHaveBeenCalledOnce()
|
|
|
|
const transport = vi.mocked(publishToutiaoArticle).mock.calls[0]?.[1]
|
|
expect(transport).toBeTruthy()
|
|
|
|
const bodyBlob = await transport?.fetchImageBlob('/api/public/assets/body-token')
|
|
const coverBlob = await transport?.fetchImageBlob('/api/public/assets/cover-token')
|
|
|
|
expect(bodyBlob?.type).toBe('image/png')
|
|
expect(coverBlob?.type).toBe('image/png')
|
|
expect(fetchImageAssetBlob).toHaveBeenCalledWith(
|
|
'/api/public/assets/body-token',
|
|
expect.anything(),
|
|
)
|
|
expect(fetchImageAssetBlob).toHaveBeenCalledWith(
|
|
'/api/public/assets/cover-token',
|
|
expect.anything(),
|
|
)
|
|
})
|
|
})
|