Fix cached-page 500s and flaky smoke/API tests

- terms/privacy/community-guidelines views accessed the cached page as an
  object ($page->title), but cachedPage() returns an array, causing a 500
  whenever a custom Page row existed. Switch to array access.
- PublicRouteSmokeTest: enable open_registration before hitting /register,
  which 404s by default when registration is disabled.
- Api/AccountTest: derive sanctum.stateful domain from app.url instead of
  hardcoding pixelfed.test, so the first-party auth test is environment
  independent.
pull/7265/head
Your Name 1 week ago
parent d49bab829f
commit a14fba166f

@ -8,9 +8,9 @@
<hr>
@if($page)
<div>
{!!$page->content!!}
{!!$page['content']!!}
<hr>
<p class="">This document was last updated {{$page->created_at->format('M d, Y')}}.</p>
<p class="">This document was last updated {{$page['created_at']}}.</p>
</div>
@else
<div>

@ -4,8 +4,8 @@
<div class="container mt-5">
<div class="col-12">
<p class="font-weight-bold text-lighter text-uppercase">
@if($page && $page->title)
{!! $page->title !!}
@if($page && $page['title'])
{!! $page['title'] !!}
@else
Privacy Policy
@endif
@ -97,5 +97,5 @@
</div>
@endsection
@push('meta')
<meta property="og:description" content="@if($page && $page->title) {!! $page->title !!} @else Privacy Policy @endif">
<meta property="og:description" content="@if($page && $page['title']) {!! $page['title'] !!} @else Privacy Policy @endif">
@endpush

@ -4,8 +4,8 @@
<div class="container mt-5">
<div class="col-12">
<p class="font-weight-bold text-lighter text-uppercase">
@if($page && $page->title)
{!! $page->title !!}
@if($page && $page['title'])
{!! $page['title'] !!}
@else
Terms of Use
@endif
@ -57,5 +57,5 @@
@endsection
@push('meta')
<meta property="og:description" content="@if($page && $page->title) {!! $page->title !!} @else Terms of Use @endif">
<meta property="og:description" content="@if($page && $page['title']) {!! $page['title'] !!} @else Terms of Use @endif">
@endpush

@ -167,7 +167,11 @@ describe('scope enforcement on writes', function () {
describe('first-party session auth', function () {
it('allows writes without a token', function () {
config(['sanctum.stateful' => ['pixelfed.test']]);
// Derive the stateful domain from app.url so the Origin header and the
// sanctum.stateful entry always match, regardless of the environment's
// configured APP_URL (e.g. pixelfed.test in CI vs a local dev domain).
$host = parse_url(config('app.url'), PHP_URL_HOST);
config(['sanctum.stateful' => [$host]]);
$user = User::factory()->create();
$user->refresh();
$status = Status::factory()->create([

@ -44,6 +44,10 @@ describe('routes that require database', function () {
uses(LazilyRefreshDatabase::class);
test('register page loads', function () {
// The register form 404s when open registration is disabled (the
// default), so enable it for this smoke test.
config(['pixelfed.open_registration' => true]);
$this->get('/register')
->assertStatus(200);
});

Loading…
Cancel
Save