Skip to content

fix(test/whatsapp): use stale timestamp for append-skip test case#47224

Closed
rocky-d wants to merge 1 commit into
openclaw:mainfrom
rocky-d:fix/monitor-inbox-append-test-timestamp
Closed

fix(test/whatsapp): use stale timestamp for append-skip test case#47224
rocky-d wants to merge 1 commit into
openclaw:mainfrom
rocky-d:fix/monitor-inbox-append-test-timestamp

Conversation

@rocky-d

@rocky-d rocky-d commented Mar 15, 2026

Copy link
Copy Markdown

Bug

After #42588 (843e3c1) added APPEND_RECENT_GRACE_MS = 60_000, the existing test 'handles append messages by marking them read but skipping auto-reply' started failing.

Root cause: The test passed nowSeconds() (current time) as messageTimestamp for a message that was supposed to be treated as stale history. With the new grace window, a message timestamped right now is considered recent, so the monitor processes it instead of skipping it — which is the opposite of what the test expects.

Fix

Change the test's message timestamp from nowSeconds() to nowSeconds(-120_000) (2 minutes ago), so it is clearly outside the 60-second grace window and gets skipped as intended.

- messageTimestamp: nowSeconds(),
+ messageTimestamp: nowSeconds(-120_000),

One line change. No behavior change — only test correctness fix.

Impact

Unblocks the checks (node, channels) job which has been failing on multiple open PRs since 843e3c1 was merged.

The append recency filter added in 843e3c1 uses a 60s grace window
(APPEND_RECENT_GRACE_MS). The existing test 'handles append messages by
marking them read but skipping auto-reply' passed nowSeconds() as the
message timestamp, meaning the message appeared as recent and was NOT
skipped — causing the test to fail.

Fix: use nowSeconds(-120_000) (2 minutes ago) to produce a clearly stale
timestamp that falls outside the grace window, matching the test's intent.
@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XS labels Mar 15, 2026
@greptile-apps

greptile-apps Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a broken test by correcting the message timestamp used in the 'handles append messages by marking them read but skipping auto-reply' test case.

After APPEND_RECENT_GRACE_MS = 60_000 was introduced in monitor.ts (line 416), messages with a timestamp within the last 60 seconds on an "append" upsert are treated as recent and processed normally — rather than skipped. The test was passing nowSeconds() (current time), which fell inside the grace window and caused the message to be processed instead of skipped, breaking the assertion expect(onMessage).not.toHaveBeenCalled().

The fix sets the timestamp to nowSeconds(-120_000) (2 minutes ago), which is clearly outside the 60-second window, restoring the expected skip behavior.

  • nowSeconds is defined as (offsetMs = 0) => Math.floor((Date.now() + offsetMs) / 1000), so the argument is a millisecond offset — passing -120_000 correctly produces a timestamp 2 minutes in the past (in seconds), well outside the grace boundary.
  • No production behavior is changed; this is a test-only fix.
  • The sibling test file (monitor-inbox.blocks-messages-from-unauthorized-senders-not-allowfrom.test.ts) also uses nowSeconds() but only for "notify"-type upserts where the grace window logic does not apply, so no change is needed there.

Confidence Score: 5/5

  • Safe to merge — single-line test-only fix that correctly restores intended test behavior with no production code changes.
  • The root cause is clearly diagnosed, the fix is minimal and precisely targeted (one line, test file only), the math checks out (2 min > 60 s grace window), and there are no side effects on production logic or other tests.
  • No files require special attention.

Last reviewed commit: c42339b

@rocky-d

rocky-d commented Mar 15, 2026

Copy link
Copy Markdown
Author

All CI checks are passing ✅. This is a one-line fix that unblocks the channels test suite for all current open PRs — would love a review when you get a chance!

@who96

who96 commented Mar 15, 2026

Copy link
Copy Markdown

This one-line fix unblocks the channels CI suite for all open PRs — confirmed it is failing identically on our unrelated PRs #37940 and #38232 (as well as #47347, #47305, etc.). Would love to see this merged quickly. 👍

@rocky-d

rocky-d commented Mar 16, 2026

Copy link
Copy Markdown
Author

Thanks @who96 for confirming — good to know this unblocks the channels suite for other PRs too. The fix is a one-line timestamp correction so the stale-entry guard doesn't reject legitimately recent appends during tests. Happy to rebase or add anything needed to move this forward.

@rocky-d

rocky-d commented Mar 16, 2026

Copy link
Copy Markdown
Author

All CI checks are green ✅ (25 passed, 10 skipped, 0 failed). However, the PR has conflicts with the base branch main that need to be resolved. Could you rebase this PR against the latest main branch? Once rebased, this should be ready for merge since the fix is validated and unblocks the channels test suite for other PRs.

@rocky-d

rocky-d commented Mar 16, 2026

Copy link
Copy Markdown
Author

Thank you for the contribution @who96! We appreciate the effort.

This PR's objective has been superseded by commit b2e9221 ("test(whatsapp): fix stale append inbox expectation", Mar 15) merged by maintainer Peter Steinberger. The upstream fix addresses the same issue with equivalent semantics.

Closing as superseded.

@rocky-d rocky-d closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants