Files
bitvid/issues/todo-hashtag-preferences-unit-test.md
T
google-labs-jules[bot]andPR0M3TH3AN e858f5210f chore(ai): triage TODOs and create issue for flaky test
- Created `issues/todo-hashtag-preferences-unit-test.md` to document a flaky unit test in `tests/hashtag-preferences.test.mjs`.
- Generated `artifacts/todos.txt` with the scan results.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 01:13:14 +00:00

1.3 KiB

TODO: Fix flaky unit test in tests/hashtag-preferences.test.mjs

Source: tests/hashtag-preferences.test.mjs:303

Context: The test case "load defers permission-required decrypts until explicitly enabled" has a commented-out section marked with a TODO.

// TODO: This part of the test is flaky in CI environments.
// Logs confirm the code attempts decryption ("Attempting decryption via window.nostr fallback"),
// but the mock spy is not consistently called, likely due to runNip07WithRetry/microtask timing.
//
// await hashtagPreferences.load(pubkey, { allowPermissionPrompt: true });
// ...

Problem: The test attempts to verify that hashtagPreferences.load retries decryption when allowPermissionPrompt is set to true after a previous failure. However, the mock spy for the decryption method is not consistently called in the test environment, leading to flakiness. This is likely due to race conditions or timing issues with runNip07WithRetry or microtask processing.

Suggested Next Steps:

  1. Uncomment the test code.
  2. Investigate the timing of the load call and the mock invocation.
  3. Consider using fakeTimers or explicit promise resolution waits to ensure the async operations complete before assertion.
  4. Verify the fix by running the test multiple times locally and in CI (if possible).