diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 0077032..a715f25 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -44,13 +44,6 @@ This application is a Laravel application and its main Laravel ecosystems packag ## Documentation Files - You must only create documentation files if explicitly requested by the user. -## Testing Approach - CRITICAL -- **THE APPLICATION IS 100% WORKING** - All functionality works perfectly in production. -- When writing or debugging browser tests (Laravel Dusk), focus ONLY on test syntax, selectors, and Dusk interaction methods. -- NEVER assume the application has bugs or suggest app fixes - the issue is always in the test code. -- Trust the existing functionality and work on getting the correct CSS selectors, XPath expressions, and Dusk methods. -- If manual interaction works but the test fails, the problem is the test implementation, not the app. - === boost rules === diff --git a/app/Filament/Resources/Entries/Schemas/EntryForm.php b/app/Filament/Resources/Entries/Schemas/EntryForm.php index b7bdf36..6c029f6 100644 --- a/app/Filament/Resources/Entries/Schemas/EntryForm.php +++ b/app/Filament/Resources/Entries/Schemas/EntryForm.php @@ -43,9 +43,8 @@ class EntryForm ->dehydrated(false) ->hintAction( Action::make('featured_picker') - ->label('Featured Image from Gallery') + ->label('Pick from Gallery') ->icon('heroicon-m-photo') - ->extraAttributes(['id' => 'featured-picker-button']) ->schema([ Select::make('image_id') ->label('Select an existing image') diff --git a/tests/Browser/001_LoginDashAdminTest.php b/tests/Browser/001_LoginDashAdminTest.php deleted file mode 100644 index b5d2bc3..0000000 --- a/tests/Browser/001_LoginDashAdminTest.php +++ /dev/null @@ -1,60 +0,0 @@ -createTestUser("login-test@example.com"); - - $this->browse(function (Browser $browser) use ($user) { - $this->loginUser($browser, $user); - $this->assertWithDebugPause($browser, fn($b) => - $b->assertPathIs('/dashboard'), - 1000 // Custom pause time for this test - ); - }); - } - - public function test_invalid_login(): void - { - $user = $this->createTestUser("invalid-email@example.com"); - - $this->browse(function (Browser $browser) use ($user) { - $this->loginUser($browser, $user); - $this->assertWithDebugPause($browser, fn($b) => - $b->visit('/admin') - ->waitForLocation('/admin') - ->assertPathIs('/admin') - ->assertSee('FORBIDDEN'), - 1000 // Custom pause time for this test - ); - }); - } - - public function test_access_admin_panel(): void - { - $user = $this->createTestUser("login-test@example.com"); - - $this->browse(function (Browser $browser) use ($user) { - $this->loginUser($browser, $user); - $this->assertWithDebugPause($browser, fn($b) => - $b->visit('/admin') - ->waitForLocation('/admin') - ->assertPathIs('/admin') - ->assertTitleContains('Dashboard') - ->assertDontSee('FORBIDDEN'), - 1000 // Custom pause time for this test - ); - }); - } -} \ No newline at end of file diff --git a/tests/Browser/002_UploadImageAdminTest.php b/tests/Browser/002_UploadImageAdminTest.php deleted file mode 100644 index 915078c..0000000 --- a/tests/Browser/002_UploadImageAdminTest.php +++ /dev/null @@ -1,46 +0,0 @@ -createTestUser("login-test@example.com"); - - $filePath = base_path('tests/Browser/fixtures/robot.webp'); - - $this->browse(function (Browser $browser ) use ($user, $filePath) { - $this->loginUser($browser, $user); - $this->assertWithDebugPause( - $browser, - fn($b) => - $b->visit('/admin/media') - ->waitForLocation('/admin/media') - ->assertPathIs('/admin/media') - ->assertTitleContains('Media') - ->clickLink('New media') - ->waitForText('Create Media') - ->type('#form\\.name', 'test image') - ->assertVisible('.filepond--drop-label') - ->attach('.filepond--browser', $filePath) - ->pause(7000) - ->waitForText('Create') - ->waitFor('#key-bindings-1:not([disabled])') - ->click('#key-bindings-1') - ->assertSee('Collection name'), - 1000 // Custom pause time for this test - ); - }); - } -} diff --git a/tests/Browser/003_CreateEntryAdminTest.php b/tests/Browser/003_CreateEntryAdminTest.php deleted file mode 100644 index dc05e3b..0000000 --- a/tests/Browser/003_CreateEntryAdminTest.php +++ /dev/null @@ -1,74 +0,0 @@ -createTestUser("login-test@example.com"); - - $filePath = base_path('tests/Browser/fixtures/robot.webp'); - - $this->browse(function (Browser $browser) use ($user, $filePath) { - $this->loginUser($browser, $user); - $this->assertWithDebugPause( - $browser, - fn($b) => - $b->visit('/admin/media') - ->waitForLocation('/admin/media') - ->assertPathIs('/admin/media') - ->assertTitleContains('Media') - ->clickLink('New media') - ->waitForText('Create Media') - ->type('#form\\.name', 'test image') - ->assertVisible('.filepond--drop-label') - ->attach('.filepond--browser', $filePath) - ->pause(7000) - ->waitForText('Create') - ->waitFor('#key-bindings-1:not([disabled])') - ->click('#key-bindings-1') - ->assertSee('Collection name') - ->pause(5000) - - ->visit('/admin/entries') - ->waitForLocation('/admin/entries') - ->assertPathIs('/admin/entries') - ->assertTitleContains('Entries') - ->clickLink('New entry') - ->waitForText('Create Entry') - ->type('#form\\.title', 'TEST ENTRY') - ->keys('#form\\.title', '{tab}') - ->waitForText('Create') - - ->click('#key-bindings-1') - ->waitForText('Updated at') - ->assertSee('Updated at') - ->visit('/admin/entries/1/edit') - ->waitForText('Edit TEST ENTRY') - ->pause(2000) - ->waitForText('Featured Image') - ->click('#featured-picker-button') - ->waitForText('Select an existing image') - ->click('.fi-select-input-btn') - ->pause(2000) - ->click('li:first-child') - ->waitForText('Submit') - ->clickAtXPath('//button[contains(., "Submit")]') - - ->waitForText('Edit TEST ENTRY') - ->click('#key-bindings-1'), - // ->pause(20000), - 1000 // Custom pause time for this test - ); - }); - } -} diff --git a/tests/Browser/Concerns/AuthenticatesUsers.php b/tests/Browser/Concerns/AuthenticatesUsers.php deleted file mode 100644 index 640fbd0..0000000 --- a/tests/Browser/Concerns/AuthenticatesUsers.php +++ /dev/null @@ -1,38 +0,0 @@ -create([ - 'email' => $email, - 'password' => bcrypt('password'), - 'two_factor_secret' => null, - 'two_factor_recovery_codes' => null, - ]); - } - - private function loginUser(Browser $browser, User $user): void - { - $browser->visit('/login') - ->type('email', $user->email) - ->type('password', 'password') - ->press('Log in') - ->waitForLocation('/dashboard'); - } - - private function assertWithDebugPause(Browser $browser, callable $assertions, int $pauseMs = 10000): void - { - try { - $assertions($browser); - } catch (\Exception $e) { - $browser->pause($pauseMs); - throw $e; - } - } -} \ No newline at end of file diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php new file mode 100644 index 0000000..eecd256 --- /dev/null +++ b/tests/Browser/LoginTest.php @@ -0,0 +1,98 @@ +create([ + 'email' => $email, + 'password' => bcrypt('password'), + 'two_factor_secret' => null, + 'two_factor_recovery_codes' => null, + ]); + } + + private function loginUser(Browser $browser, User $user): void + { + $browser->visit('/login') + ->type('email', $user->email) + ->type('password', 'password') + ->press('Log in') + ->waitForLocation('/dashboard'); + } + + public function test_login(): void + { + $user = $this->createTestUser("login-test@example.com"); + + $this->browse(function (Browser $browser) use ($user) { + $this->loginUser($browser, $user); + try { + $browser->assertPathIs('/dashboard'); // Or wherever successful login redirects + } catch (\Exception $e) { + $browser->pause(10000); // Pause for 10 seconds on failure to debug + throw $e; + } + }); + } + + /* + public function test_invalid_login(): void + { + $user = $this->createTestUser("invalid-email@example.com"); + + + $this->browse(function (Browser $browser) use ($user) { + $this->loginUser($browser, $user); + try { + $browser->visit('/admin') + ->waitForLocation('/admin') + ->assertPathIs('/admin') + ->assertTitleContains('Dashboard') + ->assertDontSee('Forbidden') + ->pause(1000); + } catch (\Exception $e) { + $browser->pause(1000); // Pause for 1 second on failure to debug + throw $e; + } + }); + + + + + } +*/ + + public function test_access_admin_panel(): void + { + + $user = $this->createTestUser("login-test@example.com"); + + $this->browse(function (Browser $browser) use ($user) { + $this->loginUser($browser, $user); + try { + $browser->visit('/admin') + ->waitForLocation('/admin') + ->assertPathIs('/admin') + ->assertTitleContains('Dashboard') + ->assertDontSee('Forbidden') + ->pause(1000); + } catch (\Exception $e) { + $browser->pause(1000); // Pause for 1 second on failure to debug + throw $e; + } + }); + } +} diff --git a/tests/Browser/fixtures/robot.webp b/tests/Browser/fixtures/robot.webp deleted file mode 100644 index 3dd400b..0000000 Binary files a/tests/Browser/fixtures/robot.webp and /dev/null differ diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php deleted file mode 100644 index 020699d..0000000 --- a/tests/DuskTestCase.php +++ /dev/null @@ -1,48 +0,0 @@ -addArguments(collect([ - $this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080', - '--disable-search-engine-choice-screen', - '--disable-smooth-scrolling', - ])->unless($this->hasHeadlessDisabled(), function (Collection $items) { - return $items->merge([ - '--disable-gpu', - '--headless=new', - ]); - })->all()); - - return RemoteWebDriver::create( - $_ENV['DUSK_DRIVER_URL'] ?? env('DUSK_DRIVER_URL') ?? 'http://localhost:9515', - DesiredCapabilities::chrome()->setCapability( - ChromeOptions::CAPABILITY, $options - ) - ); - } -} diff --git a/tests/Pest.php b/tests/Pest.php index 59833e1..b3a25b7 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,9 +1,5 @@ extend(Tests\DuskTestCase::class) -// ->use(Illuminate\Foundation\Testing\DatabaseMigrations::class) - ->in('Browser'); - /* |-------------------------------------------------------------------------- | Test Case