Skip to content

Commit

Permalink
tests (menu): Checks if current module is selected in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sardoj committed Dec 28, 2018
1 parent 94db719 commit eab63f6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
/vendor/
/node_modules/
/node_modules/
/coverage/
2 changes: 1 addition & 1 deletion app/Console/Commands/stubs/make/views/auth/login.stub
Expand Up @@ -20,7 +20,7 @@ login-page
<i class="material-icons">person</i>
</span>
<div class="form-line">
<input id="identity" type="identity" class="form-control{{ $errors->has('identity') ? ' is-invalid' : '' }}" name="identity" value="{{ old('identity') }}" required autofocus>
<input id="identity" type="text" class="form-control{{ $errors->has('identity') ? ' is-invalid' : '' }}" name="identity" value="{{ old('identity') }}" required autofocus>
</div>
@if ($errors->has('identity'))
<span class="invalid-feedback">
Expand Down
29 changes: 20 additions & 9 deletions phpunit.xml
@@ -1,20 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
<testsuite name="Browser">
<directory suffix="Test.php">./tests/Browser</directory>
</testsuite>

<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./app</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="./coverage"
lowUpperBound="50" highLowerBound="80" />
</logging>
</phpunit>
33 changes: 33 additions & 0 deletions tests/Browser/MenuTest.php
@@ -0,0 +1,33 @@
<?php

namespace Uccello\Core\Tests\Unit;

use Tests\DuskTestCase;
use Laravel\Dusk\Chrome;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\User;
use Uccello\Core\Models\Module;

class MenuTest extends DuskTestCase
{
public function testCurrentModuleSelected()
{
$user = User::first();
$homeModule = Module::where('name', 'home')->first();

$this->browse(function ($browser) use ($user, $homeModule) {
$browser->visit('/login')
->type('identity', $user->email)
->type('password', 'admin')
->press('Login')
->assertPathIs('/default/home')
->assertSeeLink('Home');


$linkClass = $browser->attribute('#leftsidebar .menu li.active > a', 'class');

// Module link has toggled class
$this->assertContains('toggled', $linkClass);
});
}
}

0 comments on commit eab63f6

Please sign in to comment.