57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Browser\Users;
|
||
|
|
|
||
|
|
use Laravel\Dusk\Browser;
|
||
|
|
use Tests\DuskTestCase;
|
||
|
|
use Tests\Browser\Pages\UsersPage;
|
||
|
|
use Tests\Browser\Components\UserModal;
|
||
|
|
use Tests\Browser\LoginHelpers;
|
||
|
|
use App\Models\User;
|
||
|
|
|
||
|
|
class EditUserTest extends DuskTestCase
|
||
|
|
{
|
||
|
|
use LoginHelpers;
|
||
|
|
|
||
|
|
protected static $editUserTestPlanner = null;
|
||
|
|
protected static $editUserTestEmail = null;
|
||
|
|
|
||
|
|
protected function setUp(): void
|
||
|
|
{
|
||
|
|
parent::setUp();
|
||
|
|
// Reset static planner for this specific test class
|
||
|
|
self::$testPlanner = self::$editUserTestPlanner;
|
||
|
|
self::$testEmail = self::$editUserTestEmail;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function tearDown(): void
|
||
|
|
{
|
||
|
|
// Save the planner for next test method in this class
|
||
|
|
self::$editUserTestPlanner = self::$testPlanner;
|
||
|
|
self::$editUserTestEmail = self::$testEmail;
|
||
|
|
parent::tearDown();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testCanAccessEditFeature(): void
|
||
|
|
{
|
||
|
|
// Create user before browser test
|
||
|
|
$this->ensureTestPlannerExists();
|
||
|
|
$user = User::factory()->create([
|
||
|
|
'planner_id' => self::$testPlanner->id,
|
||
|
|
'name' => 'EditTest_' . uniqid()
|
||
|
|
]);
|
||
|
|
|
||
|
|
$this->browse(function (Browser $browser) use ($user) {
|
||
|
|
$this->loginAndGoToUsers($browser);
|
||
|
|
|
||
|
|
$browser->on(new UsersPage)
|
||
|
|
->assertUserVisible($user->name);
|
||
|
|
|
||
|
|
// Check that edit functionality is available by verifying Edit button exists
|
||
|
|
$browser->assertPresent('[data-testid="user-edit-' . $user->id . '"]');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// TODO: Moved to separate single-method test files to avoid static planner issues
|
||
|
|
// See: OpenEditUserModalTest, EditUserSuccessTest, CancelEditUserTest
|
||
|
|
}
|