isWatchedBy($operator))->toBeFalse(); app(TicketService::class)->toggleWatch($ticket, $operator); expect($ticket->fresh()->isWatchedBy($operator))->toBeTrue() ->and($operator->watchedTickets()->pluck('tickets.id'))->toContain($ticket->id); app(TicketService::class)->toggleWatch($ticket, $operator); expect($ticket->fresh()->isWatchedBy($operator))->toBeFalse(); }); test('the ticket-show watch button toggles watch state for the viewing operator', function () { seedStatusesAndPriorities(); $operator = operatorUser(); $ticket = makeTicket(); Livewire::actingAs($operator)->test(OperatorTicketShow::class, ['ticket' => $ticket]) ->assertSet('isWatching', false) ->call('toggleWatch') ->assertSet('isWatching', true); expect($ticket->fresh()->isWatchedBy($operator))->toBeTrue(); }); test('watching a ticket is per-operator, not shared', function () { seedStatusesAndPriorities(); $watcher = operatorUser('watcher@example.com'); $other = operatorUser('other@example.com'); $ticket = makeTicket(); app(TicketService::class)->toggleWatch($ticket, $watcher); expect($ticket->fresh()->isWatchedBy($watcher))->toBeTrue() ->and($ticket->fresh()->isWatchedBy($other))->toBeFalse(); });