occupation-onboarding.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { TID_TASK_SETTINGS_BUTTON } from "@zcode/shared/test-ids";
  2. import { sel } from "./selectors.js";
  3. // 新隔离 profile 的职业引导会覆盖工作区;通过真实 UI 完成,不伪造业务记录。
  4. // keepCloudDialog:营销专项用例要断言投放弹窗本身,传 true 保留弹窗。
  5. export async function skipOccupationOnboardingIfPresent(
  6. options: { keepCloudDialog?: boolean } = {},
  7. ) {
  8. await browser.waitUntil(
  9. async () =>
  10. (await $('[data-testid="onboarding-page"]').isExisting()) ||
  11. (await $(sel(TID_TASK_SETTINGS_BUTTON)).isExisting()),
  12. { timeout: 30000 },
  13. );
  14. // 新隔离 profile 可能进入职业引导,按真实 UI 跳过三步,不改全局测试夹具。
  15. for (
  16. let step = 0;
  17. step < 3 && (await $('[data-testid="onboarding-page"]').isExisting());
  18. step++
  19. ) {
  20. if (!options.keepCloudDialog) {
  21. await closeCloudContentDialogIfPresent();
  22. }
  23. const skip = $('//button[normalize-space(.)="Skip" or normalize-space(.)="跳过"]');
  24. await skip.waitForClickable({ timeout: 15000 });
  25. await skip.click();
  26. }
  27. await $('[data-testid="onboarding-page"]').waitForExist({ reverse: true, timeout: 15000 });
  28. }
  29. // 测试后端的真实营销投放(如 2026-11 的版本介绍弹窗)会盖住引导页,「跳过」一直不可点,
  30. // 整条用例开局就失败。弹窗是真实流程的一部分:出现就按用户操作点关闭,不出现不等待。
  31. async function closeCloudContentDialogIfPresent() {
  32. const dialog = $('[data-testid="cloud-content-dialog"]');
  33. if (!(await dialog.isDisplayed())) return;
  34. await dialog.$('[data-slot="dialog-close"]').click();
  35. await dialog.waitForExist({ reverse: true, timeout: 15000 });
  36. }
  37. // 用产品支持的 Escape 退出引导(与“退出引导”按钮同一 closeOnboarding 路径,且不依赖界面语言):
  38. // 只持久化 dismissed 决策,不像“跳过”那样把 memoryEnabled 等偏好落成保守默认值,
  39. // 供通用工作区就绪等待使用。
  40. export async function dismissOccupationOnboarding() {
  41. await browser.keys("Escape");
  42. }