Skip to content

fix: various improvements for charts#1675

Merged
graphieros merged 4 commits intonpmx-dev:mainfrom
graphieros:main
Feb 26, 2026
Merged

fix: various improvements for charts#1675
graphieros merged 4 commits intonpmx-dev:mainfrom
graphieros:main

Conversation

@graphieros
Copy link
Contributor

@graphieros graphieros commented Feb 26, 2026

  • Add missing full stop in translation keys (versions chart composed alt text)
  • Improve chart utils test coverage

@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 26, 2026 4:54pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 26, 2026 4:54pm
npmx-lunaria Ignored Ignored Feb 26, 2026 4:54pm

Request Review

@graphieros graphieros marked this pull request as draft February 26, 2026 16:09
@github-actions
Copy link

github-actions bot commented Feb 26, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
lunaria/files/en-GB.json Localization changed, will be marked as complete.
lunaria/files/en-US.json Source changed, localizations will be marked as outdated.
lunaria/files/fr-FR.json Localization changed, will be marked as complete.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

This pull request updates localisation strings in multiple files (i18n/locales/en.json, i18n/locales/fr-FR.json, lunaria/files/en-GB.json, lunaria/files/en-US.json, lunaria/files/fr-FR.json) by inserting a period after the {per_version_analysis} placeholder and moving {watermark} to a new sentence within copy_alt.general_description. It also adds extensive unit tests at test/unit/app/utils/charts.spec.ts covering alt-text generation for trend-line and versions-bar charts, including translation mocks, dataset/config factories and numerous assertions for translation keys and named parameters.

Possibly related PRs

Suggested reviewers

  • alexdln
  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description accurately describes the changeset, covering both the punctuation fixes in translation files and the test coverage improvements for chart utilities.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf4b537 and 52aef82.

📒 Files selected for processing (6)
  • i18n/locales/en.json
  • i18n/locales/fr-FR.json
  • lunaria/files/en-GB.json
  • lunaria/files/en-US.json
  • lunaria/files/fr-FR.json
  • test/unit/app/utils/charts.spec.ts

@graphieros graphieros marked this pull request as draft February 26, 2026 16:23
auto-merge was automatically disabled February 26, 2026 16:23

Pull request was converted to draft

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
test/unit/app/utils/charts.spec.ts (2)

793-804: Add boundary tests for empty lines / bars datasets.

The suite now covers dataset: null, but not structurally empty datasets. Adding those cases will lock behaviour for index-based paths and prevent silent regressions.

Proposed test additions
 describe('createAltTextForTrendLineChart', () => {
+  it('handles dataset with empty lines without throwing', () => {
+    const { translate } = createTranslateMock()
+    const trendLineConfig = createTrendLineConfig({ $t: translate })
+
+    expect(() =>
+      createAltTextForTrendLineChart({
+        dataset: { lines: [] },
+        config: trendLineConfig,
+      } as AltCopyArgs<TrendLineDataset, TrendLineConfig>),
+    ).not.toThrow()
+  })
+
   it('returns empty string when dataset is null', () => {
     const translateMock = createTranslateMock()
     const trendLineConfig = createTrendLineConfig({ $t: translateMock.translate })
@@
 describe('createAltTextForVersionsBarChart', () => {
+  it('handles dataset with empty bars without throwing', () => {
+    const { translate } = createTranslateMock()
+    const config = createVersionsBarConfigForTests({ $t: translate as any })
+
+    expect(() =>
+      createAltTextForVersionsBarChart({
+        dataset: { bars: [] },
+        config,
+      } as AltCopyArgs<VersionsBarDataset, VersionsBarConfig>),
+    ).not.toThrow()
+  })
+
   it('returns empty string when dataset is null (does not translate)', () => {
     const { translate, calls } = createTranslateMock()

As per coding guidelines "Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index".

Also applies to: 1055-1066


35-130: Use narrower types for fixture builders to maintain type safety.

The fixture helpers (createTrendLineConfig, createDatasetWithSingleLine, createDatasetWithTwoLines, createConfig, createDataset, createVersionsBarConfigForTests, createVersionsBarDatasetForTests) use broad as any and as unknown as casts. While the tests currently work, these casts can mask contract changes if TrendLineConfig, TrendLineDataset, VersionsBarConfig, or VersionsBarDataset are updated. Consider using more specific types—for example, casting individual items to Partial<VueUiXyDatasetLineItem> rather than any, or leveraging TypeScript's type inference more directly. This aligns with the requirement to write strictly type-safe code.


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52aef82 and 46cf169.

📒 Files selected for processing (1)
  • test/unit/app/utils/charts.spec.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/unit/app/utils/charts.spec.ts (1)

35-52: Consider consolidating similar factory functions.

There are two config factory functions (createTrendLineConfig and createConfig) with overlapping purposes. Additionally, createTrendLineConfig creates an internal translateMock on line 36 that gets discarded when callers pass their own $t override.

This is a minor observation and doesn't affect test correctness, but consolidating these factories could improve maintainability.

Also applies to: 77-91


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46cf169 and e0326f9.

📒 Files selected for processing (1)
  • test/unit/app/utils/charts.spec.ts

@graphieros graphieros added this pull request to the merge queue Feb 26, 2026
Merged via the queue into npmx-dev:main with commit 7acb904 Feb 26, 2026
16 checks passed
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.

2 participants