From 5828d2995208bc9d1224fe5730ba20a8789f5589 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 30 Aug 2023 16:43:18 -0700 Subject: [PATCH] Remove Dusk --- .chipperci.yml | 17 ---- .gitignore | 2 - TESTING.md | 31 ------ app/Providers/AppServiceProvider.php | 7 +- composer.json | 2 - composer.lock | 140 +-------------------------- tests/Browser/LoginTest.php | 46 --------- tests/Browser/Pages/HomePage.php | 41 -------- tests/Browser/Pages/Page.php | 20 ---- tests/Browser/console/.gitignore | 2 - tests/Browser/screenshots/.gitignore | 2 - tests/Browser/source/.gitignore | 2 - tests/DuskTestCase.php | 70 -------------- 13 files changed, 2 insertions(+), 380 deletions(-) delete mode 100644 tests/Browser/LoginTest.php delete mode 100644 tests/Browser/Pages/HomePage.php delete mode 100644 tests/Browser/Pages/Page.php delete mode 100644 tests/Browser/console/.gitignore delete mode 100644 tests/Browser/screenshots/.gitignore delete mode 100644 tests/Browser/source/.gitignore delete mode 100644 tests/DuskTestCase.php diff --git a/.chipperci.yml b/.chipperci.yml index 0c18b253c9..bfd1e9ecb8 100644 --- a/.chipperci.yml +++ b/.chipperci.yml @@ -6,7 +6,6 @@ environment: services: - mysql: 5.7 - - dusk: on: push: @@ -43,19 +42,3 @@ pipeline: - name: PHPUnit Feature Tests cmd: | php artisan test --testsuite Feature - -# - name: Browser Tests -# cmd: | -# cp -v .env.dusk.example .env.dusk.ci -# sed -i "s@APP_ENV=.*@APP_ENV=ci@g" .env.dusk.ci -# sed -i "s@APP_URL=.*@APP_URL=http://$BUILD_HOST:8000@g" .env.dusk.ci -# #sed -i "s@DB_HOST=.*@DB_HOST=mysql@g" .env.dusk.ci -# sed -i "s@DB_HOST=.*@DB_HOST=$DB_HOST@g" .env.dusk.ci -# sed -i "s@DB_USERNAME=.*@DB_USERNAME=chipperci@g" .env.dusk.ci -# sed -i "s@DB_DATABASE=.*@DB_DATABASE=chipperci@g" .env.dusk.ci -# sed -i "s@DB_PASSWORD=.*@DB_PASSWORD=secret@g" .env.dusk.ci -# -# php -S [::0]:8000 -t public 2>server.log & -# sleep 2 -# php artisan dusk:chrome-driver $CHROME_DRIVER -# php artisan dusk --env=ci diff --git a/.gitignore b/.gitignore index f0e9bfcec2..bf8360ba24 100755 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ .couscous .DS_Store .env -.env.dusk.* -!.env.dusk.example .env.testing phpstan.neon .idea diff --git a/TESTING.md b/TESTING.md index 3f0e588105..d1e0625419 100644 --- a/TESTING.md +++ b/TESTING.md @@ -18,34 +18,3 @@ Now you are ready to run the entire test suite from your terminal: To run individual test files, you can pass the path to the test that you want to run: `php artisan test tests/Unit/AccessoryTest.php` - -## Browser Tests - -Browser tests are run via [Laravel Dusk](https://laravel.com/docs/8.x/dusk) and require Google Chrome to be installed. - -Before attempting to run Dusk tests copy the example environment file for Dusk and update the values to match your environment: - -`cp .env.dusk.example .env.dusk.local` -> `local` refers to the value of `APP_ENV` in your `.env` so if you have it set to `dev` then the file should be named `.env.dusk.dev`. - -**Important**: Dusk tests cannot be run using an in-memory SQLite database. Additionally, the Dusk test suite uses the `DatabaseMigrations` trait which will leave the database in a fresh state after running. Therefore, it is recommended that you create a test database and point `DB_DATABASE` in `.env.dusk.local` to it. - -### Running Browser Tests - -Your application needs to be configured and up and running in order for the browser tests to actually run. When running the tests locally, you can start the application using the following command: - -`php artisan serve` - -Now you are ready to run the test suite. Use the following command from another terminal tab or window: - -`php artisan dusk` - -To run individual test files, you can pass the path to the test that you want to run: - -`php artisan dusk tests/Browser/LoginTest.php` - -If you get an error when attempting to run Dusk tests that says `Couldn't connect to server` run: - -`php artisan dusk:chrome-driver --detect` - -This command will install the specific ChromeDriver Dusk needs for your operating system and Chrome version. diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 607d206a67..325fb8ad12 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -75,12 +75,7 @@ class AppServiceProvider extends ServiceProvider // Only load rollbar if there is a rollbar key and the app is in production if (($this->app->environment('production')) && (config('logging.channels.rollbar.access_token'))) { $this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class); - } - - // Only load dusk's service provider if the app is in local or develop mode - if ($this->app->environment(['local', 'develop'])) { - $this->app->register(\Laravel\Dusk\DuskServiceProvider::class); - } + } $this->app->singleton('ArieTimmerman\Laravel\SCIMServer\SCIMConfig', SnipeSCIMConfig::class); // this overrides the default SCIM configuration with our own diff --git a/composer.json b/composer.json index 20d76a1d91..020b2f9ca7 100644 --- a/composer.json +++ b/composer.json @@ -77,7 +77,6 @@ "require-dev": { "brianium/paratest": "^6.6", "fakerphp/faker": "^1.16", - "laravel/dusk": "^6.25", "mockery/mockery": "^1.4", "nunomaduro/larastan": "^1.0", "nunomaduro/phpinsights": "^2.7", @@ -107,7 +106,6 @@ }, "autoload-dev": { "classmap": [ - "tests/DuskTestCase.php", "tests/TestCase.php" ], "psr-4": { diff --git a/composer.lock b/composer.lock index 54d3e556b6..9f84ec8b29 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f30d1bebf56af36eb55a56d093b54650", + "content-hash": "348f96db24a0f8dfb595ee38b38b34eb", "packages": [ { "name": "alek13/slack", @@ -13521,79 +13521,6 @@ }, "time": "2022-04-13T08:02:27+00:00" }, - { - "name": "laravel/dusk", - "version": "v6.25.2", - "source": { - "type": "git", - "url": "https://github.com/laravel/dusk.git", - "reference": "25a595ac3dc82089a91af10dd23b0d58fd3f6d0b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/25a595ac3dc82089a91af10dd23b0d58fd3f6d0b", - "reference": "25a595ac3dc82089a91af10dd23b0d58fd3f6d0b", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-zip": "*", - "illuminate/console": "^6.0|^7.0|^8.0|^9.0", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0", - "nesbot/carbon": "^2.0", - "php": "^7.2|^8.0", - "php-webdriver/webdriver": "^1.9.0", - "symfony/console": "^4.3|^5.0|^6.0", - "symfony/finder": "^4.3|^5.0|^6.0", - "symfony/process": "^4.3|^5.0|^6.0", - "vlucas/phpdotenv": "^3.0|^4.0|^5.2" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "orchestra/testbench": "^4.16|^5.17.1|^6.12.1|^7.0", - "phpunit/phpunit": "^7.5.15|^8.4|^9.0" - }, - "suggest": { - "ext-pcntl": "Used to gracefully terminate Dusk when tests are running." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.x-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Dusk\\DuskServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Laravel\\Dusk\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Laravel Dusk provides simple end-to-end testing and browser automation.", - "keywords": [ - "laravel", - "testing", - "webdriver" - ], - "support": { - "issues": "https://github.com/laravel/dusk/issues", - "source": "https://github.com/laravel/dusk/tree/v6.25.2" - }, - "time": "2022-09-29T09:37:07+00:00" - }, { "name": "league/container", "version": "4.2.0", @@ -14230,71 +14157,6 @@ }, "time": "2022-02-21T12:50:22+00:00" }, - { - "name": "php-webdriver/webdriver", - "version": "1.12.1", - "source": { - "type": "git", - "url": "https://github.com/php-webdriver/php-webdriver.git", - "reference": "b27ddf458d273c7d4602106fcaf978aa0b7fe15a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/b27ddf458d273c7d4602106fcaf978aa0b7fe15a", - "reference": "b27ddf458d273c7d4602106fcaf978aa0b7fe15a", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-zip": "*", - "php": "^5.6 || ~7.0 || ^8.0", - "symfony/polyfill-mbstring": "^1.12", - "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0 || ^6.0" - }, - "replace": { - "facebook/webdriver": "*" - }, - "require-dev": { - "ondram/ci-detector": "^2.1 || ^3.5 || ^4.0", - "php-coveralls/php-coveralls": "^2.4", - "php-mock/php-mock-phpunit": "^1.1 || ^2.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpunit/phpunit": "^5.7 || ^7 || ^8 || ^9", - "squizlabs/php_codesniffer": "^3.5", - "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0 || ^6.0" - }, - "suggest": { - "ext-SimpleXML": "For Firefox profile creation" - }, - "type": "library", - "autoload": { - "files": [ - "lib/Exception/TimeoutException.php" - ], - "psr-4": { - "Facebook\\WebDriver\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", - "homepage": "https://github.com/php-webdriver/php-webdriver", - "keywords": [ - "Chromedriver", - "geckodriver", - "php", - "selenium", - "webdriver" - ], - "support": { - "issues": "https://github.com/php-webdriver/php-webdriver/issues", - "source": "https://github.com/php-webdriver/php-webdriver/tree/1.12.1" - }, - "time": "2022-05-03T12:16:34+00:00" - }, { "name": "phpstan/phpdoc-parser", "version": "1.22.1", diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php deleted file mode 100644 index 18f5172f15..0000000000 --- a/tests/Browser/LoginTest.php +++ /dev/null @@ -1,46 +0,0 @@ -make(); - - // We override the existing password to use a hash of one we know - $user->password = '$2y$10$8o5W8fgAKJbN3Kz4taepeeRVgKsG8pkZ1L4eJfdEKrn2mgI/JgCJy'; - - // We want a user that is a superuser - $user->permissions = '{"superuser": 1}'; - - $user->save(); - - Setting::factory()->create(); - - $this->browse(function (Browser $browser) { - $browser->visitRoute('login') - ->assertSee(trans('auth/general.login_prompt')); - }); - - $this->browse(function ($browser) use ($user) { - $browser->visitRoute('login') - ->type('username', $user->username) - ->type('password', 'password') - ->press(trans('auth/general.login')) - ->assertPathIs('/'); - $browser->screenshot('dashboard'); - }); - } -} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php deleted file mode 100644 index 26bf174f3d..0000000000 --- a/tests/Browser/Pages/HomePage.php +++ /dev/null @@ -1,41 +0,0 @@ - '#selector', - ]; - } -} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php deleted file mode 100644 index f8d76222c0..0000000000 --- a/tests/Browser/Pages/Page.php +++ /dev/null @@ -1,20 +0,0 @@ - '#selector', - ]; - } -} diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/tests/Browser/console/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/tests/Browser/screenshots/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/Browser/source/.gitignore b/tests/Browser/source/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/tests/Browser/source/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php deleted file mode 100644 index af46d0e3dc..0000000000 --- a/tests/DuskTestCase.php +++ /dev/null @@ -1,70 +0,0 @@ -addArguments(collect([ - '--window-size=1920,1080', - ])->unless($this->hasHeadlessDisabled(), function ($items) { - return $items->merge([ - '--disable-gpu', - '--headless', - ]); - })->all()); - - return RemoteWebDriver::create( - $_ENV['DUSK_DRIVER_URL'] ?? 'http://127.0.0.1:9515', - DesiredCapabilities::chrome()->setCapability( - ChromeOptions::CAPABILITY, $options - ) - ); - } - - /** - * Determine whether the Dusk command has disabled headless mode. - * - * @return bool - */ - protected function hasHeadlessDisabled() - { - return isset($_SERVER['DUSK_HEADLESS_DISABLED']) || - isset($_ENV['DUSK_HEADLESS_DISABLED']); - } -}