auditionadmin/tests/Feature/app/Http/Controllers/Judging/PrelimJudgingControllerTest...

79 lines
2.7 KiB
PHP

<?php
use App\Actions\Draw\RunDraw;
use App\Models\Audition;
use App\Models\Entry;
use App\Models\PrelimDefinition;
use App\Models\Room;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
describe('PrelimJudgingController:prelimEntryList', function () {
it('only allows access to an assigned judge', function () {
$judgeUser = User::factory()->create();
$notJudgeUser = User::factory()->create();
$finalsRoom = Room::factory()->create();
$audition = Audition::factory()->create(['room_id' => $finalsRoom->id]);
$room = Room::factory()->create();
$finalsRoom = Room::factory()->create();
$prelimDefinition = PrelimDefinition::create([
'audition_id' => $audition->id,
'room_id' => $room->id,
'scoring_guide_id' => 0,
'passing_score' => 75,
]);
$room->addJudge($judgeUser);
$finalsRoom->addJudge($notJudgeUser);
$this->actingAs($notJudgeUser);
$this->get(route('judging.prelimEntryList', $prelimDefinition))
->assertRedirect(route('dashboard'))
->assertSessionHas('error', 'You are not assigned to judge that prelim audition.');
$this->actingAs($judgeUser);
$this->get(route('judging.prelimEntryList', $prelimDefinition))
->assertOk();
});
it('shows all auditions entered in the given audition', function () {
$judgeUser = User::factory()->create();
$finalsRoom = Room::factory()->create();
$audition = Audition::factory()->create(['room_id' => $finalsRoom->id, 'name' => 'Euphonium']);
$room = Room::factory()->create();
$prelimDefinition = PrelimDefinition::create([
'audition_id' => $audition->id,
'room_id' => $room->id,
'scoring_guide_id' => 0,
'passing_score' => 75,
]);
$room->addJudge($judgeUser);
$entries = Entry::factory()->count(5)->create(['audition_id' => $audition->id]);
app(RunDraw::class)($audition);
$this->actingAs($judgeUser);
$response = $this->get(route('judging.prelimEntryList', $prelimDefinition));
$response->assertOk();
foreach ($entries as $entry) {
$entry->refresh();
$identifierString = $entry->audition->name.' '.$entry->draw_number;
$response->assertSee($identifierString);
}
});
it('shows scores for previously judged entries', function () {
});
it('has links to enter scores for each entry', function () {
});
it('does not allow modifications to an entry that has finals scores', function () {
});
});