Setzt Visualization.md Abschnitt 9, Phasen 3-5 vollstaendig um: Phase 3 (Kanban-Board live): Board zeigt echte Ticket-Daten aus GET /api/v1/tickets (office-api.js), Klick auf eine Spalte oeffnet ein Modal mit Titel/Beschreibung/Typ und einem Link auf die Codeberg-Quelle bei per Sync angelegten Tickets (F4). Phase 4 (Monitor-Wand live): Event-, System- und KPI-Monitor zeigen echte Daten, Klick-Modals fuer alle drei. Neuer SSE-Endpoint GET /api/v1/stream (F13) meldet per ChangeFeed-Fingerabdruck, welche Ressourcen sich geaendert haben; office-realtime.js nutzt EventSource mit Polling-Fallback. KPI-Monitor zeichnet eine eigene SVG-Sparkline (F10, kein Chart-Lib) sobald KPIs gemeldet wurden, sonst weiterhin der Phase-2-Platzhalter (F7 bleibt inhaltlich offen). API-Antworten tragen jetzt CORS-Header, da Frontend (:8090) und API (:8091) im Docker-Compose-Setup unterschiedliche Origins sind. Phase 5 (Agenten & Animation): resolveAgentVisualState bildet gemeldete Agenten-Zustaende auf Ort/Pose ab; Agenten-Avatare sind eine per CSS transition animierte, von Board/ Schreibtisch-Moebeln entkoppelte Schicht, die zwischen Schreibtisch, Board, Monitor-Wand und einer neuen Kaffee-Ecke laufen. Idle-Varianten (Zeitung/Kaffee/Schwaetzchen) werden rein kosmetisch client-seitig zufaellig ausgeloest (F8), eine AnimationQueue serialisiert Update-Animationen bei vielen gleichzeitigen Ereignissen (F9). 29 Node-Tests (100% Line-Coverage office-scene.js) und neue PHPUnit-Tests fuer Response::stream(), ChangeFeed, StreamController und die neuen Repository::fingerprint()- Methoden. PHP/Docker-Ausfuehrung konnte in dieser Umgebung nicht verifiziert werden (kein PHP verfuegbar) - vor dem Merge bitte `docker compose run --rm api composer test` pruefen. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
150 lines
4.6 KiB
PHP
150 lines
4.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Monitor\Api\Tests\Repository;
|
|
|
|
use InvalidArgumentException;
|
|
use Monitor\Api\Db\Database;
|
|
use Monitor\Api\Http\NotFoundException;
|
|
use Monitor\Api\Repository\TicketRepository;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class TicketRepositoryTest extends TestCase
|
|
{
|
|
private TicketRepository $repository;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->repository = new TicketRepository(Database::inMemory());
|
|
}
|
|
|
|
public function testCreateDefaultsToBacklogColumn(): void
|
|
{
|
|
$ticket = $this->repository->create(['title' => 'Neues Ticket']);
|
|
|
|
self::assertSame('backlog', $ticket['column_name']);
|
|
self::assertSame('Neues Ticket', $ticket['title']);
|
|
}
|
|
|
|
public function testCreateRejectsUnknownColumn(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
|
|
$this->repository->create(['title' => 'X', 'column' => 'unknown']);
|
|
}
|
|
|
|
public function testUpdateMovesTicketToAnotherColumn(): void
|
|
{
|
|
$ticket = $this->repository->create(['title' => 'X']);
|
|
|
|
$updated = $this->repository->update((int) $ticket['id'], ['column' => 'in_arbeit']);
|
|
|
|
self::assertSame('in_arbeit', $updated['column_name']);
|
|
}
|
|
|
|
public function testUpdateRejectsUnknownColumn(): void
|
|
{
|
|
$ticket = $this->repository->create(['title' => 'X']);
|
|
|
|
$this->expectException(InvalidArgumentException::class);
|
|
|
|
$this->repository->update((int) $ticket['id'], ['column' => 'unknown']);
|
|
}
|
|
|
|
public function testUpdateThrowsNotFoundForMissingTicket(): void
|
|
{
|
|
$this->expectException(NotFoundException::class);
|
|
|
|
$this->repository->update(999, ['column' => 'bereit']);
|
|
}
|
|
|
|
public function testAllFiltersByColumn(): void
|
|
{
|
|
$this->repository->create(['title' => 'A', 'column' => 'backlog']);
|
|
$this->repository->create(['title' => 'B', 'column' => 'done']);
|
|
|
|
$backlog = $this->repository->all('backlog');
|
|
|
|
self::assertCount(1, $backlog);
|
|
self::assertSame('A', $backlog[0]['title']);
|
|
}
|
|
|
|
public function testAllOrdersByColumnThenCreatedAt(): void
|
|
{
|
|
$this->repository->create(['title' => 'first', 'column' => 'backlog']);
|
|
$this->repository->create(['title' => 'second', 'column' => 'backlog']);
|
|
|
|
$tickets = $this->repository->all();
|
|
|
|
self::assertSame('first', $tickets[0]['title']);
|
|
self::assertSame('second', $tickets[1]['title']);
|
|
}
|
|
|
|
public function testUpsertFromCodebergCreatesNewTicket(): void
|
|
{
|
|
$ticket = $this->repository->upsertFromCodeberg([
|
|
'external_ref' => '42',
|
|
'title' => 'Issue 42',
|
|
'description' => 'Body',
|
|
'column' => 'backlog',
|
|
'type' => 'bug',
|
|
'color' => '#ff0000',
|
|
]);
|
|
|
|
self::assertSame('42', $ticket['external_ref']);
|
|
self::assertSame('codeberg', $ticket['source']);
|
|
}
|
|
|
|
public function testUpsertFromCodebergUpdatesExistingBacklogTicket(): void
|
|
{
|
|
$this->repository->upsertFromCodeberg([
|
|
'external_ref' => '42',
|
|
'title' => 'Issue 42',
|
|
'column' => 'backlog',
|
|
]);
|
|
|
|
$updated = $this->repository->upsertFromCodeberg([
|
|
'external_ref' => '42',
|
|
'title' => 'Issue 42 (closed)',
|
|
'column' => 'done',
|
|
]);
|
|
|
|
self::assertSame('done', $updated['column_name']);
|
|
self::assertSame('Issue 42 (closed)', $updated['title']);
|
|
}
|
|
|
|
public function testUpsertFromCodebergDoesNotResetManuallyMovedTicket(): void
|
|
{
|
|
$this->repository->upsertFromCodeberg([
|
|
'external_ref' => '42',
|
|
'title' => 'Issue 42',
|
|
'column' => 'backlog',
|
|
]);
|
|
$ticket = $this->repository->findByExternalRef('42');
|
|
$this->repository->update((int) $ticket['id'], ['column' => 'in_arbeit']);
|
|
|
|
$result = $this->repository->upsertFromCodeberg([
|
|
'external_ref' => '42',
|
|
'title' => 'Issue 42 geaendert',
|
|
'column' => 'backlog',
|
|
]);
|
|
|
|
self::assertSame('in_arbeit', $result['column_name']);
|
|
}
|
|
|
|
public function testFingerprintChangesWhenATicketIsCreated(): void
|
|
{
|
|
$before = $this->repository->fingerprint();
|
|
$this->repository->create(['title' => 'X']);
|
|
|
|
self::assertNotSame($before, $this->repository->fingerprint());
|
|
}
|
|
|
|
public function testFingerprintIsStableWithoutChanges(): void
|
|
{
|
|
$this->repository->create(['title' => 'X']);
|
|
|
|
self::assertSame($this->repository->fingerprint(), $this->repository->fingerprint());
|
|
}
|
|
}
|