Correctly tear down tests and remove cookies
This commit is contained in:
parent
8bbe6bc279
commit
6e9123af19
|
@ -4,7 +4,9 @@ namespace Pterodactyl\Tests\Browser;
|
||||||
|
|
||||||
use Laravel\Dusk\TestCase;
|
use Laravel\Dusk\TestCase;
|
||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
|
use Pterodactyl\Models\User;
|
||||||
use Tests\CreatesApplication;
|
use Tests\CreatesApplication;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||||
|
@ -15,6 +17,13 @@ abstract class BrowserTestCase extends TestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication, DatabaseMigrations;
|
use CreatesApplication, DatabaseMigrations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default password to use for new accounts.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $userPassword = 'Password123';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup tests.
|
* Setup tests.
|
||||||
*/
|
*/
|
||||||
|
@ -61,4 +70,31 @@ abstract class BrowserTestCase extends TestCase
|
||||||
{
|
{
|
||||||
return new PterodactylBrowser($driver);
|
return new PterodactylBrowser($driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tear down the test and delete all cookies from the browser instance to address
|
||||||
|
* instances where the test would be kicked over to the login page.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
/** @var \Pterodactyl\Tests\Browser\PterodactylBrowser $browser */
|
||||||
|
foreach (static::$browsers as $browser) {
|
||||||
|
$browser->driver->manage()->deleteAllCookies();
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a user model to authenticate aganist and use in the tests.
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
* @return \Pterodactyl\Models\User
|
||||||
|
*/
|
||||||
|
protected function user(array $attributes = []): User
|
||||||
|
{
|
||||||
|
return factory(User::class)->create(array_merge([
|
||||||
|
'password' => Hash::make(static::$userPassword),
|
||||||
|
], $attributes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue