feat(short-drama-agent-front): 完善镜头定位与项目配置
This commit is contained in:
1 parent
470b52e26d
commit
5b134207b8
66 files changed
+2042
-984
No files matched your search
@@ -169,7 +169,9 @@ describe('全站平面主题', () => {
|
||||
expect(css).toMatch(/\.asset-impact-links\s*\{[^}]*width:\s*max-content;[^}]*white-space:\s*nowrap;/)
|
||||
expect(css).toMatch(/\.gallery-sticky-controls > \.form-image-filter-region\s*\{[^}]*margin-block:\s*0;/)
|
||||
// 间距归列表所有,吸顶时底部不留固定色带。
|
||||
expect(css).toMatch(/\.gallery-workspace-page \.form-image-grid\s*\{[^}]*padding-top:\s*12px;/)
|
||||
expect(css).toMatch(
|
||||
/\.gallery-workspace-page \.form-image-grid\s*\{[^}]*padding-top:\s*var\(--app-content-gap\);/
|
||||
)
|
||||
const sticky = css.match(/\.gallery-workspace-page \.gallery-sticky-controls\s*\{([^}]*)\}/)?.[1]
|
||||
expect(sticky).not.toMatch(/padding|border-bottom|::after/)
|
||||
expect(css).toMatch(
|
||||
@@ -177,7 +179,7 @@ describe('全站平面主题', () => {
|
||||
)
|
||||
expect(css).toMatch(/\.asset-impact-links-scroll\.n-scrollbar\s*\{[^}]*height:\s*auto;[^}]*max-width:\s*100%;/)
|
||||
expect(readFileSync('src/features/subject-images/SubjectImagesPage.vue', 'utf8')).toMatch(
|
||||
/<WorkspacePage\b[^>]*>\s*<template #default>/
|
||||
/<WorkspacePage\b[^>]*>[\s\S]*?<template #default>/
|
||||
)
|
||||
})
|
||||
|
||||
@@ -205,10 +207,8 @@ describe('全站平面主题', () => {
|
||||
const source = readFileSync('src/features/subject-images/SubjectImagesPage.vue', 'utf8')
|
||||
expect(source).not.toContain('class="toolbar-summary"')
|
||||
expect(source).toMatch(/<WorkspaceTools\s+triggerless/)
|
||||
expect(source.match(/<NPopover trigger="hover" placement="top" :disabled="isMobile">/g)).toHaveLength(4)
|
||||
expect(source).toMatch(/aria-label="网格布局"/)
|
||||
expect(source).toMatch(/aria-label="瀑布流布局"/)
|
||||
expect(source).toMatch(/aria-label="刷新图库"/)
|
||||
expect(source).toMatch(/data-workspace-tools\s+aria-label="批量生图"/)
|
||||
expect(source).not.toContain('title="网格布局"')
|
||||
expect(source).not.toContain('title="瀑布流布局"')
|
||||
@@ -239,7 +239,6 @@ describe('全站平面主题', () => {
|
||||
expect(css).toMatch(
|
||||
/\.gallery-layout-switch \.layout-option-button:not\(\.layout-option-active\),\s*\.gallery-layout-switch \.gallery-action-button\s*\{[^}]*background:\s*var\(--app-control-hover\);/
|
||||
)
|
||||
expect(source.match(/class="icon-button gallery-action-button"/g)).toHaveLength(2)
|
||||
expect(css).toMatch(
|
||||
/\.gallery-layout-switch\s*\{[^}]*display:\s*flex;[^}]*align-items:\s*center;[^}]*gap:\s*8px;/
|
||||
)
|
||||
@@ -262,15 +261,17 @@ describe('全站平面主题', () => {
|
||||
for (const file of [
|
||||
'src/App.vue',
|
||||
'src/components/ui/ThemeToggle.vue',
|
||||
'src/components/ui/WorkspaceTools.vue',
|
||||
'src/features/projects/ProjectsPage.vue',
|
||||
'src/features/subject-identity/SubjectIdentityPage.vue'
|
||||
'src/features/subject-images/SubjectImagesPage.vue'
|
||||
]) {
|
||||
const source = readFileSync(file, 'utf8')
|
||||
expect(source).toContain('icon-button')
|
||||
expect(source).not.toMatch(/<NButton\b[^>]*\bcircle\b/)
|
||||
}
|
||||
expect(readFileSync('src/components/ui/DirectoryItem.vue', 'utf8')).not.toContain('icon-button')
|
||||
expect(readFileSync('src/components/ui/WorkspaceTools.vue', 'utf8')).not.toContain('icon-button')
|
||||
const projects = readFileSync('src/features/projects/ProjectsPage.vue', 'utf8')
|
||||
expect(projects).not.toContain('aria-label="刷新项目"')
|
||||
expect(projects).not.toMatch(/<NButton\b[^>]*\bcircle\b/)
|
||||
})
|
||||
|
||||
it('风格参考图操作按钮与输入行对齐,缩略图在宽屏下保持紧凑', () => {
|
||||
@@ -285,7 +286,13 @@ describe('全站平面主题', () => {
|
||||
// happy-dom 不计算布局;此项保护 CSS 契约,不能替代浏览器视觉验收。
|
||||
const css = readAllStyles()
|
||||
expect(css).not.toMatch(/border-radius:\s*[1-9]/)
|
||||
expect(css).not.toMatch(/border(?:-[\w]+)?:\s*1px (?:solid|dashed) var\(--(?:app-border|color-line)\)/)
|
||||
// 主体身份的新流程用单条分隔线区分下一步操作,普通业务面板仍保持平面表面。
|
||||
const separators = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
|
||||
.filter(([, , declarations]) =>
|
||||
/border(?:-[\w]+)?:\s*1px (?:solid|dashed) var\(--(?:app-border|color-line)\)/.test(declarations!)
|
||||
)
|
||||
.map(([, selector]) => selector!.trim())
|
||||
expect(separators).toEqual(['.identity-next-action'])
|
||||
expect(css).toMatch(/\.surface-inset\s*\{[^}]*background:\s*var\(--app-subtle\)/)
|
||||
expect(css).toMatch(/\.record-list > article:nth-child\(even\)\s*\{\s*background:/)
|
||||
expect(css).toMatch(/\.directory-group-heading\s*\{[^}]*background:\s*var\(--app-control\)/)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { imageCatalog, generationProfile } from '../../fixtures/generation'
|
||||
import { defineComponent, h, reactive } from 'vue'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NFormItem, NInput } from 'naive-ui'
|
||||
import { NFormItem, NInput, NSelect } from 'naive-ui'
|
||||
import AppForm from '@/components/ui/AppForm.vue'
|
||||
import CreateProjectDialog from '@/features/projects/components/CreateProjectDialog.vue'
|
||||
import GenerateImageDialog from '@/features/subject-images/components/GenerateImageDialog.vue'
|
||||
@@ -10,22 +11,8 @@ import StyleImages from '@/features/visual-style/components/StyleImages.vue'
|
||||
import { formFixture } from '@/features/subject-images/testing/fixtures'
|
||||
import { requiredTextRule } from '@/lib/form-rules'
|
||||
|
||||
const imageCatalog = {
|
||||
defaults: { imageProvider: 'qwen-image', videoProvider: 'seedance' },
|
||||
images: [{
|
||||
type: 'image' as const, provider: 'qwen-image', providerLabel: 'Qwen', model: 'qwen-image-3.0-pro',
|
||||
modelLabel: 'Qwen Image', supported: true as const, enabled: true, isDefault: true, capabilities: {},
|
||||
generationOptions: [{ key: 'size', label: '图片尺寸', type: 'size' as const, required: true,
|
||||
options: [{ label: '1:1 · 2048×2048', value: '2048*2048' }] }],
|
||||
defaults: { size: '2048*2048' }, projectConstraints: []
|
||||
}],
|
||||
videos: []
|
||||
}
|
||||
const creativeProfile = {
|
||||
projectId: 'gallery-test', aspectRatio: '1:1' as const, imageProvider: 'qwen-image',
|
||||
imageModel: 'qwen-image-3.0-pro', imageOptions: { size: '2048*2048' },
|
||||
videoProvider: 'seedance', videoModel: 'seedance', videoOptions: {}
|
||||
}
|
||||
/** 当前测试使用真实目录契约构造项目模型配置。 */
|
||||
const creativeProfile = generationProfile('gallery-test')
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
@@ -34,6 +21,11 @@ afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
/**
|
||||
* 查找真实弹窗的可见操作按钮。
|
||||
* @param text 按钮完整文案
|
||||
* @returns 实际按钮元素
|
||||
*/
|
||||
function button(text: string) {
|
||||
const result = [...document.querySelectorAll<HTMLButtonElement>('button')].find(
|
||||
el => el.textContent?.trim() === text
|
||||
@@ -41,15 +33,29 @@ function button(text: string) {
|
||||
if (!result) throw new Error(`找不到按钮:${text}`)
|
||||
return result
|
||||
}
|
||||
/**
|
||||
* 更新真实表单字段并等待 Vue 绑定同步。
|
||||
* @param selector 字段选择器
|
||||
* @param value 本次输入值
|
||||
* @returns 字段绑定同步完成
|
||||
*/
|
||||
async function input(selector: string, value: string) {
|
||||
const el = document.querySelector<HTMLInputElement | HTMLTextAreaElement>(selector)!
|
||||
el.value = value
|
||||
el.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
await flushPromises()
|
||||
}
|
||||
/**
|
||||
* 汇总实际字段错误反馈。
|
||||
* @returns 当前全部校验错误文案
|
||||
*/
|
||||
function feedback() {
|
||||
return [...document.querySelectorAll('.n-form-item-feedback--error')].map(el => el.textContent).join(' ')
|
||||
}
|
||||
/**
|
||||
* 提交实际表单以执行统一字段校验。
|
||||
* @returns 表单校验与响应同步完成
|
||||
*/
|
||||
async function submit() {
|
||||
document.querySelector('form')!.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
|
||||
await flushPromises()
|
||||
@@ -57,25 +63,30 @@ async function submit() {
|
||||
|
||||
describe('统一的 Naive UI 表单校验', () => {
|
||||
it('新建剧本使用字段反馈拦截空白主题和小数集数,修正后只发送一次请求', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValue(new Response('{"projectId":"created","status":"generating"}', { status: 202 }))
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response('{"projectId":"created","executionId":"create-execution-1","status":"pending"}', {
|
||||
status: 202
|
||||
})
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(CreateProjectDialog, { attachTo: document.body })
|
||||
button('新建剧本').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('form')!.noValidate).toBe(true)
|
||||
expect(document.querySelector('[required]')).toBeNull()
|
||||
await input('#title', ' 雨夜来信标题 ')
|
||||
await input('#topic', ' ')
|
||||
const focus = vi.spyOn(HTMLTextAreaElement.prototype, 'focus')
|
||||
await submit()
|
||||
button('开始生成').click()
|
||||
await flushPromises()
|
||||
expect(feedback()).toContain('请填写故事主题')
|
||||
// 无布局的 DOM 环境会被模态框焦点圈带回哨兵,检查实际聚焦目标。
|
||||
expect(focus.mock.contexts).toContain(document.querySelector('#topic'))
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
await input('#topic', ' 雨夜来信 ')
|
||||
await input('#episode-count', '1.5')
|
||||
await submit()
|
||||
button('开始生成').click()
|
||||
await flushPromises()
|
||||
expect(feedback()).toContain('计划集数须为正整数')
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
await input('#episode-count', '3')
|
||||
@@ -84,24 +95,34 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
button('开始生成').click()
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(1)
|
||||
expect(wrapper.emitted('created')).toEqual([['created']])
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]?.[1]?.body))).toEqual({
|
||||
title: '雨夜来信标题',
|
||||
topic: '雨夜来信',
|
||||
style: '',
|
||||
episodeCount: 3
|
||||
})
|
||||
expect(wrapper.emitted('created')).toEqual([['created', 'create-execution-1']])
|
||||
})
|
||||
|
||||
it('图片宽高错误显示在两侧字段,补全后同时消失,切换目标清除校验状态', async () => {
|
||||
it('图片尺寸采用目录必填枚举,切换目标清空提示词和费用确认', async () => {
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile }
|
||||
})
|
||||
await flushPromises()
|
||||
await input('#image-width', '1024')
|
||||
expect(document.querySelectorAll('.n-form-item-feedback--error')).toHaveLength(2)
|
||||
expect(feedback()).toContain('宽高须同时填写正整数')
|
||||
await input('#image-height', '768')
|
||||
expect(feedback()).toBe('')
|
||||
await input('#image-height', '')
|
||||
expect(feedback()).not.toBe('')
|
||||
await wrapper.setProps({ form: formFixture('other') })
|
||||
const size = wrapper.findAllComponents(NSelect).find(select => select.props('value') === '2048*2048')!
|
||||
expect(size.props('clearable')).toBe(false)
|
||||
expect(size.props('options')).toEqual([{ label: '1:1 · 2048×2048', value: '2048*2048' }])
|
||||
expect(document.querySelector('#image-width')).toBeNull()
|
||||
expect(document.querySelector('#image-height')).toBeNull()
|
||||
await input('#image-prompt', '仅用于上一形态')
|
||||
document.querySelector<HTMLElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
expect(button('确认生成图片').disabled).toBe(false)
|
||||
await wrapper.setProps({ form: { ...formFixture(), id: 'other-form' } })
|
||||
await flushPromises()
|
||||
expect(document.querySelector<HTMLTextAreaElement>('#image-prompt')?.value).toBe('')
|
||||
expect(button('确认生成图片').disabled).toBe(true)
|
||||
expect(feedback()).toBe('')
|
||||
expect(wrapper.emitted('generate')).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { h } from 'vue'
|
||||
import { h, ref } from 'vue'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NConfigProvider, NDrawer, NDrawerContent, NMenu, NModal, NPopover, NScrollbar, NTooltip } from 'naive-ui'
|
||||
import { NConfigProvider, NMenu, NModal, NPopover, NScrollbar, NTooltip } from 'naive-ui'
|
||||
import App from '@/App.vue'
|
||||
import WorkspacePage from '@/components/ui/WorkspacePage.vue'
|
||||
import AppDialog from '@/components/ui/AppDialog.vue'
|
||||
@@ -115,6 +115,7 @@ describe('管理后台组件边界', () => {
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/assets', component: { render: () => h('p', '资产库') } },
|
||||
{ path: '/projects', component: { render: () => h('p', '项目列表') } },
|
||||
{
|
||||
path: '/projects/:projectId/:workspace',
|
||||
@@ -156,9 +157,9 @@ describe('管理后台组件边界', () => {
|
||||
expect(document.documentElement.dataset.theme).toBe(expectedTheme)
|
||||
expect(wrapper.getComponent(NConfigProvider).props('theme')?.name ?? 'light').toBe(expectedTheme)
|
||||
}
|
||||
expect(wrapper.find('.admin-topbar [aria-label="后端连接"]').exists()).toBe(false)
|
||||
expect(wrapper.find('.admin-nav-scroll [aria-label="后端连接"]').exists()).toBe(false)
|
||||
expect(wrapper.get('.admin-sider-footer [aria-label="后端连接"]').text()).toBe('后端连接')
|
||||
expect(wrapper.find('.admin-topbar [aria-label="连接设置"]').exists()).toBe(false)
|
||||
expect(wrapper.find('.admin-nav-scroll [aria-label="连接设置"]').exists()).toBe(false)
|
||||
expect(wrapper.get('.admin-sider-footer [aria-label="连接设置"]').text()).toBe('连接设置')
|
||||
expect(wrapper.getComponent(NMenu).props()).toMatchObject({
|
||||
collapsed: false,
|
||||
collapsedWidth: 64,
|
||||
@@ -205,11 +206,11 @@ describe('管理后台组件边界', () => {
|
||||
'分镜设计',
|
||||
'镜头生产'
|
||||
])
|
||||
const settings = wrapper.get('.admin-sider-footer [aria-label="后端连接"]')
|
||||
expect(settings.text()).toBe('后端连接')
|
||||
const settings = wrapper.get('.admin-sider-footer [aria-label="连接设置"]')
|
||||
expect(settings.text()).toBe('连接设置')
|
||||
await settings.trigger('click')
|
||||
await flushPromises()
|
||||
expect(document.querySelector('[role="dialog"][aria-label="后端连接"]')).not.toBeNull()
|
||||
expect(document.querySelector('[role="dialog"][aria-label="连接设置"]')).not.toBeNull()
|
||||
expect(wrapper.findAll('.admin-nav-scroll .n-menu .n-menu-item')).toHaveLength(9)
|
||||
})
|
||||
|
||||
@@ -227,8 +228,8 @@ describe('管理后台组件边界', () => {
|
||||
expect(css).toMatch(/@media \(max-width: 800px\)[\s\S]*?\.admin-brand\s*\{[^}]*height:\s*48px/)
|
||||
expect(css).toContain('@media (max-width: 800px)')
|
||||
expect(css).toMatch(/\.admin-sider\s*\{[^}]*transition:\s*width\s+0\.32s/)
|
||||
expect(css).toMatch(/\.workspace-tools-body\s*\{[^}]*padding:\s*16px/)
|
||||
expect(css).toMatch(/\.workspace-tools-drawer \.n-drawer-header[\s\S]*?padding:\s*16px/)
|
||||
expect(css).toMatch(/\.workspace-tools-body\s*\{[^}]*padding-inline:\s*0;[^}]*padding-bottom:\s*20px/)
|
||||
expect(css).toMatch(/\.app-dialog\s*\{[^}]*max-width:\s*calc\(100vw\s*-\s*32px\)/)
|
||||
expect(css).toMatch(
|
||||
/@media \(max-width: 800px\)[\s\S]*?\.admin-sider\s*\{[^}]*position:\s*fixed;[^}]*inset:\s*0;[^}]*width:\s*100%\s*!important;[^}]*transform:\s*translateX\(0\)/
|
||||
)
|
||||
@@ -271,6 +272,7 @@ describe('管理后台组件边界', () => {
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/assets', component: { render: () => h('p', '资产库') } },
|
||||
{ path: '/projects', component: { render: () => h('p', '项目列表') } },
|
||||
{
|
||||
path: '/projects/:projectId/:workspace',
|
||||
@@ -300,8 +302,8 @@ describe('管理后台组件边界', () => {
|
||||
const collapsedBrand = wrapper.get('.admin-brand')
|
||||
expect(collapsedBrand.classes()).toContain('is-collapsed')
|
||||
expect(collapsedBrand.text()).toContain('短剧工作台')
|
||||
const collapsedSettings = wrapper.get('.admin-sider-footer [aria-label="后端连接"]')
|
||||
expect(collapsedSettings.text()).toBe('后端连接')
|
||||
const collapsedSettings = wrapper.get('.admin-sider-footer [aria-label="连接设置"]')
|
||||
expect(collapsedSettings.text()).toBe('连接设置')
|
||||
expect(collapsedSettings.classes()).toContain('is-collapsed')
|
||||
expect(wrapper.get('.admin-topbar [aria-label="打开主菜单"] svg').classes()).toContain('lucide-panel-left-open')
|
||||
await wrapper.get('.admin-topbar [aria-label="打开主菜单"]').trigger('click')
|
||||
@@ -320,8 +322,8 @@ describe('管理后台组件边界', () => {
|
||||
const expandedBrand = wrapper.get('.admin-brand')
|
||||
expect(expandedBrand.classes()).not.toContain('is-collapsed')
|
||||
expect(expandedBrand.text()).toContain('短剧工作台')
|
||||
const expandedSettings = wrapper.get('.admin-sider-footer [aria-label="后端连接"]')
|
||||
expect(expandedSettings.text()).toBe('后端连接')
|
||||
const expandedSettings = wrapper.get('.admin-sider-footer [aria-label="连接设置"]')
|
||||
expect(expandedSettings.text()).toBe('连接设置')
|
||||
expect(expandedSettings.classes()).not.toContain('is-collapsed')
|
||||
expect(wrapper.get('.mobile-sider-close').attributes('aria-label')).toBe('关闭主菜单')
|
||||
await wrapper.get('.mobile-sider-close').trigger('click')
|
||||
@@ -330,7 +332,7 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.get('.admin-sider').attributes('style')).toContain('width: 100%')
|
||||
expect(wrapper.get('.admin-sider').attributes('aria-hidden')).toBe('true')
|
||||
expect(wrapper.get('.admin-brand').text()).toContain('短剧工作台')
|
||||
expect(wrapper.get('.admin-sider-footer [aria-label="后端连接"]').text()).toBe('后端连接')
|
||||
expect(wrapper.get('.admin-sider-footer [aria-label="连接设置"]').text()).toBe('连接设置')
|
||||
})
|
||||
|
||||
it('长弹窗使用内部滚动,提交期间禁止遮罩和 Esc 关闭', async () => {
|
||||
@@ -348,12 +350,24 @@ describe('管理后台组件边界', () => {
|
||||
expect(document.querySelector('.dialog-body-scroll .n-scrollbar-container')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('抽屉挂载 body 覆盖完整视口,开关保留列表与配置草稿', async () => {
|
||||
it('操作弹窗挂载 body 并限制视口尺寸,开关保留列表与配置草稿', async () => {
|
||||
/** 配置由工作区拥有,弹窗开关不会清空用户填写的数据。 */
|
||||
const draft = ref('')
|
||||
wrapper = mount(WorkspacePage, {
|
||||
attachTo: document.body,
|
||||
props: { split: true, compact: true },
|
||||
slots: {
|
||||
header: () => h(WorkspaceTools, { title: '测试操作' }, () => h('input', { 'aria-label': '配置草稿' })),
|
||||
header: () =>
|
||||
h(WorkspaceTools, { title: '测试操作' }, () =>
|
||||
h('input', {
|
||||
'aria-label': '配置草稿',
|
||||
value: draft.value,
|
||||
/** 输入后的草稿保存在工作区,关闭弹窗后仍可恢复。 */
|
||||
onInput: (event: Event) => {
|
||||
draft.value = (event.target as HTMLInputElement).value
|
||||
}
|
||||
})
|
||||
),
|
||||
default: '<article class="test-list">主体列表</article>'
|
||||
}
|
||||
})
|
||||
@@ -362,39 +376,42 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.get('.workspace-heading').find('[data-workspace-tools]').exists()).toBe(true)
|
||||
await wrapper.get('[data-workspace-tools]').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.getComponent(NDrawer).props()).toMatchObject({
|
||||
to: 'body',
|
||||
expect(wrapper.getComponent(AppDialog).props('wide')).toBe(true)
|
||||
expect(wrapper.getComponent(NModal).props()).toMatchObject({
|
||||
preset: 'card',
|
||||
blockScroll: true,
|
||||
placement: 'right',
|
||||
width: 'min(960px, 100%)',
|
||||
trapFocus: true,
|
||||
maskClosable: true,
|
||||
closeOnEsc: true
|
||||
})
|
||||
expect(wrapper.getComponent(NDrawerContent).props('nativeScrollbar')).toBe(false)
|
||||
expect(wrapper.find('.workspace-tools-drawer').exists()).toBe(false)
|
||||
const container = drawerPanel().element.closest('.n-drawer-container')!
|
||||
expect(wrapper.find('.app-dialog').exists()).toBe(false)
|
||||
const container = drawerPanel().element.closest('.n-modal-container')!
|
||||
expect(container.parentElement).toBe(document.body)
|
||||
expect(container.closest('main, .admin-content, .workspace-page')).toBeNull()
|
||||
expect(container.querySelector('.n-drawer-mask')).not.toBeNull()
|
||||
expect(drawerPanel().find('.n-scrollbar-container').exists()).toBe(true)
|
||||
expect(container.querySelector('.n-modal-mask')).not.toBeNull()
|
||||
expect(drawerPanel().find('.dialog-body-scroll .n-scrollbar-container').exists()).toBe(true)
|
||||
await drawerPanel().get('input[aria-label="配置草稿"]').setValue('保留配置')
|
||||
await drawerPanel().get('[aria-label="关闭操作面板"]').trigger('click')
|
||||
await drawerPanel().get('.n-card-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.getComponent(NDrawer).props('show')).toBe(false)
|
||||
expect(wrapper.getComponent(NModal).props('show')).toBe(false)
|
||||
expect(wrapper.get('.test-list').element).toBe(list)
|
||||
await wrapper.get('[data-workspace-tools]').trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().get<HTMLInputElement>('input[aria-label="配置草稿"]').element.value).toBe('保留配置')
|
||||
container.querySelector<HTMLElement>('.n-drawer-mask')!.click()
|
||||
const reopenedContainer = drawerPanel().element.closest('.n-modal-container')!
|
||||
// Naive 的 clickoutside 由完整按下/抬起事件触发,单独 click 不代表遮罩交互。
|
||||
const mask = reopenedContainer.querySelector<HTMLElement>('.n-modal-mask')!
|
||||
mask.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
|
||||
mask.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }))
|
||||
await flushPromises()
|
||||
expect(wrapper.getComponent(NDrawer).props('show')).toBe(false)
|
||||
expect(wrapper.getComponent(NModal).props('show')).toBe(false)
|
||||
expect(wrapper.get('.test-list').element).toBe(list)
|
||||
wrapper.unmount()
|
||||
wrapper = undefined
|
||||
expect(document.querySelector('.n-drawer-container')).toBeNull()
|
||||
expect(document.querySelector('.n-modal-container')).toBeNull()
|
||||
})
|
||||
|
||||
it('完成项目解锁全部左侧链接,标题不再显示状态标签和刷新按钮', async () => {
|
||||
it('服务端制作阶段就绪后解锁全部左侧链接,标题只保留项目配置入口', async () => {
|
||||
const detail = vi.spyOn(projectsApi, 'detail').mockResolvedValue({
|
||||
id: 'navigation-test',
|
||||
title: '导航测试项目',
|
||||
@@ -408,6 +425,15 @@ describe('管理后台组件边界', () => {
|
||||
world: null
|
||||
})
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
vi.spyOn(projectsApi, 'stageReadiness').mockResolvedValue({
|
||||
projectId: 'navigation-test',
|
||||
script: { ready: true, reason: null },
|
||||
breakdown: { ready: true, reason: null },
|
||||
visualStyle: { ready: true, reason: null },
|
||||
identity: { ready: true, reason: null },
|
||||
subjectAssets: { ready: true, reason: null },
|
||||
storyboard: { ready: true, reason: null }
|
||||
})
|
||||
const paths = [
|
||||
'create-drama',
|
||||
'breakdown',
|
||||
@@ -420,6 +446,8 @@ describe('管理后台组件边界', () => {
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/assets', component: { render: () => h('p', '资产库') } },
|
||||
{ path: '/projects', component: { render: () => h('p', '项目列表') } },
|
||||
{
|
||||
path: '/projects/:projectId',
|
||||
component: ProjectLayout,
|
||||
@@ -442,11 +470,12 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.get('.project-view .workspace-page').text()).toBe(path)
|
||||
}
|
||||
expect(detail).toHaveBeenCalledOnce()
|
||||
expect(wrapper.find('.project-header .n-button').exists()).toBe(false)
|
||||
expect(wrapper.get('.project-header .n-button').text()).toBe('项目配置')
|
||||
expect(wrapper.find('.project-header [aria-label="刷新项目"]').exists()).toBe(false)
|
||||
expect(wrapper.find('.project-header .n-tag').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('确认按钮有稳定根元素承接调用方间距,生产按钮显式保留上下留白', () => {
|
||||
it('确认按钮有稳定根元素承接调用方间距,生产卡片用网格间距排列操作', () => {
|
||||
wrapper = mount(ConfirmAction, {
|
||||
props: { label: '测试操作', description: '仅展示,不提交请求' },
|
||||
attrs: { class: 'mt-4' }
|
||||
@@ -455,8 +484,6 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.classes()).toContain('confirm-action')
|
||||
expect(wrapper.classes()).toContain('mt-4')
|
||||
expect(wrapper.get('button').text()).toBe('测试操作')
|
||||
expect(readAllStyles()).toMatch(
|
||||
/\.production-pipeline-card > \.confirm-action\s*\{[^}]*margin-block:\s*16px 4px/
|
||||
)
|
||||
expect(readAllStyles()).toMatch(/\.production-pipeline-card\s*\{[^}]*display:\s*grid;[^}]*gap:\s*16px;/)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user