From e66ab870e55a1033a2a2182b1d0926d37d0513ba Mon Sep 17 00:00:00 2001 From: leiyun Date: Sun, 30 Aug 2026 18:33:19 +0800 Subject: [PATCH] =?UTF-8?q?test(system-config):=20=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E4=BA=BA=E6=B5=AE=E7=AA=97=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E4=B8=8E=E4=B8=BB=E9=A2=98=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/system-config.spec.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/system-config.spec.ts b/tests/system-config.spec.ts index 573ae9d..1d467ac 100644 --- a/tests/system-config.spec.ts +++ b/tests/system-config.spec.ts @@ -131,7 +131,16 @@ class SystemConfigurationMock { headers: { 'Content-Type': 'text/html; charset=utf-8' }, body: ` - + `, })) } @@ -394,7 +403,26 @@ test.describe('系统配置(状态化 Mock,不访问真实 API/数据库)' await page.getByTestId('system-config-save-widget').click() await expect(page.getByTestId('system-config-widget-drawer')).toBeHidden() await expect(page.getByTestId('system-config-digital-human-widget-card')).toContainText('已接入数字教员') - await expect(page.getByTestId('global-digital-human-widget')).toHaveAttribute('src', /human\.example\.test\/embed\/dh-global-demo/) + const globalWidget = page.getByTestId('global-digital-human-widget') + await expect(globalWidget).toHaveAttribute('src', /human\.example\.test\/embed\/dh-global-demo/) + const globalWidgetBody = page.frameLocator('[data-testid="global-digital-human-widget"]').locator('body') + await expect(globalWidgetBody).toHaveAttribute('data-host-theme', 'light') + await expect(globalWidgetBody).toHaveAttribute('data-host-accent', '#197fc8') + + const widgetBeforeDrag = await globalWidget.boundingBox() + const widgetHandle = await globalWidget.elementHandle() + const widgetContent = await widgetHandle?.contentFrame() + expect(widgetBeforeDrag).not.toBeNull() + expect(widgetContent).not.toBeNull() + await widgetContent!.evaluate(() => { + parent.postMessage({ source: 'virtual-instructor-widget', type: 'drag-start', handle: 'launcher' }, '*') + parent.postMessage({ source: 'virtual-instructor-widget', type: 'drag-move', handle: 'launcher', deltaX: -180, deltaY: -120 }, '*') + parent.postMessage({ source: 'virtual-instructor-widget', type: 'drag-end', handle: 'launcher' }, '*') + }) + await expect.poll(async () => (await globalWidget.boundingBox())?.x).toBeLessThan(widgetBeforeDrag!.x - 100) + const storedWidgetPosition = await page.evaluate(() => Object.entries(localStorage) + .find(([key]) => key.startsWith('unreal-tran:web:digital-human-widget-position:v1:'))?.[1] ?? '') + expect(storedWidgetPosition).toContain('offsetX') await page.getByTestId('system-config-remove-widget').click() await page.locator('.el-message-box:visible').getByRole('button', { name: '确认移除' }).click()