From f71a5ba4b53c9c83134dc32a8b740871113203cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B2=A9=E5=B2=A9?= Date: Thu, 23 Jul 2026 09:53:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=20quicktime=20?= =?UTF-8?q?=E2=80=94=20Vue=20=E7=BB=84=E4=BB=B6=E5=8C=96=20+=206=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=88=E6=92=AD=E6=94=BE/=E6=9A=82?= =?UTF-8?q?=E5=81=9C/=E5=88=87=E6=AD=8C/=E8=BF=9B=E5=BA=A6/=E9=9F=B3?= =?UTF-8?q?=E9=87=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apps/quicktime/QuickTime.vue | 132 +++++++++++++++++++++++++------ tests/cases/25-quicktime.test.ts | 43 ++++++++++ 2 files changed, 149 insertions(+), 26 deletions(-) create mode 100644 tests/cases/25-quicktime.test.ts diff --git a/src/apps/quicktime/QuickTime.vue b/src/apps/quicktime/QuickTime.vue index f5d7f08..8b05a30 100644 --- a/src/apps/quicktime/QuickTime.vue +++ b/src/apps/quicktime/QuickTime.vue @@ -1,42 +1,122 @@ + diff --git a/tests/cases/25-quicktime.test.ts b/tests/cases/25-quicktime.test.ts new file mode 100644 index 0000000..4674d59 --- /dev/null +++ b/tests/cases/25-quicktime.test.ts @@ -0,0 +1,43 @@ +/** + * 25-quicktime: QuickTime Vue 组件化测试 + * 覆盖: 播放器结构、视频列表、播放/暂停/上/下首、进度条、音量、卸载 + */ +import { describe, it, expect, beforeEach, afterEach } from 'vitest' +import { h, render, nextTick } from 'vue' +import QuickTimeComponent from '../../src/apps/quicktime/QuickTime.vue' +import { setupDOM } from '../helpers' + +function makeMockWin() { + const el = document.createElement('div'); el.className = 'window' + document.getElementById('window-layer')?.appendChild(el) + const body = document.createElement('div'); body.className = 'win-body' + el.appendChild(body) + return { id: 'qt', appId: 'quicktime', el, body, timers: [] as any[], data: {} } +} + +describe('25-quicktime — QuickTime Vue 组件化', () => { + let win: any + beforeEach(() => { setupDOM(); win = makeMockWin() }) + afterEach(() => { render(null, win.body); win.el.remove() }) + + function mount() { const v = h(QuickTimeComponent, { win }); render(v, win.body) } + + it('挂载后渲染播放器', () => { mount(); expect(win.body.querySelector('.qt-body')).toBeTruthy() }) + it('有播放/上/下首按钮', () => { + mount() + const btns = win.body.querySelectorAll('.qt-btn') + expect(btns.length).toBeGreaterThanOrEqual(3) + }) + it('有进度条和音量', () => { + mount() + expect(win.body.querySelector('.qt-seek')).toBeTruthy() + expect(win.body.querySelector('.qt-vol')).toBeTruthy() + }) + it('有视频播放区', () => { mount(); expect(win.body.querySelector('.qt-stage')).toBeTruthy() }) + it('暴露 toggle/nav 给菜单', () => { + mount() + expect(typeof win.appState.toggle).toBe('function') + expect(typeof win.appState.nav).toBe('function') + }) + it('卸载后 DOM 为空', () => { mount(); render(null, win.body); expect(win.body.children.length).toBe(0) }) +})