Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/microweber/microweber into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Feb 14, 2022
2 parents 4c8296a + 1a174eb commit 048da30
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 3 deletions.
12 changes: 11 additions & 1 deletion tests/Browser/AbppInstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@
namespace Tests\Browser;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Auth;
use Laravel\Dusk\Browser;
use MicroweberPackages\User\Models\User;
use Tests\Browser\Components\AdminLogin;
use Tests\Browser\Components\AdminMakeInstall;
use Tests\Browser\Components\ChekForJavascriptErrors;
use Tests\DuskTestCase;

class AbppInstallTest extends DuskTestCase
{
public $siteUrl = 'http://127.0.0.1:8000/';


public function testViewDashboard()
{
// $this->testInstallation();
// $user = User::where('is_admin', '=', '1')->first();
// Auth::login($user);
$siteUrl = $this->siteUrl;

$this->browse(function (Browser $browser) use($siteUrl) {


$browser->within(new AdminMakeInstall(), function ($browser) {
$browser->makeInstallation();
});


$browser->within(new AdminLogin(), function ($browser) {
$browser->fillForm();
});
Expand Down
2 changes: 2 additions & 0 deletions tests/Browser/Components/AdminLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ public function fillForm(Browser $browser, $username = 1, $password = 1)
$browser->pause(100);
}
}


}
91 changes: 91 additions & 0 deletions tests/Browser/Components/AdminMakeInstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace Tests\Browser\Components;

use Facebook\WebDriver\WebDriverBy;
use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;

class AdminMakeInstall extends BaseComponent
{
/**
* Get the root selector for the component.
*
* @return string
*/
public function selector()
{
return '';
}

/**
* Assert that the browser page contains the component.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{

}

/**
* Get the element shortcuts for the component.
*
* @return array
*/
public function elements()
{
return [];
}



public function makeInstallation(Browser $browser)
{

$siteUrl = site_url();
$this->browse(function (Browser $browser) use($siteUrl) {

if (mw_is_installed()) {
$this->assertTrue(true);
return true;
}

/* $deleteDbFiles = [];
$deleteDbFiles[] = dirname(dirname(__DIR__)) . DS . 'config/microweber.php';
$deleteDbFiles[] = dirname(dirname(__DIR__)) . DS . 'storage/127_0_0_1.sqlite';
foreach ($deleteDbFiles as $file) {
if (is_file($file)) {
unlink($file);
}
}*/

$browser->visit($siteUrl)->assertSee('install');

$browser->within(new ChekForJavascriptErrors(), function ($browser) {
$browser->validate();
});


// Fill the install fields
$browser->type('admin_username', '1');
$browser->type('admin_password', '1');
$browser->type('admin_password2', '1');
$browser->type('admin_email', 'bobi@microweber.com');

$browser->pause(300);
$browser->select('#default_template', 'new-world');

$browser->pause(100);
$browser->click('@install-button');

$browser->pause(20000);

clearcache();



});
}
}
3 changes: 1 addition & 2 deletions tests/DuskTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public function testInstallation()

clearcache();

$user = User::where('is_admin', '=', '1')->first();
Auth::login($user);


});
}
Expand Down

0 comments on commit 048da30

Please sign in to comment.