entry = Entry::factory()->create(); }); describe('EntryFlagController::noShowSelect', function () { it('presents a from to choose an entry by ID', function () { actAsTab(); $this->get(route('entry-flags.noShowSelect'))->assertOk() ->assertViewis('tabulation.choose_entry') ->assertSee(route('entry-flags.confirmNoShow')); }); it('does not allow access to guests or normal users', function () { $this->get(route('entry-flags.noShowSelect'))->assertRedirect(route('home')); actAsNormal(); $this->get(route('entry-flags.noShowSelect'))->assertRedirect(route('dashboard')); }); }); describe('EntryFlagController::noShowConfirm', function () { it('does not allow access to guests or normal users', function () { $this->get(route('entry-flags.noShowSelect'))->assertRedirect(route('home')); actAsNormal(); $this->get(route('entry-flags.noShowSelect'))->assertRedirect(route('dashboard')); }); it('shows a form to enter a no-show or failed-prelim if the entry has no flags', function () { actAsAdmin(); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => $this->entry->id])); $response->assertOk() ->assertViewIs('tabulation.no_show_confirm') ->assertSee('No-Show') ->assertSee('Fail Prelim'); }); it('does not entertain an invalid entry id', function () { actAsAdmin(); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => 999999999])); $response->assertRedirect(); }); it('does not allow us to set a flag if the relevant audition seats are published', function () { actAsAdmin(); $this->entry->audition->addFlag('seats_published'); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => $this->entry->id])); $response->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot enter a no-show or failed-prelim for an entry in an audition where seats are published'); }); it('does not allow us to set a flag if the relevant audition advancement is published', function () { actAsAdmin(); $this->entry->audition->addFlag('advancement_published'); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => $this->entry->id])); $response->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot enter a no-show or failed-prelim for an entry in an audition where advancement is published'); }); it('returns the appropriate form if the entry is already a no-show', function () { actAsAdmin(); $this->entry->addFlag('no_show'); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => $this->entry->id])); $response->assertOk() ->assertSee('Remove No Show'); }); it('returns the appropriate form if the entry is already a failed-prelim', function () { actAsAdmin(); $this->entry->addFlag('failed_prelim'); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => $this->entry->id])); $response->assertOk() ->assertSee('Remove Failed Prelim'); }); it('shows scores if they exist', function () { $judge = User::factory()->create(); DB::table('score_sheets')->insert([ 'entry_id' => $this->entry->id, 'user_id' => $judge->id, 'subscores' => json_encode([ 3 => [ 'score' => 12, 'subscore_id' => 3, 'subscore_name' => 'Subscore 3', ], ]), 'seating_total' => 35, 'advancement_total' => 35, ]); actAsAdmin(); $response = $this->get(route('entry-flags.confirmNoShow', ['entry_id' => $this->entry->id])); $response->assertOk() ->assertViewIs('tabulation.no_show_confirm') ->assertSee('Subscore 3'); }); }); describe('EntryFlagController::enterNoShow', function () { it('does not allow access to guests or normal users', function () { $this->post(route('entry-flags.enterNoShow', $this->entry))->assertRedirect(route('home')); actAsNormal(); $this->post(route('entry-flags.enterNoShow', $this->entry))->assertRedirect(route('dashboard')); }); it('passes exception from AuditionAdminException', function () { $this->entry->audition->addFlag('seats_published'); actAsAdmin(); $resposne = $this->post(route('entry-flags.enterNoShow', $this->entry), [ 'noshow-type' => 'noshow', ]); $resposne->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot enter a no-show for an entry in an audition where seats are published'); }); it('can set a flag', function () { actAsAdmin(); $response = $this->post(route('entry-flags.enterNoShow', $this->entry), [ 'noshow-type' => 'noshow', ]); $response->assertRedirect(route('entry-flags.noShowSelect'))->assertSessionHas('success'); expect($this->entry->fresh()->hasFlag('no_show'))->toBeTrue(); }); }); describe('EntryFlagController::removeNoShow', function () { it('does not allow access to guests or normal users', function () { $this->delete(route('entry-flags.undoNoShow', $this->entry))->assertRedirect(route('home')); actAsNormal(); $this->delete(route('entry-flags.undoNoShow', $this->entry))->assertRedirect(route('dashboard')); }); it('removes a no-show flag', function () { $this->entry->addFlag('no_show'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoNoShow', $this->entry)); $response->assertRedirect(route('entry-flags.noShowSelect'))->assertSessionHas('success'); expect($this->entry->fresh()->hasFlag('no_show'))->toBeFalse(); }); it('removes a failed-prelim flag', function () { $this->entry->addFlag('failed_prelim'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoNoShow', $this->entry)); $response->assertRedirect(route('entry-flags.noShowSelect'))->assertSessionHas('success'); expect($this->entry->fresh()->hasFlag('failed_prelim'))->toBeFalse(); }); it('will not remove flags if the audition seats are published', function () { $this->entry->addFlag('failed_prelim'); $this->entry->audition->addFlag('seats_published'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoNoShow', $this->entry)); $response->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot undo a no-show or failed-prelim for an entry in an audition where seats are published'); expect($this->entry->fresh()->hasFlag('failed_prelim'))->toBeTrue(); }); it('will not remove flags if the audition advancement is published', function () { $this->entry->addFlag('failed_prelim'); $this->entry->audition->addFlag('advancement_published'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoNoShow', $this->entry)); $response->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot undo a no-show or failed-prelim for an entry in an audition where advancement is published'); expect($this->entry->fresh()->hasFlag('failed_prelim'))->toBeTrue(); }); }); describe('EntryFlagController::undoDecline', function () { it('does not allow access to guests or normal users', function () { $this->delete(route('entry-flags.undoDecline', $this->entry))->assertRedirect(route('home')); actAsNormal(); $this->delete(route('entry-flags.undoDecline', $this->entry))->assertRedirect(route('dashboard')); }); it('removes a declined flag', function () { $this->entry->addFlag('declined'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoDecline', $this->entry)); $response->assertRedirect()->assertSessionHas('success'); expect($this->entry->fresh()->hasFlag('declined'))->toBeFalse(); }); it('will not remove flags if the audition seats are published', function () { $this->entry->addFlag('declined'); $this->entry->audition->addFlag('seats_published'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoDecline', $this->entry)); $response->assertRedirect() ->assertSessionHas('error', 'Cannot undo a decline for an entry in an audition where seats are published'); expect($this->entry->fresh()->hasFlag('declined'))->toBeTrue(); }); it('will not remove flags if the audition advancement is published', function () { $this->entry->addFlag('declined'); $this->entry->audition->addFlag('advancement_published'); actAsAdmin(); $response = $this->delete(route('entry-flags.undoDecline', $this->entry)); $response->assertRedirect() ->assertSessionHas('error', 'Cannot undo a no-show or failed-prelim for an entry in an audition where advancement is published'); expect($this->entry->fresh()->hasFlag('declined'))->toBeTrue(); }); });