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> <hr>
@if($page) @if($page)
<div> <div>
{!!$page->content!!} {!!$page['content']!!}
<hr> <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> </div>
@else @else
<div> <div>

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

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

@ -167,7 +167,11 @@ describe('scope enforcement on writes', function () {
describe('first-party session auth', function () { describe('first-party session auth', function () {
it('allows writes without a token', 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 = User::factory()->create();
$user->refresh(); $user->refresh();
$status = Status::factory()->create([ $status = Status::factory()->create([

@ -44,6 +44,10 @@ describe('routes that require database', function () {
uses(LazilyRefreshDatabase::class); uses(LazilyRefreshDatabase::class);
test('register page loads', function () { 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') $this->get('/register')
->assertStatus(200); ->assertStatus(200);
}); });

Loading…
Cancel
Save