<?php

namespace Tests\Feature\V2\Dashboard\SafetyAndPrivacy;

use App\Models\LogList;
use App\Models\Permission;
use App\Models\SafetyAndPrivacy;
use App\Models\User;
use App\Models\UserActivityLog;
use Illuminate\Foundation\Testing\RefreshDataBase;
use Tests\TestCase;

class DeleteTest extends TestCase
{
    use RefreshDataBase;
    /**
     * A basic feature test example.
     */
    public function test_user_should_have_delete_road_item_permission(): void
    {
        $user = User::factory()->create();
        $safetyAndPrivacy = SafetyAndPrivacy::factory()->create();

        $response = $this->actingAs($user)->postJson("v2/safety_and_privacy/delete/{$safetyAndPrivacy->id}");

        $response->assertForbidden();
    }

    public function test_can_delete_a_safety_and_privacy(): void
    {
        $safetyAndPrivacy = SafetyAndPrivacy::factory()->create();
        $logList = LogList::factory()->create([
            'log_unique_code' => 1155
        ]);
        $userActivityLog = UserActivityLog::factory()->create();

        $user = User::factory()
            ->has(Permission::factory([
                'name' => 'delete-road-item'
            ]))
            ->create();

        $response = $this->actingAs($user)->postJson("v2/safety_and_privacy/delete/{$safetyAndPrivacy->id}");

        $response->assertStatus(200)
            ->assertExactJson([
                'status' => 'succeed'
            ]);
    }
}
