An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
<?php
use App\Models\InstanceSettings;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
uses(RefreshDatabase::class);
beforeEach(function () {
config()->set('app.maintenance.store', 'array');
InstanceSettings::forceCreate(['id' => 0, 'is_sponsorship_popup_enabled' => false]);
Team::factory()->create(['id' => 0, 'name' => 'Root Team']);
User::factory()->create(['id' => 0, 'name' => 'Root', 'email' => '[email protected]']);
$this->user = User::factory()->create([
'name' => 'Leaving User',
'email' => '[email protected]',
'password' => Hash::make('password'),
]);
Team::query()->update(['show_boarding' => false]);
Cache::flush();
});
it('lets a user delete their own account from the profile page', function () {
$page = visit('/login')
->fill('email', '[email protected]')
->fill('password', 'password')
->click('Login')
->assertDontSee('These credentials do not match')
->navigate('/profile')
->assertSee('Delete account')
->screenshot(filename: 'delete-account-profile');
$page->click('button:has-text("Delete Account")')
->assertSee('Confirm Account Deletion?')
->screenshot(filename: 'delete-account-modal')
->fill('[x-model="userConfirmationText"]', '[email protected]')
->screenshot(filename: 'delete-account-confirm-text')
// Password managers detect fields when they are added or focused, not when a hidden one shows.
->assertScript('() => document.querySelector(\'input[type="password"][x-model="password"]\') === null', true)
->click('button:visible:has-text("Continue")')
->wait(0.3)
->assertScript('() => document.activeElement?.matches(\'input[type="password"][x-model="password"]\')', true)
->fill('[x-model="password"]', 'password')
->screenshot(filename: 'delete-account-password');
// Count the Livewire update requests sent after the final confirmation.
$page->script("sessionStorage.setItem('livewireUpdates', '0'); const originalFetch = window.fetch; window.fetch = (input, init) => { if (String(input?.url ?? input).includes('/update')) { sessionStorage.setItem('livewireUpdates', String(Number(sessionStorage.getItem('livewireUpdates')) + 1)); } return originalFetch(input, init); };");
$page->click('button:visible:has-text("Permanently Delete")')
->assertPathIs('/login')
->screenshot(filename: 'delete-account-done');
expect($page->script("sessionStorage.getItem('livewireUpdates')"))->toBe('1')
->and(User::query()->where('email', '[email protected]')->exists())->toBeFalse();
});