A free open source IT asset/license management system
Add failing test
Marcus Moorec458cc904a89
diff --git a/tests/Feature/Users/Ui/UpdateUserTest.php b/tests/Feature/Users/Ui/UpdateUserTest.phpindex abaec1b70e..30be2053b0 100644--- a/tests/Feature/Users/Ui/UpdateUserTest.php+++ b/tests/Feature/Users/Ui/UpdateUserTest.php@@ -5,6 +5,7 @@ namespace Tests\Feature\Users\Ui;use App\Models\Asset;use App\Models\Company;use App\Models\User;+use Error;use Tests\TestCase;class UpdateUserTest extends TestCase@@ -161,4 +162,32 @@ class UpdateUserTest extends TestCase$this->followRedirects($response)->assertSee('success');}++ /**+ * This can occur if the user edit screen is open in one tab and+ * the user is deleted in another before the edit form is submitted.+ * @link https://app.shortcut.com/grokability/story/29166+ */+ public function testAttemptingToUpdateDeletedUserIsHandledGracefully()+ {+ [$companyA, $companyB] = Company::factory()->count(2)->create();+ $user = User::factory()->for($companyA)->create();+ Asset::factory()->assignedToUser($user)->create();++ $id = $user->id;++ $user->delete();++ $response = $this->actingAs(User::factory()->editUsers()->create())+ ->put(route('users.update', $id), [+ 'first_name' => 'test',+ 'username' => 'test',+ 'company_id' => $companyB->id,+ ]);++ $this->assertFalse($response->exceptions->contains(function ($exception) {+ // Avoid hard 500+ return $exception instanceof Error;+ }));+ }}