Add background timeline rebuild task (mirroring stats cache pattern)
that refreshes denormalized timeline event snapshots when entities are
updated. Includes cascade logic so editing a roaster refreshes timeline
events for its roasts, bags, brews, and cups.
- Add update_by_entity/delete_by_entity/delete_all to TimelineEventRepository
- Add TimelineInvalidator with debounced background rebuild task
- Add invalidate() calls to all 7 entity update handlers
- Add delete_by_entity cleanup to define_delete_handler! macro
- Add gear_id filter to BrewFilter for cascade traversal
- Add `brewlog timeline rebuild` CLI command for full rebuild
- Add 5 integration tests for timeline sync behavior
Add {contentType: 'form'} to all edit template @put() calls so form
inputs are submitted by name rather than as Datastar signals. Replace
the quick notes text input on the brew edit page with toggle pill
buttons matching the add form. Add CLI tests for brew and cup update
commands.
Default BREWLOG_RP_ID to "localhost" and BREWLOG_RP_ORIGIN to
"http://localhost:3000". When these localhost defaults are active,
insecure cookies are enabled automatically so local dev works without
setting BREWLOG_INSECURE_COOKIES. A warning is logged at startup when
insecure cookies are active.
The insecure_cookies flag is now threaded through AppState instead of
reading the env var at cookie-set time.
- Add `define_cli_auth_test!` macro for authentication-required tests
- Add `define_cli_list_test!` macro for unauthenticated list tests
- Replace 18 auth tests and 5 list tests with macro invocations
- Add `create_entity_cli()` generic, convert per-entity helpers to
thin wrappers
- Move `create_bag` and `create_gear` from brews_cli.rs to helpers.rs
Replace CLI test child process with in-process server on a background
thread, eliminating orphan processes after test runs. Simplify server
test helpers to use AppState::from_database() instead of manual repo
construction.
- Replace password-based token creation with direct DB inserts in CLI helpers
- Use INSERT OR IGNORE for concurrent test thread safety on shared user
- Update server test helpers with passkey/registration_token repos and WebAuthn state
- Remove password-based auth tests, keep bearer token validation tests
- Set BREWLOG_RP_ID, RP_ORIGIN, OPENROUTER_API_KEY, FOURSQUARE_API_KEY in test env
- Use localhost instead of 127.0.0.1 for WebAuthn RP ID compatibility
Add 14 server API tests, 6 CLI tests, 4 Datastar fragment tests,
1 timeline event test, and backup round-trip verification. Wire
cafe_repo into test helpers.
The CLI tests hardcoded target/debug/brewlog, but nix builds in
release mode. Use Cargo's CARGO_BIN_EXE_brewlog env var which
automatically points to the correct binary location.
This enables running tests during nix build (removes doCheck = false).
The project is already built by cargo test before running tests,
so the explicit cargo build step in the TEST_SERVER lazy static
was redundant and wasteful.
All 70 tests pass (8 unit + 46 server + 16 CLI) ✅
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
- Fix server command arguments (--bind-address instead of --port, --database-url instead of --database)
- Use BREWLOG_URL environment variable for CLI commands (not BREWLOG_SERVER)
- Implement shared test server with proper mutex handling to avoid poisoning
- Create tokens via API (not interactive CLI) to avoid stdin issues
- Fix roasts tests to include required --tasting-notes argument
- Fix roasts list test to handle RoastWithRoaster nested JSON structure
- Remove create-token CLI tests (interactive stdin handling too complex for automation)
- Configure CLI tests to run serially with --test-threads=1 to share single server
All tests pass:
- ✅ 8 unit tests (password/token generation)
- ✅ 42 server API tests (including 9 auth tests)
- ✅ 15 CLI tests (roasters: 6, roasts: 5, tokens: 4)
- ✅ Total: 65 tests passing
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
- Remove unused post/put/delete/get helper methods from TestApp
- Create shared test server instance for all CLI tests using once_cell
- Use API directly to create tokens for testing (avoids interactive CLI issues)
- Simplify CLI test structure with server_info() and create_token() helpers
- Update all CLI tests to use shared server infrastructure
- Server tests (42 tests) still pass ✅
Note: CLI tests have stdin handling issues with interactive create-token command.
Using API directly for token creation in tests as workaround.
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
- Fix create_token helper to properly parse interactive output and extract token
- Update roasters_cli tests to parse JSON output and verify roaster data
- Update roasts_cli tests to parse JSON output and verify roast data
- Use BREWLOG_SERVER environment variable instead of --server flag
- Add proper assertions on JSON structure and content
Note: CLI tests currently fail due to server startup timing issues when
running multiple tests concurrently. Server tests (42 tests) all pass.
CLI test infrastructure is functional but needs serial execution or
better port management.
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
- Create tests/cli directory with test modules for roasters, roasts, and tokens
- Add helper functions for spawning test servers and running CLI commands
- Add portpicker and tempfile dev dependencies for CLI tests
- Tests demonstrate expected behavior but need CLI refinements to fully work:
* CLI commands need --server flag or better env variable handling
* create-token needs non-interactive mode for testing
* Commands should support --json output format for easier parsing
Infrastructure is ready for completion once CLI improvements are made
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>