vendor-onboarding.spec.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * ================================================================
  3. * 场景:供应商入驻 E2E 测试
  4. * ================================================================
  5. * 目标:管理员通过 cfc-web Element UI 管理后台审核供应商
  6. * 部署地址:http://cfc.iwintrue.com/admin
  7. *
  8. * 路由映射:
  9. * 服务商审核 → /vendor-review
  10. * ================================================================
  11. */
  12. const { test, expect } = require('@playwright/test');
  13. async function ensureLoggedIn(page) {
  14. const sidebar = page.locator('.sidebar-container, .el-menu-vertical-demo, .el-aside');
  15. if (await sidebar.isVisible({ timeout: 3000 }).catch(() => false)) {
  16. return;
  17. }
  18. await page.goto('/login');
  19. await page.waitForSelector('.el-input__inner', { timeout: 15000 });
  20. await page.fill('.el-input__inner', 'admin', { timeout: 5000 });
  21. const passwordInputs = page.locator('.el-input__inner').filter({ hasPlaceholder: /密码/ });
  22. if (await passwordInputs.count() > 0) {
  23. await passwordInputs.first().fill('admin123');
  24. } else {
  25. const inputs = page.locator('.el-input__inner');
  26. const count = await inputs.count();
  27. if (count >= 2) {
  28. await inputs.nth(1).fill('admin123');
  29. }
  30. }
  31. await page.click('.el-button--primary.login-btn, .el-button[type="primary"]:not(.skip)');
  32. await page.waitForURL(/\/dashboard|\/admin\/dashboard/, { timeout: 15000 });
  33. }
  34. test.describe('【场景流程】供应商入驻全流程', () => {
  35. test('[场景1] 管理员查看服务商审核列表', async ({ page }) => {
  36. await ensureLoggedIn(page);
  37. await page.goto('/vendor-review');
  38. await page.waitForLoadState('networkidle');
  39. await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 });
  40. });
  41. test('[场景2] 管理员查看服务商类型管理', async ({ page }) => {
  42. await ensureLoggedIn(page);
  43. await page.goto('/service-types');
  44. await page.waitForLoadState('networkidle');
  45. await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 });
  46. });
  47. test('[场景3] 管理员查看服务内容管理', async ({ page }) => {
  48. await ensureLoggedIn(page);
  49. await page.goto('/service-contents');
  50. await page.waitForLoadState('networkidle');
  51. await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 });
  52. });
  53. });