Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/build-profile.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { buildProfile } from '../dist/history/store.js';

const history = [
{ message: 'fix: bug' },
{ message: 'feat: feature' },
];

test('buildProfile returns correct profile', async () => {
const profile = await buildProfile(history);
Comment on lines +10 to +11

Copy link
Copy Markdown
Contributor

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

echo "## files"
git ls-files | rg '(^|/)(build-profile.test.mjs|store.ts|(dist|src)/history/store\.(js|ts))$' || true

echo "## test file"
if [ -f tests/build-profile.test.mjs ]; then
  cat -n tests/build-profile.test.mjs
fi

echo "## store candidates outline"
for f in $(git ls-files | rg '(^|/)store\.ts$' || true); do
  echo "--- $f"
  wc -l "$f"
  ast-grep outline "$f" --match buildProfile --view expanded || true
done

echo "## relevant buildProfile usages"
rg -n "buildProfile|historySize|history" tests src dist 2>/dev/null || true

Repository: 404-PF/commit-echo

Length of output: 43815


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "## package/test scripts"
cat -n package.json | sed -n '1,180p'

echo "## source buildProfile/loadEntries body"
sed -n '70,140p' src/history/store.ts | cat -n

echo "## existing profile tests around history fixture"
sed -n '1,110p' tests/history-profile.test.mjs | cat -n

echo "## lock dependency availability"
node - <<'JS'
const path = require('node:path');
console.log(process.version);
try {
  console.log('fs:', require.resolve('node:fs'));
} catch (e) {
  console.log('require node:fs failed:', e.message);
}
JS

Repository: 404-PF/commit-echo

Length of output: 8470


Use buildProfile’s numeric API and validate the fixture.

buildProfile only takes a numeric historySize and reads the configured history file. Passing the history array does not use the fixture through the exported API; this test can also assert only truthiness, so it may miss profile metric regressions. Create the test history file and call buildProfile(history.length), or change the exported API to accept the entries.

[functional_correcteness]

🤖 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 `@tests/build-profile.test.mjs` around lines 10 - 11, Update the test around
buildProfile to use its numeric historySize API: write the history fixture to
the configured history file, call buildProfile(history.length), and retain
assertions that validate the expected profile metrics rather than only
truthiness.

@cubic-dev-ai cubic-dev-ai Bot Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P0: The test passes an array of commit objects to buildProfile, but the function signature is buildProfile(historySize: number) — it takes a number controlling how many entries to load from the JSONL history file on disk, not an array of data. The array is silently ignored and the function returns the empty-history fallback profile every time. assert.ok(profile) passes vacuously because any object is truthy.

This test is a no-op: it never actually exercises buildProfile with the provided commit data. The existing tests/history-profile.test.mjs shows the correct approach — write real history files to a temp config directory, set HOME/APPDATA/XDG_CONFIG_HOME env vars, and call buildProfile(N) with a number.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/build-profile.test.mjs, line 11:

<comment>The test passes an array of commit objects to `buildProfile`, but the function signature is `buildProfile(historySize: number)` — it takes a **number** controlling how many entries to load from the JSONL history file on disk, not an array of data. The array is silently ignored and the function returns the empty-history fallback profile every time. `assert.ok(profile)` passes vacuously because any object is truthy.

This test is a no-op: it never actually exercises `buildProfile` with the provided commit data. The existing `tests/history-profile.test.mjs` shows the correct approach — write real history files to a temp config directory, set `HOME`/`APPDATA`/`XDG_CONFIG_HOME` env vars, and call `buildProfile(N)` with a number.</comment>

<file context>
@@ -0,0 +1,13 @@
+];
+
+test('buildProfile returns correct profile', async () => {
+  const profile = await buildProfile(history);
+  assert.ok(profile);
+});
</file context>
Fix with cubic

assert.ok(profile);

@cubic-dev-ai cubic-dev-ai Bot Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The test only checks assert.ok(profile), which passes for any truthy value and doesn't verify the actual profile fields (avgLength, prefix rates, imperative rate, sentence-case rate, scope/body usage, totalCommits). Add concrete assertions on these fields, plus fixtures covering scoped commits, non-empty bodies, and an empty-history case, so regressions in the profile computation are actually caught.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/build-profile.test.mjs, line 12:

<comment>The test only checks `assert.ok(profile)`, which passes for any truthy value and doesn't verify the actual profile fields (avgLength, prefix rates, imperative rate, sentence-case rate, scope/body usage, totalCommits). Add concrete assertions on these fields, plus fixtures covering scoped commits, non-empty bodies, and an empty-history case, so regressions in the profile computation are actually caught.</comment>

<file context>
@@ -0,0 +1,13 @@
+
+test('buildProfile returns correct profile', async () => {
+  const profile = await buildProfile(history);
+  assert.ok(profile);
+});
\ No newline at end of file
</file context>
Fix with cubic

});
Comment on lines +5 to +13

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the profile values, not only truthiness.

assert.ok(profile) passes for any truthy object. It does not verify avgLength, prefix rates, imperative rate, sentence-case rate, scope usage, body usage, or totalCommits. Add exact assertions with fixtures for scoped commits and non-empty bodies, plus an empty-history case.

🤖 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 `@tests/build-profile.test.mjs` around lines 5 - 13, Strengthen the test for
buildProfile by replacing the truthiness-only assertion with exact checks for
avgLength, prefix rates, imperative and sentence-case rates, scope and body
usage, and totalCommits. Expand the fixtures to include scoped commits and
non-empty bodies, and add a separate empty-history case asserting the expected
zero/default profile values.