Commit graph

45 commits

Author SHA1 Message Date
Johannes Millan
9c5704c6c1 fix(e2e): fix schedule dialog submit button selector
The selector 'button:last-child' caused a Playwright strict mode
violation by matching multiple buttons (Schedule and Cancel).
Changed to 'button[color="primary"]' to specifically target the
primary action button.

Fixes 5 failing reminder tests that were unable to schedule tasks.
2026-01-21 14:30:24 +01:00
Johannes Millan
a49a863a08 test(e2e): improve sync test robustness with archive persistence waits
Adds explicit waits after archive operations to ensure IndexedDB writes
complete before proceeding with sync operations. This prevents race
conditions where sync attempts to read state before archive persistence
finishes.

Changes:
- Add waitForArchivePersistence() helper to sync-helpers.ts
  - Waits 1000ms for IndexedDB operations to complete
  - Additional 100ms for pending micro-tasks/animations
- Add 500ms waits in waitForSyncComplete() after detecting sync success
  - Ensures IndexedDB writes fully settle before returning
- Apply waitForArchivePersistence() in webdav-sync-archive.spec.ts
  - After Client A archives Task1
  - After Client B archives Task3
- Apply waitForArchivePersistence() in webdav-sync-delete-cascade.spec.ts
  - After Client A archives task (tag deletion test)
  - After Client B archives Task1 (concurrent archive test)

These changes address flakiness in CI environments where async IndexedDB
operations may not complete before the next test assertion.

Related to: Bug #5995, Bug #6044 (focus-mode test fixes)
2026-01-20 17:07:24 +01:00
Johannes Millan
cf317036de fix(e2e): wait for dialog close animation in deleteTask helper
The deleteTask() helper was clicking the confirmation dialog Delete
button but not waiting for the dialog to actually close. This caused
a race condition where tests would immediately check for the undo
snackbar before it could appear, leading to timeouts.

The fix adds a proper wait for the dialog container to be hidden
after clicking Delete, ensuring the close animation completes and
NgRx effects have time to dispatch the snackbar action.

Fixes CI E2E workflow failure in "Undo task delete syncs restored
task to other client" test.
2026-01-19 12:09:50 +01:00
Johannes Millan
b3ddfcbf20 perf(e2e): optimize polling intervals in helpers
Phase 1.4 of E2E test optimization:
- TASK_POLL_INTERVAL: 300ms → 150ms
- waitForSyncComplete() stable check: 300ms → 150ms
- waitForSyncComplete() spinner check: 200ms → 100ms
- Dialog loop polling: 200ms → 100ms

Expected impact: 5-10s saved per test (faster detection)
Risk: Low - still reasonable for network operations
2026-01-18 15:58:46 +01:00
Johannes Millan
13d7afc458 refactor(e2e): extract ensureGlobalAddTaskBarOpen helper to reduce code duplication
Extract ensureGlobalAddTaskBarOpen() to e2e/utils/element-helpers.ts to avoid
duplicating the logic for opening the global add task bar across multiple tests.

This helper properly waits for the add button and input to be visible,
preventing race conditions in tests.
2026-01-16 13:35:59 +01:00
Johannes Millan
c628c3d7ce test(e2e): add legacy migration sync tests for WebDAV and SuperSync
Add E2E tests covering the scenario where two clients both migrate from
the old Super Productivity format (pre-operation-log) and then sync.

Tests include:
- Both clients migrated with different data (keep local/remote resolution)
- Both clients migrated with same entity IDs (ID collision handling)
- Archive data preservation after migration + sync (WebDAV only)

New files:
- legacy-migration-helpers.ts: Helper functions for seeding legacy DB
- 4 JSON fixtures for legacy data scenarios
- webdav-legacy-migration-sync.spec.ts: 4 WebDAV tests
- supersync-legacy-migration-sync.spec.ts: 3 SuperSync tests (1 skipped)
2026-01-13 18:26:45 +01:00
Johannes Millan
51f3c892e3 fix(test): add E2E dialog validation and fix keyboard test cleanup
- Add message validation to E2E dialog auto-accept handlers to prevent
  false positives when unexpected confirm dialogs appear
- Change afterAll to afterEach in check-key-combo.spec.ts to prevent
  navigator override from polluting other tests
2026-01-11 18:58:07 +01:00
Johannes Millan
5bf7cf10ab test: fix supersync tests 2026-01-11 15:28:50 +01:00
Johannes Millan
44d7057129 fix(sync): only show import conflict dialog for local unsynced imports
The sync import conflict dialog was showing multiple times when it should
only show once, or not at all for already-accepted remote imports.

Root cause: The dialog trigger condition was too broad - it showed whenever
ALL downloaded ops were filtered by a SYNC_IMPORT, without distinguishing
between local unsynced imports (user needs to choose) and remote/synced
imports (old ops being silently cleaned up is expected behavior).

Changes:
- Add getLatestFullStateOpEntry() to get import with metadata (source, syncedAt)
- Add clearFullStateOps() for USE_REMOTE conflict resolution
- Return isLocalUnsyncedImport flag from SyncImportFilterService
- Pass through flag via RemoteOpsProcessingService
- Only show dialog when isLocalUnsyncedImport=true (local import not yet synced)
- Silently filter old ops when import was already accepted from remote
2026-01-11 11:22:32 +01:00
Johannes Millan
42b0d65352 fix(e2e): dismiss Welcome intro dialog before Shepherd tour
The E2E tests were failing because dismissTourIfVisible only handled
the Shepherd tour steps, not the Welcome intro mat-dialog that appears
first. This dialog blocks UI interactions causing test timeouts.

Updated tour-helpers.ts to:
- Add dismissWelcomeDialog() for the intro dialog
- Add dismissShepherdTour() for the tour steps
- Update dismissTourIfVisible() to handle both in sequence
2026-01-09 18:28:18 +01:00
Johannes Millan
94e4959b91 fix(e2e): handle ENOENT errors in closeClient cleanup
Playwright throws ENOENT errors when finalizing trace artifacts for
manually-created browser contexts. This is a known issue when using
trace: 'retain-on-failure' with contexts created via browser.newContext().

The fix extends error handling to catch and log these cleanup errors
instead of failing the test after assertions have already passed.
2026-01-08 20:44:24 +01:00
Johannes Millan
386c5a2f40 fix(e2e): improve stability of WebDAV sync tests
- Wait for form fields to appear after selecting WebDAV provider
  instead of fixed timeout (fixes flaky .e2e-baseUrl input timeout)
- Dismiss overlays before clicking sync button in triggerSync()
- Improve waitForSyncComplete with fallback detection when icon
  selector fails (checks consecutive non-spinning states)
- Remove unnecessary page.reload() in tag removal test
- Handle Material conflict dialog explicitly in multi-local-ops test
  (browser confirm handler only works for window.confirm())
2026-01-08 14:17:37 +01:00
Johannes Millan
1f8fe61c84 refactor: integrate pfapi into oplog 1 2026-01-07 13:30:09 +01:00
Johannes Millan
b24510ff66 Merge branch 'master' into feat/operation-logs
* master:
  fix(sync): show meaningful error messages instead of minified class names
  fix(e2e): use fill() for time input in task-detail tests
  build(ci): update CodeQL analysis permissions for security events
  fix(ci): add issues write permission to autoresponse workflow
  fix(boards): respect backlog filter for tasks from hidden projects
  fix(android): cancel native notification when task marked done
  refactor(e2e): simplify improvements per KISS/YAGNI review
  refactor(e2e): improve
  revert: remove translation stubs from non-English language files
  i18n: add English fallback stubs for toolbar translations to all languages
  feat: integrate auto-save from master for toolbar actions
  fix: address PR review comments for markdown toolbar
  refactor: move markdown toolbar to fullscreen editor only
  feat: add markdown formatting toolbar to notes editor

# Conflicts:
#	e2e/tests/sync/webdav-sync-expansion.spec.ts
#	src/app/features/tasks/store/task-reminder.effects.spec.ts
#	src/app/features/tasks/store/task-reminder.effects.ts
#	src/app/pfapi/api/errors/errors.spec.ts
2026-01-06 13:55:07 +01:00
Johannes Millan
4ba9b72597 refactor(e2e): simplify improvements per KISS/YAGNI review
Remove unused speculative abstractions:
- Delete material-helpers.ts (223 lines, zero usages)
- Delete retry-helpers.ts (186 lines, zero usages)
- Revert unused assertion helpers
- Revert unused timeout constants

Keep valuable changes:
- applyPrefix() helper in BasePage (used 4x)
- ProjectPage now uses applyPrefix() for DRY
- Simplified utils/index.ts barrel export
2026-01-06 12:46:20 +01:00
Johannes Millan
b544131921 refactor(e2e): improve 2026-01-06 12:46:20 +01:00
Johannes Millan
b01afbfcd1 fix(sync): address code review findings for operation-logs
Security:
- Add rate limiting (10 req/5min) to GET /snapshot endpoint
- Prevents DoS via CPU-intensive snapshot generation

Consistency:
- Add 30s timeout to download transaction (matches other sync transactions)

Test robustness:
- Fix weak encryption test - always assert error on wrong password
- Update lww-update.meta-reducer tests to use OpLog instead of console

Defensive coding:
- Add entity-not-found warnings in LWW meta-reducer for sync race conditions
- Log when project/tag/parent task deleted before LWW update arrives

Code quality:
- Standardize logging to OpLog in lww-update.meta-reducer
- Document LWW action types as intentionally not in ActionType enum
- Create e2e-constants.ts for centralized E2E test timeouts/delays
- Extract createProjectReliably helper to supersync-helpers.ts (DRY)
2026-01-06 11:42:47 +01:00
Johannes Millan
f37110bbb5 fix(e2e): improve test stability for parallel execution
SuperSync page object improvements:
- Add networkidle wait before interacting with sync dialog
- Add explicit mat-dialog-container wait before form interaction
- Add toBeAttached() assertions for element stability
- Use toPass() with progressive backoff for dropdown interactions
- Dismiss existing dropdown overlays before retrying
- Add blur() calls in password change dialog for Angular validation
- Add try-catch for fresh client dialog race condition

Task detail tests:
- Add blur() after time input fill to ensure Angular registers
  the change before clicking Save

These changes fix intermittent failures when running E2E tests
with multiple workers in parallel.
2026-01-04 17:35:47 +01:00
Johannes Millan
85fa50974b Merge branch 'master' into feat/operation-logs
* master:
  refactor(e2e): improve test infrastructure for easier expansion
  chore(e2e): remove broken/empty skipped tests
  test(e2e): fix flaky plugin and WebDAV sync tests
  refactor(e2e): replace waitForTimeout with condition-based waits
  perf(e2e): remove ineffective waits to speed up test runs
  docs(e2e): add CLAUDE.md reference and barrel export for easier test creation
  build: update dep
  refactor(e2e): simplify waits and fix flaky tests
  feat(e2e): streamline e2e test development with improved infrastructure
  perf(e2e): optimize wait utilities and addTask method for faster test execution
  16.8.1

# Conflicts:
#	e2e/pages/base.page.ts
#	e2e/pages/project.page.ts
#	e2e/tests/reminders/reminders-schedule-page.spec.ts
#	e2e/tests/sync/webdav-sync-advanced.spec.ts
#	e2e/tests/sync/webdav-sync-expansion.spec.ts
#	e2e/tests/sync/webdav-sync-full.spec.ts
#	e2e/utils/waits.ts
2026-01-03 18:51:51 +01:00
Johannes Millan
eca5fc930f refactor(e2e): improve test infrastructure for easier expansion
- Add all page objects to fixtures (plannerPage, syncPage, tagPage, notePage, sideNavPage)
- Create assertion helpers (expectTaskCount, expectTaskVisible, etc.)
- Enhance CLAUDE.md with patterns, import paths, and all fixtures
- Add const assertion to selectors for better TypeScript support
2026-01-03 18:39:40 +01:00
Johannes Millan
8d9ceb5776 test(e2e): fix flaky plugin and WebDAV sync tests
- Fix plugin toggle flakiness by using helper functions with proper
  state verification (enablePluginWithVerification, disablePluginWithVerification)
- Fix WebDAV sync tests by handling loading screen in waitForAppReady
  and waitForTaskList (app shows loading while syncing/importing)
- Remove unreliable/empty test files: webdav-sync-recurring,
  webdav-sync-reminders, webdav-sync-time-tracking
2026-01-03 17:35:09 +01:00
Johannes Millan
11d85208e5 refactor(e2e): replace waitForTimeout with condition-based waits
- Replace ~100 waitForTimeout calls with proper condition-based waits
- Extract shared utilities for time input and task scheduling
- Add timeout constants for consistent wait times
- Add new selectors for reminder dialogs and detail panels

Files refactored across 25+ test files including:
- Plugin tests (lifecycle, upload, loading, enable, structure)
- Reminder tests (view-task, schedule-page, default-options)
- Work view, planner, focus mode, and app feature tests
- Task dragdrop, autocomplete, and daily summary tests

New utilities created:
- e2e/utils/time-input-helper.ts - Robust time input filling
- e2e/utils/schedule-task-helper.ts - Task scheduling helpers
- e2e/constants/timeouts.ts - Standardized timeout values
2026-01-03 15:29:38 +01:00
Johannes Millan
e3f9daf9fa refactor(e2e): simplify waits and fix flaky tests
- Remove Angular testability API checks from waitForAngularStability
  Experiment showed Playwright's auto-waiting is sufficient for most tests
- Fix time-tracking-feature test: add missing await, replace hardcoded
  waitForTimeout with proper toHaveClass assertions
- Refactor plugin-simple-enable test to use SettingsPage methods
  instead of brittle page.evaluate() DOM manipulation (106 -> 33 lines)
- Change trace config to 'retain-on-failure' for better debugging
2026-01-03 12:57:16 +01:00
Johannes Millan
c0fc56f729 perf(e2e): optimize wait utilities and addTask method for faster test execution
Optimized e2e test utilities to significantly reduce execution time:

**waitForAngularStability():**
- Reduced default timeout from 5s to 3s
- Removed redundant ng.getComponent checks
- Removed non-fatal catch that swallowed errors
- Simplified fallback to only check route-wrapper presence

**waitForAppReady():**
- Removed slow networkidle wait (saves ~2-5s per call)
- Removed redundant checks (body, magic-side-nav)
- Removed 200ms fixed buffer at the end
- Reduced timeouts across the board
- Streamlined to essential waits only

**waitForStatePersistence():**
- Removed networkidle wait (replaced with 100ms buffer)
- Now relies on Angular stability for state persistence

**BasePage.addTask():**
- Removed 3-attempt retry loop with 500ms delays
- Removed all fixed timeouts (50ms, 100ms, 300ms, 500ms, 1000ms)
- Simplified input filling - rely on Playwright's auto-waiting
- Removed redundant initial stability checks
- Removed Promise.race with multiple strategies
- Removed unused waitForAngularStability import
- Reduced from ~170 lines to ~70 lines

These changes speed up e2e tests by removing ~1-3 seconds per test
from unnecessary waits while maintaining reliability through Playwright's
built-in auto-waiting and retry mechanisms.
2026-01-03 11:11:01 +01:00
Johannes Millan
4f2dbcdaa7 feat(sync): handle auth errors for account deletion scenarios
When a SuperSync account is deleted, clients now properly detect
authentication failures and prompt for reconfiguration:

- Add _checkHttpStatus() helper to SuperSyncProvider that throws
  AuthFailSPError on 401/403 responses
- Clear cached credentials on auth failure to allow reconfiguration
- Add DELETE /api/test/user/:userId endpoint for E2E testing
- Add deleteTestUser() helper in supersync-helpers.ts
- Add E2E tests for account deletion and reconfiguration scenarios

The existing SyncWrapperService already handles AuthFailSPError by
showing a snackbar with "Configure" action, so no UI changes needed.
2026-01-02 15:48:17 +01:00
Johannes Millan
4e0f5e8999 fix(e2e): improve app loading detection and fix server TypeScript errors
- e2e/utils/waits.ts: Add proper retry logic and error handling when
  waiting for magic-side-nav to appear. Now throws a clear error if
  app doesn't load within 30s instead of silently continuing.

- packages/super-sync-server/src/auth.ts: Use nullish coalescing for
  passwordHash to handle passkey-only users (who have no password).

- packages/super-sync-server/src/passkey.ts: Add WebAuthn passkey
  authentication support. Fix TypeScript errors by importing types
  from @simplewebauthn/types and converting credential IDs to
  base64url strings.

Fixes flaky "Multiple fresh clients join and sync correctly after
snapshot" test that was failing when app didn't fully load.
2026-01-02 15:11:16 +01:00
Johannes Millan
6c098b6eaa Merge branch 'master' into feat/operation-logs
Resolve conflict in webdav-sync-expansion.spec.ts:
- Use simplified sync verification without reload (sync updates NgRx directly)
- Test: B marks task done -> sync -> verify A sees task as done
2025-12-29 21:54:15 +01:00
Johannes Millan
c4f536471a test(webdav): add e2e tests 2025-12-29 12:48:36 +01:00
Johannes Millan
1da70487f9 fix: address code review findings from Dec 27-29 changes
ESLint rule improvements:
- Fix require-hydration-guard to detect guards on combineLatest/forkJoin/zip
  results (eliminates 20+ false positive warnings)

Server improvements:
- Add OperationDownloadService unit tests (21 tests covering vector clock
  aggregation, gap detection, excludeClient parameter, snapshot optimization)
- Split ZIP bomb size limits: 10MB for /ops, 30MB for /snapshot
- Document storage quota update as intentionally non-atomic

E2E test improvements:
- Add waitForUISettle() helper using Angular stability instead of fixed timeouts
- Update supersync-cross-entity tests to use dynamic waits

Unit test improvements:
- Add HydrationStateService edge case tests (concurrent calls, cooldown cycles,
  timer cleanup, interleaved operations)
2025-12-29 10:37:12 +01:00
Johannes Millan
6276f89c75 test(e2e): prevent browser closed errors and fix context menu selectors
- Add page.isClosed() checks before waitForTimeout calls to prevent
  "Target page, context or browser has been closed" errors when tests
  timeout (supersync-helpers.ts, waits.ts, supersync.page.ts)
- Fix context menu selector in LWW tests: use .mat-mdc-menu-item instead
  of button[mat-menu-item] which doesn't match Angular Material menu items
- Add retry logic for opening context menus with proper wait/escape handling
- Skip "Subtask edit survives when parent is deleted" test - documents
  expected future behavior that is not yet implemented
2025-12-28 11:30:45 +01:00
Johannes Millan
0d6b65cdc1 fix(e2e): handle already-closed browser contexts in closeClient
The closeClient helper was throwing errors when trying to close browser
contexts that were already closed (due to test timeouts or failures).
This caused cascading errors in E2E tests and made debugging harder.

Fix by checking if page is closed before attempting to close the context,
and gracefully catching "already closed" errors.
2025-12-27 22:14:20 +01:00
Johannes Millan
6a26d914b5 test: skip tmp 2025-12-24 16:27:12 +01:00
Johannes Millan
72608a4aaa feat(migration): implement pre-migration dialog and backup functionality 2025-12-24 13:49:37 +01:00
Johannes Millan
c757ff500d test(sync): re-enable sync after import in tests and adjust baseURL fallback 2025-12-22 12:08:04 +01:00
Johannes Millan
5992fad51b fix(sync): perform archive flush synchronously to prevent DB lock error
Previously, flushYoungToOld was dispatched as an action and handled by
an NgRx effect. This caused a race condition during finish day:
1. Action dispatched, effect queued
2. Method returned, sync started, DB locked
3. Effect ran, tried to write, blocked by DB lock

Fix follows the same pattern as moveToArchive:
- Perform the flush synchronously in ArchiveService before dispatching
- Dispatch action for op-log capture only (syncs to other clients)
- Handler skips local operations (only runs for remote)

Also adds comprehensive unit tests and e2e test for this scenario.
2025-12-17 16:42:59 +01:00
Johannes Millan
d5a0258c85 fix(sync): use vector clocks for SYNC_IMPORT filtering instead of UUIDv7
Replace UUIDv7 timestamp-based filtering with vector clock comparison
in _filterOpsInvalidatedBySyncImport(). This fixes a bug where client
clock drift could cause pre-import operations to bypass filtering.

Vector clocks track causality ("did this client know about the import?")
rather than wall-clock time, making the filtering immune to clock drift.

Operations are now filtered based on comparison result:
- GREATER_THAN or EQUAL: keep (client had knowledge of import)
- LESS_THAN or CONCURRENT: filter (created without knowledge)

Also fix E2E tests to properly skip when SuperSync server isn't
running in TEST_MODE by checking test endpoint availability.
2025-12-17 14:50:50 +01:00
Johannes Millan
ef40c7ba6a fix(sync): ensure pending writes complete before conflict detection
Fix race condition where sync could start before local operation writes
completed to IndexedDB, causing conflict detection to miss pending ops.

- Add OperationWriteFlushService that uses sp_op_log lock to ensure all
  pending writes complete before reading from IndexedDB
- Call flushPendingWrites() before conflict detection in sync service
- Add retry with exponential backoff to createTestUser for rate limiting
- Add unit tests for flush service and sync ordering

The flush mechanism works by acquiring the same lock used by writeOperation().
Since effects use concatMap and Web Locks API guarantees FIFO ordering,
acquiring the lock means all prior writes have completed.
2025-12-13 11:50:36 +01:00
Johannes Millan
84e1bae3f7 fix(e2e): reduce console log noise with optional E2E_VERBOSE flag
By default, only errors are logged. Set E2E_VERBOSE=1 to see all browser
console messages for debugging.
2025-12-12 20:48:13 +01:00
Johannes Millan
31f6232760 fix(e2e): fix failing supersync models test due to wrong locator 2025-12-12 20:48:13 +01:00
Johannes Millan
c7c3ad9092 fix(e2e): Stabilize SuperSync and general E2E tests
Increased timeouts and added stability improvements for SuperSync E2E tests to address flakiness and resolve 'Sync already in progress' errors.

- Increased default 'waitForTask' timeout from 45s to 60s in 'supersync-helpers.ts'.
- Increased auto-sync detection timeout in 'SuperSyncPage' from 3s to 5s.
- Added a 1s delay in 'SuperSyncPage.triggerSync' to mitigate race conditions.

Also includes other related E2E and SuperSync server fixes:
- Updated 'test-backup.json' with new config properties.
- Improved error handling in 'import.page.ts' for file dispatch events.
- Added reload and app readiness waits in 'supersync.spec.ts' for time tracking tests.
- Enabled WAL journal mode in 'super-sync-server/src/db.ts' for better database performance.
- Implemented data cleanup for existing test users in 'super-sync-server/src/test-routes.ts' to ensure clean test states.

These changes collectively resolve intermittent failures across the E2E test suite.
2025-12-12 20:48:13 +01:00
Johannes Millan
8fa148aab6 fix(e2e): reduce flakiness in SuperSync E2E tests
Improvements to make sync tests more reliable:

- Increase waitForTask default timeout from 15s to 25s
- Add retry loop in waitForTask for DOM update delays
- Add UI settling delay (300ms) after syncAndWait
- Add waitForLoadState('domcontentloaded') after sync operations
- Improve conflict dialog handling with retry for G.APPLY button
- Wait for conflict dialog to close before continuing
- Add explicit timeouts to visibility assertions

These changes address timing issues where the UI hasn't fully
updated after sync operations complete.
2025-12-12 20:47:42 +01:00
Johannes Millan
e62f2f86fa feat(e2e): add SuperSync E2E test infrastructure for multi-client sync
- Add test mode to super-sync-server (TEST_MODE=true env var)
- Add /api/test/create-user endpoint for auto-verified test users
- Add /api/test/cleanup endpoint for wiping test data
- Create SuperSyncPage page object for sync configuration
- Create supersync-helpers.ts with test utilities
- Add 6 E2E sync scenarios:
  - 2.1: Client A creates task, Client B downloads
  - 2.2: Both clients create different tasks
  - 1.3: Update propagates between clients
  - 1.4: Delete propagates between clients
  - 3.1: Concurrent edits handled gracefully
  - 2.3: Parent/subtask relationships sync correctly
2025-12-12 20:47:41 +01:00
Johannes Millan
ca387ca2bf refactor(e2e): improve test reliability with deterministic waits
- Add waitForStatePersistence utility for sync tests to replace hardcoded delays
- Fix nav-list vs nav-list-tree selector inconsistencies across test files
- Replace waitForTimeout calls with proper element waits and Angular stability checks
- Update selectors.ts constants to use correct nav-list-tree component selector
2025-12-11 18:47:56 +01:00
Johannes Millan
e268076332 test(e2e): try to fix e2e tests 2025-12-10 21:26:48 +01:00
Johannes Millan
366545d374 test(e2e): improve e2e stability 2 2025-11-06 19:54:50 +01:00