Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/grade-matches-shown-score.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@advance-labs/scoring': patch
---

Grade the rounded overall score, so the letter grade always matches the number shown. A raw 59.7 displayed as 60 but graded F (seen on amazon.com and adidas.com), and 79.6 displayed as 80 but graded C.
2 changes: 1 addition & 1 deletion apps/chrome-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@advance-labs/chrome-extension",
"version": "0.3.1",
"version": "0.3.2",
"private": true,
"type": "module",
"description": "AEO/GEO Chrome MV3 extension — runs a client-side AI-readiness audit on the active tab and exports a PDF.",
Expand Down
10 changes: 10 additions & 0 deletions packages/scoring/src/engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ describe('runRules', () => {
expect(score.criticalCount).toBe(1);
});

it('grades the score it shows: 59.7 displays as 60 and grades D, not F', async () => {
// Seen live on amazon.com and adidas.com ("60, grade F") and microsoft.com ("80, grade C").
const { score } = await runRules(goodContext(), [
{ ...passRule, weight: 597 },
{ ...failRule, weight: 403 },
]);
expect(score.overall).toBe(60);
expect(score.grade).toBe('D');
});

it('runs async rules and folds a thrown rule into a failed finding', async () => {
const ctx = goodContext();
const { categories, score } = await runRules(ctx, [asyncRule, throwingRule]);
Expand Down
6 changes: 4 additions & 2 deletions packages/scoring/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ export function aggregateScore(categories: ScoreCategory[]): Score {
}
}

const overall = weightTotal > 0 ? clampScore(weightedSum / weightTotal) : 100;
// Round once and grade the rounded number, so the grade always matches the score shown
// (unrounded 79.6 used to display "80" and grade C).
const overall = Math.round(weightTotal > 0 ? clampScore(weightedSum / weightTotal) : 100);

return {
overall: Math.round(overall),
overall,
grade: scoreToGrade(overall),
categories,
passedCount,
Expand Down
Loading