get(route('judging.bonusScore.EntryList', 1)); $response->assertRedirect(route('home')); }); it('denies access to a user not assigned to judge this bonus score', function () { $bonusScore = BonusScoreDefinition::factory()->create(); $audition = Audition::factory()->create(); $audition->bonusScore()->attach($bonusScore->id); $room = Room::factory()->create(); $user = User::factory()->create(); $room->addJudge($user->id); actingAs($user); $this->get(route('judging.bonusScore.EntryList', $audition->id)) ->assertRedirect(route('dashboard')) ->assertSessionHas('error', 'You are not assigned to judge this bonus score'); }); it('shows all entries to an authorized judge', function () { // Arrange $bonusScore = BonusScoreDefinition::factory()->create(); $audition = Audition::factory()->create(); $audition->bonusScore()->attach($bonusScore->id); $entries[1] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 1]); $entries[2] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 2]); $entries[3] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 3]); $entries[4] = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 4]); $entries = collect($entries); $judge = User::factory()->create(); $bonusScore->judges()->attach($judge->id); actingAs($judge); // Act & Assert $response = $this->get(route('judging.bonusScore.EntryList', $audition->id)); $response->assertOk(); $entries->each(fn ($entry) => $response->assertSee($entry->audition->name.' '.$entry->draw_number)); }); it('shows existing scores for an entry', function () { $bonusScore = BonusScoreDefinition::factory()->create(['max_score' => 100]); $audition = Audition::factory()->create(); $audition->bonusScore()->attach($bonusScore->id); $entry = Entry::factory()->create(['audition_id' => $audition->id, 'draw_number' => 1]); $judge = User::factory()->create(); $bonusScore->judges()->attach($judge->id); BonusScore::create([ 'entry_id' => $entry->id, 'user_id' => $judge->id, 'originally_scored_entry' => $entry->id, 'score' => 42, ]); actingAs($judge); // Act $response = $this->get(route('judging.bonusScore.EntryList', $audition)); $response->assertOk() ->assertSeeInOrder(['', e($audition->name), $entry->draw_number, 42, ''], false); });