CluPilotCloud/tests/Feature/ConnectionStateTest.php

38 lines
1.4 KiB
PHP

<?php
use App\Models\User;
/**
* "Keine Verbindung" / "Verbindung wiederhergestellt".
*
* The banner itself and its 419 recovery are client-side (resources/js/app.js,
* resources/views/components/shell/connection-banner.blade.php) — not
* something a request/response test can drive. What IS server-rendered, and
* what has broken silently before (R21: the console and the portal do not
* share a login), is which sign-in route each shell hands the JS as its
* reload-loop fallback, and that the banner is bound exactly once per page.
*/
it('gives the console its own sign-in route as the 419 fallback', function () {
$html = $this->actingAs(operator('Owner'), 'operator')
->get(route('admin.overview'))
->assertOk()
->getContent();
expect($html)->toContain('connectionBanner(')
->and($html)->toContain('data-login-url="'.route('admin.login').'"')
->and(substr_count($html, 'connectionBanner('))->toBe(1);
});
it('gives the portal its own sign-in route as the 419 fallback', function () {
$user = User::factory()->create();
$html = $this->actingAs($user)
->get('/dashboard')
->assertOk()
->getContent();
expect($html)->toContain('connectionBanner(')
->and($html)->toContain('data-login-url="'.route('login').'"')
->and(substr_count($html, 'connectionBanner('))->toBe(1);
});