export filtered timesheets without additional search form (#5234)

This commit is contained in:
Kevin Papst
2024-12-15 18:38:30 +01:00
committed by GitHub
parent 17a815e5a9
commit 21c031f2c8
33 changed files with 98 additions and 306 deletions

View File

@@ -245,14 +245,6 @@ abstract class ControllerBaseTest extends WebTestCase
self::assertEquals(Response::HTTP_NOT_FOUND, $client->getResponse()->getStatusCode());
}
protected function assert404(Response $response, ?string $message = null): void
{
$message = 'Page not found';
self::assertFalse($response->isSuccessful());
self::assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
self::assertStringContainsString($message, $response->getContent());
}
protected function assertMainContentClass(HttpKernelBrowser $client, string $classname): void
{
self::assertStringContainsString('<section id="" class="content ' . $classname . '">', $client->getResponse()->getContent());

View File

@@ -172,9 +172,7 @@ class ExportControllerTest extends ControllerBaseTest
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
$this->request($client, '/export/data', 'POST');
$response = $client->getResponse();
$this->assert404($response, 'Missing export renderer');
$this->assertRouteNotFound($client);
}
public function testExportActionWithInvalidRenderer(): void
@@ -193,8 +191,7 @@ class ExportControllerTest extends ControllerBaseTest
'renderer' => 'default'
]);
$response = $client->getResponse();
$this->assert404($response, 'Unknown export renderer');
$this->assertRouteNotFound($client);
}
public function testExportAction(): void

View File

@@ -41,8 +41,11 @@ class TimesheetControllerTest extends ControllerBaseTest
// there are no records by default in the test database
$this->assertHasNoEntriesWithFilter($client);
$this->assertPageActions($client, [
'download modal-ajax-form' => $this->createUrl('/timesheet/export/'),
'create modal-ajax-form' => $this->createUrl('/timesheet/create'),
'dropdown-item action-csv toolbar-action' => $this->createUrl('/timesheet/export/csv'),
'dropdown-item action-print toolbar-action' => $this->createUrl('/timesheet/export/print'),
'dropdown-item action-pdf toolbar-action' => $this->createUrl('/timesheet/export/pdf'),
'dropdown-item action-xlsx toolbar-action' => $this->createUrl('/timesheet/export/xlsx'),
]);
}
@@ -155,12 +158,14 @@ class TimesheetControllerTest extends ControllerBaseTest
$fixture->setStartDate(new \DateTime('-10 days'));
$this->importFixture($fixture);
$this->request($client, '/timesheet/export/');
$this->request($client, '/timesheet/');
$this->assertTrue($client->getResponse()->isSuccessful());
$dateRange = $this->formatDateRange(new \DateTime('-10 days'), new \DateTime());
$client->submitForm('export-btn-print', [
$form = $client->getCrawler()->filter('form.searchform')->form();
$form->getNode()->setAttribute('action', $this->createUrl('/timesheet/export/print'));
$client->submit($form, [
'state' => 1,
'daterange' => $dateRange,
'customers' => [],
@@ -177,6 +182,13 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertEquals(5, \count($result));
}
public function testExporterNotFoundAction(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->request($client, '/timesheet/export/notfound');
$this->assertRouteNotFound($client);
}
public function testCreateAction(): void
{
$client = $this->getClientForAuthenticatedUser();

View File

@@ -43,9 +43,12 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$this->assertHasNoEntriesWithFilter($client);
$this->assertPageActions($client, [
'download modal-ajax-form' => $this->createUrl('/team/timesheet/export/'),
'create create-ts modal-ajax-form' => $this->createUrl('/team/timesheet/create'),
'multi-user create-ts-mu modal-ajax-form' => $this->createUrl('/team/timesheet/create_mu'),
'dropdown-item action-csv toolbar-action' => $this->createUrl('/team/timesheet/export/csv'),
'dropdown-item action-print toolbar-action' => $this->createUrl('/team/timesheet/export/print'),
'dropdown-item action-pdf toolbar-action' => $this->createUrl('/team/timesheet/export/pdf'),
'dropdown-item action-xlsx toolbar-action' => $this->createUrl('/team/timesheet/export/xlsx'),
]);
}
@@ -136,12 +139,14 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$fixture->setStartDate(new \DateTime('-10 days'));
$this->importFixture($fixture);
$this->request($client, '/team/timesheet/export/');
$this->request($client, '/team/timesheet/');
$this->assertTrue($client->getResponse()->isSuccessful());
$dateRange = $this->formatDateRange(new \DateTime('-10 days'), new \DateTime());
$client->submitForm('export-btn-print', [
$form = $client->getCrawler()->filter('form.searchform')->form();
$form->getNode()->setAttribute('action', $this->createUrl('/team/timesheet/export/print'));
$client->submit($form, [
'state' => 1,
'daterange' => $dateRange,
'customers' => [],
@@ -158,6 +163,13 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$this->assertEquals(10, \count($result));
}
public function testExporterNotFoundAction(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->request($client, '/team/timesheet/export/notfound');
$this->assertRouteNotFound($client);
}
public function testCreateAction(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);