jqh vor 5 Jahren
Ursprung
Commit
178fce763b

+ 15 - 10
browser-tests/Browser/MenuTest.php

@@ -58,16 +58,21 @@ class MenuTest extends TestCase
         $this->delete('admin/auth/menu/8');
         $this->assertEquals(7, Menu::count());
     }
-    //
-    //public function testEditMenu()
-    //{
-    //    $this->visit('admin/auth/menu/1/edit')
-    //        ->see('Menu')
-    //        ->submitForm('Submit', ['title' => 'blablabla'])
-    //        ->seePageIs('admin/auth/menu')
-    //        ->seeInDatabase(config('admin.database.menu_table'), ['title' => 'blablabla'])
-    //        ->assertEquals(7, Menu::count());
-    //}
+
+    public function testEditMenu()
+    {
+        $this->browse(function (Browser $browser) {
+            $browser->visit(test_admin_path('auth/menu/1/edit'))
+                ->assertSee('Menu')
+                ->assertSee('Edit')
+                ->type('title', 'blablabla')
+                ->press('Submit')
+                ->waitForLocation(test_admin_path('auth/menu'), 2);
+
+            $this->seeInDatabase(config('admin.database.menu_table'), ['title' => 'blablabla'])
+                ->assertEquals(7, Menu::count());
+        });
+    }
     //
     //public function testEditMenuParent()
     //{

+ 21 - 0
browser-tests/ChromeProcess.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace Tests;
+
+use Laravel\Dusk\Chrome\ChromeProcess as BaseChromeProcess;
+
+class ChromeProcess extends BaseChromeProcess
+{
+    public function __construct($driver = null)
+    {
+        parent::__construct($driver);
+
+        if ($this->onWindows()) {
+            $this->driver = realpath(__DIR__.'/resources/drivers/chromedriver-win.exe');
+        } elseif ($this->onMac()) {
+            $this->driver = realpath(__DIR__.'/resources/drivers/chromedriver-mac');
+        } else {
+            $this->driver = realpath(__DIR__.'/resources/drivers/chromedriver-linux');
+        }
+    }
+}

+ 14 - 2
browser-tests/DuskTestCase.php

@@ -37,7 +37,6 @@ abstract class DuskTestCase extends BaseTestCase
         $this->boot();
     }
 
-
     public function tearDown(): void
     {
         $this->destory();
@@ -63,7 +62,7 @@ abstract class DuskTestCase extends BaseTestCase
      */
     protected function newBrowser($driver)
     {
-        $browser = parent::newBrowser($driver)->resize(1440, 1080);
+        $browser = parent::newBrowser($driver)->resize(1566, 1080);
 
         if ($this->login) {
             $this->login($browser);
@@ -91,4 +90,17 @@ abstract class DuskTestCase extends BaseTestCase
             )
         );
     }
+
+    /**
+     * Build the process to run the Chromedriver.
+     *
+     * @param  array  $arguments
+     * @return \Symfony\Component\Process\Process
+     *
+     * @throws \RuntimeException
+     */
+    protected static function buildChromeProcess(array $arguments = [])
+    {
+        return (new ChromeProcess(static::$chromeDriver))->toProcess($arguments);
+    }
 }

+ 1 - 13
src/Console/Tests/InstallCommand.php

@@ -24,23 +24,11 @@ class InstallCommand extends Command
 
         $this->initTestsDirectory();
 
-        $this->files->link(realpath(__DIR__.'/../../../tests'), $this->directory);
-
-        $this->info('The [tests/] directory has been linked.');
+        $this->files->copyDirectory(realpath(__DIR__.'/../../../browser-tests'), base_path('tests'));
     }
 
     protected function initTestsDirectory()
     {
-        $dir = realpath(__DIR__.'/../../../vendor/laravel/laravel/tests');
-        if ($this->files->isDirectory($dir)) {
-            $this->directory = $dir;
-
-            $this->files->deleteDirectory($this->directory);
-            $this->files->makeDirectory($this->directory);
-
-            return;
-        }
-
         $this->directory = base_path();
     }
 }