Skip to content

fix(api): link created resources to the selected course offering - #2

Open
sclibraries wants to merge 1 commit into
share/sanitized-monorepofrom
fix/section-resource-offering
Open

fix(api): link created resources to the selected course offering#2
sclibraries wants to merge 1 commit into
share/sanitized-monorepofrom
fix/section-resource-offering

Conversation

@sclibraries

Copy link
Copy Markdown
Owner

Summary

  • Ports the production section hotfix into apps/api: POST /course/create-resource now requires offering_id, checks it belongs to the course and matches the FOLIO listing, and links the resource to that exact offering. Previously the lookup by course + term returned the first section, so a resource added in section 03 landed on section 01.
  • Adds CreateResourceOfferingCest, a Codeception port of the legacy regression harness: section 03 links to 03, mismatched listing → 400, missing offering_id → 400.
  • Test config now mirrors config/web.php (JSON body parser, JwtIdentity for bearer tokens) plus a tiny Helper\Functional module for raw JSON posts. This also makes the pre-existing FacultySubmissionCest authenticated read pass.

actionCreateResource() is byte-identical to the deployed production controller. No frontend change needed; the admin client already sends offering_id.

Test plan

Run in the isolated stack (docker-compose.test.yml, PHP 7.2.34 / MariaDB 10.3.39):

  • codecept run functional CreateResourceOfferingCest — red before the fix (03 linked to 01; invalid requests returned 200), green after: 3 tests, 7 assertions
  • codecept run functional — 18 tests, 4 errors, 1 failure (baseline was 15 tests, 4 errors, 2 failures; the delta is the now-passing faculty read)
  • codecept run unit — 75 tests, unchanged from baseline
  • phpcs --standard=PHPCompatibility --runtime-set testVersion 7.2 clean on changed files

🤖 Generated with Claude Code

POST /course/create-resource resolved the offering by (course_id, term_id),
which is ambiguous when a course has several sections in one term: a
resource added while viewing section 03 was linked to section 01. This
ports the production hotfix into apps/api unchanged: require offering_id,
verify it belongs to the course, verify its FOLIO listing matches the
request, and link to that exact offering. The admin client already sends
offering_id.

Regression coverage ports the legacy standalone harness into the
isolated Codeception stack (CreateResourceOfferingCest): section 03 links
to section 03, a mismatched listing is rejected, a missing offering_id is
rejected.

Test-config changes needed for that: a small Helper\Functional module to
post raw JSON bodies, and config/test.php now mirrors config/web.php by
parsing JSON bodies and resolving bearer tokens through JwtIdentity. The
latter also makes FacultySubmissionCest's authenticated read pass; the
remaining functional errors/failures are the pre-existing baseline.

Verified in the isolated stack on PHP 7.2.34 / MariaDB 10.3.39:
CreateResourceOfferingCest 3/3 green (red before the fix), functional
18 tests (4 errors, 1 failure = baseline minus the now-passing read),
unit 75 tests unchanged from baseline, PHPCompatibility 7.2 clean.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lr3h4fx5cxzRJbQoZ6ijPa
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.

1 participant