This commit is contained in:
@@ -325,6 +325,45 @@ test('restoring a deleted booking brings it back', function () {
|
||||
expect(Booking::find($booking->id)->trashed())->toBeFalse();
|
||||
});
|
||||
|
||||
test('the remark action is visible for a user with manage_bookings', function () {
|
||||
$booking = Booking::factory()->create();
|
||||
|
||||
Livewire::test(ListBookings::class)
|
||||
->assertTableActionVisible('setRemark', $booking);
|
||||
});
|
||||
|
||||
test('the remark action is hidden from a user without manage_bookings', function () {
|
||||
$viewer = User::factory()->create()->givePermissionTo('view_bookings');
|
||||
$this->actingAs($viewer);
|
||||
|
||||
$booking = Booking::factory()->create();
|
||||
|
||||
Livewire::test(ListBookings::class)
|
||||
->assertTableActionHidden('setRemark', $booking);
|
||||
});
|
||||
|
||||
test('calling the remark action sets the staff remark on a booking', function () {
|
||||
$booking = Booking::factory()->create();
|
||||
|
||||
Livewire::test(ListBookings::class)
|
||||
->callTableAction('setRemark', $booking, data: [
|
||||
'remark' => 'Passenger requested a child seat.',
|
||||
])
|
||||
->assertNotified();
|
||||
|
||||
expect($booking->refresh()->remark)->toBe('Passenger requested a child seat.');
|
||||
});
|
||||
|
||||
test('the remark form is pre-filled with the booking\'s existing remark', function () {
|
||||
$booking = Booking::factory()->create(['remark' => 'Existing remark.']);
|
||||
|
||||
Livewire::test(ListBookings::class)
|
||||
->mountTableAction('setRemark', $booking)
|
||||
->assertTableActionDataSet([
|
||||
'remark' => 'Existing remark.',
|
||||
]);
|
||||
});
|
||||
|
||||
test('the restore action is hidden from a user without manage_bookings', function () {
|
||||
$stranger = User::factory()->create();
|
||||
$booking = Booking::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user