get(route('admin.bonus-scores.judges')) ->assertRedirect(route('home')); actAsNormal(); $this->get(route('admin.bonus-scores.judges')) ->assertRedirect(route('dashboard')) ->assertSessionHas('error', 'You are not authorized to perform this action'); actAsTab(); $this->get(route('admin.bonus-scores.judges')) ->assertRedirect(route('dashboard')) ->assertSessionHas('error', 'You are not authorized to perform this action'); }); it('grants access to an administrator', function () { // Arrange actAsAdmin(); // Act & Assert $this->get(route('admin.bonus-scores.judges')) ->assertOk() ->assertViewIs('admin.bonus-scores.judge-assignments'); }); it('shows a link to the room judge assignment screen', function () { // Arrange actAsAdmin(); // Act & Assert $this->get(route('admin.bonus-scores.judges')) ->assertOk() ->assertSee(route('admin.rooms.judgingAssignment')); }); it('shows a card for each bonus score', function () { // Arrange $bonusScores = BonusScoreDefinition::factory()->count(3)->create(); actAsAdmin(); // Act & Assert $response = $this->get(route('admin.bonus-scores.judges')); $response->assertOk(); $bonusScores->each(fn ($bonus) => $response->assertElementExists('#bonus-'.$bonus->id.'-card')); }); it('can assign a judge to a bonus score', function () { // Arrange $bonusScore = BonusScoreDefinition::factory()->create(); $judge = User::factory()->create(); actAsAdmin(); // Act & Assert $this->post(route('admin.bonus-scores.judges.assign', $bonusScore), ['judge' => $judge->id]) ->assertRedirect(route('admin.bonus-scores.judges')) ->assertSessionHas('success', 'Judge assigned to bonus score'); expect($bonusScore->judges()->count())->toBe(1); }); it('can assign a judge to a room', function () { // Arrange $bonusScore = BonusScoreDefinition::factory()->create(); $judge = User::factory()->create(); $bonusScore->judges()->attach($judge->id); actAsAdmin(); // Act & Assert $this->delete(route('admin.bonus-scores.judges.remove', $bonusScore), ['judge' => $judge->id]) ->assertRedirect(route('admin.bonus-scores.judges')) ->assertSessionHas('success', 'Judge removed from bonus score'); expect($bonusScore->judges()->count())->toBe(0); });