Add a speaker view with a next-slide preview and keep the live slide in view
- New /admin/{token}/speaker page for a second window: current slide, preview of
the next slide and the usual controls. It does not start the presentation.
- The presenter state gets `next` (labels only, no solutions).
- The dashboard scrolls the live slide into view when the presenter moves on.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8262411225
commit
66ed198f87
11 files changed
+264
-5
No files matched your search
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\TestCase\Controller;
|
||||
|
||||
use App\Model\Entity\Slide;
|
||||
use App\Test\TestCase\PlenarioTestTrait;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* Speaker view (second window): preview of the next slide, no side effects, no solutions in the JSON.
|
||||
*/
|
||||
class SpeakerViewTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
use PlenarioTestTrait;
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function state(string $token): array
|
||||
{
|
||||
$this->get("/admin/$token/state");
|
||||
$this->assertResponseOk();
|
||||
|
||||
return json_decode((string)$this->_response->getBody(), true);
|
||||
}
|
||||
|
||||
public function testSpeakerPageDoesNotStartThePresentation(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$this->createSlide($poll, Slide::TYPE_CHOICE);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$this->get("/admin/$token/speaker");
|
||||
$this->assertResponseOk();
|
||||
$this->assertResponseContains('data-next');
|
||||
$this->assertNull($this->pollsTable()->get($poll->id)->current_slide_id);
|
||||
}
|
||||
|
||||
$this->get("/admin/$token/present");
|
||||
$this->assertResponseNotContains('data-next-question');
|
||||
}
|
||||
|
||||
public function testSpeakerPageNeedsTheToken(): void
|
||||
{
|
||||
$this->get('/admin/' . str_repeat('x', 30) . '/speaker');
|
||||
$this->assertResponseCode(404);
|
||||
}
|
||||
|
||||
public function testNextIsTheSlideBehindTheLiveOne(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$first = $this->createSlide($poll, Slide::TYPE_CHOICE);
|
||||
$second = $this->createSlide($poll, Slide::TYPE_CHOICE, ['question' => 'Zweite?']);
|
||||
$hidden = $this->createSlide($poll, Slide::TYPE_CONTENT);
|
||||
$hidden->is_hidden = true;
|
||||
$this->slidesTable()->saveOrFail($hidden);
|
||||
$this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['question' => 'Letzte?']);
|
||||
|
||||
$this->assertSame($first->id, $this->state($token)['next']['id'], 'before the start: the first slide');
|
||||
|
||||
$this->goLive($poll, $first);
|
||||
$next = $this->state($token)['next'];
|
||||
$this->assertSame($second->id, $next['id']);
|
||||
$this->assertSame('Zweite?', $next['question']);
|
||||
$this->assertSame(['Ja', 'Nein'], $next['options']);
|
||||
|
||||
$this->goLive($poll, $second);
|
||||
$this->assertSame('Letzte?', $this->state($token)['next']['question'], 'hidden slides are skipped');
|
||||
|
||||
$last = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_WORDCLOUD])->firstOrFail();
|
||||
$this->goLive($poll, $last);
|
||||
$this->assertNull($this->state($token)['next'], 'nothing after the last slide');
|
||||
}
|
||||
|
||||
public function testPreviewRevealsNoSolution(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$first = $this->createSlide($poll, Slide::TYPE_CONTENT);
|
||||
$this->createSlide($poll, Slide::TYPE_QUIZ, [], ['Richtig', 'Falsch']);
|
||||
$this->createSlide($poll, Slide::TYPE_ORDER, [], ['Eins', 'Zwei', 'Drei']);
|
||||
$this->goLive($poll, $first);
|
||||
|
||||
$quiz = $this->state($token)['next'];
|
||||
$this->assertSame(['Richtig', 'Falsch'], $quiz['options']);
|
||||
$this->assertStringNotContainsString('is_correct', json_encode($quiz));
|
||||
|
||||
$order = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_ORDER])->firstOrFail();
|
||||
$quizSlide = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_QUIZ])->firstOrFail();
|
||||
$this->goLive($poll, $quizSlide);
|
||||
$this->assertSame([], $this->state($token)['next']['options'], 'the stored order is the solution');
|
||||
$this->assertSame($order->id, $this->state($token)['next']['id']);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user