Results page testing and disregarding coverage measurement for some classes
This commit is contained in:
parent
d9688fd3b0
commit
0ea7ea2f14
|
|
@ -9,6 +9,10 @@ use Illuminate\Http\Request;
|
||||||
|
|
||||||
use function auditionSetting;
|
use function auditionSetting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
* TODO: Figure out testing for printing
|
||||||
|
*/
|
||||||
class PdfInvoiceController extends Controller
|
class PdfInvoiceController extends Controller
|
||||||
{
|
{
|
||||||
protected $pdf;
|
protected $pdf;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ use App\Actions\Tabulation\RankAuditionEntries;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
|
/** @codeCoverageIgnore */
|
||||||
|
// TODO: Rewrite Recap
|
||||||
class RecapController extends Controller
|
class RecapController extends Controller
|
||||||
{
|
{
|
||||||
public function selectAudition()
|
public function selectAudition()
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class ResultsPage extends Controller
|
||||||
$cacheKey = 'publicResultsPage';
|
$cacheKey = 'publicResultsPage';
|
||||||
|
|
||||||
if (Cache::has($cacheKey)) {
|
if (Cache::has($cacheKey)) {
|
||||||
|
/** @codeCoverageIgnore */
|
||||||
return response(Cache::get($cacheKey));
|
return response(Cache::get($cacheKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,9 +94,4 @@ class ResultsPage extends Controller
|
||||||
|
|
||||||
return response($content);
|
return response($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateResultsPage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<x-results.layout>
|
s<x-results.layout>
|
||||||
<div class="w-full md:flex justify-between gap-8 @if(! auditionSetting('advanceTo') ) max-w-sm mx-auto @endif">
|
<div class="w-full md:flex justify-between gap-8 @if(! auditionSetting('advanceTo') ) max-w-sm mx-auto @endif">
|
||||||
<div class="h-full overflow-y-auto w-full">
|
<div class="h-full overflow-y-auto w-full">
|
||||||
<h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('auditionAbbreviation') }} Seats</h3>
|
<h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('auditionAbbreviation') }} Seats</h3>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Ensemble;
|
||||||
|
use App\Models\Entry;
|
||||||
|
use App\Models\Seat;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
Cache::flush();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('includes seated entries for published auditions', function () {
|
||||||
|
$entry = Entry::factory()->create();
|
||||||
|
$ensemble = Ensemble::factory()->create(['event_id' => $entry->audition->event_id]);
|
||||||
|
Seat::create([
|
||||||
|
'ensemble_id' => $ensemble->id,
|
||||||
|
'audition_id' => $entry->audition_id,
|
||||||
|
'seat' => 5,
|
||||||
|
'entry_id' => $entry->id,
|
||||||
|
]);
|
||||||
|
$entry->audition->addFlag('seats_published');
|
||||||
|
$response = $this->get(route('results'));
|
||||||
|
$response->assertSee($entry->student->full_name());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not show results that are not published', function () {
|
||||||
|
$entry = Entry::factory()->create();
|
||||||
|
$ensemble = Ensemble::factory()->create(['event_id' => $entry->audition->event_id]);
|
||||||
|
Seat::create([
|
||||||
|
'ensemble_id' => $ensemble->id,
|
||||||
|
'audition_id' => $entry->audition_id,
|
||||||
|
'seat' => 5,
|
||||||
|
'entry_id' => $entry->id,
|
||||||
|
]);
|
||||||
|
$response = $this->get(route('results'));
|
||||||
|
$response->assertDontSee($entry->student->full_name());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not show an audition with no seats', function () {
|
||||||
|
$entry = Entry::factory()->create();
|
||||||
|
$ensemble = Ensemble::factory()->create(['event_id' => $entry->audition->event_id]);
|
||||||
|
|
||||||
|
$entry->audition->addFlag('seats_published');
|
||||||
|
|
||||||
|
$response = $this->get(route('results'));
|
||||||
|
$response->assertDontSee($ensemble->name);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows advancement results that are published', function () {
|
||||||
|
$entry = Entry::factory()->create();
|
||||||
|
$entry->addFlag('will_advance');
|
||||||
|
$entry->audition->addFlag('advancement_published');
|
||||||
|
|
||||||
|
$response = $this->get(route('results'));
|
||||||
|
$response->assertSee($entry->student->full_name());
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('test caching', function () {
|
||||||
|
test('results are served from cache when available', function () {
|
||||||
|
Cache::forever('publicResultsPage', 'test');
|
||||||
|
$response = $this->get(route('results'));
|
||||||
|
expect($response->getContent())->toBe('test');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('results are generated and cached when not in cache', function () {
|
||||||
|
expect(Cache::has('publicResultsPage'))->toBeFalse();
|
||||||
|
$response = $this->get(route('results'));
|
||||||
|
$response->assertOk();
|
||||||
|
expect(Cache::has('publicResultsPage'))->toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('cached and fresh results match', function () {
|
||||||
|
// Clear cache
|
||||||
|
Cache::forget('publicResultsPage');
|
||||||
|
|
||||||
|
// Get fresh content
|
||||||
|
$freshContent = $this->get(route('results'))->getContent();
|
||||||
|
|
||||||
|
// Get cached content
|
||||||
|
$cachedContent = $this->get(route('results'))->getContent();
|
||||||
|
|
||||||
|
expect($cachedContent)->toBe($freshContent);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue