fix: add navigation role attribute for better test selector

This commit is contained in:
张翔
2026-03-05 20:59:25 +08:00
parent 3c5d79f7e3
commit 2f6f6a6aca
3 changed files with 90 additions and 22 deletions
+23 -1
View File
@@ -26,11 +26,33 @@ test.describe('首页冒烟测试 @smoke', () => {
});
test('应该显示主导航菜单', async ({ homePage }) => {
await expect(homePage.navigation).toBeVisible();
const isMobile = await homePage.mobileMenuButton.isVisible();
if (isMobile) {
await expect(homePage.mobileMenuButton).toBeVisible();
} else {
await expect(homePage.desktopNavigation).toBeVisible();
}
const navItems = await homePage.getNavigationItemCount();
expect(navItems).toBeGreaterThan(0);
});
test('移动端应该显示导航菜单按钮', async ({ homePage, page }) => {
await page.setViewportSize({ width: 375, height: 667 });
await expect(homePage.mobileMenuButton).toBeVisible();
});
test('应该显示立即咨询按钮', async ({ homePage }) => {
const isMobile = await homePage.mobileMenuButton.isVisible();
if (isMobile) {
await homePage.mobileMenuButton.click();
await expect(homePage.mobileNavigation).toBeVisible();
const consultButton = homePage.mobileNavigation.locator('a[href="/contact"]').first();
await expect(consultButton).toBeVisible();
} else {
await expect(homePage.consultButton).toBeVisible();
}
});
test('应该显示所有主要区块', async ({ homePage }) => {
await expect(homePage.heroSection).toBeVisible();
await homePage.scrollToSection('services');