Skip to content

test(e2e): collab Messaging metrics — messages_sent, channel_posts (#1527) - #1578

Closed
mozhaev-dev wants to merge 1 commit into
mainfrom
test/e2e-collab-messaging
Closed

test(e2e): collab Messaging metrics — messages_sent, channel_posts (#1527)#1578
mozhaev-dev wants to merge 1 commit into
mainfrom
test/e2e-collab-messaging

Conversation

@mozhaev-dev

@mozhaev-dev mozhaev-dev commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

PR C of the #1527 split — end-to-end YAML specs over the gold view (PR A, #1567) and peer-counter query + catalog seed (PR B, #1568).

Split plan: A gold view (#1567) → B backend (#1568) → C (this) → D FE (insight-front).

Changes

One metric_key per file (current rig convention, à la collab_emails_{sent,received,read}); both query metric_id …0053.

  • collab_messaging_messages_sent.test.yaml — department of 5 with per-person totals {10,20,30,40,50} sourced across Teams + Zulip to prove the cross-vendor UNION: carol = Teams 15 + Zulip 15 = 30. Cases:
    • cross-vendor SUM (carol → 30, dept median 30 / p25 20 / p75 40 / range [10,50]),
    • single-vendor still non-NULL (bob, Zulip-only → 20),
    • empty window → NULL, not 0.
  • collab_messaging_channel_posts.test.yaml — department of 5 with Teams post+reply counts summing to {2,4,6,8,10}, proving the posts+replies fold (carol = post 4 + reply 2 = 6). Cases: fold · empty window → NULL, not 0.

Reuses existing people / m365_teams / zulip templates + schemas.

Validation

Scope notes

  • Slack is a declared source for these metrics but has no e2e fixtures yet (needs schemas/bronze_slack.users_details.yaml + a template generated from the real bronze). The multi-vendor honest-NULL contract ("drop a source → others non-NULL; drop all → NULL, not 0") is proven here with Teams + Zulip; adding Slack is a follow-up.
  • Honest-NULL "No data"/source-tooltip rendering is QUALITY 5: data + UX: honest-NULL and showing missing data (collaboration counters) #1517.

Refs #1527 · #1516

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added end-to-end metric tests for collaboration messaging activity.
    • Expanded coverage for post, reply, and message counts across multiple sources.
    • Verified duplicate records are handled correctly and empty date windows return no results.
    • Added checks for expected distribution statistics and cross-source aggregation behavior.

…1527)

PR C of the #1527 split — end-to-end YAML specs over the gold view (PR A) and
peer-counter query + catalog seed (PR B). One metric_key per file (current rig
convention, à la collab_emails_{sent,received,read}); both query metric_id …0053.

- collab_messaging_messages_sent.test.yaml: department of 5 with per-person
  totals {10,20,30,40,50} sourced across Teams + Zulip to prove the cross-vendor
  UNION — carol = Teams 15 + Zulip 15 = 30. Cases: cross-vendor sum · single-
  vendor still non-NULL (bob, Zulip-only) · empty window → NULL, not 0.
- collab_messaging_channel_posts.test.yaml: department of 5 with per-person
  Teams post+reply counts summing to {2,4,6,8,10}, proving the posts+replies
  fold (carol = post 4 + reply 2 = 6). Cases: fold · empty window → NULL, not 0.

Reuses existing people / m365_teams / zulip templates + schemas; both specs pass
static validation (ref resolution + schema padding + additionalProperties:false).

Scope notes:
- Slack is a declared source but has no e2e fixtures yet (needs
  schemas/bronze_slack.users_details.yaml + a template from the real bronze).
  The multi-vendor honest-NULL contract is proven with Teams + Zulip; adding
  Slack is a follow-up.
- Depends on PR A (gold view) + PR B (query_ref + seed) being present for the
  full ClickHouse run; not runnable green until those land. Honest-NULL "No
  data"/tooltip rendering is #1517.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergei Mozhaev <mozhaev.dev@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds two new end-to-end YAML test specifications for Collaboration Messaging metrics: collab_person_counter_daily.channel_posts and collab_person_counter_daily.messages_sent. Each defines bronze fixtures, deduplication scenarios, and query test cases validating cross-vendor aggregation, distribution statistics, and empty-window honest-NULL behavior.

Changes

Collaboration Messaging metrics e2e tests

Layer / File(s) Summary
channel_posts metric test
src/ingestion/tests/e2e/metrics/collab_messaging_channel_posts.test.yaml
Defines the channel_posts metric contract, seeds BambooHR employee and M365 Teams bronze fixtures (with a duplicate record for dedup testing), and asserts folded post+reply values, distribution stats, and empty-window NULL behavior.
messages_sent metric test
src/ingestion/tests/e2e/metrics/collab_messaging_messages_sent.test.yaml
Defines the messages_sent metric contract with honest-NULL union semantics, seeds Teams and Zulip bronze fixtures (with duplicates), and asserts cross-vendor SUM, single-vendor results, and empty-window behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Suggested reviewers: ktursunov, mitasovr

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: adding e2e tests for collab messaging metrics messages_sent and channel_posts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/e2e-collab-messaging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mozhaev-dev
mozhaev-dev marked this pull request as ready for review July 3, 2026 07:34
@mozhaev-dev
mozhaev-dev requested a review from a team as a code owner July 3, 2026 07:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/ingestion/tests/e2e/metrics/collab_messaging_messages_sent.test.yaml`:
- Around line 81-97: The bob Zulip-only test currently checks only
collab_person_counter_daily.messages_sent.value, leaving the rest of the stat
payload unverified. Update the expectation in this test case to assert the full
row shape for the messages_sent metric, including median, range_min, range_max,
p25, and p75 alongside value. Use the collab_person_counter_daily.messages_sent
metric_key in the existing collaboration query to locate the assertion block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9671b70f-ddb3-4ade-8870-7d42e9b4d19c

📥 Commits

Reviewing files that changed from the base of the PR and between 84862c5 and 9c000f0.

📒 Files selected for processing (2)
  • src/ingestion/tests/e2e/metrics/collab_messaging_channel_posts.test.yaml
  • src/ingestion/tests/e2e/metrics/collab_messaging_messages_sent.test.yaml

Comment on lines +81 to +97
# bob has ONLY Zulip — the metric is still non-NULL from the remaining source
- name: "messages_sent — single-vendor still non-NULL (bob, Zulip-only = 20)"
request:
url: /v1/metrics/queries
method: POST
body:
queries:
- id: collaboration
metric_id: 00000000-0000-0000-0001-000000000053
$filter: "person_id eq 'bob@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'"
expect:
- assert: "status == 200"
- in: collaboration
assert: "result.status == 'ok'"
- in: collaboration
find: { metric_key: collab_person_counter_daily.messages_sent }
equal: { value: 20 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== target file context ==\n'
cat -n src/ingestion/tests/e2e/metrics/collab_messaging_messages_sent.test.yaml | sed -n '1,220p'

printf '\n== sibling fixture names ==\n'
git ls-files 'src/ingestion/tests/e2e/metrics/*.test.yaml' | sed 's#^`#-` #'

printf '\n== search for no-unasserted-stat / equal semantics ==\n'
rg -n "no-unasserted-stat|unasserted-stat|range_min|range_max|p25|p75|median|metric_key: collab_person_counter_daily.messages_sent" src . -g '!**/node_modules/**'

Repository: constructorfabric/insight

Length of output: 50382


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== collab_zulip_chat fixture ==\n'
cat -n src/ingestion/tests/e2e/metrics/collab_zulip_chat.test.yaml | sed -n '1,220p'

printf '\n== collab_emails_sent fixture ==\n'
cat -n src/ingestion/tests/e2e/metrics/collab_emails_sent.test.yaml | sed -n '1,220p'

printf '\n== collab_meeting_hours fixture ==\n'
cat -n src/ingestion/tests/e2e/metrics/collab_meeting_hours.test.yaml | sed -n '1,260p'

printf '\n== exact compare / equal semantics ==\n'
rg -n "no-unasserted-stat|unasserted|find: \{ metric_key|equal: \{ value:" src docs -g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**'

Repository: constructorfabric/insight

Length of output: 30262


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== expect_engine.py relevant sections ==\n'
cat -n src/ingestion/tests/e2e/lib/expect_engine.py | sed -n '1,280p'

printf '\n== collab messaging migration ==\n'
cat -n src/backend/services/analytics-api/src/migration/m20260624_000001_collab_zulip_chat.rs | sed -n '1,260p'

Repository: constructorfabric/insight

Length of output: 26588


Complete the bob case’s stat assertions. The collab_person_counter_daily.messages_sent row also carries median, range_min, range_max, p25, and p75, so asserting only value leaves the row under-checked.

Suggested fix
       - in: collaboration
         find: { metric_key: collab_person_counter_daily.messages_sent }
-        equal: { value: 20 }
+        equal: { value: 20, median: 30, range_min: 10, range_max: 50, p25: 20, p75: 40 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# bob has ONLY Zulip — the metric is still non-NULL from the remaining source
- name: "messages_sent — single-vendor still non-NULL (bob, Zulip-only = 20)"
request:
url: /v1/metrics/queries
method: POST
body:
queries:
- id: collaboration
metric_id: 00000000-0000-0000-0001-000000000053
$filter: "person_id eq 'bob@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'"
expect:
- assert: "status == 200"
- in: collaboration
assert: "result.status == 'ok'"
- in: collaboration
find: { metric_key: collab_person_counter_daily.messages_sent }
equal: { value: 20 }
# bob has ONLY Zulip — the metric is still non-NULL from the remaining source
- name: "messages_sent — single-vendor still non-NULL (bob, Zulip-only = 20)"
request:
url: /v1/metrics/queries
method: POST
body:
queries:
- id: collaboration
metric_id: 00000000-0000-0000-0001-000000000053
$filter: "person_id eq 'bob@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'"
expect:
- assert: "status == 200"
- in: collaboration
assert: "result.status == 'ok'"
- in: collaboration
find: { metric_key: collab_person_counter_daily.messages_sent }
equal: { value: 20, median: 30, range_min: 10, range_max: 50, p25: 20, p75: 40 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ingestion/tests/e2e/metrics/collab_messaging_messages_sent.test.yaml`
around lines 81 - 97, The bob Zulip-only test currently checks only
collab_person_counter_daily.messages_sent.value, leaving the rest of the stat
payload unverified. Update the expectation in this test case to assert the full
row shape for the messages_sent metric, including median, range_min, range_max,
p25, and p75 alongside value. Use the collab_person_counter_daily.messages_sent
metric_key in the existing collaboration query to locate the assertion block.

Source: Learnings

@mozhaev-dev

Copy link
Copy Markdown
Contributor Author

Superseded by #1580 — consolidated with the e2e YAML (and the gold view #1567 as base) so the Metric coverage gate + E2E suite go green on one branch. See #1580.

@mozhaev-dev mozhaev-dev closed this Jul 3, 2026
mozhaev-dev added a commit that referenced this pull request Jul 6, 2026
The single-vendor non-NULL case asserted only `value`; the row also carries the
department bands, which are deterministic (same org_unit distribution as the
carol case). Assert median/p25/p75/range too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergei Mozhaev <mozhaev.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant