readest/apps/readest-app/e2e
You Gao 0535ac710a
feat(reader): vim-style find to start and extend a selection from the keyboard (#7282)
* feat(reader): search select

* refactor(reader): moved select into view

* feat: added tests for select logic

* fix: does not select from search, only options

* fix: test

* fix: CFI validation

* fix: code cleaning

* Revert "fix: code cleaning"

This reverts commit 00c9ec3b78e7f91828e28d9239f366cafddc4743.

* Revert "Revert "fix: code cleaning""

This reverts commit 2f85d454de39d3f551594a2fe0eb3c146314cbfe.

* Revert "fix: CFI validation"

This reverts commit 9ed92a3d9e6be0707513ba873687d54ad7b59d70.

* fix: cfi validation

* fix: test pt2

* feat(reader): vim-style find to start and extend a selection from the keyboard

A keyboard-only reader could act on a selection (Ctrl+H/U/N/D/T/R/C)
and adjust it with Shift+Arrows (#4728), but couldn't start one without
a mouse (#7281). Vim-style find fills that gap:

- `/` opens a command line at the bottom of the book. Enter searches the
  whole book and selects the first match at or after the current page,
  wrapping to the first. The line shows the term and `[i/N]` until Esc.
- `n` / `Shift+N` jump the selection to the next / previous match.
- While a match is selected, h l w b e j k 0 $ ( ) { } extend its moving
  end and `o` swaps the ends, as in visual mode. The page turns when the
  moving end leaves it. `y` copies (also added to Copy Selection).
- Esc clears the selection and ends it. The search stays live across
  Ctrl+H, so `/term`, Ctrl+H, `n`, Ctrl+H highlights match after match.

None of these keys change meaning unless a find is live: the handlers sit
ahead of page navigation and the Notebook in one shortcut listener and
fall through otherwise. The sidebar search and Previous/Next Result are
unchanged and keep using goTo(); vim find runs its own search so their
highlights are left alone.

A selection made by view.select(), and the keyboard extending it, opens
the toolbar and never runs the instant quick action, until the next
pointer press. Jumping to a match clears the last one's selection in
another section under the guard the cross-page path uses, so the
throttled popup dismiss can't close the new toolbar.

Chromium quirks handled: `paragraph` steps keep the caret's x, and a
forward selection won't extend back to a line or paragraph boundary, so
`}` steps to paragraphboundary and `0`/`{` move a collapsed caret and
re-extend. `w`/`e` skip spaces so they land the same with macOS and
Windows word steps.

This replaces the PR's first approach: the select() wrapper in
types/view.ts and its test are removed (foliate's view.select() already
selects), and the sidebar result click is back to goTo().

Text objects (iw/is/ip) were left out: a two-key sequence doesn't fit
the shortcut config without bare s/p bindings.

Verified:
- e2e/tests/vim-find.spec.ts (7 tests): 28/28 with --repeat-each 4.
  Before the feature 5 of 6 failed (no find line); the sidebar test
  passed. Resetting the navigated mark after the first selection fails
  "a match never runs the instant quick action, nor does extending it"
  (Dictionary opens on `e`). Dropping the stale-selection clear fails
  "n and N step through matches" (the old match stays selected).
- dev-web, Chromium: light, dark, e-ink, chrome shown (line sits above
  the footer); scrolled mode; `}` across a page turns the page; Ctrl+H,
  n, Ctrl+H made two highlights.
- annotation.spec.ts + reading.spec.ts: passed except #6540's "keeps the
  note bubble on restyle", which also fails 3/3 on main under dev-web.
- pnpm test: 1250 files, 15210 tests passed (shortcut tests updated for
  the new `n` / Shift+N defaults). pnpm lint, format:check: clean.
- i18n: 5 new strings added and translated in all 34 locales; nothing
  else in the locale files changed.
- Not run: Windows WebView2 and WebKit (macOS/iOS) word and boundary
  steps, Firefox web (no sentence/paragraph steps), Tauri builds.

Reported by you-gao on GitHub

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 18:45:25 +01:00
..
fixtures test(e2e): add a Playwright web e2e lane (reading & annotation flows) (#4214) 2026-05-18 08:22:17 +02:00
pages feat(annotator): make keeping the selection after an instant lookup optional (#6460) 2026-09-29 20:42:53 +08:00
tests feat(reader): vim-style find to start and extend a selection from the keyboard (#7282) 2026-11-03 18:45:25 +01:00
app.e2e.ts chore(testing): add Tauri integration tests and E2E test infrastructure (#3483) 2026-03-05 19:14:01 +01:00
README.md test(e2e): add a Playwright web e2e lane (reading & annotation flows) (#4214) 2026-05-18 08:22:17 +02:00
tsconfig.json chore(testing): add Tauri integration tests and E2E test infrastructure (#3483) 2026-03-05 19:14:01 +01:00

End-to-end tests

Readest has two end-to-end lanes. They cover different layers and are run separately.

Web lane — Playwright

Drives the Next.js web build (pnpm dev-web) in a real browser. Fast, no Rust build required. Tests run unauthenticated against a fresh browser context, so each test starts from an isolated, empty local library.

pnpm test:e2e:web          # run the web e2e suite (auto-starts pnpm dev-web)
pnpm test:e2e:web:headed   # run headed, one test at a time, with traces
pnpm test:e2e:web:ui       # run in the Playwright UI mode
pnpm test:e2e:web:report   # open the last HTML report

Every run writes an HTML report to playwright-report/; open it with pnpm test:e2e:web:report.

Layout:

Path Purpose
playwright.config.ts (app root) Runner config, projects, web server.
e2e/tests/ Specs (*.spec.ts).
e2e/pages/ Page Object Model — actions/queries, no assertions.
e2e/fixtures/ Shared fixtures; fixtures/books/ holds sample books.

Page objects expose locators and actions; assertions stay in the specs so failures point at test intent. To add coverage, prefer extending a page object over inlining selectors in a spec.

The demo-book auto-import (useDemoBooks) is suppressed by the base fixture so the library is deterministic; authenticated/sync flows are out of scope for this lane until a test account is provisioned.

Tauri lane — WebdriverIO

Drives the actual Tauri desktop shell via tauri-driver. Use this for coverage that depends on the native build (Rust integration, window management, platform globals).

pnpm tauri:dev:test        # start the Tauri app with the webdriver feature
pnpm test:e2e              # run wdio against it (specs: e2e/*.e2e.ts)