<?php

namespace Tests\Feature;

use Tests\TestCase;

class PaymentSuccessPageTest extends TestCase
{
    public function test_maya_payment_success_page_is_available(): void
    {
        $response = $this->get('/payments/success?booking_id=booking-123');

        $response
            ->assertOk()
            ->assertHeader('Cache-Control', 'must-revalidate, no-cache, no-store, private')
            ->assertSee('Payment successful')
            ->assertSee('booking-123')
            ->assertSee('maya_payment_return');
    }

    public function test_booking_reference_is_escaped(): void
    {
        $response = $this->get('/payments/success?booking_id=%3Cscript%3Ealert(1)%3C%2Fscript%3E');

        $response
            ->assertOk()
            ->assertDontSee('<script>alert(1)</script>', false);
    }

    public function test_maya_payment_failure_page_is_available(): void
    {
        $this->get('/payments/failure?booking_id=booking-123')
            ->assertOk()
            ->assertSee('Payment unsuccessful')
            ->assertSee('result-failure')
            ->assertSee('maya_payment_return');
    }

    public function test_maya_payment_dropout_page_is_available(): void
    {
        $this->get('/payments/dropout?booking_id=booking-123')
            ->assertOk()
            ->assertSee('Payment cancelled')
            ->assertSee('result-dropout')
            ->assertSee('maya_payment_return');
    }
}
