--dryRun fails for navigate callbacks and startNavigation/endNavigation

未关闭 适合新手
#355 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cli, typescript
领域
cli, testing-qa

调研方向

从 packages/cli/src/lib/commands/collect/utils/user-flow/user-flow.mock.ts 中的 UserFlowMock 开始。让 navigate 在 requestor 为函数时调用它,否则调用 page.goto。然后仿照 startTimespan 和 endTimespan,添加仅输出日志的空操作风格方法 startNavigation 和 endNavigation。当一个使用回调式 navigate 的 dry-run e2e 用例,以及一个使用 startNavigation/endNavigation 的用例都能完成,且不写入报告、不抛出协议错误时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug

Problem

collect --dryRun fails for any flow that navigates with a callback, or calls startNavigation/endNavigation. It fails before writing any report.

UserFlowMock (packages/cli/src/lib/commands/collect/utils/user-flow/user-flow.mock.ts) stands in for Lighthouse's UserFlow in a dry run:

  • navigate(requestor) always calls page.goto(requestor). When requestor is a function, as in flow.navigate(async () => page.click('a')), Chrome rejects it:

    ProtocolError: Protocol error (Page.navigate): Invalid parameters Failed to deserialize params.url - BINDINGS: mandatory field missing at position 50
    
  • It has no startNavigation or endNavigation methods. A flow that calls them, or a recording with startNavigation/endNavigation steps, cannot run.

Reproduction

user-flow 0.21.6, with no Lighthouse config:

// user-flows/click.uf.mts
export default {
  flowOptions: { name: 'Click' },
  interactions: async ({ flow, page, collectOptions }) => {
    await flow.navigate(collectOptions.url);
    await flow.navigate(async () => {
      await page.click('a');
    });
  },
};
npx user-flow collect --url https://example.com --ufPath ./user-flows --dryRun

flow.navigate(collectOptions.url) alone dry-runs fine.

Proposed fix

In UserFlowMock:

  • navigate: run the callback when requestor is a function, otherwise page.goto(requestor);
  • add startNavigation and endNavigation, which only log, like startTimespan and endTimespan.

Tests: a dry-run e2e case with a callback navigate and with startNavigation/endNavigation.

Context: these are how @push-based/lighthouse-soft-navigation measures soft navigations, so dry runs of those flows fail today.

主要语言
HTML
星标
131
派生
7
平均合并
7 小时 58 分钟
30 天内合并 PR
42

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

push-based/user-flow 的其他 Issue

查看 push-based/user-flow 的全部 Issue

相似的 Issue

更多 CLI Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。