mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-19 13:42:14 +01:00
Compare commits
3 Commits
64ca1e9115
...
5b89be04ce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b89be04ce | ||
|
|
8a68673a48 | ||
|
|
34f8eb0970 |
@@ -132,8 +132,12 @@ class ReportPropertiesDto implements Castable
|
|||||||
$dto->roundingType = isset($data->roundingType) ? TimeEntryRoundingType::from($data->roundingType) : null;
|
$dto->roundingType = isset($data->roundingType) ? TimeEntryRoundingType::from($data->roundingType) : null;
|
||||||
// Note: roundingMinutes was added later so it is possible that the value is missing in persisted reports in the DB
|
// Note: roundingMinutes was added later so it is possible that the value is missing in persisted reports in the DB
|
||||||
$dto->roundingMinutes = isset($data->roundingMinutes) ? (int) $data->roundingMinutes : null;
|
$dto->roundingMinutes = isset($data->roundingMinutes) ? (int) $data->roundingMinutes : null;
|
||||||
// Note: timeEntryType was added later so it is possible that the value is missing in persisted reports in the DB
|
// Note: timeEntryType was added later, reports persisted before that are missing the value and default to "work"
|
||||||
$dto->timeEntryType = isset($data->timeEntryType) ? TimeEntryType::from($data->timeEntryType) : null;
|
if (property_exists($data, 'timeEntryType')) {
|
||||||
|
$dto->timeEntryType = $data->timeEntryType !== null ? TimeEntryType::from($data->timeEntryType) : null;
|
||||||
|
} else {
|
||||||
|
$dto->timeEntryType = TimeEntryType::Work;
|
||||||
|
}
|
||||||
|
|
||||||
return $dto;
|
return $dto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { PLAYWRIGHT_BASE_URL, TEST_USER_PASSWORD } from '../playwright/config';
|
|||||||
async function goToOrganizationSettings(page) {
|
async function goToOrganizationSettings(page) {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||||
await page.locator('[data-testid="organization_switcher"]:visible').click();
|
await page.locator('[data-testid="organization_switcher"]:visible').click();
|
||||||
await page.getByText('Organization Settings').click();
|
await page.getByRole('menuitem', { name: 'Organization Settings' }).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createTimeEntry(page, duration: string) {
|
async function createTimeEntry(page, duration: string) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ async function goToTimeOverview(page: Page) {
|
|||||||
async function goToOrganizationSettings(page: Page) {
|
async function goToOrganizationSettings(page: Page) {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||||
await page.locator('[data-testid="organization_switcher"]:visible').click();
|
await page.locator('[data-testid="organization_switcher"]:visible').click();
|
||||||
await page.getByText('Organization Settings').click();
|
await page.getByRole('menuitem', { name: 'Organization Settings' }).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createEmptyTimeEntry(page: Page) {
|
async function createEmptyTimeEntry(page: Page) {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -8396,7 +8396,7 @@
|
|||||||
},
|
},
|
||||||
"resources/js/packages/api": {
|
"resources/js/packages/api": {
|
||||||
"name": "@solidtime/api",
|
"name": "@solidtime/api",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite-plugin-dts": "^4.5.4"
|
"vite-plugin-dts": "^4.5.4"
|
||||||
@@ -8411,7 +8411,7 @@
|
|||||||
},
|
},
|
||||||
"resources/js/packages/ui": {
|
"resources/js/packages/ui": {
|
||||||
"name": "@solidtime/ui",
|
"name": "@solidtime/ui",
|
||||||
"version": "0.0.21",
|
"version": "0.0.22",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chroma-js": "^3.1.2",
|
"@types/chroma-js": "^3.1.2",
|
||||||
|
|||||||
@@ -2,10 +2,17 @@
|
|||||||
import { BellAlertIcon, XMarkIcon } from '@heroicons/vue/20/solid';
|
import { BellAlertIcon, XMarkIcon } from '@heroicons/vue/20/solid';
|
||||||
import { SecondaryButton } from '@/packages/ui/src';
|
import { SecondaryButton } from '@/packages/ui/src';
|
||||||
import { useStorage } from '@vueuse/core';
|
import { useStorage } from '@vueuse/core';
|
||||||
const showReleaseInfo = useStorage('showReleaseInfo-desktop', true);
|
import { router } from '@inertiajs/vue3';
|
||||||
|
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||||
|
import { canUpdateOrganization } from '@/utils/permissions';
|
||||||
|
const showReleaseInfo = useStorage('showReleaseInfo-breaks', true);
|
||||||
|
|
||||||
function openDesktopGithubRepo() {
|
function openOrganizationSettings() {
|
||||||
window.open('https://github.com/solidtime-io/solidtime-desktop', '_blank')?.focus();
|
router.visit(route('organizations.show', getCurrentOrganizationId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
function openBreaksDocs() {
|
||||||
|
window.open('https://docs.solidtime.io/user-guide/breaks', '_blank')?.focus();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -16,7 +23,7 @@ function openDesktopGithubRepo() {
|
|||||||
<div
|
<div
|
||||||
class="text-xs pb-1.5 font-semibold text-text-tertiary flex items-center space-x-1">
|
class="text-xs pb-1.5 font-semibold text-text-tertiary flex items-center space-x-1">
|
||||||
<BellAlertIcon class="w-3.5"></BellAlertIcon>
|
<BellAlertIcon class="w-3.5"></BellAlertIcon>
|
||||||
<span> New Update </span>
|
<span> New Feature </span>
|
||||||
</div>
|
</div>
|
||||||
<button>
|
<button>
|
||||||
<XMarkIcon
|
<XMarkIcon
|
||||||
@@ -26,14 +33,22 @@ function openDesktopGithubRepo() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="text-xs">
|
<p class="text-xs">
|
||||||
<span class="font-semibold">Solidtime Desktop Beta</span> is here! Test our brand
|
<span class="font-semibold">Breaks</span> are here! Enable them in the organization
|
||||||
new clients for Windows, macOS and Linux now.
|
settings to track break time in the time tracker and timesheet.
|
||||||
</p>
|
</p>
|
||||||
<SecondaryButton
|
<SecondaryButton
|
||||||
|
v-if="canUpdateOrganization()"
|
||||||
size="small"
|
size="small"
|
||||||
class="w-full text-center justify-center mt-1.5"
|
class="w-full text-center justify-center mt-1.5"
|
||||||
@click="openDesktopGithubRepo"
|
@click="openOrganizationSettings"
|
||||||
>Download now</SecondaryButton
|
>Enable now</SecondaryButton
|
||||||
|
>
|
||||||
|
<SecondaryButton
|
||||||
|
v-else
|
||||||
|
size="small"
|
||||||
|
class="w-full text-center justify-center mt-1.5"
|
||||||
|
@click="openBreaksDocs"
|
||||||
|
>Learn more</SecondaryButton
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@solidtime/api",
|
"name": "@solidtime/api",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"description": "Package containing the solidtime api client and type declarations",
|
"description": "Package containing the solidtime api client and type declarations",
|
||||||
"main": "./dist/solidtime-api.umd.cjs",
|
"main": "./dist/solidtime-api.umd.cjs",
|
||||||
"module": "./dist/solidtime-api.js",
|
"module": "./dist/solidtime-api.js",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@solidtime/ui",
|
"name": "@solidtime/ui",
|
||||||
"version": "0.0.21",
|
"version": "0.0.22",
|
||||||
"description": "Package containing the solidtime ui components",
|
"description": "Package containing the solidtime ui components",
|
||||||
"main": "./dist/solidtime-ui-lib.umd.cjs",
|
"main": "./dist/solidtime-ui-lib.umd.cjs",
|
||||||
"module": "./dist/solidtime-ui-lib.js",
|
"module": "./dist/solidtime-ui-lib.js",
|
||||||
|
|||||||
91
tests/Unit/Service/Dto/ReportPropertiesDtoTest.php
Normal file
91
tests/Unit/Service/Dto/ReportPropertiesDtoTest.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tests\Unit\Service\Dto;
|
||||||
|
|
||||||
|
use App\Enums\TimeEntryType;
|
||||||
|
use App\Models\Report;
|
||||||
|
use App\Service\Dto\ReportPropertiesDto;
|
||||||
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
#[CoversClass(ReportPropertiesDto::class)]
|
||||||
|
class ReportPropertiesDtoTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function getBaseProperties(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'group' => 'project',
|
||||||
|
'subGroup' => 'task',
|
||||||
|
'historyGroup' => 'day',
|
||||||
|
'weekStart' => 'monday',
|
||||||
|
'timezone' => 'Europe/Vienna',
|
||||||
|
'start' => '2024-01-01T00:00:00Z',
|
||||||
|
'end' => '2024-01-31T00:00:00Z',
|
||||||
|
'active' => null,
|
||||||
|
'memberIds' => null,
|
||||||
|
'billable' => null,
|
||||||
|
'clientIds' => null,
|
||||||
|
'projectIds' => null,
|
||||||
|
'tagIds' => null,
|
||||||
|
'taskIds' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $properties
|
||||||
|
*/
|
||||||
|
private function castFromJson(array $properties): ReportPropertiesDto
|
||||||
|
{
|
||||||
|
$json = json_encode($properties);
|
||||||
|
$this->assertIsString($json);
|
||||||
|
|
||||||
|
return ReportPropertiesDto::castUsing([])->get(new Report, 'properties', $json, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_time_entry_type_defaults_to_work_if_the_value_is_missing_in_the_persisted_report(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$properties = $this->getBaseProperties();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$dto = $this->castFromJson($properties);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$this->assertSame(TimeEntryType::Work, $dto->timeEntryType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_time_entry_type_is_null_if_the_persisted_report_has_it_set_to_null(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$properties = $this->getBaseProperties();
|
||||||
|
$properties['timeEntryType'] = null;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$dto = $this->castFromJson($properties);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$this->assertNull($dto->timeEntryType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_time_entry_type_is_casted_to_the_enum_if_the_persisted_report_has_a_value(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$propertiesWork = $this->getBaseProperties();
|
||||||
|
$propertiesWork['timeEntryType'] = 'work';
|
||||||
|
$propertiesBreak = $this->getBaseProperties();
|
||||||
|
$propertiesBreak['timeEntryType'] = 'break';
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$dtoWork = $this->castFromJson($propertiesWork);
|
||||||
|
$dtoBreak = $this->castFromJson($propertiesBreak);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$this->assertSame(TimeEntryType::Work, $dtoWork->timeEntryType);
|
||||||
|
$this->assertSame(TimeEntryType::Break, $dtoBreak->timeEntryType);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user