--dryRun fails for navigate callbacks and startNavigation/endNavigation

Open Beginner friendly
#355 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cli, typescript
Domain
cli, testing-qa

Research direction

Start with UserFlowMock in packages/cli/src/lib/commands/collect/utils/user-flow/user-flow.mock.ts. Make navigate call the requestor when it is a function and otherwise call page.goto, then add no-op-style startNavigation and endNavigation methods that only log, following startTimespan and endTimespan. Done when a dry-run e2e case with a callback navigate and one with startNavigation/endNavigation completes without writing a report or raising a protocol error.

Written by the indexing model from the issue text.

Description

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.

Dominant language
HTML
Stars
131
Forks
7
Avg merge
7h 58m
Merged PRs (30d)
42

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from push-based/user-flow

All issues in push-based/user-flow

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.