billable timesheets, inactive projects report, bookmark export search (#2503)

This commit is contained in:
Kevin Papst
2021-04-18 21:51:27 +02:00
committed by GitHub
parent 8664d94ea6
commit 0330f45c6a
97 changed files with 1516 additions and 664 deletions

View File

@@ -139,6 +139,8 @@ class ActivityControllerTest extends ControllerBaseTest
$node = $client->getCrawler()->filter('div.box#activity_details_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#time_budget_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#budget_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#activity_rates_box');

View File

@@ -199,12 +199,12 @@ abstract class ControllerBaseTest extends WebTestCase
/**
* @param HttpKernelBrowser $client
* @param string $id
* @param string $class
* @param int $count
*/
protected function assertDataTableRowCount(HttpKernelBrowser $client, string $id, int $count)
protected function assertDataTableRowCount(HttpKernelBrowser $client, string $class, int $count)
{
$node = $client->getCrawler()->filter('section.content div.' . $id . ' table.dataTable tbody tr:not(.summary)');
$node = $client->getCrawler()->filter('section.content div.' . $class . ' table.dataTable tbody tr:not(.summary)');
self::assertEquals($count, $node->count());
}

View File

@@ -114,6 +114,8 @@ class CustomerControllerTest extends ControllerBaseTest
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#project_list_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#time_budget_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#budget_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#team_listing_box');

View File

@@ -34,7 +34,7 @@ class ExportControllerTest extends ControllerBaseTest
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
$this->request($client, '/export/?preview=');
$this->request($client, '/export/?performSearch=performSearch');
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertHasNoEntriesWithFilter($client);
@@ -83,13 +83,13 @@ class ExportControllerTest extends ControllerBaseTest
$this->importFixture($fixture);
$em->flush();
$this->request($client, '/export/?preview=');
$this->request($client, '/export/?performSearch=performSearch');
$this->assertTrue($client->getResponse()->isSuccessful());
// make sure all existing records are displayed
$this->assertHasDataTable($client);
// +1 row for summary
$this->assertDataTableRowCount($client, 'datatable_export', 23);
$this->assertDataTableRowCount($client, 'datatable_export', 22);
// assert export type buttons are available
$expected = [
@@ -113,7 +113,6 @@ class ExportControllerTest extends ControllerBaseTest
public function testIndexActionWithEntriesForTeamleadDoesNotShowUserWithoutTeam()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
$em = $this->getEntityManager();
$begin = new \DateTime('first day of this month');
$user = $this->getUserByRole(User::ROLE_USER);
@@ -127,10 +126,10 @@ class ExportControllerTest extends ControllerBaseTest
;
$this->importFixture($fixture);
$this->request($client, '/export/?preview=');
$this->request($client, '/export/?performSearch=performSearch');
$this->assertTrue($client->getResponse()->isSuccessful());
// make sure all existing records are displayed
// make sure existing records are not displayed
$this->assertHasNoEntriesWithFilter($client);
$teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD);
@@ -143,13 +142,13 @@ class ExportControllerTest extends ControllerBaseTest
;
$this->importFixture($fixture);
$this->request($client, '/export/?preview=');
$this->request($client, '/export/?performSearch=performSearch');
$this->assertTrue($client->getResponse()->isSuccessful());
// make sure all existing records are displayed
$this->assertHasDataTable($client);
// +1 row for summary
$this->assertDataTableRowCount($client, 'datatable_export', 3);
$this->assertDataTableRowCount($client, 'datatable_export', 2);
// assert export type buttons are available
$expected = [

View File

@@ -148,6 +148,8 @@ class ProjectControllerTest extends ControllerBaseTest
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#activity_list_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#time_budget_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#budget_box');
self::assertEquals(1, $node->count());
$node = $client->getCrawler()->filter('div.box#team_listing_box');

View File

@@ -0,0 +1,60 @@
<?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\Reporting;
use App\Entity\User;
use App\Tests\Controller\ControllerBaseTest;
use App\Tests\DataFixtures\ActivityFixtures;
use App\Tests\DataFixtures\CustomerFixtures;
use App\Tests\DataFixtures\ProjectFixtures;
use App\Tests\DataFixtures\TimesheetFixtures;
/**
* @group integration
*/
class InactiveProjectControllerTest extends ControllerBaseTest
{
public function testReportIsSecure()
{
$this->assertUrlIsSecured('/reporting/project_inactive');
}
public function testReport()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$customers = new CustomerFixtures();
$customers->setIsVisible(true);
$customers->setAmount(1);
$customers = $this->importFixture($customers);
$projects = new ProjectFixtures();
$projects->setCustomers($customers);
$projects->setAmount(2);
$projects->setIsVisible(true);
$this->importFixture($projects);
$activities = new ActivityFixtures();
$activities->setAmount(5);
$activities->setIsGlobal(true);
$activities = $this->importFixture($activities);
$timesheets = new TimesheetFixtures();
$timesheets->setAmount(50);
$timesheets->setActivities($activities);
$timesheets->setUser($this->getUserByRole(User::ROLE_TEAMLEAD));
$this->importFixture($timesheets);
$this->assertAccessIsGranted($client, '/reporting/project_inactive');
self::assertStringContainsString('<div class="box-body inactive_project_reporting-box', $client->getResponse()->getContent());
$rows = $client->getCrawler()->filterXPath("//table[contains(@class, 'dataTable')]/tbody/tr[not(@class='summary')]");
self::assertGreaterThan(0, $rows->count());
}
}

View File

@@ -21,12 +21,12 @@ use App\Tests\DataFixtures\TimesheetFixtures;
*/
class ProjectViewControllerTest extends ControllerBaseTest
{
public function testProjectViewIsSecure()
public function testReportIsSecure()
{
$this->assertUrlIsSecured('/reporting/project_view');
}
public function testProjectViewReport()
public function testReport()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
@@ -39,7 +39,7 @@ class ProjectViewControllerTest extends ControllerBaseTest
$projects->setCustomers($customers);
$projects->setAmount(2);
$projects->setIsVisible(true);
$projects = $this->importFixture($projects);
$this->importFixture($projects);
$activities = new ActivityFixtures();
$activities->setAmount(5);
@@ -53,7 +53,7 @@ class ProjectViewControllerTest extends ControllerBaseTest
$this->importFixture($timesheets);
$this->assertAccessIsGranted($client, '/reporting/project_view');
self::assertStringContainsString('<div class="box-body project-view-reporting-box', $client->getResponse()->getContent());
self::assertStringContainsString('<div class="box-body project_view_reporting-box', $client->getResponse()->getContent());
$rows = $client->getCrawler()->filterXPath("//table[contains(@class, 'dataTable')]/tbody/tr[not(@class='summary')]");
self::assertGreaterThan(0, $rows->count());
}