cc2f3ef68a
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m19s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 3m9s
AI Code Review / AI Code Review (pull_request) Successful in 4m0s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 4m13s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 10s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1419h14m49s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1419h14m50s
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Failing after 1419h15m8s
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Failing after 1419h15m12s
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Failing after 1419h15m12s
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Failing after 1419h15m12s
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Failing after 1419h15m13s
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Failing after 1419h15m14s
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Failing after 1419h15m14s
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Failing after 1419h15m14s
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1419h46m56s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1419h47m19s
CI Build & Deploy Pipeline / Deploy Production (pull_request) Failing after 1419h47m18s
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Failing after 1419h47m18s
Phase2(22%→39%): - 5个Layout组件测试 - AssetSelector业务组件测试 - ~18个页面smoke test - useUndoRedo hook + useAuth增强 - navigation配置 + auth-normalize纯函数 Phase3(39%→51%): - editing-planner剩余10个子组件全覆盖 - 3个页面smoke test(MyTemplates/EditPlans/PlanClipsManager) - voice/CloneModal业务组件测试 总计:85个测试文件,452个用例全通过
93 lines
2.5 KiB
TypeScript
93 lines
2.5 KiB
TypeScript
import React from "react"
|
|
import { describe, it, expect, vi } from "vitest"
|
|
import { render, screen } from "@testing-library/react"
|
|
import AssetSelector from "@/components/AssetSelector/AssetSelector"
|
|
import type { MediaAsset } from "@/api/editPlans"
|
|
|
|
vi.mock("@/components/ui", () => ({
|
|
Input: ({ placeholder }: any) => <input placeholder={placeholder} />,
|
|
Select: ({ options }: any) => (
|
|
<select>
|
|
{options?.map((o: any) => (
|
|
<option key={o.value} value={o.value}>
|
|
{o.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
),
|
|
Button: ({ children, onClick }: any) => <button onClick={onClick}>{children}</button>,
|
|
}))
|
|
|
|
vi.mock("@/components/AssetSelector/AssetSelector.css", () => ({}))
|
|
|
|
const mockAssets: MediaAsset[] = [
|
|
{
|
|
id: "1",
|
|
name: "视频1.mp4",
|
|
type: "video",
|
|
thumbnail_url: "http://example.com/1.jpg",
|
|
duration: 125,
|
|
size: 5 * 1024 * 1024,
|
|
tags: [],
|
|
created_at: "2024-01-01",
|
|
quality_score: 85,
|
|
},
|
|
{
|
|
id: "2",
|
|
name: "音频1.mp3",
|
|
type: "audio",
|
|
duration: 30,
|
|
size: 100 * 1024,
|
|
tags: ["bgm"],
|
|
created_at: "2024-01-02",
|
|
quality_score: 70,
|
|
},
|
|
{
|
|
id: "3",
|
|
name: "图片1.jpg",
|
|
type: "image",
|
|
thumbnail_url: "http://example.com/3.jpg",
|
|
size: 500 * 1024,
|
|
tags: [],
|
|
created_at: "2024-01-03",
|
|
quality_score: 90,
|
|
},
|
|
]
|
|
|
|
describe("AssetSelector", () => {
|
|
it("应该渲染所有素材", () => {
|
|
render(<AssetSelector assets={mockAssets} />)
|
|
expect(screen.getByText("视频1.mp4")).toBeInTheDocument()
|
|
expect(screen.getByText("音频1.mp3")).toBeInTheDocument()
|
|
expect(screen.getByText("图片1.jpg")).toBeInTheDocument()
|
|
})
|
|
|
|
it("空素材时显示空状态", () => {
|
|
render(<AssetSelector assets={[]} />)
|
|
expect(screen.getByText(/暂无素材/)).toBeInTheDocument()
|
|
})
|
|
|
|
it("应该有搜索框", () => {
|
|
render(<AssetSelector assets={mockAssets} />)
|
|
expect(screen.getByPlaceholderText(/搜索/)).toBeInTheDocument()
|
|
})
|
|
|
|
it("应该有类型筛选", () => {
|
|
render(<AssetSelector assets={mockAssets} />)
|
|
const selects = screen.getAllByRole("combobox")
|
|
expect(selects.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
it("应该显示文件大小格式化", () => {
|
|
render(<AssetSelector assets={mockAssets} />)
|
|
// 5MB = 5 * 1024 * 1024 bytes
|
|
expect(screen.getByText(/5.0MB|5\.0MB/)).toBeInTheDocument()
|
|
})
|
|
|
|
it("应该显示时长格式化", () => {
|
|
render(<AssetSelector assets={mockAssets} />)
|
|
// 125秒 = 2:05
|
|
expect(screen.getByText(/2:05/)).toBeInTheDocument()
|
|
})
|
|
})
|