Skip to content

Add minimal browser test harness for tag-filter mutation sites #751

@memtomem

Description

@memtomem

What

There are now three places in packages/memtomem/src/memtomem/web/static/app.js that mutate tag-filter and trigger a re-search, and they keep accumulating subtle behavioural differences:

Site File:line Behaviour
Result-panel chip click app.js:2413 Overwrites tag-filter, calls doSearch()
Inline tag remove (clears matching filter) app.js:1885 Conditionally clears tag-filter if it equals the removed tag, calls doSearch()
Tags Cloud / List pill click (_searchByTag) app.js:4059 (post-#749) Sets tag-filter only, calls doSearch() (early-returns on empty q)

Issue #672 / PR #749 fixed the dual-axis bug in _searchByTag purely by code review + manual checking — there is no automated guard against a future helper extraction re-coupling these paths or someone "fixing" _searchByTag to also set search-input again.

Why

Suggested approach

Pick the lowest-overhead option that catches regressions in CI:

  1. Playwright + tiny smoke spec (recommended): one spec per mutation site, asserting the correct fields are populated and doSearch() request shape. Adds a Node toolchain dependency but the model is well-understood and CI patterns exist (Playwright's GitHub Action). Runs against mm web started in a fixture.
  2. jsdom + vitest: pure-JS, fast, no browser. Can exercise _searchByTag / chip handlers in isolation by injecting the DOM. Cheaper to run but requires shimming qs, api, STATE, etc. Better as a unit-test layer than an integration check.
  3. Backend-driven assertion: extend existing pytest by hitting /api/search?q=...&tag_filter=... and asserting the param shape that the frontend should send. Catches API contract drift but not the actual click → request wiring.

Option 1 + Option 3 together would give the most coverage; Option 2 alone is probably enough for the tag-filter cluster.

Out of scope

  • Full SPA test coverage (this is a foothold, not a sweep).
  • Visual regression testing.
  • Performance / load testing of the search pipeline.

Acceptance

  • A new test directory (e.g. packages/memtomem/tests/web/) runs in CI.
  • At minimum: regression test for _searchByTag pollutes search-input with tag text #672 — clicking a tag pill must NOT populate search-input.
  • Optional: regression tests for app.js:1885 and app.js:2413 paths.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions