Files
peptiderepo 31ad0463f7 Adopt reusable CI standard + PHPUnit suite (#8)
* feat(ci): adopt estate CI + add PHPUnit suite from scratch (v1.2.0)

- Add PHPUnit 9.6 test suite (WP stubs, tests: stubs) — 40 tests across 4 files:
  MathTest: 25 tests covering all PRC_Math public methods and calculate()
  orchestrator with real peptide scenarios (BPC-157/TB-500/Semaglutide/MK-677/
  Ipamorelin) plus edge cases (zero water, negative inputs, floor rounding,
  rounding precision, mcg↔mg conversion).
  DefaultPresetsTest: 11 tests — all 8 expected slugs, required keys per preset
  (dataProvider), dose_unit validity, min<max range, source field, spot-checks.
  RestControllerTest: 7 tests — calculate() 200 + correct values (mcg+mg),
  get_presets() 200, get_preset() 200 for known slug / WP_Error for unknown.
  PresetProviderTest: 4 tests — fallback to defaults sans PR Core, slug key
  present, cache invalidation, idempotent invalidation.
- Add phpunit.xml.dist + tests/bootstrap.php (WP function/class stubs).
- Add composer test script: vendor/bin/phpunit --configuration phpunit.xml.dist.
- Add phpunit/phpunit ^9.6 + yoast/phpunit-polyfills ^2.0 to require-dev.
- Replace standalone ci.yml with thin caller to estate reusable workflow:
  uses: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main
  with: tests: stubs, has_js: true
  permissions: contents: write (required for phpcbf commit-back)
  workflow_call (required for deploy.yml gate).
- deploy.yml unchanged — already gates on ./ci.yml + uses shared deploy-app.yml.
- Version bump 1.1.0 → 1.2.0.

Agent-Session: claude/adopt-ci-20260616

* style: auto-fix PHPCS violations via phpcbf

* fix(ci): resolve latent PHPCS + JS lint failures

Latent debt surfaced by the reusable PHPCS job (previously continue-on-error).

PHPCS fixes (all pre-existing, not introduced by this PR):
- Add @package PeptideReconstitutionCalculator to file docblocks in all 12 PHP
  files (previously missing; phpcbf cannot insert missing docblock tags).
- Replace two short-ternary ?: operators in class-prc-preset-provider.php with
  full ternary (Universal.Operators.DisallowShortTernary.Found; lines 136+152).

JS lint fix:
- Add package.json + package-lock.json (no deps; lint script = node --check)
  so the reusable lint-js job's npm ci / cache: npm steps succeed. The
  calculator ships vanilla JS with no build toolchain — package.json is the
  minimal stub the reusable workflow requires for has_js: true.

Agent-Session: claude/adopt-ci-20260616

* style: auto-fix PHPCS violations via phpcbf

* fix(phpcs): suppress intentional warnings with phpcs:ignore annotations

uninstall.php: direct wpdb->query() intentional in uninstall (no caching
available); add phpcs:ignore DirectDatabaseQuery.DirectQuery and NoCaching.
class-prc-rest-controller.php get_presets(): request param required by
WP REST API callback contract; add phpcs:ignore UnusedFunctionParameter.

Agent-Session: claude/adopt-ci-20260616

---------

Co-authored-by: peptiderepo <bot@peptiderepo.com>
Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
2026-06-17 01:25:11 +07:00

53 lines
2.9 KiB
Markdown

# Changelog
All notable changes to Peptide Reconstitution Calculator are documented here.
Format: [Semantic Versioning](https://semver.org/).
## [1.2.0] — 2026-06-16
### Added
- PHPUnit test suite (WP stubs, `tests: stubs`) — 40 tests across four classes:
- `MathTest`: 25 tests covering all PRC_Math methods — concentration mg/mL,
mcg/unit, injection volume, syringe units, doses per vial, and the full
`calculate()` orchestrator with named peptide scenarios (BPC-157, TB-500,
Semaglutide, MK-677, Ipamorelin) plus edge cases (zero water, zero dose,
negative inputs, floor rounding, rounding precision).
- `DefaultPresetsTest`: 11 tests — collection count, all 8 expected slugs present,
required keys on every preset (via dataProvider), valid dose units, min < max,
source='default', and spot-checks on BPC-157 / Semaglutide / MK-677.
- `RestControllerTest`: 7 tests — calculate() 200 response + correct values for
mcg and mg dose units; get_presets() returns 200; get_preset() 200 for known
slug and WP_Error for unknown slug.
- `PresetProviderTest`: 4 tests — fallback to defaults without PR Core, all
presets have slug, cache invalidation, idempotent invalidation.
- `phpunit.xml.dist` + `tests/bootstrap.php` (WP function/class stubs).
- `composer test` script (`vendor/bin/phpunit --configuration phpunit.xml.dist`).
- `phpunit/phpunit ^9.6` and `yoast/phpunit-polyfills ^2.0` in `require-dev`.
### Changed
- `ci.yml` replaced with thin caller delegating to estate reusable workflow
(`peptide-e2e/.github/workflows/ci.yml@main`; `tests: stubs`, `has_js: true`,
`permissions: contents: write`, `workflow_call` so `deploy.yml` gate works).
## [1.1.0] — 2026-04-26
### Changed
- `assets/css/calculator.css`: adopted brand tokens — header gradient → teal (was blue), focus states → teal, results panel → teal-50, font → Inter; dark mode updated to teal scale
## [1.0.0] — 2026-04-17
### Added
- Interactive reconstitution calculator via `[prc_calculator]` shortcode.
- Client-side instant calculation: concentration (mg/mL), mcg per syringe unit, injection volume (mL), syringe units (IU), doses per vial.
- Peptide-specific presets from Peptide Repo Core (when active) with live dosing data.
- 8 built-in default presets: BPC-157, TB-500, Semaglutide, CJC-1295 (DAC), Ipamorelin, PT-141, MK-677, GHRP-6.
- Preset pre-selection via shortcode attribute: `[prc_calculator peptide="bpc-157"]`.
- REST API (`prc/v1`): GET /presets, GET /presets/{slug}, POST /calculate.
- Server-side math engine (`PRC_Math`) mirroring client-side calculations.
- Transient-cached presets with event-driven invalidation on PR Core data changes.
- Admin notice when PR Core is not installed (informational, not blocking).
- Dark mode support via `prefers-color-scheme`.
- Responsive design down to 320px viewport.
- Full teardown in `uninstall.php` (options + transients).
- CI workflow: PHP lint (8.1/8.2/8.3), PHPCS WordPress, 300-line file check.