test(timetable): Phase C — 57 new tests covering session 2 surface
Nine test files under tests/Feature/Artist/ exercising:
ArtistEngagementStateMachineTest 8 tests — terminal blocks, conditional
gates (Option/Contracted), full happy
path, cancel cascade
LaneCascadeServiceTest 5 tests — simple move, cascade-bump,
version mismatch, park, unpark
BumaVatCalculationTest 6 tests — D26 formula coverage:
Organisation/BookingAgency/NotApplicable,
VAT off, breakdown sum, zero fee
DemoteExpiredOptionsTest 4 tests — expired demote, future
untouched, non-Option untouched, run
twice → single option_expired entry
IdempotencyKey60sRedisTest 4 tests — missing header 400, first
cache, replay header, failed not cached
ArtistControllerTest 8 tests — index/create/destroy + cross-
tenant + duplicate detection + restore
StageControllerTest 7 tests — create + uniqueness, destroy
cascade-park, reorder permutation,
replaceDays orphan 409 + force_orphan
ArtistEngagementControllerTest 5 tests — index/create/update/destroy +
422 on invalid status transition
TimetableMoveControllerTest 3 tests — happy path with idempotency
header, missing header → 400, version
mismatch → 409
ArtistPolicyTest 6 tests — role checks, cross-tenant
denial, super_admin bypass, D27 active-
engagement gate
ActivityLogShapeTest 4 tests — performance.moved cascade
props, status_changed vs cancelled,
stage.day_added subject + props,
stage.reordered on Event subject
Bug fixes surfaced by Phase C:
Schema reality: events table uses `start_date`/`end_date` (date), not
`start_at`/`end_at`. Updated WithinEventBounds rule and the two stage_day
resolvers (LaneCascadeService + MoveTimetablePerformanceRequest) to
query the actual columns. ArtistResource.engagements_summary upcoming
filter likewise.
performances table has no organisation_id column (FK-chain via
engagement_id). Removed the org-id filter from the Rule::exists in
MoveTimetablePerformanceRequest; cross-tenant is caught by the policy
in TimetableMoveController.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1\Artist;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Stage;
|
||||
use App\Models\StageDay;
|
||||
use App\Rules\Artist\StageActiveOnEvent;
|
||||
@@ -30,13 +29,15 @@ final class MoveTimetablePerformanceRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$event = $this->route('event');
|
||||
$organisationId = $event instanceof Event ? $event->organisation_id : null;
|
||||
$resolvedEventId = $this->resolveTargetEventId();
|
||||
|
||||
return [
|
||||
// performances has no organisation_id column (FK-chain via
|
||||
// engagement_id); cross-tenant is caught by the policy in
|
||||
// TimetableMoveController via Gate::authorize('move', ...).
|
||||
'performance_id' => [
|
||||
'required', 'string', 'max:30',
|
||||
Rule::exists('performances', 'id')->where('organisation_id', $organisationId),
|
||||
Rule::exists('performances', 'id'),
|
||||
],
|
||||
'target_stage_id' => [
|
||||
'nullable', 'string', 'max:30',
|
||||
@@ -96,9 +97,9 @@ final class MoveTimetablePerformanceRequest extends FormRequest
|
||||
$match = StageDay::query()
|
||||
->where('stage_id', $stage->id)
|
||||
->join('events', 'events.id', '=', 'stage_days.event_id')
|
||||
->where('events.start_at', '<=', $start)
|
||||
->where('events.end_at', '>=', $start)
|
||||
->orderBy('events.start_at', 'desc')
|
||||
->where('events.start_date', '<=', $start->toDateString())
|
||||
->where('events.end_date', '>=', $start->toDateString())
|
||||
->orderBy('events.start_date', 'desc')
|
||||
->limit(1)
|
||||
->value('stage_days.event_id');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user