Fix tests

This commit is contained in:
Jay Sizzla
2025-10-30 16:22:00 +00:00
parent 6a472433c9
commit 25acde5e8d
6 changed files with 15 additions and 13 deletions

View File

@@ -29,7 +29,7 @@ class ReportAssigneeController extends Controller
{
$report->update($request->validated());
$assignedStaff = User::findOrFail($request->integer('staff_id'));
$assignedStaff = User::findOrFail($request->integer('assigned_to'));
$assignedStaff->notify(new NewReportAssigned($report));

View File

@@ -70,7 +70,7 @@ class ReportSearch extends Component
*/
final protected \Illuminate\Pagination\LengthAwarePaginator $reports {
get => Report::query()
->with('reported.group', 'reporter.group', 'staff.group')
->with('reported.group', 'reporter.group', 'assignee.group')
->when($this->type !== null, fn ($query) => $query->where('type', '=', $this->type))
->when($this->reporter !== null, fn ($query) => $query->whereRelation('reporter', 'username', 'LIKE', '%'.$this->reporter.'%'))
->when($this->reported !== null, fn ($query) => $query->whereRelation('reported', 'username', 'LIKE', '%'.$this->reported.'%'))

View File

@@ -28,7 +28,9 @@ use AllowDynamicProperties;
* @property int $id
* @property string $type
* @property int $reporter_id
* @property int|null $staff_id
* @property int $reported_user_id
* @property int $reported_torrent_id
* @property int $reported_request_id
* @property string $title
* @property string $message
* @property int|null $solved_by
@@ -59,13 +61,13 @@ final class Report extends Model
/**
* Get the attributes that should be cast.
*
* @return array{snoozed_until: 'datetime', closed_at: 'datetime'}
* @return array{snoozed_until: 'datetime', solved_at: 'datetime'}
*/
protected function casts(): array
{
return [
'snoozed_until' => 'datetime',
'closed_at' => 'datetime',
'solved_at' => 'datetime',
];
}

View File

@@ -43,7 +43,7 @@ class ReportFactory extends Factory
'reported_torrent_id' => Torrent::factory(),
'reported_request_id' => TorrentRequest::factory(),
'message' => $this->faker->text(),
'staff_id' => User::factory(),
'assigned_to' => User::factory(),
'verdict' => $this->faker->text(),
'created_at' => $this->faker->dateTime(),
'updated_at' => $this->faker->optional()->dateTime(),

View File

@@ -157,8 +157,8 @@
@csrf
<p class="form__group">
<select
id="staff_id"
name="staff_id"
id="assigned_to"
name="assigned_to"
class="form__select"
x-on:change="$root.submit()"
>
@@ -166,13 +166,13 @@
@foreach ($staff as $staffUser)
<option
value="{{ $staffUser->id }}"
@selected($staffUser->id === $report->staff_id)
@selected($staffUser->id === $report->assigned_to)
>
{{ $staffUser->username }}
</option>
@endforeach
</select>
<label class="form__label form__label--floating" for="staff_id">
<label class="form__label form__label--floating" for="assigned_to">
{{ __('ticket.assign') }}
</label>
</p>

View File

@@ -34,14 +34,14 @@ test('assign a staff member to a report returns an ok response', function (): vo
]);
$response = $this->actingAs($staff1)->post(route('staff.reports.assignee.store', [$report]), [
'staff_id' => $staff2->id,
'assigned_to' => $staff2->id,
]);
$response->assertRedirect(route('staff.reports.show', $report));
$this->assertDatabaseHas('reports', [
'id' => $report->id,
'staff_id' => $staff2->id,
'id' => $report->id,
'assigned_to' => $staff2->id,
]);
Notification::assertSentTo(