Skip to content

test(widget): add tests for bubble persistence, pre-chat message submit, and streamed sources - #633

Merged
anurag629 merged 1 commit into
codercops:devfrom
bhushan4work:613
Nov 21, 2026
Merged

anurag629 merged 1 commit into
codercops:devfrom
bhushan4work:613

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

What does this change?

Adds unit tests for three documented widget behaviors that lacked test coverage:

  1. Welcome bubble showOnce persistence across local, session, and none modes, as well as position: 'bottom-left'.
  2. Pre-chat form submission with a message field sending a chat request with that text, and sending nothing when empty.
  3. Streamed replies with multiple source parts, asserting links are rendered, included in the message event payload, stored in localStorage, and restored on next widget open.

Closes #613

How I tested this

  1. Mutation checks:
    • Temporarily commented packages/widget/src/dom/bubble.ts line 56: confirmed the new bubble persistence tests failed, restored the line, and confirmed they passed.
    • Temporarily commented packages/widget/src/widget.ts line 754: confirmed the new pre-chat submit tests failed, restored the line, and confirmed they passed.
    • Temporarily commented packages/widget/src/widget.ts line 963: confirmed the new stream sources test failed, restored the line, and confirmed it passed.
  2. Verified coverage:
    • Ran pnpm vitest run --project @chatcops/widget (passed, 33/33 test files).
    • Ran pnpm test:coverage and confirmed in coverage/lcov-report/index.html that bubble.ts line 56 and widget.ts lines 754, 962, 963 are now covered.
    • Ran pnpm lint (passed cleanly).

AI assistance

None

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • pnpm api run and api/ committed if an exported type or option changed
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bhushan4work. The 'local' and 'session' tests have a second widget stay hidden after the first one's bubble was shown, which only holds because of the early return at packages/widget/src/dom/bubble.ts:56, and 'none' shows it again. The pre-chat test covers both sides of if (data.message) at widget.ts:756, and since the message case sees sendMessage called right away, the empty case would catch a stray send. The sources test follows both links from the stream through the message event and localStorage to a new widget. All checks pass, including e2e.

@anurag629
anurag629 merged commit 4ed590e into codercops:dev Nov 21, 2026
5 checks passed
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @bhushan4work.

@github-actions github-actions Bot added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for three documented widget behaviors that no unit test runs

2 participants