create(); SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $scoringGuide->id]); $this->user = User::factory()->create(); $this->room = Room::factory()->create(); $this->room->addJudge($this->user->id); $this->audition = Audition::factory()->create([ 'room_id' => $this->room->id, 'scoring_guide_id' => $scoringGuide->id, ]); $this->entries = Entry::factory()->count(35)->create(['audition_id' => $this->audition->id]); $n = 1; foreach ($this->entries as $entry) { $entry->draw_number = $n++; $entry->save(); } }); test('responds favorably to a user assigned to judge this audition', function () { $this->actingAs($this->user); $this->get(route('judging.auditionEntryList', $this->audition->id)) ->assertOK(); }); test('redirects a user that is not assigned to judge this audition', function () { $user = User::factory()->create(); $this->actingAs($user); $this->get(route('judging.auditionEntryList', $this->audition->id)) ->assertRedirect(route('dashboard')); }); test('redirects a guest', function () { $this->get(route('judging.auditionEntryList', $this->audition->id)) ->assertRedirect(route('home')); }); it('redirects if judging is not enabled', function () { // Arrange Settings::set('judging_enabled', false); // Act & Assert $this->actingAs($this->user); $this->get(route('judging.auditionEntryList', $this->audition->id)) ->assertRedirect(route('dashboard')); }); test('shows headings for each subscore', function () { $this->actingAs($this->user); $response = $this->get(route('judging.auditionEntryList', $this->audition->id)); foreach ($this->audition->scoringGuide->subscores as $subscore) { $response->assertSeeInOrder(['th', $subscore->name, '/th']); } }); test('it shows each entry in the audition', function () { $this->actingAs($this->user); $response = $this->get(route('judging.auditionEntryList', $this->audition->id)); foreach ($this->entries as $entry) { $response->assertSeeInOrder(['td', $entry->draw_number, '/td']); } }); test('it shows a working link to the score sheet for each entry in the audition', function () { $this->actingAs($this->user); $response = $this->get(route('judging.auditionEntryList', $this->audition->id)); foreach ($this->entries as $entry) { $response->assertSee(route('judging.entryScoreSheet', $entry)); $this->get(route('judging.entryScoreSheet', $entry)) ->assertOK(); } }); test('it has a column for votes if advancement is enabled', function () { Settings::set('advanceTo', 'OMEA'); $this->actingAs($this->user); $response = $this->get(route('judging.auditionEntryList', $this->audition->id)); $response->assertSeeInOrder(['th', 'OMEA', '/th']); }); test('it shows scores previously entered', function () { $this->actingAs($this->user); Artisan::call('db:seed', ['--class' => ScoreAllAuditions::class]); $response = $this->get(route('judging.auditionEntryList', $this->audition->id)); $testEntry = $this->entries->first(); $testSubscores = ScoreSheet::where('entry_id', $testEntry->id)->first()->subscores; $arrayToTest = []; $orderedSubscores = $this->audition->scoringGuide->subscores()->orderBy('display_order')->get(); foreach ($orderedSubscores as $subscore) { $arrayToTest[] = $testSubscores[$subscore->id]['score']; } $response->assertSeeInOrder([ 'td', $arrayToTest[0], '/td', 'td', $arrayToTest[1], '/td', 'td', $arrayToTest[2], '/td', 'td', $arrayToTest[3], '/td', 'td', $arrayToTest[4], '/td', ]); }); it('indicates when an audition has published seats or advancement', function () { // Arrange $seatsPublishedAudition = Audition::factory()->create(); $advancePublishedAudition = Audition::factory()->create(); $seatsPublishedAudition->addFlag('seats_published'); $advancePublishedAudition->addFlag('advancement_published'); // Act & Assert });