/** * ================================================================ * 场景:供应商入驻 E2E 测试 * ================================================================ * 目标:管理员通过 cfc-web Element UI 管理后台审核供应商 * 部署地址:http://cfc.iwintrue.com/admin * * 路由映射: * 服务商审核 → /vendor-review * ================================================================ */ const { test, expect } = require('@playwright/test'); async function ensureLoggedIn(page) { const sidebar = page.locator('.sidebar-container, .el-menu-vertical-demo, .el-aside'); if (await sidebar.isVisible({ timeout: 3000 }).catch(() => false)) { return; } await page.goto('/login'); await page.waitForSelector('.el-input__inner', { timeout: 15000 }); await page.fill('.el-input__inner', 'admin', { timeout: 5000 }); const passwordInputs = page.locator('.el-input__inner').filter({ hasPlaceholder: /密码/ }); if (await passwordInputs.count() > 0) { await passwordInputs.first().fill('admin123'); } else { const inputs = page.locator('.el-input__inner'); const count = await inputs.count(); if (count >= 2) { await inputs.nth(1).fill('admin123'); } } await page.click('.el-button--primary.login-btn, .el-button[type="primary"]:not(.skip)'); await page.waitForURL(/\/dashboard|\/admin\/dashboard/, { timeout: 15000 }); } test.describe('【场景流程】供应商入驻全流程', () => { test('[场景1] 管理员查看服务商审核列表', async ({ page }) => { await ensureLoggedIn(page); await page.goto('/vendor-review'); await page.waitForLoadState('networkidle'); await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 }); }); test('[场景2] 管理员查看服务商类型管理', async ({ page }) => { await ensureLoggedIn(page); await page.goto('/service-types'); await page.waitForLoadState('networkidle'); await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 }); }); test('[场景3] 管理员查看服务内容管理', async ({ page }) => { await ensureLoggedIn(page); await page.goto('/service-contents'); await page.waitForLoadState('networkidle'); await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 }); }); });