From 6b983cc0758711299b77c8802320c485756d4c5c Mon Sep 17 00:00:00 2001 From: Matt Young Date: Mon, 1 Jul 2024 23:43:03 -0500 Subject: [PATCH] Page Test for AuditionEntryList --- .../judging/audition_entry_list.blade.php | 2 +- .../Pages/JudgingAudtionEntryListTest.php | 110 ++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/Pages/JudgingAudtionEntryListTest.php diff --git a/resources/views/judging/audition_entry_list.blade.php b/resources/views/judging/audition_entry_list.blade.php index dfaec6a..a510a12 100644 --- a/resources/views/judging/audition_entry_list.blade.php +++ b/resources/views/judging/audition_entry_list.blade.php @@ -20,7 +20,7 @@ @foreach($entries as $entry) - + {{ $audition->name }} {{ $entry->draw_number }} diff --git a/tests/Feature/Pages/JudgingAudtionEntryListTest.php b/tests/Feature/Pages/JudgingAudtionEntryListTest.php new file mode 100644 index 0000000..e700af0 --- /dev/null +++ b/tests/Feature/Pages/JudgingAudtionEntryListTest.php @@ -0,0 +1,110 @@ +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', + ]); + +});