fix: resolve remaining TypeScript errors in mobile testing~

This commit is contained in:
张翔
2026-03-05 16:42:16 +08:00
parent c4fcbb6059
commit 941e5170e1
3 changed files with 15 additions and 15 deletions
@@ -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);
});
@@ -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);
+12 -12
View File
@@ -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<void> {
@@ -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<void> {
@@ -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<void> {
@@ -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<void> {