File: D:/HostingSpaces/SBogers10/hours.komma.pro/tests/Browser/navigateTest.php
<?php
namespace Tests\Browser;
use App\User;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
class navigateTest extends DuskTestCase
{
public function setUp()
{
Parent::setUp();
}
/**
* @test
* @group Navigate
public function navigateAsUser()
{
$employeeUserID = User::whereHas('roles', function ($query) {
$query->where('id', 3);
})->first()->id;
$this->browse(function (Browser $browser) use ($employeeUserID) {
$browser->loginAs($employeeUserID)
// -------------- Hours -------------------- //
->visit('/hours')
->assertPathIs('/hours')
->click('ul.nav-tabs > li:nth-child(2)')
->assertVisible('#internal')
->click('ul.nav-tabs > li:nth-child(3)')
->assertVisible('#expense')
->click('ul.nav-tabs > li:nth-child(1)')
->assertVisible('#hours')
->click('#weekPill')
->assertVisible('#week')
->click('#monthPill')
->assertVisible('#maand')
->click('#dayPill')
->assertVisible('#dag')
// -------------- Projects -------------------- //
->visit('/projecten')
->waitUntil('pageLoaded')
->assertPathIs('/projecten');
$projectID = $browser->script('return $(".project").first().attr("pid")')[0];
$browser->click('[pid="' . $projectID . '"] h2 a')
->waitUntil('pageLoaded')
->assertPathIs('/projecten/' . $projectID)
->click('@editProject')
->waitUntil('pageLoaded')
->assertPathIs('/projecten/' . $projectID . '/edit')
->click('input[type=submit]')
->assertPathIs('/projecten/' . $projectID);
$subprojectID = $browser->script('return $(".subproject").first().attr("sid")')[0];
$browser->click('[sid="' . $subprojectID . '"] h4 a')
->waitUntil('pageLoaded')
->assertPathIs('/subprojecten/' . $subprojectID)
->click('@editSubproject')
->waitUntil('pageLoaded')
->assertPathIs('/subprojecten/' . $subprojectID . '/edit')
->click('input[type=submit]')
->assertPathIs('/subprojecten/' . $subprojectID)
->click('.content h1 a')
->assertPathIs('/projecten/' . $projectID)
// -------------- Companies -------------------- //
->visit('/klanten')
->waitUntil('pageLoaded')
->assertPathIs('/klanten');
$companyID = $browser->script('return $(".company").first().attr("cid")')[0];
$browser->click('[cid="' . $companyID . '"] h2 a')
->waitUntil('pageLoaded')
->assertPathIs('/klanten/' . $companyID)
->click('@editCompany')
->waitUntil('pageLoaded')
->assertPathIs('/klanten/' . $companyID . '/edit')
->click('input[type=submit]')
->assertPathIs('/klanten/' . $companyID)
// -------------- Absences -------------------- //
->visit('/absences')
->waitUntil('pageLoaded')
->assertPathIs('/absences');
$absenceID = $browser->script('return $(".absence").first().attr("aid")')[0];
$browser->click('[aid="' . $absenceID . '"] h2 a')
->waitUntil('pageLoaded')
->assertPathIs('/absences/' . $absenceID);
});
}
*/
/**
* @test
* @group Navigate
*
**/
public function navigateAsAdmin()
{
$adminUserID = User::whereHas('roles', function ($query) {
$query->where('id', 2);
})->first()->id;
$this->browse(function (Browser $browser) use ($adminUserID) {
$browser->loginAs($adminUserID)
// -------------- Hours -------------------- //
->visit('/hours')
->assertPathIs('/hours')
->click('ul.nav-tabs > li:nth-child(2)')
->assertVisible('#internal')
->click('ul.nav-tabs > li:nth-child(3)')
->assertVisible('#expense')
->click('ul.nav-tabs > li:nth-child(1)')
->assertVisible('#hours')
->click('#weekPill')
->assertVisible('#week')
->click('#monthPill')
->assertVisible('#maand')
->click('#dayPill')
->assertVisible('#dag')
// -------------- Projects -------------------- //
->visit('/projecten')
->waitUntil('pageLoaded')
->assertPathIs('/projecten');
$projectID = $browser->script('return $(".project").first().attr("pid")')[0];
$browser->click('[pid="' . $projectID . '"] h2 a')
->waitUntil('pageLoaded')
->assertPathIs('/projecten/' . $projectID)
->click('@editProject')
->waitUntil('pageLoaded')
->assertPathIs('/projecten/' . $projectID . '/edit')
->click('input[type=submit]')
->assertPathIs('/projecten/' . $projectID);
$subprojectID = $browser->script('return $(".subproject").first().attr("sid")')[0];
$browser->click('[sid="' . $subprojectID . '"] h4 a')
->waitUntil('pageLoaded')
->assertPathIs('/subprojecten/' . $subprojectID)
->click('@editSubproject')
->waitUntil('pageLoaded')
->assertPathIs('/subprojecten/' . $subprojectID . '/edit')
->click('input[type=submit]')
->assertPathIs('/subprojecten/' . $subprojectID)
->click('.content h1 a')
->assertPathIs('/projecten/' . $projectID)
// -------------- Companies -------------------- //
->visit('/klanten')
->waitUntil('pageLoaded')
->assertPathIs('/klanten');
$companyID = $browser->script('return $(".company").first().attr("cid")')[0];
$browser->click('[cid="' . $companyID . '"] h2 a')
->waitUntil('pageLoaded')
->assertPathIs('/klanten/' . $companyID)
->click('@editCompany')
->waitUntil('pageLoaded')
->assertPathIs('/klanten/' . $companyID . '/edit')
->click('input[type=submit]')
->assertPathIs('/klanten/' . $companyID)
// -------------- Absences -------------------- //
->visit('/absences')
->waitUntil('pageLoaded')
->assertPathIs('/absences');
$absenceID = $browser->script('return $(".absence").first().attr("aid")')[0];
$browser->click('[aid="' . $absenceID . '"] h2 a')
->waitUntil('pageLoaded')
->assertPathIs('/absences/' . $absenceID)
->click('ul.navbar-right li:nth-child(2) a.dropdown-toggle')
->waitFor('ul.navbar-right li.open')
->click('ul.navbar-right li.open ul.dropdown-menu li:nth-child(2) a')
->assertPathIs('/instellingen')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(2) > a')
->assertPathIs('/instellingen/taken')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(3) > a')
->assertPathIs('/instellingen/deelprojecten')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(4) > a')
->assertPathIs('/instellingen/projecten')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(7) > a')
->assertPathIs('/instellingen/onkosten')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(8) > a')
->assertPathIs('/instellingen/eenheden')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(11) > a')
->assertPathIs('/instellingen/landen')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(12) > a')
->assertPathIs('/instellingen/acquisities')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(13) > a')
->assertPathIs('/instellingen/soorten')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(16) > a')
->assertPathIs('/instellingen/AbsenceTypes')
->waitUntil('pageLoaded')
->click('.content ul.nav > li:nth-child(17) > a')
->assertPathIs('/instellingen/balance')
->waitUntil('pageLoaded');
$browser->script('window.scrollTo(0, $(".content ul.nav > li:nth-child(29)").offset().top);');
$browser->click('.content ul.nav > li:nth-child(20) > a')
->assertPathIs('/register')
->waitUntil('pageLoaded');
$browser->script('window.scrollTo(0, $(".content ul.nav > li:nth-child(29)").offset().top);');
$browser->click('.content ul.nav > li:nth-child(21) > a')
->assertPathIs('/instellingen/users')
->waitUntil('pageLoaded');
$browser->script('window.scrollTo(0, $(".content ul.nav > li:nth-child(29)").offset().top);');
$browser->click('.content ul.nav > li:nth-child(22) > a')
->assertPathIs('/instellingen/roles')
->waitUntil('pageLoaded');
$browser->script('window.scrollTo(0, $(".content ul.nav > li:nth-child(29)").offset().top);');
$browser->click('.content ul.nav > li:nth-child(23) > a')
->assertPathIs('/instellingen/resetPassword')
->waitUntil('pageLoaded');
$browser->script('window.scrollTo(0, $(".content ul.nav > li:nth-child(29)").offset().top);');
$browser->click('.content ul.nav > li:nth-child(26) > a')
->assertPathIs('/instellingen/import')
->waitUntil('pageLoaded');
$browser->script('window.scrollTo(0, $(".content ul.nav > li:nth-child(29)").offset().top);');
$browser->click('.content ul.nav > li:nth-child(29) > a')
->assertPathIs('/instellingen/KPI');
});
}
}