Beautiful Open-Source Form Builder
refactor: remove Laravel Dusk test scaffolding
JhumanJa905afc659ab
diff --git a/.gitattributes b/.gitattributesindex 81f8ed652..7f6951473 100644--- a/.gitattributes+++ b/.gitattributes@@ -5,5 +5,3 @@CHANGELOG.md export-ignoreREADME.md export-ignore.travis.yml export-ignore-.env.dusk.local export-ignore-.env.dusk.testing export-ignorediff --git a/.gitignore b/.gitignoreindex e4f011f39..a72daf4a3 100644--- a/.gitignore+++ b/.gitignore@@ -3,7 +3,6 @@ Homestead.jsonHomestead.yamlnpm-debug.logyarn-error.log-phpunit.dusk.xml.DS_Storepublic/.DS_Store*.DS_Storediff --git a/api/.gitignore b/api/.gitignoreindex c4b7dd800..f2c4f78fc 100644--- a/api/.gitignore+++ b/api/.gitignore@@ -9,7 +9,6 @@.env.api-production.env.backup.env.testing-.env.dusk.local.env.api-*.env.docker.local.phpunit.result.cache@@ -18,7 +17,6 @@ Homestead.jsonHomestead.yamlnpm-debug.logyarn-error.log-phpunit.dusk.xml/public/dist/public/build/public/mix-manifest.jsondiff --git a/api/app/Providers/AppServiceProvider.php b/api/app/Providers/AppServiceProvider.phpindex fd23b2916..ac429a8e6 100644--- a/api/app/Providers/AppServiceProvider.php+++ b/api/app/Providers/AppServiceProvider.php@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Event;use Illuminate\Support\Facades\Route;use Illuminate\Support\ServiceProvider;use Laravel\Cashier\Cashier;-use Laravel\Dusk\DuskServiceProvider;+use RuntimeException;class AppServiceProvider extends ServiceProvider{@@ -37,7 +37,8 @@ class AppServiceProvider extends ServiceProviderCashier::calculateTaxes();Cashier::useSubscriptionModel(Subscription::class);- if ($this->app->runningUnitTests()) {+ if ($this->app->environment('testing')) {+ $this->ensureSafeTestingDatabase();Schema::defaultStringLength(191);}@@ -80,14 +81,39 @@ class AppServiceProvider extends ServiceProvider*/public function register(){- if ($this->app->environment('local', 'testing') && class_exists(DuskServiceProvider::class)) {- $this->app->register(DuskServiceProvider::class);- }-// OAuth Services$this->app->singleton(\App\Service\OAuth\OAuthContextService::class);$this->app->singleton(\App\Service\OAuth\OAuthInviteService::class);$this->app->singleton(\App\Service\OAuth\OAuthUserDataService::class);$this->app->singleton(\App\Service\OAuth\OAuthFlowOrchestrator::class);}++ private function ensureSafeTestingDatabase(): void+ {+ $connectionName = config('database.default');+ $connections = config('database.connections', []);+ $connection = $connections[$connectionName] ?? null;++ if (!is_array($connection)) {+ throw new RuntimeException('Missing database configuration for the active test connection.');+ }++ $driver = strtolower((string) ($connection['driver'] ?? ''));+ $url = strtolower((string) ($connection['url'] ?? ''));+ $database = strtolower((string) ($connection['database'] ?? ''));++ if ($driver !== 'sqlite') {+ throw new RuntimeException('Only sqlite is allowed while testing.');+ }++ $isInMemoryDatabase = $database === ':memory:';+ $isTestingDatabase = str_contains($database, 'test');+ $isSafeUrl = $url === '';++ if ($isSafeUrl && ($isInMemoryDatabase || $isTestingDatabase)) {+ return;+ }++ throw new RuntimeException('Unsafe testing sqlite configuration detected.');+ }}diff --git a/api/composer.json b/api/composer.jsonindex 9fb819938..577cbee0e 100644--- a/api/composer.json+++ b/api/composer.json@@ -49,7 +49,6 @@"require-dev": {"barryvdh/laravel-ide-helper": "^3.0.0","larastan/larastan": "^3.0",- "laravel/dusk": "^8.2.0","laravel/pint": "^1.13","laravel/sail": "^1.26","mockery/mockery": "^1.6",@@ -74,7 +73,6 @@"extra": {"laravel": {"dont-discover": [- "laravel/dusk","nunomaduro/collision","pestphp/pest-plugin-laravel","spatie/laravel-ignition",diff --git a/api/composer.lock b/api/composer.lockindex 7d88cd531..fac8b7ef1 100644--- a/api/composer.lock+++ b/api/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": "a5dd840c90900d7798ca7ff87b2c48ef",+ "content-hash": "d850ed3a2994eefced4f63a9eac0f5de","packages": [{"name": "aws/aws-crt-php",@@ -13762,80 +13762,6 @@],"time": "2026-01-30T15:16:32+00:00"},- {- "name": "laravel/dusk",- "version": "v8.3.3",- "source": {- "type": "git",- "url": "https://github.com/laravel/dusk.git",- "reference": "077d448cd993a08f97bfccf0ea3d6478b3908f7e"- },- "dist": {- "type": "zip",- "url": "https://api.github.com/repos/laravel/dusk/zipball/077d448cd993a08f97bfccf0ea3d6478b3908f7e",- "reference": "077d448cd993a08f97bfccf0ea3d6478b3908f7e",- "shasum": ""- },- "require": {- "ext-json": "*",- "ext-zip": "*",- "guzzlehttp/guzzle": "^7.5",- "illuminate/console": "^10.0|^11.0|^12.0",- "illuminate/support": "^10.0|^11.0|^12.0",- "php": "^8.1",- "php-webdriver/webdriver": "^1.15.2",- "symfony/console": "^6.2|^7.0",- "symfony/finder": "^6.2|^7.0",- "symfony/process": "^6.2|^7.0",- "vlucas/phpdotenv": "^5.2"- },- "require-dev": {- "laravel/framework": "^10.0|^11.0|^12.0",- "mockery/mockery": "^1.6",- "orchestra/testbench-core": "^8.19|^9.0|^10.0",- "phpstan/phpstan": "^1.10",- "phpunit/phpunit": "^10.1|^11.0|^12.0.1",- "psy/psysh": "^0.11.12|^0.12",- "symfony/yaml": "^6.2|^7.0"- },- "suggest": {- "ext-pcntl": "Used to gracefully terminate Dusk when tests are running."- },- "type": "library",- "extra": {- "laravel": {- "providers": [- "Laravel\\Dusk\\DuskServiceProvider"- ]- }- },- "autoload": {- "psr-4": {- "Laravel\\Dusk\\": "src/"- }- },- "notification-url": "https://packagist.org/downloads/",- "license": [- "MIT"- ],- "authors": [- {- "name": "Taylor Otwell",- "email": "[email protected]"- }- ],- "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/v8.3.3"- },- "time": "2025-06-10T13:59:27+00:00"- },{"name": "laravel/pint","version": "v1.25.1",@@ -14647,72 +14573,6 @@},"time": "2022-02-21T01:04:05+00:00"},- {- "name": "php-webdriver/webdriver",- "version": "1.15.2",- "source": {- "type": "git",- "url": "https://github.com/php-webdriver/php-webdriver.git",- "reference": "998e499b786805568deaf8cbf06f4044f05d91bf"- },- "dist": {- "type": "zip",- "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/998e499b786805568deaf8cbf06f4044f05d91bf",- "reference": "998e499b786805568deaf8cbf06f4044f05d91bf",- "shasum": ""- },- "require": {- "ext-curl": "*",- "ext-json": "*",- "ext-zip": "*",- "php": "^7.3 || ^8.0",- "symfony/polyfill-mbstring": "^1.12",- "symfony/process": "^5.0 || ^6.0 || ^7.0"- },- "replace": {- "facebook/webdriver": "*"- },- "require-dev": {- "ergebnis/composer-normalize": "^2.20.0",- "ondram/ci-detector": "^4.0",- "php-coveralls/php-coveralls": "^2.4",- "php-mock/php-mock-phpunit": "^2.0",- "php-parallel-lint/php-parallel-lint": "^1.2",- "phpunit/phpunit": "^9.3",- "squizlabs/php_codesniffer": "^3.5",- "symfony/var-dumper": "^5.0 || ^6.0 || ^7.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.15.2"- },- "time": "2024-11-21T15:12:59+00:00"- },{"name": "phpstan/phpstan","version": "2.1.39",diff --git a/api/config/database.php b/api/config/database.phpindex 731295291..d196ec140 100644--- a/api/config/database.php+++ b/api/config/database.php@@ -106,14 +106,6 @@ return ['prefix_indexes' => true,],- 'dusk' => [- 'driver' => 'sqlite',- 'url' => env('DATABASE_URL'),- 'database' => database_path('dusk.sqlite'),- 'prefix' => '',- 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),- ],-],/*diff --git a/api/phpunit.xml b/api/phpunit.xmlindex 35b9e00ef..0681a776c 100644--- a/api/phpunit.xml+++ b/api/phpunit.xml@@ -7,31 +7,31 @@<testsuite name="Feature"><directory suffix="Test.php">./tests/Feature</directory></testsuite>- <!-- <testsuite name="Browser">-->- <!-- <directory suffix="Test.php">./tests/Browser</directory>-->- <!-- </testsuite>--></testsuites><php>- <env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>- <env name="APP_ENV" value="testing"/>- <env name="BCRYPT_ROUNDS" value="4"/>- <env name="CACHE_DRIVER" value="array"/>- <env name="DB_CONNECTION" value="sqlite"/>- <env name="DB_DATABASE" value=":memory:"/>- <env name="DB_FOREIGN_KEYS" value="(false)"/>- <env name="MAIL_MAILER" value="log"/>- <env name="MAIL_FROM_ADDRESS" value="[email protected]"/>- <env name="MAIL_FROM_NAME" value="NotionForms"/>- <env name="QUEUE_CONNECTION" value="sync"/>- <env name="FILESYSTEM_DISK" value="local"/>- <env name="SESSION_DRIVER" value="array"/>- <env name="SELF_HOSTED" value="false"/>- <env name="TEMPLATE_EDITOR_EMAILS" value="[email protected]"/>- <env name="JWT_SECRET" value="9K6whOetAFaokQgSIdbMQZuJuDV5uS2Y"/>- <env name="STRIPE_KEY" value="TEST_KEY"/>- <env name="STRIPE_SECRET" value="TEST_SECRET"/>- <env name="H_CAPTCHA_SITE_KEY" value="TEST_SITE_KEY"/>- <env name="H_CAPTCHA_SECRET_KEY" value="TEST_SECRET"/>+ <server name="APP_DEBUG" value="true"/>+ <server name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>+ <server name="APP_NAME" value="NotionForms TESTING"/>+ <server name="APP_ENV" value="testing"/>+ <server name="BCRYPT_ROUNDS" value="4"/>+ <server name="CACHE_DRIVER" value="array"/>+ <server name="DATABASE_URL" value=""/>+ <server name="DB_CONNECTION" value="sqlite"/>+ <server name="DB_DATABASE" value=":memory:"/>+ <server name="DB_FOREIGN_KEYS" value="(false)"/>+ <server name="MAIL_MAILER" value="log"/>+ <server name="MAIL_FROM_ADDRESS" value="[email protected]"/>+ <server name="MAIL_FROM_NAME" value="NotionForms"/>+ <server name="QUEUE_CONNECTION" value="sync"/>+ <server name="FILESYSTEM_DISK" value="local"/>+ <server name="SESSION_DRIVER" value="array"/>+ <server name="SELF_HOSTED" value="false"/>+ <server name="TEMPLATE_EDITOR_EMAILS" value="[email protected]"/>+ <server name="JWT_SECRET" value="9K6whOetAFaokQgSIdbMQZuJuDV5uS2Y"/>+ <server name="STRIPE_KEY" value="TEST_KEY"/>+ <server name="STRIPE_SECRET" value="TEST_SECRET"/>+ <server name="H_CAPTCHA_SITE_KEY" value="TEST_SITE_KEY"/>+ <server name="H_CAPTCHA_SECRET_KEY" value="TEST_SECRET"/></php><source><include>diff --git a/api/tests/Browser/LoginTest.php b/api/tests/Browser/LoginTest.phpdeleted file mode 100644index 8e0134240..000000000--- a/api/tests/Browser/LoginTest.php+++ /dev/null@@ -1,40 +0,0 @@-<?php--use App\Models\User;-use Tests\Browser\Pages\Home;-use Tests\Browser\Pages\Login;--uses(\Tests\DuskTestCase::class);--/** @test */-it('can login onboarded users', function () {- $user = User::factory()->create();- $this->createUserWorkspace($user);-- $this->browse(function ($browser) use ($user) {- $browser->visit(new Login())- ->submit($user->email, 'Abcd@1234')- ->assertPageIs(Home::class);- });-});--it('cannot login with invalid credentials', function () {- $this->browse(function ($browser) {- $browser->visit(new Login())- ->submit('[email protected]', 'password')- ->pause(100)- ->assertSee('These credentials do not match our records.');- });-});--it('can log out the user', function () {- $user = User::factory()->create();-- $this->browse(function ($browser) use ($user) {- $browser->visit(new Login())- ->submit($user->email, 'Abcd@1234')- ->on(new Home())- ->clickLogout()- ->assertPageIs(Login::class);- });-});diff --git a/api/tests/Browser/Pages/Home.php b/api/tests/Browser/Pages/Home.phpdeleted file mode 100644index 6af320bf2..000000000--- a/api/tests/Browser/Pages/Home.php+++ /dev/null@@ -1,53 +0,0 @@-<?php--namespace Tests\Browser\Pages;--use Laravel\Dusk\Browser;--class Home extends Page-{- /**- * Get the URL for the page.- *- * @return string- */- public function url()- {- return '/home';- }-- /**- * Assert that the browser is on the page.- *- * @return void- */- public function assert(Browser $browser)- {- $browser->waitForLocation($this->url())->assertPathIs($this->url());- }-- /**- * Get the element shortcuts for the page.- *- * @return array- */- public function elements()- {- return [];- }-- /**- * Click on the log out link.- *- * @param \Laravel\Dusk\Browser $browser- * @return void- */- public function clickLogout($browser)- {- $browser->click('@nav-dropdown-button')- ->waitFor('@nav-dropdown')- ->waitForText('Logout')- ->clickLink('Logout')- ->pause(100);- }-}diff --git a/api/tests/Browser/Pages/HomePage.php b/api/tests/Browser/Pages/HomePage.phpdeleted file mode 100644index c04a7f0ae..000000000--- a/api/tests/Browser/Pages/HomePage.php+++ /dev/null@@ -1,40 +0,0 @@-<?php--namespace Tests\Browser\Pages;--use Laravel\Dusk\Browser;--class HomePage extends Page-{- /**- * Get the URL for the page.- *- * @return string- */- public function url()- {- return '/';- }-- /**- * Assert that the browser is on the page.- *- * @return void- */- public function assert(Browser $browser)- {- //- }-- /**- * Get the element shortcuts for the page.- *- * @return array- */- public function elements()- {- return [- '@element' => '#selector',- ];- }-}diff --git a/api/tests/Browser/Pages/Login.php b/api/tests/Browser/Pages/Login.phpdeleted file mode 100644index 51fa4f088..000000000--- a/api/tests/Browser/Pages/Login.php+++ /dev/null@@ -1,32 +0,0 @@-<?php--namespace Tests\Browser\Pages;--class Login extends Page-{- /**- * Get the URL for the page.- *- * @return string- */- public function url()- {- return '/login';- }-- /**- * Submit the form with the given credentials.- *- * @param \Laravel\Dusk\Browser $browser- * @param string $email- * @param string $password- * @return void- */- public function submit($browser, $email, $password)- {- $browser->type('email', $email)- ->type('password', $password)- ->press('@btn_login')- ->pause(500);- }-}diff --git a/api/tests/Browser/Pages/Onboarding.php b/api/tests/Browser/Pages/Onboarding.phpdeleted file mode 100644index 49a55450f..000000000--- a/api/tests/Browser/Pages/Onboarding.php+++ /dev/null@@ -1,38 +0,0 @@-<?php--namespace Tests\Browser\Pages;--use Laravel\Dusk\Browser;--class Onboarding extends Page-{- /**- * Get the URL for the page.- *- * @return string- */- public function url()- {- return '/onboarding';- }-- /**- * Assert that the browser is on the page.- *- * @return void- */- public function assert(Browser $browser)- {- $browser->waitForLocation($this->url())->assertPathIs($this->url());- }-- /**- * Get the element shortcuts for the page.- *- * @return array- */- public function elements()- {- return [];- }-}diff --git a/api/tests/Browser/Pages/Page.php b/api/tests/Browser/Pages/Page.phpdeleted file mode 100644index 09b5a35d5..000000000--- a/api/tests/Browser/Pages/Page.php+++ /dev/null@@ -1,31 +0,0 @@-<?php--namespace Tests\Browser\Pages;--use Laravel\Dusk\Browser;-use Laravel\Dusk\Page as BasePage;--abstract class Page extends BasePage-{- /**- * Assert that the browser is on the page.- *- * @return void- */- public function assert(Browser $browser)- {- $browser->assertPathIs($this->url());- }-- /**- * Get the global element shortcuts for the site.- *- * @return array- */- public static function siteElements()- {- return [- '@element' => '#selector',- ];- }-}diff --git a/api/tests/Browser/Pages/Register.php b/api/tests/Browser/Pages/Register.phpdeleted file mode 100644index 5e7f897ae..000000000--- a/api/tests/Browser/Pages/Register.php+++ /dev/null@@ -1,32 +0,0 @@-<?php--namespace Tests\Browser\Pages;--class Register extends Page-{- /**- * Get the URL for the page.- *- * @return string- */- public function url()- {- return '/register';- }-- /**- * Submit the form with the given data.- *- * @param \Laravel\Dusk\Browser $browser- * @return void- */- public function submit($browser, array $data = [])- {- foreach ($data as $key => $value) {- $browser->type($key, $value);- }-- $browser->press('Register')- ->pause(1000);- }-}diff --git a/api/tests/Browser/RegisterTest.php b/api/tests/Browser/RegisterTest.phpdeleted file mode 100644index af1d97ddd..000000000--- a/api/tests/Browser/RegisterTest.php+++ /dev/null@@ -1,72 +0,0 @@-<?php--namespace Tests\Browser;--use App\Models\User;-use Illuminate\Foundation\Testing\DatabaseMigrations;-use Laravel\Dusk\Browser;-use Tests\Browser\Pages\Onboarding;-use Tests\Browser\Pages\Register;-use Tests\DuskTestCase;--class RegisterTest extends DuskTestCase-{- use DatabaseMigrations;-- public function setUp(): void- {- parent::setup();-- static::closeAll();- }-- /**- * Pick Random option from custom select- *- * @throws \Facebook\WebDriver\Exception\TimeOutException- */- public function selectHearAboutUsReason(Browser $browser)- {- $browser->waitFor('@hear_about_us')- ->click('@hear_about_us')- ->waitFor('@hear_about_us_dropdown');- $options = $browser->elements('@hear_about_us_option');- shuffle($options);- $options[0]->click();- }-- /** @test */- public function register_with_valid_data()- {- $this->browse(function (Browser $browser) {- $browser->visit(new Register());- $this->selectHearAboutUsReason($browser);- $browser->submit([- 'name' => 'Test User',- 'email' => '[email protected]',- 'password' => 'Abcd@1234',- 'password_confirmation' => 'Abcd@1234',- ])- ->assertPageIs(Onboarding::class);- });- }-- /** @test */- public function can_not_register_with_the_same_twice()- {- $user = User::factory()->create();-- $this->browse(function (Browser $browser) use ($user) {- $browser->visit(new Register());- $this->selectHearAboutUsReason($browser);- $browser->submit([- 'name' => 'Test User',- 'email' => $user->email,- 'password' => 'Abcd@1234',- 'password_confirmation' => 'Abcd@1234',- ])- ->pause(3000)- ->assertSee('The email has already been taken.');- });- }-}diff --git a/api/tests/Browser/WelcomeTest.php b/api/tests/Browser/WelcomeTest.phpdeleted file mode 100644index 558482be4..000000000--- a/api/tests/Browser/WelcomeTest.php+++ /dev/null@@ -1,18 +0,0 @@-<?php--namespace Tests\Browser;--use Tests\DuskTestCase;--class WelcomeTest extends DuskTestCase-{- /** @test */- public function basic_test()- {- $this->browse(function ($browser) {- $browser->visit('/')- ->waitFor('@title', 1)- ->assertSee('Forms for Notion');- });- }-}diff --git a/api/tests/DuskTestCase.php b/api/tests/DuskTestCase.phpdeleted file mode 100644index fd4f6035d..000000000--- a/api/tests/DuskTestCase.php+++ /dev/null@@ -1,61 +0,0 @@-<?php--namespace Tests;--use Facebook\WebDriver\Chrome\ChromeOptions;-use Facebook\WebDriver\Remote\DesiredCapabilities;-use Facebook\WebDriver\Remote\RemoteWebDriver;-use Illuminate\Foundation\Testing\DatabaseMigrations;-use Laravel\Dusk\Browser;-use Laravel\Dusk\Page;-use Laravel\Dusk\TestCase as BaseTestCase;--Browser::macro('assertPageIs', function ($page) {- if (! $page instanceof Page) {- $page = new $page();- }-- // waiting for location before asserting, because window.location.pathname may be updated asynchronously- return $this->waitForLocation($page->url())->assertPathIs($page->url());-});--abstract class DuskTestCase extends BaseTestCase-{- use CreatesApplication;- use DatabaseMigrations;- use TestHelpers;-- /**- * Prepare for Dusk test execution.- *- * @beforeClass- *- * @return void- */- public static function prepare()- {- static::startChromeDriver();- }-- /**- * Create the RemoteWebDriver instance.- *- * @return \Facebook\WebDriver\Remote\RemoteWebDriver- */- protected function driver()- {- $options = (new ChromeOptions())->addArguments([- '--disable-gpu',- '--headless',- '--window-size=1920,1080',- ]);-- return RemoteWebDriver::create(- 'http://localhost:9515',- DesiredCapabilities::chrome()->setCapability(- ChromeOptions::CAPABILITY,- $options- )- );- }-}diff --git a/api/tests/Feature/Forms/FormStatTest.php b/api/tests/Feature/Forms/FormStatTest.phpindex 406598d5e..3c0f816c1 100644--- a/api/tests/Feature/Forms/FormStatTest.php+++ b/api/tests/Feature/Forms/FormStatTest.php@@ -68,6 +68,10 @@ it('check formstat chart data', function () {it('checks form stats details', function () {+ if (config('database.default') === 'sqlite') {+ $this->markTestSkipped('Skipped on sqlite because the stats query uses PostgreSQL JSON casting syntax.');+ }+$user = $this->actingAsProUser();$workspace = $this->createUserWorkspace($user);$form = $this->createForm($user, $workspace, []);