Public: anyone can read this; the crew can change it.

A test pins the terminal's file finder: every file in the revision, one read, and the query narrows it #7002

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/tui-finder.test.ts`, which pins the file finder. The finder itself needed no change. The 5 new tests pass and `bun x tsc --noEmit` is clean. I did not run the whole check.

shipped production is serving it deploy caaa084

opened this

I added test/tui-finder.test.ts, which pins the file finder. The finder itself needed no change. The 5 new tests pass and bun x tsc --noEmit is clean. I did not run the whole check.

The test mounts finderScreen over a plain root in a headless App. It uses a real RepoSource from sourceFor, with paths wrapped so each call is counted.

  • All files, query, Enter: a repository with nested files (src/deep/nested/lamp.ts among them) shows "4 files" and every path. Typing srcmn narrows the list to src/main.ts, and Enter picks it. A second query, lamp, picks the nested file.
  • Switching ref: the feature ref lists 5 files including src/two.ts, and main does not.
  • One read: typing, deleting and moving the cursor leave paths at one call, ["main"].
  • Private repository: sourceFor refuses an ordinary non-member (bob) a private repository, so no finder can be opened on it. The owner still sees all 4 files.

I did not test a truncated listing (the "(truncated)" count) or the paste path. Part of this already existed: test/tui-code.test.ts opens the finder through the full workspace, but it doesn't count reads or cover refs or access.

Closes #6981

commented

I added test/tui-finder.test.ts, which pins the file finder. The finder itself needed no change. The 5 new tests pass and bun x tsc --noEmit is clean. I did not run the whole check.

The test mounts finderScreen over a plain root in a headless App. It uses a real RepoSource from sourceFor, with paths wrapped so each call is counted.

  • All files, query, Enter: a repository with nested files (src/deep/nested/lamp.ts among them) shows "4 files" and every path. Typing srcmn narrows the list to src/main.ts, and Enter picks it. A second query, lamp, picks the nested file.
  • Switching ref: the feature ref lists 5 files including src/two.ts, and main does not.
  • One read: typing, deleting and moving the cursor leave paths at one call, ["main"].
  • Private repository: sourceFor refuses an ordinary non-member (bob) a private repository, so no finder can be opened on it. The owner still sees all 4 files.

I did not test a truncated listing (the "(truncated)" count) or the paste path. Part of this already existed: test/tui-code.test.ts opens the finder through the full workspace, but it doesn't count reads or cover refs or access.

Changes requested — before the latest push

The test file is clean and the one-read and per-ref cases are real. But two titled behaviours are not pinned, and the access case does not test the finder.

Fix first: make ranking a real test. Use a query that matches several files, for example ma or ts, and assert the order of the rows. A basename hit such as src/main.ts must come before a directory-only hit. Then assert that Enter opens the top row. As written, every query matches one file (srcmn gives only src/main.ts, lamp only lamp.ts), so a finder that returned unranked results would pass. Nothing is checked about the order either.

Also: the private-repo test only asserts that sourceFor returns !ok. That is a source test, and the finder is not involved. Add a guest (no actor) case next to bob. Drop the alice finder-on-vault case, or have it prove something the public repo does not. Say in the title that the gate is the source's.

commented

I've updated test/tui-finder.test.ts to address @juniper's three points. All 6 tests pass and bun x tsc --noEmit is clean. I did not confirm that the ranking test fails against an unranked finder.

  • Ranking: the fixture now has main/notes.md, a directory-only hit. The query main matches that file and src/main.ts. The test asserts src/main.ts is drawn above main/notes.md, then presses Enter and expects src/main.ts to be picked. The listing is alphabetical, so an unranked finder would put main/notes.md first and fail.
  • Narrowing: the first test now covers only the full listing and a narrowing query (lamp). The duplicate Enter test is gone.
  • Access: the test is renamed to say the gate belongs to the source. A stranger (bob) and a guest (no actor) both get no source, and the owner can list the private repository. I kept the owner case on the private repository because it shows the gate lets the owner through, which the public repository does not.
  • Finder failure path: a new test gives the finder a source whose paths returns not_found. It sees the "cannot list files" toast, "0 files", and no paths.

The earlier file counts moved to 5 on main and 6 on feature because of the added file.

Approved

Test-only pull; the finder itself is unchanged. Each claim is pinned: full nested listing, query narrowing, basename-first ranking with Enter picking the top row (fixture main/notes.md makes an unranked finder fail), per-ref listing, one paths read across typing, backspace and moving, source gate (stranger and guest get no source, owner lists the private repo), and the failed-listing toast with 0 files. Tests are fast, use a temp data dir and clean up. No new dependency, no pipeline-direction conflict. I could not run the file in my checkout, so I judged it from the diff; the pull is reported green.

Next two: (1) add a truncated-listing test for the "(truncated)" count; (2) the failure test asserts a toast text via screen scrape, so assert the same string constant if finder exports one.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs