Skip to content

reports: Fix broken test suite and add CI test job - #225

Open
j0ntz wants to merge 2 commits into
masterfrom
jon/fix-reports-test-ci
Open

reports: Fix broken test suite and add CI test job#225
j0ntz wants to merge 2 commits into
masterfrom
jon/fix-reports-test-ci

Conversation

@j0ntz

@j0ntz j0ntz commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

The mocha suite was broken on master and CI never caught it because no CI job ran the tests, so PRs stayed green while npm test failed. This blocks pr-land's mandatory local verification (it runs npm test) on every edge-reports-server landing.

Fix the broken suite

  • test/util.test.ts imported createQuarterBuckets, movingAveDataSort, and sevenDayDataMerge from ../lib/util, which does not exist (lib/ is gitignored build output). The functions live in src/demo/clientUtil.ts, so the import resolved to undefined and crashed the entire suite at load. Repointed the import at ../src/demo/clientUtil, matching the repo convention of importing source directly under sucrase/register (e.g. test/analytics.test.ts imports ../src/apiAnalytics).
  • The analytics fixtures (outputOne..Four in test/testData.json) still expected the stale key pluginId, but getAnalytics and the asAnalyticsResult cleaner both use partnerId. Renamed the fixture keys so they match the type contract and the function output.

Add a CI test job

  • New .github/workflows/test.yml runs the mocha suite on every pull_request, so a failing suite now blocks the PR.
  • The suite loads src/demo/clientUtil.ts, which imports the gitignored clientConfig.json. The workflow generates it with defaults via the existing src/bin/configure.ts (the same step scripts/prepare.sh runs) before running the tests, so the job is self-contained without needing the committed config.

Result: npm test passes (31 passing, 1 pending — the pre-existing describe.skipped createQuarterBuckets block).

Asana: https://app.asana.com/0/1215088146871429/1216467990623863


Note

Low Risk
Changes are limited to tests, fixtures, CI workflow, and changelog with no production runtime behavior changes.

Overview
Restores a green npm test run and adds GitHub Actions coverage so broken suites can’t slip through on green PRs.

Test fixes: test/util.test.ts now imports util helpers from src/demo/clientUtil instead of the non-existent lib/util build path. Analytics golden data in test/testData.json renames expected pluginId fields to partnerId so fixtures match getAnalytics output.

CI: New .github/workflows/test.yml runs on every pull request—checkout, Node 18, npm install --ignore-scripts, generate clientConfig.json via src/bin/configure.ts, then npm test.

CHANGELOG documents the CI job and test repair.

Reviewed by Cursor Bugbot for commit 89b314b. Bugbot is set up for automated code reviews on this repo. Configure here.

util.test.ts imported createQuarterBuckets, movingAveDataSort, and
sevenDayDataMerge from '../lib/util', which does not exist (lib/ is
gitignored build output). The functions live in src/demo/clientUtil.ts,
so the import resolved to undefined and crashed the whole suite at load.
Point the import at '../src/demo/clientUtil', matching the repo
convention of importing source directly under sucrase/register.

The analytics fixtures (outputOne..Four in testData.json) still expected
the stale keys 'appId' and 'pluginId', but getAnalytics and the
asAnalyticsResult cleaner both use 'app' and 'partnerId'. Rename the
fixture keys so they match the type contract and the function output.

@cursor cursor 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.

Stale comment

Comment thread .github/workflows/test.yml Outdated
The repo had no CI job that runs the tests, so PRs showed green while
npm test failed. Add a GitHub Actions workflow that runs the mocha suite
on every pull request.

The suite loads src/demo/clientUtil.ts, which imports clientConfig.json
(gitignored local dev config). The workflow generates it with defaults
via the existing configure.ts (the same step scripts/prepare.sh runs)
before running the tests, so the job is self-contained without needing
the committed config.
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