diff --git a/e2e/src/tests/mobile/compatibility/mobile-compatibility.spec.ts b/e2e/src/tests/mobile/compatibility/mobile-compatibility.spec.ts index 4935f5d..03d6a4b 100644 --- a/e2e/src/tests/mobile/compatibility/mobile-compatibility.spec.ts +++ b/e2e/src/tests/mobile/compatibility/mobile-compatibility.spec.ts @@ -76,7 +76,7 @@ test.describe('移动端兼容性测试 @mobile @compatibility', () => { await expect(page.locator('header')).toBeVisible(); await expect(page.locator('main')).toBeVisible(); - const headerHeight = await page.locator('header').evaluate(el => el.offsetHeight); + const headerHeight = await page.locator('header').evaluate(el => (el as HTMLElement).offsetHeight); expect(headerHeight).toBeLessThan(100); }); diff --git a/e2e/src/tests/mobile/performance/mobile-performance.spec.ts b/e2e/src/tests/mobile/performance/mobile-performance.spec.ts index f34f3b5..e67ccff 100644 --- a/e2e/src/tests/mobile/performance/mobile-performance.spec.ts +++ b/e2e/src/tests/mobile/performance/mobile-performance.spec.ts @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; import { getMobileDevices } from '../../../utils/devices'; import { networkConfigs } from '../../../config/network-configs'; import { MobilePerformanceMonitor } from '../../../utils/MobilePerformanceMonitor'; -import { MobileTestDataGenerator } from '../../../utils/MobileTestDataGenerator'; +import { generatePerformanceBaseline } from '../../../utils/MobileTestDataGenerator'; test.describe('移动端性能测试 @mobile @performance', () => { const devices = getMobileDevices().slice(0, 3); @@ -19,7 +19,7 @@ test.describe('移动端性能测试 @mobile @performance', () => { const monitor = new MobilePerformanceMonitor(page); const vitals = await monitor.getCoreWebVitals(); - const baseline = MobileTestDataGenerator.generatePerformanceBaseline(device.name, network); + const baseline = generatePerformanceBaseline(device.name, network); expect(vitals.LCP).toBeLessThan(baseline.LCP); expect(vitals.FCP).toBeLessThan(baseline.FCP); diff --git a/e2e/src/utils/GestureSimulator.ts b/e2e/src/utils/GestureSimulator.ts index 63d3b84..b9659e7 100644 --- a/e2e/src/utils/GestureSimulator.ts +++ b/e2e/src/utils/GestureSimulator.ts @@ -37,7 +37,7 @@ export class GestureSimulator { clientY: startY, }]; - await this.page.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches }); + await this.page.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any); for (let i = 1; i <= steps; i++) { const x = startX + (endX - startX) * (i / steps); @@ -49,11 +49,11 @@ export class GestureSimulator { clientY: y, }]; - await this.page.dispatchEvent('touchmove', { touches: moveTouches, changedTouches: moveTouches, targetTouches: moveTouches }); + await this.page.dispatchEvent('touchmove', { touches: moveTouches, changedTouches: moveTouches, targetTouches: moveTouches } as any); await this.page.waitForTimeout(stepDuration); } - await this.page.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] }); + await this.page.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any); } async quickSwipeDown(): Promise { @@ -106,7 +106,7 @@ export class GestureSimulator { }, ]; - await this.page.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches }); + await this.page.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any); for (let i = 1; i <= steps; i++) { const progress = i / steps; @@ -126,11 +126,11 @@ export class GestureSimulator { }, ]; - await this.page.dispatchEvent('touchmove', { touches: moveTouches, changedTouches: moveTouches, targetTouches: moveTouches }); + await this.page.dispatchEvent('touchmove', { touches: moveTouches, changedTouches: moveTouches, targetTouches: moveTouches } as any); await this.page.waitForTimeout(stepDuration); } - await this.page.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] }); + await this.page.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any); } async longPress(element: Locator, duration: number = 1000): Promise { @@ -146,9 +146,9 @@ export class GestureSimulator { clientY: y, }]; - await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches }); + await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any); await this.page.waitForTimeout(duration); - await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] }); + await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any); } async doubleTap(element: Locator): Promise { @@ -164,11 +164,11 @@ export class GestureSimulator { clientY: y, }]; - await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches }); - await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] }); + await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any); + await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any); await this.page.waitForTimeout(100); - await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches }); - await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] }); + await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any); + await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any); } async drag(options: DragOptions): Promise {