Skip to content

Fix 5 minor bugs with regression tests#25343

Draft
jkmassel wants to merge 6 commits intotrunkfrom
jkmassel/validate-bugs-tests
Draft

Fix 5 minor bugs with regression tests#25343
jkmassel wants to merge 6 commits intotrunkfrom
jkmassel/validate-bugs-tests

Conversation

@jkmassel
Copy link
Contributor

@jkmassel jkmassel commented Mar 4, 2026

Summary

Fixes five independently-identified bugs, three with accompanying unit tests:

  • Fix plugin directory entry lookup using slug instead of idPluginViewModel passed plugin.id (e.g. "jetpack/jetpack.php") to getPluginDirectoryEntry(slug:) in 4 places, but entries are keyed by plugin.state.slug (e.g. "jetpack"). Directory metadata was never populated.
  • Fix crash in DonutChartView with empty segments — When totalCount > 0 but all segment values are 0, normalizedSegments() returns [], and 0..<segments.count - 1 evaluates to 0..<-1, crashing at runtime.
  • Fix YYYY (week-year) date format to yyyy (calendar year) — The date formatter used YYYY (ISO week-year) instead of yyyy, causing dates near year boundaries to parse with the wrong year.
  • Fix nil-coalescing operator precedence in GutenbergViewControllerheight ?? 0 - borderWidth parsed as height ?? (0 - borderWidth) instead of (height ?? 0) - borderWidth.
  • Fix arrowWidth/arrowHeight mix-up in StatsChartMarkerdrawTopRightRect used arrowHeight (8px) for an x-axis calculation instead of arrowWidth (12px).

Test plan

  • Verify testDateParsingNearYearBoundary passes (PluginDirectoryTests)
  • Verify DonutChartViewTests pass (3 cases: empty segments, valid segments, zero total)
  • Verify PluginDirectoryEntryLookupTests pass (4 cases: id/slug distinction, lookup by slug, lookup by id, store lookup)
  • Visual check: Stats chart tooltip arrows render symmetrically
  • Visual check: Gutenberg editor nav bar border is correctly positioned

🤖 Generated with Claude Code

jkmassel and others added 5 commits March 3, 2026 21:50
drawTopRightRect was using arrowHeight (8px) for the x-axis
calculation instead of arrowWidth (12px), causing a 4px horizontal
offset on the tooltip arrow. All other draw*Rect methods correctly
use arrowWidth for x-axis positioning.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The ?? operator has lower precedence than -, so the expression
`height ?? 0 - borderWidth` was parsed as `height ?? (0 - borderWidth)`
instead of `(height ?? 0) - borderWidth`. This caused the navigation
bar border to be positioned at -borderWidth when navigationController
was nil.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The date formatter in PluginDirectoryServiceRemote used "YYYY"
(ISO week-year) instead of "yyyy" (calendar year). Near year
boundaries (Dec 31 / Jan 1), this caused dates to be parsed
with the wrong year. Also fixed the matching format in the
test helper.

Added a test that verifies Dec 31 2024 parses as year 2024.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
When totalCount > 0 but all segments have value 0,
normalizedSegments() filters them all out, leaving an empty array.
The loop `0..<segments.count - 1` then evaluates to `0..<-1`,
causing a fatal range error. Fixed by using max(count, 1) - 1.

Added tests for empty segments, valid segments, and zero total count.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
PluginViewModel was passing plugin.id (e.g. "jetpack/jetpack.php")
to getPluginDirectoryEntry(slug:) in 4 places, but directory entries
are keyed by plugin.state.slug (e.g. "jetpack"). This caused lookups
to always return nil, so directory metadata (descriptions, FAQs,
changelogs, ratings) was never populated.

Changed all 4 call sites to use plugin.state.slug. Added tests that
verify the id/slug distinction and correct lookup behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

The test was creating its own DateFormatter with the same format
string as production code, so a bug in both would go undetected.
Now uses PluginDirectoryGetInformationEndpoint.parseResponse()
which exercises the real decoder.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number31307
VersionPR #25343
Bundle IDcom.jetpack.alpha
Commitb35cf70
Installation URL4f85c9der6sc8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number31307
VersionPR #25343
Bundle IDorg.wordpress.alpha
Commitb35cf70
Installation URL760iq6k0k1k90
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

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.

3 participants