From d1df4dd8b2e41559f0f8b0069bde8b238a3709db34da9a60c50be6a8d444da35 Mon Sep 17 00:00:00 2001 From: Claude Dev Date: Sat, 14 Mar 2026 23:37:22 -0400 Subject: [PATCH] test: add multi-cycle checkout tests Co-Authored-By: Claude Opus 4.6 (1M context) --- .../tests/Feature/MultiCycleCheckoutTest.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 website/tests/Feature/MultiCycleCheckoutTest.php diff --git a/website/tests/Feature/MultiCycleCheckoutTest.php b/website/tests/Feature/MultiCycleCheckoutTest.php new file mode 100644 index 0000000..5de9249 --- /dev/null +++ b/website/tests/Feature/MultiCycleCheckoutTest.php @@ -0,0 +1,59 @@ +plan = Plan::factory()->create([ + 'slug' => 'vps-test', + 'service_type' => 'vps', + 'price' => 15.00, + 'status' => 'active', + 'features' => ['cpu' => '2 vCPU', 'ram' => '4 GB'], + ]); + + PlanPrice::create(['plan_id' => $this->plan->id, 'billing_cycle' => 'monthly', 'price' => 15.00]); + PlanPrice::create(['plan_id' => $this->plan->id, 'billing_cycle' => 'quarterly', 'price' => 42.75]); + PlanPrice::create(['plan_id' => $this->plan->id, 'billing_cycle' => 'semi_annual', 'price' => 81.00]); + PlanPrice::create(['plan_id' => $this->plan->id, 'billing_cycle' => 'annual', 'price' => 153.00]); +}); + +it('loads checkout page with plan prices', function () { + $user = User::factory()->create(); + + $response = $this->actingAs($user) + ->get("http://account.ezscale.dev/checkout/{$this->plan->id}"); + + $response->assertOk(); + $response->assertInertia(fn ($page) => $page + ->component('Checkout/Show') + ->has('plan.prices', 4) + ); +}); + +it('validates billing_cycle on checkout', function () { + $user = User::factory()->create(); + + $response = $this->actingAs($user) + ->post("http://account.ezscale.dev/checkout/{$this->plan->id}", [ + 'gateway' => 'stripe', + 'billing_cycle' => 'weekly', + ]); + + $response->assertSessionHasErrors('billing_cycle'); +}); + +it('accepts valid billing cycles', function (string $cycle) { + $user = User::factory()->create(); + + $response = $this->actingAs($user) + ->post("http://account.ezscale.dev/checkout/{$this->plan->id}", [ + 'gateway' => 'stripe', + 'billing_cycle' => $cycle, + ]); + + $response->assertSessionDoesntHaveErrors('billing_cycle'); +})->with(['monthly', 'quarterly', 'semi_annual', 'annual']);