Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
fix(#581): Update what error text is being asserted
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Hayeur authored and a-drew committed Apr 9, 2021
1 parent 7bbffef commit abb5b01
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions tests/Browser/BookRoomsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,48 +144,32 @@ public function testCannotBookUnavailableTime()
});
}

/**
/**
* Create a blackout, and then attempts to book a room during that time
* assert that the page doesn't change to the booking creation.
*/
public function testCannotBookDuringBlackout()
{
$this->browse(function (Browser $browser){

$admin = User::first();


if($admin === null) {

$admin = User::factory()->create();
$admin->assignRole('super-admin');
}

$browser->loginAs($admin);
$browser->visit('/bookings/search');

$browser
->assertSourceHas('<title>CSU Booking Platform</title>');

$user = $this->createUserWithPermissions(['bookings.create']);
$room = Room::inRandomOrder()->first();
$blackout=Blackout::factory()->create();
$blackout->rooms()->attach($room);

$browser->press("@room-select-".$room->id);

$blackout = Blackout::factory()->create([
'start_time' => today(config('app.timezone'))->addDays(1)->setHour(12),
'end_time' => today(config('app.timezone'))->addDays(20)->setHour(13),
]);
$room->blackouts()->attach($blackout);
$room->save();
$browser->loginAs($user)->visitRoute('bookings.search');
$browser->press("@room-select-$room->id");
$browser->mouseover('#add-recurences-button');

$browser->within( new DateTimePicker('start_time_0'), function($browser) {
$browser->setDatetime(10,02);
$browser->within( new DateTimePicker('start_time_0'), function($browser) use ($blackout) {
$browser->setDatetime(15, $blackout->start_time->format('H'));
})->pause(250);

$browser->within( new DateTimePicker('end_time_0'), function($browser) {
$browser->setDatetime(10,03);
$browser->within( new DateTimePicker('end_time_0'), function($browser) use ($blackout) {
$browser->setDatetime(15, $blackout->end_time->format('H'));
})->pause(250);

$browser->pressAndWaitFor('#createBookingRequest');

$browser->assertSee('Create a booking request');
$browser->assertSee("Blocked schedule");
});
}

Expand Down

0 comments on commit abb5b01

Please sign in to comment.