admin = User::factory()->create(); app(Settings::class)->set(Setting::DownloadIpLogging, 'all'); }); function savePrivacySettings(): Illuminate\Testing\TestResponse { // No from(): the test client sends no Referer, which is the condition // under which the bug appears. return test()->patch('/system/settings/privacy', [ 'download_ip_logging' => 'all', 'account_erasure_grace_days' => 30, 'account_erasure_content_action' => 'cascade_delete', 'account_self_delete_files' => 'after_grace_period', 'account_self_delete_scope' => 'any', 'api_request_log_retention_days' => 30, 'discourage_search_indexing' => false, ]); } test('a JSON poll between opening a form and saving it is not where the save goes back to', function () { $this->actingAs($this->admin)->get('/system/settings/privacy')->assertOk(); // Exactly what the bell sends: a GET asking for JSON, not marked as Ajax. $this->actingAs($this->admin) ->get('/notifications/unread-count', ['Accept' => 'application/json']) ->assertOk(); savePrivacySettings()->assertRedirect('/system/settings/privacy'); }); test('an ordinary page visit is still remembered as the previous page', function () { // The pin: the fix must not stop back() working at all. $this->actingAs($this->admin)->get('/system/settings/privacy')->assertOk(); $this->actingAs($this->admin)->get('/system/settings/general')->assertOk(); savePrivacySettings()->assertRedirect('/system/settings/general'); });