fix: resolve remaining TypeScript errors in mobile testing~
This commit is contained in:
@@ -76,7 +76,7 @@ test.describe('移动端兼容性测试 @mobile @compatibility', () => {
|
|||||||
await expect(page.locator('header')).toBeVisible();
|
await expect(page.locator('header')).toBeVisible();
|
||||||
await expect(page.locator('main')).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);
|
expect(headerHeight).toBeLessThan(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test';
|
|||||||
import { getMobileDevices } from '../../../utils/devices';
|
import { getMobileDevices } from '../../../utils/devices';
|
||||||
import { networkConfigs } from '../../../config/network-configs';
|
import { networkConfigs } from '../../../config/network-configs';
|
||||||
import { MobilePerformanceMonitor } from '../../../utils/MobilePerformanceMonitor';
|
import { MobilePerformanceMonitor } from '../../../utils/MobilePerformanceMonitor';
|
||||||
import { MobileTestDataGenerator } from '../../../utils/MobileTestDataGenerator';
|
import { generatePerformanceBaseline } from '../../../utils/MobileTestDataGenerator';
|
||||||
|
|
||||||
test.describe('移动端性能测试 @mobile @performance', () => {
|
test.describe('移动端性能测试 @mobile @performance', () => {
|
||||||
const devices = getMobileDevices().slice(0, 3);
|
const devices = getMobileDevices().slice(0, 3);
|
||||||
@@ -19,7 +19,7 @@ test.describe('移动端性能测试 @mobile @performance', () => {
|
|||||||
const monitor = new MobilePerformanceMonitor(page);
|
const monitor = new MobilePerformanceMonitor(page);
|
||||||
const vitals = await monitor.getCoreWebVitals();
|
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.LCP).toBeLessThan(baseline.LCP);
|
||||||
expect(vitals.FCP).toBeLessThan(baseline.FCP);
|
expect(vitals.FCP).toBeLessThan(baseline.FCP);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class GestureSimulator {
|
|||||||
clientY: startY,
|
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++) {
|
for (let i = 1; i <= steps; i++) {
|
||||||
const x = startX + (endX - startX) * (i / steps);
|
const x = startX + (endX - startX) * (i / steps);
|
||||||
@@ -49,11 +49,11 @@ export class GestureSimulator {
|
|||||||
clientY: y,
|
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.waitForTimeout(stepDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.page.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] });
|
await this.page.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
async quickSwipeDown(): Promise<void> {
|
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++) {
|
for (let i = 1; i <= steps; i++) {
|
||||||
const progress = i / steps;
|
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.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> {
|
async longPress(element: Locator, duration: number = 1000): Promise<void> {
|
||||||
@@ -146,9 +146,9 @@ export class GestureSimulator {
|
|||||||
clientY: y,
|
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 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> {
|
async doubleTap(element: Locator): Promise<void> {
|
||||||
@@ -164,11 +164,11 @@ export class GestureSimulator {
|
|||||||
clientY: y,
|
clientY: y,
|
||||||
}];
|
}];
|
||||||
|
|
||||||
await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches });
|
await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any);
|
||||||
await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] });
|
await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any);
|
||||||
await this.page.waitForTimeout(100);
|
await this.page.waitForTimeout(100);
|
||||||
await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches });
|
await element.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches } as any);
|
||||||
await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] });
|
await element.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] } as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
async drag(options: DragOptions): Promise<void> {
|
async drag(options: DragOptions): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user