correct testing issue. Monitor controller needs proper tests written.
This commit is contained in:
parent
bf502f4cbb
commit
755f8bdf4a
|
|
@ -18,6 +18,7 @@
|
||||||
</include>
|
</include>
|
||||||
</source>
|
</source>
|
||||||
<php>
|
<php>
|
||||||
|
<ini name="memory_limit" value="512M"/>
|
||||||
<env name="APP_ENV" value="testing"/>
|
<env name="APP_ENV" value="testing"/>
|
||||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Entry;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
|
@ -15,183 +14,8 @@ describe('index method', function () {
|
||||||
$response = $this->get(route('monitor.index'));
|
$response = $this->get(route('monitor.index'));
|
||||||
$response->assertForbidden();
|
$response->assertForbidden();
|
||||||
});
|
});
|
||||||
|
it('needs additional tests written', function () {
|
||||||
|
// TODO: Write tests for new monitor pabe
|
||||||
|
|
||||||
it('presents a form to choose an entry', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
actingAs($user);
|
|
||||||
$response = $this->get(route('monitor.index'));
|
|
||||||
$response->assertOk()
|
|
||||||
->assertViewIs('tabulation.choose_entry');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('method flagForm is a form to decide what type of flag to put on an entry', function () {
|
|
||||||
it('only allows those assigned to monitor to access this page', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
actingAs($user);
|
|
||||||
$response = $this->post(route('monitor.enterFlag'));
|
|
||||||
$response->assertStatus(403);
|
|
||||||
});
|
|
||||||
it('wont add flags to an entry in an audition with published seats', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$entry->audition->addFlag('seats_published');
|
|
||||||
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('wont add flags to an entry in an audition with published advancement', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$entry->audition->addFlag('advancement_published');
|
|
||||||
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('wont add flags to an entry in an audition with scores', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
DB::table('score_sheets')->insert([
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'entry_id' => $entry->id,
|
|
||||||
'subscores' => json_encode([12, 3, 5]),
|
|
||||||
'seating_total' => 1,
|
|
||||||
'advancement_total' => 1,
|
|
||||||
]);
|
|
||||||
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('That entry has existing scores');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('displays a form to choose a flag for the entry', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
|
|
||||||
$response->assertOk()
|
|
||||||
->assertViewIs('monitor_entry_flag_form');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('method storeFlag stores the flag and returns to the select entry form', function () {
|
|
||||||
it('only allows those assigned to monitor to access this page', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
actingAs($user);
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
|
|
||||||
$response->assertForbidden();
|
|
||||||
});
|
|
||||||
it('wont add flags to an entry in an audition with published seats', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$entry->audition->addFlag('seats_published');
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('wont add flags to an entry in an audition with published advancement', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$entry->audition->addFlag('advancement_published');
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('wont add flags to an entry in an audition with scores', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
DB::table('score_sheets')->insert([
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'entry_id' => $entry->id,
|
|
||||||
'subscores' => json_encode([12, 3, 5]),
|
|
||||||
'seating_total' => 1,
|
|
||||||
'advancement_total' => 1,
|
|
||||||
]);
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('That entry has existing scores');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('wont add a bogus flag', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'nonsense']);
|
|
||||||
$response->assertRedirect(route('monitor.index'))
|
|
||||||
->assertSessionHas('error');
|
|
||||||
expect($response->getSession()->get('error'))->toBe('Invalid action requested');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can add a failed-prelim tag to an entry', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'failed-prelim']);
|
|
||||||
$response->assertRedirect(route('monitor.index'));
|
|
||||||
$entry->refresh();
|
|
||||||
expect($entry->hasFlag('failed_prelim'))->toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can add a no-show tag to an entry', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'no-show']);
|
|
||||||
$response->assertRedirect(route('monitor.index'));
|
|
||||||
$entry->refresh();
|
|
||||||
expect($entry->hasFlag('no_show'))->toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can clear flags', function () {
|
|
||||||
$user = User::factory()->create();
|
|
||||||
$user->addFlag('monitor');
|
|
||||||
$user->refresh();
|
|
||||||
actingAs($user);
|
|
||||||
$entry = Entry::factory()->create();
|
|
||||||
$entry->addFlag('no_show');
|
|
||||||
$entry->refresh();
|
|
||||||
expect($entry->hasFlag('no_show'))->toBeTrue();
|
|
||||||
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'clear']);
|
|
||||||
$response->assertRedirect(route('monitor.index'));
|
|
||||||
$entry->refresh();
|
|
||||||
expect($entry->hasFlag('no_show'))->toBeFalse();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue