rainlab/dusk-plugin

There is no license information available for the latest version (v1.0.1) of this package.

Browser testing for October CMS, powered by Laravel Dusk.

Installs: 457

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 1

Open Issues: 1

Type:october-plugin

v1.0.1 2023-09-05 23:47 UTC

This package is auto-updated.

Last update: 2023-09-05 23:48:32 UTC


README

Browser testing for October CMS, powered by Laravel Dusk.

Installation Instructions

To install with Composer, run from your project root

composer require rainlab/dusk-plugin

If using the latest version of Chrome, install the latest version of ChromeDriver for your OS.

php artisan dusk:chrome-driver

Otherwise, check the version of the Chrome browser you have installed, and install a given version of ChromeDriver for your OS.

php artisan dusk:chrome-driver 86

Defining Tests

To make your first test, create a new class inside the tests/browser folder. The following will authenticate to the backend panel and sign out again.

// File: plugins/october/test/tests/browser/AuthenticationTest.php
//
class AuthenticationTest extends BrowserTestCase
{
    public function testAuthentication()
    {
        $this->browse(function($browser) {
            $browser
                ->visit('/admin')
                ->waitForLocation('/admin/backend/auth/signin')
                ->assertTitleContains('Administration Area |')
                ->type('login', env('DUSK_ADMIN_USER', 'admin'))
                ->type('password', env('DUSK_ADMIN_PASS', 'admin'))
                ->check('remember')
                ->press('Login');

            $browser
                ->waitForLocation('/admin')
                ->assertTitleContains('Dashboard |')
                ->click('#layout-mainmenu .mainmenu-account > a')
                ->clickLink('Sign Out');

            $browser
                ->waitForLocation('/admin/backend/auth/signin')
                ->assertTitleContains('Administration Area |');
        });
    }
}

Running Tests

Use the test:dusk artisan command to run the dusk tests for a plugin code (first argument).

php artisan test:dusk <PLUGIN CODE>

The following runs tests for the October.Test plugin.

php artisan test:dusk october.test

Use the --browse to enable interactive mode.

php artisan test:dusk october.test --browse

Use the --filter option to run a single test where the value is the test class name.

php artisan test:dusk october.test --filter=PeopleTest

See Also

License

This plugin is an official extension of the October CMS platform and is free to use if you have a platform license. See EULA license for more details.