UI updates - new user menu, updated about and profile screen and more (#723)
This commit is contained in:
@@ -38,7 +38,7 @@ class TimesheetControllerTest extends APIControllerBaseTest
|
||||
->setHourlyRate(true)
|
||||
->setAmount(10)
|
||||
->setUser($this->getUserByRole($em, $role))
|
||||
->setStartDate((new \DateTime('-10 days'))->setTime(0, 0, 1))
|
||||
->setStartDate((new \DateTime('first day of this month'))->setTime(0, 0, 1))
|
||||
->setAllowEmptyDescriptions(false)
|
||||
;
|
||||
$this->importFixture($em, $fixture);
|
||||
@@ -124,9 +124,9 @@ class TimesheetControllerTest extends APIControllerBaseTest
|
||||
|
||||
public function testGetCollectionWithQuery()
|
||||
{
|
||||
$begin = new \DateTime('-10 days');
|
||||
$begin = new \DateTime('first day of this month');
|
||||
$begin->setTime(0, 0, 0);
|
||||
$end = new \DateTime();
|
||||
$end = new \DateTime('last day of this month');
|
||||
$end->setTime(23, 59, 59);
|
||||
|
||||
$query = [
|
||||
@@ -162,14 +162,14 @@ class TimesheetControllerTest extends APIControllerBaseTest
|
||||
->setExported(true)
|
||||
->setAmount(7)
|
||||
->setUser($this->getUserByRole($em, User::ROLE_USER))
|
||||
->setStartDate(new \DateTime('-10 days'))
|
||||
->setStartDate(new \DateTime('first day of this month'))
|
||||
->setAllowEmptyDescriptions(false)
|
||||
;
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$begin = new \DateTime('-10 days');
|
||||
$begin = new \DateTime('first day of this month');
|
||||
$begin->setTime(0, 0, 0);
|
||||
$end = new \DateTime();
|
||||
$end = new \DateTime('last day of this month');
|
||||
$end->setTime(23, 59, 59);
|
||||
|
||||
$query = [
|
||||
|
||||
@@ -17,21 +17,38 @@ use App\Entity\User;
|
||||
*/
|
||||
class AboutControllerTest extends ControllerBaseTest
|
||||
{
|
||||
public function testIsSecure()
|
||||
public function testDebugIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/admin/about');
|
||||
$this->assertUrlIsSecuredForRole(User::ROLE_ADMIN, '/admin/about');
|
||||
$this->assertUrlIsSecured('/about/debug');
|
||||
$this->assertUrlIsSecuredForRole(User::ROLE_ADMIN, '/about/debug');
|
||||
}
|
||||
|
||||
public function testIndexAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->assertAccessIsGranted($client, '/about');
|
||||
|
||||
$result = $client->getCrawler()->filter('ul.nav.nav-stacked li a');
|
||||
$this->assertEquals(3, count($result));
|
||||
|
||||
$result = $client->getCrawler()->filter('div.box-body pre');
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertContains('MIT License', $result->text());
|
||||
}
|
||||
|
||||
public function testDebugAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
$this->assertAccessIsGranted($client, '/admin/about');
|
||||
$this->assertAccessIsGranted($client, '/about/debug');
|
||||
|
||||
$result = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav.nav-tabs li');
|
||||
$this->assertEquals(3, count($result));
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertContains('<h3 class="box-title">Environment</h3>', $content);
|
||||
$this->assertContains('<h3 class="box-title">PHP</h3>', $content);
|
||||
$this->assertContains('<h3 class="box-title">Server</h3>', $content);
|
||||
|
||||
$result = $client->getCrawler()->filter('div.nav-tabs-custom div.tab-content div.tab-pane');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertContains('Actions', $content);
|
||||
$this->assertContains('', $content);
|
||||
$this->assertContains('PHP', $content);
|
||||
$this->assertContains('<a href="/en/about/flush-cache"', $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,25 @@ class DashboardControllerTest extends ControllerBaseTest
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$this->assertMainContentClass($client, 'dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not a test for the dashbaord, but for the general layout
|
||||
*/
|
||||
public function testUserMenuIsAvailable()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $this->getUserByRole($em, User::ROLE_USER);
|
||||
|
||||
$this->request($client, '/dashboard/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$content = $client->getResponse()->getContent();
|
||||
|
||||
$this->assertContains('<li class="dropdown user-menu">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '/prefs">', $content);
|
||||
$this->assertContains('<a href="/en/logout">', $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace App\Tests\Controller;
|
||||
use App\DataFixtures\UserFixtures;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserPreference;
|
||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
use Symfony\Bundle\FrameworkBundle\Client;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
|
||||
/**
|
||||
@@ -25,12 +27,75 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
$this->assertUrlIsSecured('/profile/' . UserFixtures::USERNAME_USER);
|
||||
}
|
||||
|
||||
public function testIndexActionWithoutData()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER);
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$this->assertHasNoEntriesWithFilter($client);
|
||||
$this->assertHasProfileBox($client, UserFixtures::USERNAME_USER);
|
||||
$this->assertHasAboutMeBox($client, UserFixtures::USERNAME_USER);
|
||||
}
|
||||
|
||||
public function testIndexAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$dates = [
|
||||
new \DateTime('-10 days'),
|
||||
new \DateTime('-1 year'),
|
||||
];
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
|
||||
foreach ($dates as $start) {
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(10);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
$fixture->setStartDate($start);
|
||||
$this->importFixture($em, $fixture);
|
||||
}
|
||||
|
||||
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER);
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$content = $client->getResponse()->getContent();
|
||||
|
||||
foreach ($dates as $start) {
|
||||
$year = $start->format('Y');
|
||||
$this->assertContains('<h3 class="box-title">' . $year . '</h3>', $content);
|
||||
$this->assertContains('var userProfileChart' . $year . ' = new Chart(', $content);
|
||||
}
|
||||
|
||||
$this->assertHasProfileBox($client, UserFixtures::USERNAME_USER);
|
||||
$this->assertHasAboutMeBox($client, UserFixtures::USERNAME_USER);
|
||||
}
|
||||
|
||||
protected function assertHasProfileBox(Client $client, string $username)
|
||||
{
|
||||
$profileBox = $client->getCrawler()->filter('div.box-body.box-profile');
|
||||
$this->assertEquals(1, $profileBox->count());
|
||||
$profileAvatar = $profileBox->filter('img.profile-user-img');
|
||||
$this->assertEquals(1, $profileAvatar->count());
|
||||
$alt = $profileAvatar->attr('alt');
|
||||
|
||||
$this->assertEquals($username, $alt);
|
||||
}
|
||||
|
||||
protected function assertHasAboutMeBox(Client $client, string $username)
|
||||
{
|
||||
$content = $client->getResponse()->getContent();
|
||||
|
||||
$this->assertContains('<h3 class="box-title">About me</h3>', $content);
|
||||
$this->assertContains('<span class="pull-right badge bg-blue">' . $username . '</span>', $content);
|
||||
}
|
||||
|
||||
public function getTabTestData()
|
||||
{
|
||||
$userTabs = ['#charts', '#settings', '#password', '#api-token', '#preferences'];
|
||||
$userTabs = ['#settings', '#password', '#api-token'];
|
||||
|
||||
return [
|
||||
[User::ROLE_USER, UserFixtures::USERNAME_USER, ['#charts', '#settings', '#password', '#api-token', '#preferences']],
|
||||
[User::ROLE_USER, UserFixtures::USERNAME_USER, ['#settings', '#password', '#api-token']],
|
||||
[User::ROLE_SUPER_ADMIN, UserFixtures::USERNAME_SUPER_ADMIN, array_merge($userTabs, ['#roles'])],
|
||||
];
|
||||
}
|
||||
@@ -38,10 +103,10 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
/**
|
||||
* @dataProvider getTabTestData
|
||||
*/
|
||||
public function testIndexAction($role, $username, $expectedTabs)
|
||||
public function testEditActionTabs($role, $username, $expectedTabs)
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser($role);
|
||||
$this->request($client, '/profile/' . $username);
|
||||
$this->request($client, '/profile/' . $username . '/edit');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$tabs = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav-tabs li');
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Constants;
|
||||
use App\Entity\User;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Controller\SidebarController
|
||||
* @group integration
|
||||
*/
|
||||
class SidebarControllerTest extends ControllerBaseTest
|
||||
{
|
||||
public function testSettingsAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $this->getUserByRole($em, User::ROLE_USER);
|
||||
|
||||
$this->request($client, '/sidebar/settings');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$content = $client->getResponse()->getContent();
|
||||
|
||||
$this->assertContains('<ul class="control-sidebar-menu">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '/edit">', $content);
|
||||
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '/prefs">', $content);
|
||||
$this->assertContains('<a href="' . Constants::HOMEPAGE . '/documentation/" target="_blank">', $content);
|
||||
$this->assertContains('<a href="/en/logout">', $content);
|
||||
}
|
||||
}
|
||||
@@ -46,18 +46,19 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
public function testIndexActionWithQuery()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$start = new \DateTime('first day of this month');
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(5);
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
$fixture->setStartDate(new \DateTime('-10 days'));
|
||||
$fixture->setStartDate($start);
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$this->request($client, '/timesheet/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$dateRange = (new \DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime())->format('Y-m-d');
|
||||
$dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime('last day of this month'))->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.navbar-form')->form();
|
||||
$client->submit($form, [
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Controller\Admin;
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\DateRangeType;
|
||||
use App\Tests\Controller\ControllerBaseTest;
|
||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
|
||||
/**
|
||||
@@ -48,19 +47,20 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
|
||||
public function testIndexActionWithQuery()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
||||
$start = new \DateTime('first day of this month');
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $this->getUserByRole($em, User::ROLE_USER);
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(10);
|
||||
$fixture->setUser($user);
|
||||
$fixture->setStartDate(new \DateTime('-10 days'));
|
||||
$fixture->setStartDate($start);
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$this->request($client, '/team/timesheet/');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$dateRange = (new \DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime())->format('Y-m-d');
|
||||
$dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \DateTime('last day of this month'))->format('Y-m-d');
|
||||
|
||||
$form = $client->getCrawler()->filter('form.navbar-form')->form();
|
||||
$client->submit($form, [
|
||||
|
||||
@@ -52,7 +52,7 @@ class UserControllerTest extends ControllerBaseTest
|
||||
$this->assertIsRedirect($client, $this->createUrl('/profile/' . urlencode($username) . '/edit'));
|
||||
$client->followRedirect();
|
||||
|
||||
$expectedTabs = ['#charts', '#settings', '#password', '#api-token', '#roles', '#preferences'];
|
||||
$expectedTabs = ['#settings', '#password', '#api-token', '#roles'];
|
||||
|
||||
$tabs = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav-tabs li');
|
||||
$this->assertEquals(count($expectedTabs), $tabs->count());
|
||||
|
||||
@@ -236,7 +236,7 @@ class TimesheetFixtures extends Fixture
|
||||
{
|
||||
$start = \DateTime::createFromFormat('Y-m-d', $this->startDate);
|
||||
$start->modify("+ $i days");
|
||||
$start->modify('+ ' . rand(1, 172.800) . ' seconds'); // up to 2 days
|
||||
$start->modify('+ ' . rand(1, 172800) . ' seconds'); // up to 2 days
|
||||
return $start;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,8 @@ class ExtensionsTest extends TestCase
|
||||
$icons = [
|
||||
'user', 'customer', 'project', 'activity', 'admin', 'invoice', 'timesheet', 'dashboard', 'logout', 'trash',
|
||||
'delete', 'repeat', 'edit', 'manual', 'help', 'start', 'start-small', 'stop', 'stop-small', 'filter',
|
||||
'create', 'list', 'print', 'visibility', 'calendar', 'money', 'duration', 'download', 'copy', 'settings'
|
||||
'create', 'list', 'print', 'visibility', 'calendar', 'money', 'duration', 'download', 'copy', 'settings',
|
||||
'export', 'pdf', 'csv', 'ods', 'xlsx', 'on', 'off', 'audit', 'home', 'shop', 'about', 'debug', 'profile-stats'
|
||||
];
|
||||
|
||||
// test pre-defined icons
|
||||
|
||||
Reference in New Issue
Block a user