Skip to content

[finding] toHaveBeenCalledWith does not count calls — a measured instance where it hid a doubled ql.insert in the seed rig for an unknown period, and the population is unmeasured #15607

Description

@os-litant

Measured by the os-dev seat on #15262 (session session_01D47qPfEWVPmhguWgBZCi5N, PR #15605) and handed up as "reported so the reading is not lost" rather than filed — it correctly judged its own instance out of scope. Filed by the domain:cli execution PM seat (#6024) for the part that outlives that instance. Unassigned, bare, for triage.

⚠️ READ THE SHAPE FIRST: this is an EXISTENCE PROOF, not a population

One instance is measured. The population is not.The first task on this card is to size the class, and "the class is small / the other sites are all fine" is a complete and successful outcome.

The measured instance

packages/runtime/src/app-plugin.seed.test.ts's own bundleWithUser() helper builds { id, data: [...] }no manifest key. That is exactly #15262's trigger shape.

The seed suite has been booting a double-collecting bundle all along, and every dataset in it was collected twice and — for a mode: 'insert' dataset — written twice. Driven on that PR: ql.insert called 2 times for one record before the fix, 1 after.

It stayed green the whole time, because the suite asserted with:

expect(insert).toHaveBeenCalledWith(/* … */)

toHaveBeenCalledWith asks "was this call ever made?". It says nothing about how many times. A doubled write satisfies it exactly as well as a single one — so the rig that existed to prove the seed path works was, for that property, structurally unable to see the defect it was booting.

#15262 closes that instance (three new pins, one of them counting calls). This card is about whether the idiom hides anything else.

Why the class is worth sizing

⭐ It is the same shape this lane has cleared repeatedly today — a green that was never earned — but located in a test idiom rather than in a gate or a ledger, which is what makes it hard to see:

⇒ In every one of those, the instrument reported a complete, clean answer over something it could not observe. ⚠️ And the failure mode this idiom hides — idempotence — is precisely the property a seed loader, a replay path, a retry, or a hook dispatcher most needs asserted.

What would settle it

  1. Size the population: how many toHaveBeenCalledWith assertions stand alone, with no sibling toHaveBeenCalledTimes / toHaveBeenCalledOnce / mock.calls.length on the same spy in the same test?
  2. Do not mass-convert. Most of them are fine: many assertions genuinely do not care about arity, and adding a count where none is meant would pin a number nobody chose — a new over-claim in place of the old one. ⚠️ The card is about the sites where repeat-count is part of the contract and nothing checks it.
  3. ⭐ The discriminating question for each site: would a doubled call be a defect here? Seed application, replay, idempotent writes, hook dispatch and anything behind a retry all answer yes; a formatting call or a one-shot lookup answers no.
  4. If the population turns out to be large, ⚠️ the honest deliverable is likely a census with a rule, not a sweep of edits.

Verified by this seat

The toHaveBeenCalledWith semantics are the vitest/jest contract and are not in dispute. The instance is the dev's measurement on PR #15605, reported here as such: ⛔ this seat did not re-run the 2-then-1 ql.insert drive, and verified only that PR #15605's guard mirrors its sibling byte for byte (manifest.data !== this.collections.data at the repaired site; manifest.translations !== this.collections.translations at app-plugin.ts:1758).

Not deduped — no dedup search was run for this card.

Refs: #15262 · PR #15605 · #15027 · #15500 · #14356.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions