mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 05:22:44 +01:00
Compare commits
41 Commits
b3785f0aa6
...
feature/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c9159f2d4 | ||
|
|
abfa7cea0d | ||
|
|
bfc33b48c1 | ||
|
|
dc98151d42 | ||
|
|
e038870bc4 | ||
|
|
6f8f46f375 | ||
|
|
6c319fafbc | ||
|
|
d06b0633d3 | ||
|
|
2c4af95ee3 | ||
|
|
215957104f | ||
|
|
fd012e7c69 | ||
|
|
1ecb332458 | ||
|
|
bbe05ca0d8 | ||
|
|
d2644112c5 | ||
|
|
66681066bc | ||
|
|
f82f5e780c | ||
|
|
22f3af2b79 | ||
|
|
7d068fecae | ||
|
|
9be97a8f84 | ||
|
|
03e0377101 | ||
|
|
a58becc268 | ||
|
|
09c3205680 | ||
|
|
18989a9a8e | ||
|
|
98634f4a19 | ||
|
|
1597b5490a | ||
|
|
72662727c5 | ||
|
|
0d3978a55d | ||
|
|
fe8c7e9a7d | ||
|
|
66dfc511a9 | ||
|
|
8524e01033 | ||
|
|
bca1e8b3b5 | ||
|
|
44bcce97cf | ||
|
|
99400ca655 | ||
|
|
672c243c91 | ||
|
|
3fb75ec3d5 | ||
|
|
79999fde28 | ||
|
|
b2a04c8de5 | ||
|
|
900ee29a6f | ||
|
|
ebbc4e6837 | ||
|
|
6f68bbbd48 | ||
|
|
47c2d8e6de |
10
.env.ci
10
.env.ci
@@ -34,7 +34,12 @@ SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
# Mail
|
||||
MAIL_MAILER=log
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=localhost
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="no-reply@solidtime.test"
|
||||
MAIL_FROM_NAME="solidtime"
|
||||
MAIL_REPLY_TO_ADDRESS="hello@solidtime.test"
|
||||
@@ -56,3 +61,6 @@ TELESCOPE_ENABLED=false
|
||||
|
||||
# Services
|
||||
GOTENBERG_URL=http://0.0.0.0:3000
|
||||
|
||||
# Octane
|
||||
OCTANE_SERVER=frankenphp
|
||||
|
||||
63
.github/workflows/playwright.yml
vendored
63
.github/workflows/playwright.yml
vendored
@@ -6,10 +6,18 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shardIndex: [1, 2, 3, 4]
|
||||
shardTotal: [4]
|
||||
|
||||
services:
|
||||
mailpit:
|
||||
image: 'axllent/mailpit:latest'
|
||||
ports:
|
||||
- 1025:1025
|
||||
- 8025:8025
|
||||
pgsql_test:
|
||||
image: postgres:15
|
||||
env:
|
||||
@@ -57,22 +65,63 @@ jobs:
|
||||
- name: "Build Frontend"
|
||||
run: npm run build
|
||||
|
||||
- name: "Run Laravel Server"
|
||||
run: php artisan serve > /dev/null 2>&1 &
|
||||
- name: "Install FrankenPHP"
|
||||
run: |
|
||||
ARCH="$(uname -m)"
|
||||
curl -fsSL "https://github.com/dunglas/frankenphp/releases/latest/download/frankenphp-linux-${ARCH}" -o /usr/local/bin/frankenphp
|
||||
chmod +x /usr/local/bin/frankenphp
|
||||
|
||||
- name: "Run Laravel Octane Server"
|
||||
run: php artisan octane:start --server=frankenphp --host=127.0.0.1 --port=8000 --workers=4 --max-requests=500 > /dev/null 2>&1 &
|
||||
env:
|
||||
OCTANE_SERVER: frankenphp
|
||||
|
||||
- name: "Install Playwright Browsers"
|
||||
run: npx playwright install --with-deps
|
||||
|
||||
- name: "Run Playwright tests"
|
||||
run: npx playwright test
|
||||
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
||||
env:
|
||||
PLAYWRIGHT_BASE_URL: 'http://127.0.0.1:8000'
|
||||
MAILPIT_BASE_URL: 'http://localhost:8025'
|
||||
|
||||
- name: "Upload test results"
|
||||
- name: "Upload blob report"
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: test-results
|
||||
path: test-results/
|
||||
retention-days: 30
|
||||
name: blob-report-${{ matrix.shardIndex }}
|
||||
path: blob-report/
|
||||
retention-days: 7
|
||||
|
||||
merge-reports:
|
||||
if: always()
|
||||
needs: [test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: "Setup node"
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20.x'
|
||||
|
||||
- name: "Install dependencies"
|
||||
run: npm ci
|
||||
|
||||
- name: "Download blob reports"
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: all-blob-reports
|
||||
pattern: blob-report-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: "Merge reports"
|
||||
run: npx playwright merge-reports --reporter html ./all-blob-reports
|
||||
|
||||
- name: "Upload merged HTML report"
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TimeEntryResource\Pages;
|
||||
use App\Models\Member;
|
||||
use App\Models\TimeEntry;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -16,6 +17,7 @@ use Filament\Tables;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TimeEntryResource extends Resource
|
||||
{
|
||||
@@ -51,15 +53,23 @@ class TimeEntryResource extends Resource
|
||||
->rules([
|
||||
'after_or_equal:start',
|
||||
]),
|
||||
Select::make('user_id')
|
||||
->relationship(name: 'user', titleAttribute: 'email')
|
||||
->searchable(['name', 'email'])
|
||||
Select::make('member_id')
|
||||
->relationship(
|
||||
name: 'member',
|
||||
titleAttribute: 'id',
|
||||
modifyQueryUsing: fn (Builder $query) => $query->with(['user', 'organization'])
|
||||
)
|
||||
->getOptionLabelFromRecordUsing(fn (Member $record): string => $record->user->email.' ('.$record->organization->name.')')
|
||||
->searchable()
|
||||
->required(),
|
||||
Select::make('project_id')
|
||||
->relationship(name: 'project', titleAttribute: 'name')
|
||||
->searchable(['name'])
|
||||
->nullable(),
|
||||
// TODO
|
||||
Select::make('task_id')
|
||||
->relationship(name: 'task', titleAttribute: 'name')
|
||||
->searchable(['name'])
|
||||
->nullable(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,28 @@ declare(strict_types=1);
|
||||
namespace App\Filament\Resources\TimeEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TimeEntryResource;
|
||||
use App\Models\Member;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTimeEntry extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TimeEntryResource::class;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
if (isset($data['member_id'])) {
|
||||
/** @var Member|null $member */
|
||||
$member = Member::query()->find($data['member_id']);
|
||||
if ($member !== null) {
|
||||
$data['user_id'] = $member->user_id;
|
||||
$data['organization_id'] = $member->organization_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Filament\Resources\TimeEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TimeEntryResource;
|
||||
use App\Models\Member;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
@@ -19,4 +20,22 @@ class EditTimeEntry extends EditRecord
|
||||
->icon('heroicon-m-trash'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
if (isset($data['member_id'])) {
|
||||
/** @var Member|null $member */
|
||||
$member = Member::query()->find($data['member_id']);
|
||||
if ($member !== null) {
|
||||
$data['user_id'] = $member->user_id;
|
||||
$data['organization_id'] = $member->organization_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class ChartController extends Controller
|
||||
$this->checkPermission($organization, 'charts:view:own');
|
||||
$user = $this->user();
|
||||
|
||||
$dailyTrackedHours = $dashboardService->getDailyTrackedHours($user, $organization, 60);
|
||||
$dailyTrackedHours = $dashboardService->getDailyTrackedHours($user, $organization, 100);
|
||||
|
||||
return response()->json($dailyTrackedHours);
|
||||
}
|
||||
|
||||
@@ -150,6 +150,9 @@ class ReportController extends Controller
|
||||
$report->share_secret = null;
|
||||
$report->public_until = null;
|
||||
}
|
||||
} elseif ($report->is_public && $request->has('public_until')) {
|
||||
// Allow updating expiration date on already-public reports
|
||||
$report->public_until = $request->getPublicUntil();
|
||||
}
|
||||
$report->save();
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ use App\Enums\TimeEntryRoundingType;
|
||||
use App\Enums\Weekday;
|
||||
use App\Http\Requests\V1\BaseFormRequest;
|
||||
use App\Models\Organization;
|
||||
use App\Service\TimeEntryFilter;
|
||||
use Illuminate\Contracts\Validation\Rule as LegacyValidationRule;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
@@ -23,7 +25,7 @@ class ReportStoreRequest extends BaseFormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule|LegacyValidationRule>>
|
||||
* @return array<string, array<string|ValidationRule|LegacyValidationRule|\Closure>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -81,7 +83,14 @@ class ReportStoreRequest extends BaseFormRequest
|
||||
],
|
||||
'properties.client_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
if (! Str::isUuid($value)) {
|
||||
$fail('The '.$attribute.' must be a valid UUID.');
|
||||
}
|
||||
},
|
||||
],
|
||||
// Filter by project IDs, project IDs are OR combined
|
||||
'properties.project_ids' => [
|
||||
@@ -90,7 +99,14 @@ class ReportStoreRequest extends BaseFormRequest
|
||||
],
|
||||
'properties.project_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
if (! Str::isUuid($value)) {
|
||||
$fail('The '.$attribute.' must be a valid UUID.');
|
||||
}
|
||||
},
|
||||
],
|
||||
// Filter by tag IDs, tag IDs are OR combined
|
||||
'properties.tag_ids' => [
|
||||
@@ -99,7 +115,14 @@ class ReportStoreRequest extends BaseFormRequest
|
||||
],
|
||||
'properties.tag_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
if (! Str::isUuid($value)) {
|
||||
$fail('The '.$attribute.' must be a valid UUID.');
|
||||
}
|
||||
},
|
||||
],
|
||||
'properties.task_ids' => [
|
||||
'nullable',
|
||||
@@ -107,7 +130,14 @@ class ReportStoreRequest extends BaseFormRequest
|
||||
],
|
||||
'properties.task_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
if (! Str::isUuid($value)) {
|
||||
$fail('The '.$attribute.' must be a valid UUID.');
|
||||
}
|
||||
},
|
||||
],
|
||||
'properties.group' => [
|
||||
'required',
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Models\Project;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Service\TimeEntryFilter;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -30,7 +31,7 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule|\Closure>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -94,10 +95,15 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
||||
],
|
||||
'project_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by client IDs, client IDs are OR combined
|
||||
'client_ids' => [
|
||||
@@ -106,10 +112,15 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
||||
],
|
||||
'client_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by tag IDs, tag IDs are OR combined
|
||||
'tag_ids' => [
|
||||
@@ -118,10 +129,15 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
||||
],
|
||||
'tag_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
@@ -130,9 +146,14 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
||||
],
|
||||
'task_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
|
||||
'start' => [
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Models\Project;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Service\TimeEntryFilter;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -28,7 +29,7 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule|\Closure>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -80,10 +81,15 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
||||
],
|
||||
'project_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by client IDs, client IDs are OR combined
|
||||
'client_ids' => [
|
||||
@@ -92,10 +98,15 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
||||
],
|
||||
'client_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by tag IDs, tag IDs are OR combined
|
||||
'tag_ids' => [
|
||||
@@ -104,10 +115,15 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
||||
],
|
||||
'tag_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
@@ -116,9 +132,14 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
||||
],
|
||||
'task_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
|
||||
'start' => [
|
||||
|
||||
@@ -6,11 +6,13 @@ namespace App\Http\Requests\V1\TimeEntry;
|
||||
|
||||
use App\Enums\ExportFormat;
|
||||
use App\Enums\TimeEntryRoundingType;
|
||||
use App\Models\Client;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Project;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Task;
|
||||
use App\Service\TimeEntryFilter;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -25,7 +27,7 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule|\Closure>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -57,6 +59,23 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
}),
|
||||
],
|
||||
// Filter by client IDs, client IDs are OR combined
|
||||
'client_ids' => [
|
||||
'array',
|
||||
'min:1',
|
||||
],
|
||||
'client_ids.*' => [
|
||||
'string',
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by project IDs, project IDs are OR combined
|
||||
'project_ids' => [
|
||||
'array',
|
||||
@@ -64,11 +83,15 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
||||
],
|
||||
'project_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
new ExistsEloquent(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
}),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by tag IDs, tag IDs are OR combined
|
||||
'tag_ids' => [
|
||||
@@ -77,11 +100,15 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
||||
],
|
||||
'tag_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
new ExistsEloquent(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
}),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
@@ -90,11 +117,15 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
||||
],
|
||||
'task_ids.*' => [
|
||||
'string',
|
||||
'uuid',
|
||||
new ExistsEloquent(Task::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Task> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
}),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Task> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
|
||||
'start' => [
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Models\Organization;
|
||||
use App\Models\Project;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Task;
|
||||
use App\Service\TimeEntryFilter;
|
||||
use Illuminate\Contracts\Validation\Rule as RuleContract;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -26,7 +27,7 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule|RuleContract>>
|
||||
* @return array<string, array<string|ValidationRule|RuleContract|\Closure>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -58,10 +59,15 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
||||
],
|
||||
'client_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Client> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by project IDs, project IDs are OR combined
|
||||
'project_ids' => [
|
||||
@@ -70,10 +76,15 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
||||
],
|
||||
'project_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Project> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by tag IDs, tag IDs are OR combined
|
||||
'tag_ids' => [
|
||||
@@ -82,10 +93,15 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
||||
],
|
||||
'tag_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
@@ -94,10 +110,15 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
||||
],
|
||||
'task_ids.*' => [
|
||||
'string',
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Task> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid(),
|
||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if ($value === TimeEntryFilter::NONE_VALUE) {
|
||||
return;
|
||||
}
|
||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||
/** @var Builder<Task> $builder */
|
||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
// Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
|
||||
'start' => [
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Enums\TimeEntryAggregationType;
|
||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||
use App\Enums\TimeEntryRoundingType;
|
||||
use App\Enums\Weekday;
|
||||
use App\Service\TimeEntryFilter;
|
||||
use Illuminate\Contracts\Database\Eloquent\Castable;
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -174,7 +175,7 @@ class ReportPropertiesDto implements Castable
|
||||
if (! is_string($id)) {
|
||||
throw new \InvalidArgumentException('The given ID is not a string');
|
||||
}
|
||||
if (! Str::isUuid($id)) {
|
||||
if ($id !== TimeEntryFilter::NONE_VALUE && ! Str::isUuid($id)) {
|
||||
throw new \InvalidArgumentException('The given ID is not a valid UUID');
|
||||
}
|
||||
$collection->push($id);
|
||||
|
||||
@@ -12,6 +12,8 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TimeEntryFilter
|
||||
{
|
||||
public const string NONE_VALUE = 'none';
|
||||
|
||||
/**
|
||||
* @var Builder<TimeEntry>
|
||||
*/
|
||||
@@ -149,7 +151,17 @@ class TimeEntryFilter
|
||||
if ($clientIds === null) {
|
||||
return $this;
|
||||
}
|
||||
$this->builder->whereIn('client_id', $clientIds);
|
||||
$includeNone = in_array(self::NONE_VALUE, $clientIds, true);
|
||||
$clientIds = array_values(array_filter($clientIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($clientIds, $includeNone): void {
|
||||
if (count($clientIds) > 0) {
|
||||
$builder->whereIn('client_id', $clientIds);
|
||||
}
|
||||
if ($includeNone) {
|
||||
$builder->orWhereNull('client_id');
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -162,7 +174,17 @@ class TimeEntryFilter
|
||||
if ($projectIds === null) {
|
||||
return $this;
|
||||
}
|
||||
$this->builder->whereIn('project_id', $projectIds);
|
||||
$includeNone = in_array(self::NONE_VALUE, $projectIds, true);
|
||||
$projectIds = array_values(array_filter($projectIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($projectIds, $includeNone): void {
|
||||
if (count($projectIds) > 0) {
|
||||
$builder->whereIn('project_id', $projectIds);
|
||||
}
|
||||
if ($includeNone) {
|
||||
$builder->orWhereNull('project_id');
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -175,10 +197,18 @@ class TimeEntryFilter
|
||||
if ($tagIds === null) {
|
||||
return $this;
|
||||
}
|
||||
$this->builder->where(function (Builder $builder) use ($tagIds): void {
|
||||
$includeNone = in_array(self::NONE_VALUE, $tagIds, true);
|
||||
$tagIds = array_values(array_filter($tagIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($tagIds, $includeNone): void {
|
||||
foreach ($tagIds as $tagId) {
|
||||
$builder->orWhereJsonContains('tags', $tagId);
|
||||
}
|
||||
if ($includeNone) {
|
||||
$builder->orWhere(function (Builder $query): void {
|
||||
$query->whereJsonLength('tags', 0)->orWhereNull('tags');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
@@ -192,7 +222,17 @@ class TimeEntryFilter
|
||||
if ($taskIds === null) {
|
||||
return $this;
|
||||
}
|
||||
$this->builder->whereIn('task_id', $taskIds);
|
||||
$includeNone = in_array(self::NONE_VALUE, $taskIds, true);
|
||||
$taskIds = array_values(array_filter($taskIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($taskIds, $includeNone): void {
|
||||
if (count($taskIds) > 0) {
|
||||
$builder->whereIn('task_id', $taskIds);
|
||||
}
|
||||
if ($includeNone) {
|
||||
$builder->orWhereNull('task_id');
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ services:
|
||||
- sail
|
||||
- reverse-proxy
|
||||
playwright:
|
||||
image: mcr.microsoft.com/playwright:v1.57.0-jammy
|
||||
image: mcr.microsoft.com/playwright:v1.58.1-jammy
|
||||
command: ['npx', 'playwright', 'test', '--ui-port=8080', '--ui-host=0.0.0.0']
|
||||
working_dir: /src
|
||||
extra_hosts:
|
||||
|
||||
189
e2e/auth.spec.ts
189
e2e/auth.spec.ts
@@ -1,5 +1,6 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { getPasswordResetUrl } from './utils/mailpit';
|
||||
|
||||
async function registerNewUser(page, email, password) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/register');
|
||||
@@ -35,14 +36,198 @@ test('can register and delete account', async ({ page }) => {
|
||||
await registerNewUser(page, email, password);
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
await page.getByRole('button', { name: 'Delete Account' }).click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await page.getByPlaceholder('Password').fill(password);
|
||||
await page.getByRole('button', { name: 'Delete Account' }).click();
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Delete Account' }).click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill(password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(page.getByRole('paragraph')).toContainText(
|
||||
await expect(page.getByRole('alert')).toContainText(
|
||||
'These credentials do not match our records.'
|
||||
);
|
||||
});
|
||||
|
||||
test('shows error for invalid email on forgot password', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/forgot-password');
|
||||
|
||||
// Request password reset with non-existent email
|
||||
await page.getByLabel('Email').fill('nonexistent@example.com');
|
||||
await page.getByRole('button', { name: 'Email Password Reset Link' }).click();
|
||||
|
||||
// Should show error message
|
||||
await expect(page.getByText("We can't find a user with that email address.")).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows browser validation for invalid email format on forgot password', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/forgot-password');
|
||||
|
||||
// Request password reset with invalid email format
|
||||
const emailInput = page.getByLabel('Email');
|
||||
await emailInput.fill('notanemail');
|
||||
|
||||
// Check for browser validation - the input should be invalid
|
||||
const isInvalid = await emailInput.evaluate((el: HTMLInputElement) => !el.validity.valid);
|
||||
expect(isInvalid).toBe(true);
|
||||
});
|
||||
|
||||
test('shows browser validation for empty email on forgot password', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/forgot-password');
|
||||
|
||||
// The email input is required, so it should be invalid when empty
|
||||
const emailInput = page.getByLabel('Email');
|
||||
|
||||
// Check for browser validation - the input should be invalid because it's required and empty
|
||||
const isInvalid = await emailInput.evaluate((el: HTMLInputElement) => el.validity.valueMissing);
|
||||
expect(isInvalid).toBe(true);
|
||||
});
|
||||
|
||||
test('can reset password via email link', async ({ page, request }) => {
|
||||
// First register a new user
|
||||
const email = `john+${Math.round(Math.random() * 10000)}@doe.com`;
|
||||
const originalPassword = 'suchagreatpassword123';
|
||||
const newPassword = 'mynewsecurepassword456';
|
||||
await registerNewUser(page, email, originalPassword);
|
||||
|
||||
// Log out
|
||||
await page.getByTestId('current_user_button').click();
|
||||
await page.getByText('Log Out').click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
||||
|
||||
// Request password reset
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/forgot-password');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByRole('button', { name: 'Email Password Reset Link' }).click();
|
||||
await expect(page.getByText('We have emailed your password reset link.')).toBeVisible();
|
||||
|
||||
// Get password reset URL from email
|
||||
const resetUrl = await getPasswordResetUrl(request, email);
|
||||
|
||||
// Navigate to reset page
|
||||
await page.goto(resetUrl);
|
||||
|
||||
// Fill in new password
|
||||
await page.getByLabel('Password', { exact: true }).fill(newPassword);
|
||||
await page.getByLabel('Confirm Password').fill(newPassword);
|
||||
await page.getByRole('button', { name: 'Reset Password' }).click();
|
||||
|
||||
// Should redirect to login page after successful reset
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
||||
|
||||
// Try logging in with new password
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill(newPassword);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(page.getByTestId('dashboard_view')).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows validation error for password mismatch on reset', async ({ page, request }) => {
|
||||
// First register a new user
|
||||
const email = `john+${Math.round(Math.random() * 10000)}@doe.com`;
|
||||
const originalPassword = 'suchagreatpassword123';
|
||||
await registerNewUser(page, email, originalPassword);
|
||||
|
||||
// Log out
|
||||
await page.getByTestId('current_user_button').click();
|
||||
await page.getByText('Log Out').click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
||||
|
||||
// Request password reset
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/forgot-password');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByRole('button', { name: 'Email Password Reset Link' }).click();
|
||||
await expect(page.getByText('We have emailed your password reset link.')).toBeVisible();
|
||||
|
||||
// Get password reset URL from email
|
||||
const resetUrl = await getPasswordResetUrl(request, email);
|
||||
|
||||
// Navigate to reset page
|
||||
await page.goto(resetUrl);
|
||||
|
||||
// Fill in mismatched passwords
|
||||
await page.getByLabel('Password', { exact: true }).fill('newpassword123');
|
||||
await page.getByLabel('Confirm Password').fill('differentpassword456');
|
||||
await page.getByRole('button', { name: 'Reset Password' }).click();
|
||||
|
||||
// Should show validation error
|
||||
await expect(page.getByText('The password field confirmation does not match.')).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows validation error for short password on reset', async ({ page, request }) => {
|
||||
// First register a new user
|
||||
const email = `john+${Math.round(Math.random() * 10000)}@doe.com`;
|
||||
const originalPassword = 'suchagreatpassword123';
|
||||
await registerNewUser(page, email, originalPassword);
|
||||
|
||||
// Log out
|
||||
await page.getByTestId('current_user_button').click();
|
||||
await page.getByText('Log Out').click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
||||
|
||||
// Request password reset
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/forgot-password');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByRole('button', { name: 'Email Password Reset Link' }).click();
|
||||
await expect(page.getByText('We have emailed your password reset link.')).toBeVisible();
|
||||
|
||||
// Get password reset URL from email
|
||||
const resetUrl = await getPasswordResetUrl(request, email);
|
||||
|
||||
// Navigate to reset page
|
||||
await page.goto(resetUrl);
|
||||
|
||||
// Fill in short password
|
||||
await page.getByLabel('Password', { exact: true }).fill('short');
|
||||
await page.getByLabel('Confirm Password').fill('short');
|
||||
await page.getByRole('button', { name: 'Reset Password' }).click();
|
||||
|
||||
// Should show validation error about minimum length
|
||||
await expect(page.getByText('must be at least')).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows error for invalid login credentials', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
|
||||
await page.getByLabel('Email').fill('nonexistent@example.com');
|
||||
await page.getByLabel('Password').fill('wrongpassword123');
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
|
||||
await expect(page.getByText('These credentials do not match our records.')).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows error when registering with existing email', async ({ page }) => {
|
||||
const email = `john+${Math.round(Math.random() * 10000)}@doe.com`;
|
||||
const password = 'suchagreatpassword123';
|
||||
|
||||
// Register first user
|
||||
await registerNewUser(page, email, password);
|
||||
|
||||
// Log out
|
||||
await page.getByTestId('current_user_button').click();
|
||||
await page.getByText('Log Out').click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
||||
|
||||
// Try to register with the same email
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/register');
|
||||
await page.getByLabel('Name').fill('Another User');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password', { exact: true }).fill(password);
|
||||
await page.getByLabel('Confirm Password').fill(password);
|
||||
await page.getByLabel('I agree to the Terms of').click();
|
||||
await page.getByRole('button', { name: 'Register' }).click();
|
||||
|
||||
// Should show error about email already taken
|
||||
await expect(page.getByText('The resource already exists.')).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows validation error for weak password on registration', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/register');
|
||||
await page.getByLabel('Name').fill('Weak Password User');
|
||||
await page.getByLabel('Email').fill(`weak+${Math.round(Math.random() * 10000)}@test.com`);
|
||||
await page.getByLabel('Password', { exact: true }).fill('short');
|
||||
await page.getByLabel('Confirm Password').fill('short');
|
||||
await page.getByLabel('I agree to the Terms of').click();
|
||||
await page.getByRole('button', { name: 'Register' }).click();
|
||||
|
||||
await expect(page.getByText('must be at least')).toBeVisible();
|
||||
});
|
||||
|
||||
326
e2e/calendar.spec.ts
Normal file
326
e2e/calendar.spec.ts
Normal file
@@ -0,0 +1,326 @@
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import {
|
||||
createBillableProjectViaApi,
|
||||
createProjectViaApi,
|
||||
createBareTimeEntryViaApi,
|
||||
createTimeEntryViaApi,
|
||||
} from './utils/api';
|
||||
|
||||
async function goToCalendar(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/calendar');
|
||||
}
|
||||
|
||||
/**
|
||||
* These tests verify that changing the project on a time entry via the calendar
|
||||
* updates the billable status to match the new project's is_billable setting.
|
||||
*
|
||||
* Issue: https://github.com/solidtime-io/solidtime/issues/981
|
||||
*/
|
||||
|
||||
test('test that changing project in calendar edit modal from non-billable to billable updates billable status', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const billableProjectName = 'Billable Cal Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createBillableProjectViaApi(ctx, { name: billableProjectName });
|
||||
await createBareTimeEntryViaApi(ctx, 'Test billable calendar', '1h');
|
||||
|
||||
await goToCalendar(page);
|
||||
|
||||
// Click on the time entry event in the calendar
|
||||
await page.locator('.fc-event').filter({ hasText: 'Test billable calendar' }).first().click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Verify initially non-billable
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Non-Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Select the billable project
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'No Project' }).click();
|
||||
await page.getByRole('option', { name: billableProjectName }).click();
|
||||
|
||||
// Verify the billable dropdown updated to Billable
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Save and verify
|
||||
const [updateResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Time Entry' }).click(),
|
||||
]);
|
||||
const responseBody = await updateResponse.json();
|
||||
expect(responseBody.data.billable).toBe(true);
|
||||
});
|
||||
|
||||
test('test that changing project in calendar edit modal from billable to non-billable updates billable status', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const billableProjectName = 'Billable Cal Rev Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const nonBillableProjectName =
|
||||
'NonBillable Cal Rev Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createBillableProjectViaApi(ctx, { name: billableProjectName });
|
||||
await createProjectViaApi(ctx, { name: nonBillableProjectName });
|
||||
await createBareTimeEntryViaApi(ctx, 'Test billable cal reverse', '1h');
|
||||
|
||||
await goToCalendar(page);
|
||||
|
||||
// Click on the time entry event in the calendar
|
||||
await page
|
||||
.locator('.fc-event')
|
||||
.filter({ hasText: 'Test billable cal reverse' })
|
||||
.first()
|
||||
.click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// First assign the billable project
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'No Project' }).click();
|
||||
await page.getByRole('option', { name: billableProjectName }).click();
|
||||
|
||||
// Verify billable status flipped to Billable
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Now switch to the non-billable project
|
||||
await page.getByRole('dialog').getByRole('button', { name: billableProjectName }).click();
|
||||
await page.getByRole('option', { name: nonBillableProjectName }).click();
|
||||
|
||||
// Verify billable status reverted to Non-Billable
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Non-Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Save and verify
|
||||
const [updateResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Time Entry' }).click(),
|
||||
]);
|
||||
const responseBody = await updateResponse.json();
|
||||
expect(responseBody.data.billable).toBe(false);
|
||||
});
|
||||
|
||||
test('test that opening calendar edit modal for a time entry with manually overridden billable status preserves that status', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const billableProjectName =
|
||||
'Billable Cal Persist Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createBillableProjectViaApi(ctx, { name: billableProjectName });
|
||||
await createBareTimeEntryViaApi(ctx, 'Test cal persist override', '1h');
|
||||
|
||||
await goToCalendar(page);
|
||||
|
||||
// Click on the time entry event in the calendar
|
||||
await page
|
||||
.locator('.fc-event')
|
||||
.filter({ hasText: 'Test cal persist override' })
|
||||
.first()
|
||||
.click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Assign the billable project
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'No Project' }).click();
|
||||
await page.getByRole('option', { name: billableProjectName }).click();
|
||||
|
||||
// Verify it auto-set to Billable
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Now manually override billable to Non-Billable via the dropdown
|
||||
await page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Billable' }).click();
|
||||
await page.getByRole('option', { name: 'Non Billable' }).click();
|
||||
|
||||
// Verify it shows Non-Billable now
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Non-Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Save
|
||||
const [firstSaveResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Time Entry' }).click(),
|
||||
]);
|
||||
const firstBody = await firstSaveResponse.json();
|
||||
expect(firstBody.data.billable).toBe(false);
|
||||
|
||||
// Re-open the edit modal from the calendar — the project_id watcher should NOT override billable
|
||||
await page
|
||||
.locator('.fc-event')
|
||||
.filter({ hasText: 'Test cal persist override' })
|
||||
.first()
|
||||
.click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// The billable dropdown should still show Non-Billable
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Non-Billable' })
|
||||
).toBeVisible();
|
||||
|
||||
// Save without changes and verify the response still has billable=false
|
||||
const [updateResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Time Entry' }).click(),
|
||||
]);
|
||||
const responseBody = await updateResponse.json();
|
||||
expect(responseBody.data.billable).toBe(false);
|
||||
});
|
||||
|
||||
test('test that calendar page loads and displays time entries', async ({ page, ctx }) => {
|
||||
await createBareTimeEntryViaApi(ctx, 'Calendar display test', '1h');
|
||||
|
||||
await goToCalendar(page);
|
||||
|
||||
// Calendar container should be visible
|
||||
await expect(page.locator('.fc')).toBeVisible();
|
||||
|
||||
// The time entry should appear as a calendar event
|
||||
await expect(
|
||||
page.locator('.fc-event').filter({ hasText: 'Calendar display test' }).first()
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that calendar navigation buttons work', async ({ page }) => {
|
||||
await goToCalendar(page);
|
||||
await expect(page.locator('.fc')).toBeVisible();
|
||||
|
||||
// Click the "next" button to navigate forward
|
||||
await page.locator('button.fc-next-button').click();
|
||||
await expect(page.locator('.fc')).toBeVisible();
|
||||
|
||||
// Click the "prev" button to navigate back
|
||||
await page.locator('button.fc-prev-button').click();
|
||||
await expect(page.locator('.fc')).toBeVisible();
|
||||
|
||||
// Navigate forward first so "today" button becomes enabled, then click it
|
||||
await page.locator('button.fc-next-button').click();
|
||||
await page.locator('button.fc-today-button').click();
|
||||
await expect(page.locator('.fc')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that editing time entry description via calendar modal works', async ({ page, ctx }) => {
|
||||
const originalDescription = 'Edit me in calendar ' + Math.floor(1 + Math.random() * 10000);
|
||||
const updatedDescription = 'Updated in calendar ' + Math.floor(1 + Math.random() * 10000);
|
||||
await createBareTimeEntryViaApi(ctx, originalDescription, '1h');
|
||||
|
||||
await goToCalendar(page);
|
||||
|
||||
// Click on the time entry event
|
||||
await page.locator('.fc-event').filter({ hasText: originalDescription }).first().click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Update the description (edit modal uses placeholder, not data-testid)
|
||||
const descriptionInput = page.getByRole('dialog').getByPlaceholder('What did you work on?');
|
||||
await descriptionInput.fill(updatedDescription);
|
||||
|
||||
// Save and verify
|
||||
const [editResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Time Entry' }).click(),
|
||||
]);
|
||||
const editBody = await editResponse.json();
|
||||
expect(editBody.data.description).toBe(updatedDescription);
|
||||
|
||||
// Verify the updated description is shown in the calendar UI
|
||||
await expect(
|
||||
page.locator('.fc-event').filter({ hasText: updatedDescription }).first()
|
||||
).toBeVisible();
|
||||
// Verify the old description is no longer shown
|
||||
await expect(
|
||||
page.locator('.fc-event').filter({ hasText: originalDescription })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that deleting time entry from calendar modal works', async ({ page, ctx }) => {
|
||||
const description = 'Delete me from calendar ' + Math.floor(1 + Math.random() * 10000);
|
||||
await createBareTimeEntryViaApi(ctx, description, '1h');
|
||||
|
||||
await goToCalendar(page);
|
||||
|
||||
// Click on the time entry event
|
||||
await page.locator('.fc-event').filter({ hasText: description }).first().click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Click the delete button
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/') &&
|
||||
response.request().method() === 'DELETE' &&
|
||||
response.status() === 204
|
||||
),
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Delete' }).click(),
|
||||
]);
|
||||
|
||||
// Verify the event is removed from the calendar
|
||||
await expect(page.locator('.fc-event').filter({ hasText: description })).not.toBeVisible();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Calendar Isolation', () => {
|
||||
test('employee can only see their own time entries on the calendar', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
// Owner creates a time entry for today
|
||||
const ownerDescription = 'OwnerCalEntry ' + Math.floor(Math.random() * 10000);
|
||||
await createBareTimeEntryViaApi(ctx, ownerDescription, '1h');
|
||||
|
||||
// Create a time entry for the employee for today
|
||||
const employeeDescription = 'EmpCalEntry ' + Math.floor(Math.random() * 10000);
|
||||
await createTimeEntryViaApi(
|
||||
{ ...ctx, memberId: employee.memberId },
|
||||
{ description: employeeDescription, duration: '30min' }
|
||||
);
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/calendar');
|
||||
await expect(employee.page.locator('.fc')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Employee's event IS visible
|
||||
await expect(
|
||||
employee.page.locator('.fc-event').filter({ hasText: employeeDescription }).first()
|
||||
).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Owner's event is NOT visible
|
||||
await expect(
|
||||
employee.page.locator('.fc-event').filter({ hasText: ownerDescription })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -1,15 +1,22 @@
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import {
|
||||
createClientViaApi,
|
||||
createProjectMemberViaApi,
|
||||
createProjectViaApi,
|
||||
createPublicProjectViaApi,
|
||||
} from './utils/api';
|
||||
|
||||
async function goToProjectsOverview(page: Page) {
|
||||
async function goToClientsOverview(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/clients');
|
||||
}
|
||||
|
||||
// Create new project via modal
|
||||
// Create new client via modal
|
||||
test('test that creating and deleting a new client via the modal works', async ({ page }) => {
|
||||
const newClientName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await goToClientsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Client' }).click();
|
||||
await page.getByPlaceholder('Client Name').fill(newClientName);
|
||||
await Promise.all([
|
||||
@@ -26,7 +33,7 @@ test('test that creating and deleting a new client via the modal works', async (
|
||||
|
||||
await expect(page.getByTestId('client_table')).toContainText(newClientName);
|
||||
const moreButton = page.locator("[aria-label='Actions for Client " + newClientName + "']");
|
||||
moreButton.click();
|
||||
await moreButton.click();
|
||||
const deleteButton = page.locator("[aria-label='Delete Client " + newClientName + "']");
|
||||
|
||||
await Promise.all([
|
||||
@@ -41,13 +48,11 @@ test('test that creating and deleting a new client via the modal works', async (
|
||||
await expect(page.getByTestId('client_table')).not.toContainText(newClientName);
|
||||
});
|
||||
|
||||
test('test that archiving and unarchiving clients works', async ({ page }) => {
|
||||
test('test that archiving and unarchiving clients works', async ({ page, ctx }) => {
|
||||
const newClientName = 'New Client ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Client' }).click();
|
||||
await page.getByLabel('Client Name').fill(newClientName);
|
||||
await createClientViaApi(ctx, { name: newClientName });
|
||||
|
||||
await page.getByRole('button', { name: 'Create Client' }).click();
|
||||
await goToClientsOverview(page);
|
||||
await expect(page.getByText(newClientName)).toBeVisible();
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
@@ -71,4 +76,140 @@ test('test that archiving and unarchiving clients works', async ({ page }) => {
|
||||
]);
|
||||
});
|
||||
|
||||
// TODO: Add Name Update Test
|
||||
test('test that editing a client name works', async ({ page, ctx }) => {
|
||||
const originalName = 'Original Client ' + Math.floor(1 + Math.random() * 10000);
|
||||
const updatedName = 'Updated Client ' + Math.floor(1 + Math.random() * 10000);
|
||||
await createClientViaApi(ctx, { name: originalName });
|
||||
|
||||
await goToClientsOverview(page);
|
||||
await expect(page.getByText(originalName)).toBeVisible();
|
||||
|
||||
// Open edit modal via actions menu
|
||||
const moreButton = page.locator("[aria-label='Actions for Client " + originalName + "']");
|
||||
await moreButton.click();
|
||||
await page.getByTestId('client_edit').click();
|
||||
|
||||
// Update the client name
|
||||
await page.getByPlaceholder('Client Name').fill(updatedName);
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Client' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/clients') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify updated name is shown and old name is gone
|
||||
await expect(page.getByTestId('client_table')).toContainText(updatedName);
|
||||
await expect(page.getByTestId('client_table')).not.toContainText(originalName);
|
||||
});
|
||||
|
||||
test('test that deleting a client via actions menu works', async ({ page, ctx }) => {
|
||||
const clientName = 'DeleteMe Client ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createClientViaApi(ctx, { name: clientName });
|
||||
|
||||
await goToClientsOverview(page);
|
||||
await expect(page.getByTestId('client_table')).toContainText(clientName);
|
||||
|
||||
const moreButton = page.locator("[aria-label='Actions for Client " + clientName + "']");
|
||||
await moreButton.click();
|
||||
const deleteButton = page.locator("[aria-label='Delete Client " + clientName + "']");
|
||||
|
||||
await Promise.all([
|
||||
deleteButton.click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/clients') &&
|
||||
response.request().method() === 'DELETE' &&
|
||||
response.status() === 204
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('client_table')).not.toContainText(clientName);
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Clients Restrictions', () => {
|
||||
test('employee can view clients but cannot create', async ({ ctx, employee }) => {
|
||||
// Create a client with a public project so the employee can see the client
|
||||
const clientName = 'EmpViewClient ' + Math.floor(Math.random() * 10000);
|
||||
const client = await createClientViaApi(ctx, { name: clientName });
|
||||
await createPublicProjectViaApi(ctx, { name: 'EmpClientProj', client_id: client.id });
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/clients');
|
||||
await expect(employee.page.getByTestId('clients_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Employee can see the client
|
||||
await expect(employee.page.getByText(clientName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Employee cannot see Create Client button
|
||||
await expect(
|
||||
employee.page.getByRole('button', { name: 'Create Client' })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee cannot see edit/delete/archive actions on clients', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
const clientName = 'EmpActionsClient ' + Math.floor(Math.random() * 10000);
|
||||
const client = await createClientViaApi(ctx, { name: clientName });
|
||||
await createPublicProjectViaApi(ctx, { name: 'EmpClientActProj', client_id: client.id });
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/clients');
|
||||
await expect(employee.page.getByText(clientName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Click the actions dropdown trigger to open the menu
|
||||
const actionsButton = employee.page.locator(
|
||||
`[aria-label='Actions for Client ${clientName}']`
|
||||
);
|
||||
await actionsButton.click();
|
||||
|
||||
// The dropdown menu items (Edit, Archive, Delete) should NOT be visible
|
||||
await expect(
|
||||
employee.page.locator(`[aria-label='Edit Client ${clientName}']`)
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.locator(`[aria-label='Archive Client ${clientName}']`)
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.locator(`[aria-label='Delete Client ${clientName}']`)
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee can see client when they are a member of its private project', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
const clientName = 'EmpPrivateClient ' + Math.floor(Math.random() * 10000);
|
||||
const client = await createClientViaApi(ctx, { name: clientName });
|
||||
|
||||
// Create a private project under this client
|
||||
const project = await createProjectViaApi(ctx, {
|
||||
name: 'PrivateProj',
|
||||
client_id: client.id,
|
||||
is_public: false,
|
||||
});
|
||||
|
||||
// Add the employee as a project member
|
||||
await createProjectMemberViaApi(ctx, project.id, {
|
||||
member_id: employee.memberId,
|
||||
});
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/clients');
|
||||
await expect(employee.page.getByTestId('clients_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Employee can see the client because they are a member of its private project
|
||||
await expect(employee.page.getByText(clientName)).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
});
|
||||
|
||||
468
e2e/command-palette.spec.ts
Normal file
468
e2e/command-palette.spec.ts
Normal file
@@ -0,0 +1,468 @@
|
||||
import { expect, test } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
const TIMER_BUTTON_SELECTOR = '[data-testid="dashboard_timer"] [data-testid="timer_button"]';
|
||||
|
||||
async function goToDashboard(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
}
|
||||
|
||||
async function openCommandPalette(page: Page) {
|
||||
await page.getByTestId('command_palette_button').click();
|
||||
await expect(page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
}
|
||||
|
||||
async function closeCommandPalette(page: Page) {
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.locator('[role="dialog"]')).not.toBeVisible();
|
||||
}
|
||||
|
||||
async function searchInCommandPalette(page: Page, query: string) {
|
||||
await page.locator('[role="dialog"] input').fill(query);
|
||||
// Wait for search debounce to settle (command palette uses a debounced search)
|
||||
await page.waitForTimeout(300);
|
||||
}
|
||||
|
||||
async function selectCommand(page: Page, name: string) {
|
||||
const option = page.getByRole('option', { name, exact: true });
|
||||
await option.scrollIntoViewIfNeeded();
|
||||
await option.click();
|
||||
}
|
||||
|
||||
async function assertTimerIsRunning(page: Page) {
|
||||
await expect(page.locator(TIMER_BUTTON_SELECTOR)).toHaveClass(/bg-red-400\/80/, {
|
||||
timeout: 10000,
|
||||
});
|
||||
}
|
||||
|
||||
async function assertTimerIsStopped(page: Page) {
|
||||
await expect(page.locator(TIMER_BUTTON_SELECTOR)).toHaveClass(/bg-accent-300\/70/, {
|
||||
timeout: 10000,
|
||||
});
|
||||
}
|
||||
|
||||
test.describe('Command Palette', () => {
|
||||
test.describe('Opening and Closing', () => {
|
||||
test('opens via search button and closes with Escape', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await expect(
|
||||
page.locator('[role="dialog"] input[placeholder*="command"]')
|
||||
).toBeVisible();
|
||||
|
||||
await closeCommandPalette(page);
|
||||
await expect(page.locator('[role="dialog"]')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('opens with keyboard shortcut', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
// Click on body to ensure page has focus
|
||||
await page.locator('body').click();
|
||||
// Use ControlOrMeta which resolves to Ctrl on Linux/Windows and Meta on macOS
|
||||
await page.keyboard.press('ControlOrMeta+k');
|
||||
await expect(page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('clears search on close', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'dashboard');
|
||||
await closeCommandPalette(page);
|
||||
|
||||
await openCommandPalette(page);
|
||||
await expect(page.locator('[role="dialog"] input')).toHaveValue('');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Command Display', () => {
|
||||
test('displays navigation and timer commands', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
// Navigation commands
|
||||
await expect(page.getByRole('option', { name: 'Go to Dashboard' })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Go to Time' })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Go to Calendar' })).toBeVisible();
|
||||
|
||||
// Timer commands
|
||||
await expect(page.getByRole('option', { name: 'Start Timer' })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Create Time Entry' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('displays create commands', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
await expect(page.getByRole('option', { name: 'Create Project' })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Create Client' })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Create Tag' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Navigation Commands', () => {
|
||||
// Tests use element visibility assertions for consistency with codebase patterns
|
||||
const navigationTests = [
|
||||
['Go to Dashboard', 'dashboard_view', '/time'],
|
||||
['Go to Time', 'time_view', '/dashboard'],
|
||||
['Go to Calendar', 'calendar_view', '/dashboard'],
|
||||
['Go to Projects', 'projects_view', '/dashboard'],
|
||||
['Go to Clients', 'clients_view', '/dashboard'],
|
||||
['Go to Members', 'members_view', '/dashboard'],
|
||||
['Go to Tags', 'tags_view', '/dashboard'],
|
||||
] as const;
|
||||
|
||||
for (const [commandName, expectedTestId, startUrl] of navigationTests) {
|
||||
test(`${commandName}`, async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + startUrl);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, commandName.replace('Go to ', ''));
|
||||
await selectCommand(page, commandName);
|
||||
await expect(page.getByTestId(expectedTestId)).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
}
|
||||
|
||||
test('Go to Profile', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Profile');
|
||||
await selectCommand(page, 'Go to Profile');
|
||||
// Profile page doesn't have a testId, so check for a unique element
|
||||
await expect(page.getByRole('heading', { name: 'Profile Information' })).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
});
|
||||
|
||||
test('Go to Reporting Overview', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Reporting Overview');
|
||||
await selectCommand(page, 'Go to Reporting Overview');
|
||||
await expect(page.getByTestId('reporting_view')).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
test('Go to Settings', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Settings');
|
||||
await selectCommand(page, 'Go to Settings');
|
||||
// Settings page uses team settings which has an h3 heading
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Organization Name', level: 3 })
|
||||
).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Search and Filtering', () => {
|
||||
test('filters commands when searching', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
await searchInCommandPalette(page, 'dashboard');
|
||||
await expect(page.getByRole('option', { name: 'Go to Dashboard' })).toBeVisible();
|
||||
|
||||
await searchInCommandPalette(page, 'calendar');
|
||||
await expect(page.getByRole('option', { name: 'Go to Calendar' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('search is case insensitive', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
await searchInCommandPalette(page, 'DASHBOARD');
|
||||
await expect(page.getByRole('option', { name: 'Go to Dashboard' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('partial word search works', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
await searchInCommandPalette(page, 'proj');
|
||||
await expect(page.getByRole('option', { name: 'Go to Projects' })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Create Project' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('keyboard navigation and selection works', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await expect(page.locator('[role="dialog"]')).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Theme Commands', () => {
|
||||
test('switches to dark theme', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Dark Theme');
|
||||
await selectCommand(page, 'Switch to Dark Theme');
|
||||
await expect(page.locator('html')).toHaveClass(/dark/);
|
||||
});
|
||||
|
||||
test('switches to light theme', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Light Theme');
|
||||
await selectCommand(page, 'Switch to Light Theme');
|
||||
await expect(page.locator('html')).toHaveClass(/light/);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Timer Commands', () => {
|
||||
test('starts and stops timer', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
|
||||
// Start timer
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Start Timer');
|
||||
await selectCommand(page, 'Start Timer');
|
||||
await assertTimerIsRunning(page);
|
||||
|
||||
// Stop timer
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Stop Timer');
|
||||
await selectCommand(page, 'Stop Timer');
|
||||
await assertTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('shows active timer commands when running', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
|
||||
// Start timer
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Start Timer');
|
||||
await selectCommand(page, 'Start Timer');
|
||||
await assertTimerIsRunning(page);
|
||||
|
||||
// Check active timer commands - search for them to ensure visibility
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Set Project');
|
||||
await expect(page.getByRole('option', { name: 'Set Project' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Create Commands', () => {
|
||||
test('opens create time entry modal', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Create Time Entry');
|
||||
await selectCommand(page, 'Create Time Entry');
|
||||
await expect(
|
||||
page.locator('[role="dialog"]').getByText('Create manual time entry')
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('opens create project modal', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Create Project');
|
||||
await selectCommand(page, 'Create Project');
|
||||
await expect(
|
||||
page.locator('[role="dialog"]').getByRole('heading', { name: 'Create Project' })
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('opens create client modal', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Create Client');
|
||||
await selectCommand(page, 'Create Client');
|
||||
await expect(
|
||||
page.locator('[role="dialog"]').getByRole('heading', { name: 'Create Client' })
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('opens create tag modal', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Create Tag');
|
||||
await selectCommand(page, 'Create Tag');
|
||||
await expect(page.locator('[role="dialog"]').getByText('Create Tags')).toBeVisible();
|
||||
});
|
||||
|
||||
test('opens invite member modal', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Invite Member');
|
||||
await selectCommand(page, 'Invite Member');
|
||||
// Modal has title with "Invite Member" text - use first() to get the title span
|
||||
await expect(
|
||||
page.locator('[role="dialog"]').getByText('Invite Member').first()
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Entity Search', () => {
|
||||
test('searches for projects and navigates on selection', async ({ page }) => {
|
||||
const projectName = 'CmdPalette' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create project first
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByPlaceholder('The next big thing').fill(projectName);
|
||||
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
// Wait for project to be created and page to update
|
||||
await expect(page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Search from the projects page where the query cache now has the new project
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, projectName);
|
||||
|
||||
// Wait for entity search to return results
|
||||
const projectOption = page.getByRole('option').filter({ hasText: projectName });
|
||||
await expect(projectOption).toBeVisible({
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
// Select the project from search results
|
||||
await projectOption.click();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Organization Switching', () => {
|
||||
test('shows switch commands only when multiple organizations exist', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await openCommandPalette(page);
|
||||
|
||||
// With only one org, no switch commands should appear
|
||||
await searchInCommandPalette(page, 'Switch to');
|
||||
// Check that no organization switch commands appear (only theme switch commands)
|
||||
const switchOptions = page.getByRole('option', { name: /^Switch to (?!.*Theme)/ });
|
||||
await expect(switchOptions).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('switches organization via command palette', async ({ page }) => {
|
||||
const newOrgName = 'TestOrg' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create a new organization
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
||||
await page.getByLabel('Organization Name').fill(newOrgName);
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
|
||||
// Wait for navigation to new org's dashboard
|
||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Use visible switcher (desktop sidebar has one, mobile header has another)
|
||||
const orgSwitcher = page.locator('[data-testid="organization_switcher"]:visible');
|
||||
|
||||
// Verify we're in the new org by checking the switcher
|
||||
await expect(orgSwitcher).toContainText(newOrgName);
|
||||
|
||||
// Get the original org name from switcher dropdown
|
||||
await orgSwitcher.click();
|
||||
await expect(page.getByText('Switch Organizations')).toBeVisible();
|
||||
|
||||
// Find the other organization button (has ArrowRightIcon, not CheckCircleIcon)
|
||||
// The button contains an SVG and a div with the org name
|
||||
const otherOrgItem = page.locator('form button').filter({ hasText: /.+/ }).first();
|
||||
await expect(otherOrgItem).toBeVisible();
|
||||
const originalOrgName = (await otherOrgItem.innerText()).trim();
|
||||
await page.keyboard.press('Escape'); // Close dropdown
|
||||
|
||||
// Now use command palette to switch back to original org
|
||||
await openCommandPalette(page);
|
||||
await searchInCommandPalette(page, 'Switch to');
|
||||
|
||||
// Should see the switch command for the original org
|
||||
const switchCommand = page.getByRole('option', {
|
||||
name: new RegExp(`Switch to ${originalOrgName}`),
|
||||
});
|
||||
await expect(switchCommand).toBeVisible();
|
||||
await switchCommand.click();
|
||||
|
||||
// Wait for organization switch to complete
|
||||
await expect(orgSwitcher).toContainText(originalOrgName, {
|
||||
timeout: 10000,
|
||||
});
|
||||
});
|
||||
|
||||
test('organization switch commands appear in Organization group', async ({ page }) => {
|
||||
const newOrgName = 'GroupTestOrg' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create a new organization to ensure we have multiple
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
||||
await page.getByLabel('Organization Name').fill(newOrgName);
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Open command palette and check for Organization group heading
|
||||
await openCommandPalette(page);
|
||||
|
||||
// The Organization group should be visible when there are switch commands
|
||||
await expect(page.getByText('Organization', { exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Command Palette Restrictions', () => {
|
||||
test('employee command palette does not show restricted navigation commands', async ({
|
||||
employee,
|
||||
}) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Open command palette
|
||||
await employee.page.getByTestId('command_palette_button').click();
|
||||
await expect(employee.page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Available navigation commands
|
||||
await expect(employee.page.getByRole('option', { name: 'Go to Dashboard' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('option', { name: 'Go to Time' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('option', { name: 'Go to Calendar' })).toBeVisible();
|
||||
|
||||
// Restricted commands should NOT be visible
|
||||
await expect(
|
||||
employee.page.getByRole('option', { name: 'Go to Members' })
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.getByRole('option', { name: 'Go to Settings' })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee command palette does not show create commands for restricted entities', async ({
|
||||
employee,
|
||||
}) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Open command palette
|
||||
await employee.page.getByTestId('command_palette_button').click();
|
||||
await expect(employee.page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Search for "Create" to filter
|
||||
await employee.page.locator('[role="dialog"] input').fill('Create');
|
||||
await employee.page.waitForTimeout(300);
|
||||
|
||||
// Should NOT see create commands for restricted entities
|
||||
await expect(
|
||||
employee.page.getByRole('option', { name: 'Create Project' })
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.getByRole('option', { name: 'Create Client' })
|
||||
).not.toBeVisible();
|
||||
await expect(employee.page.getByRole('option', { name: 'Create Tag' })).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.getByRole('option', { name: 'Invite Member' })
|
||||
).not.toBeVisible();
|
||||
|
||||
// Should still see Create Time Entry (employees can create time entries)
|
||||
await expect(
|
||||
employee.page.getByRole('option', { name: 'Create Time Entry' })
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
190
e2e/dashboard.spec.ts
Normal file
190
e2e/dashboard.spec.ts
Normal file
@@ -0,0 +1,190 @@
|
||||
import { expect, test } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import type { Page } from '@playwright/test';
|
||||
import {
|
||||
assertThatTimerHasStarted,
|
||||
assertThatTimerIsStopped,
|
||||
newTimeEntryResponse,
|
||||
startOrStopTimerWithButton,
|
||||
stoppedTimeEntryResponse,
|
||||
} from './utils/currentTimeEntry';
|
||||
import {
|
||||
createBareTimeEntryViaApi,
|
||||
createPublicProjectViaApi,
|
||||
createTimeEntryViaApi,
|
||||
updateOrganizationSettingViaApi,
|
||||
} from './utils/api';
|
||||
|
||||
async function goToDashboard(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
}
|
||||
|
||||
test('test that dashboard loads with all expected sections', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Timer section (scoped to dashboard_timer to avoid matching sidebar timer)
|
||||
await expect(page.getByTestId('time_entry_description')).toBeVisible();
|
||||
await expect(page.getByTestId('dashboard_timer').getByTestId('timer_button')).toBeVisible();
|
||||
|
||||
// Dashboard cards
|
||||
await expect(page.getByText('Recent Time Entries', { exact: true })).toBeVisible();
|
||||
await expect(page.getByText('Last 7 Days', { exact: true })).toBeVisible();
|
||||
await expect(page.getByText('Activity Graph', { exact: true })).toBeVisible();
|
||||
await expect(page.getByText('Team Activity', { exact: true })).toBeVisible();
|
||||
|
||||
// Weekly overview section
|
||||
await expect(page.getByText('This Week', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that dashboard shows time entry data after creating entries', async ({ page, ctx }) => {
|
||||
await createBareTimeEntryViaApi(ctx, 'Dashboard test entry', '1h');
|
||||
|
||||
await goToDashboard(page);
|
||||
await expect(page.getByTestId('dashboard_view')).toBeVisible();
|
||||
|
||||
// The "Last 7 Days" or "This Week" section should reflect tracked time
|
||||
await expect(page.getByText('This Week', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that timer on dashboard can start and stop', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await Promise.all([newTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
await page.waitForTimeout(1500);
|
||||
|
||||
await Promise.all([stoppedTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that weekly overview section displays stat cards', async ({ page, ctx }) => {
|
||||
await createBareTimeEntryViaApi(ctx, 'Stats test entry', '2h');
|
||||
|
||||
await goToDashboard(page);
|
||||
|
||||
// Verify stat card labels are visible
|
||||
await expect(page.getByText('Spent Time')).toBeVisible();
|
||||
await expect(page.getByText('Billable Time')).toBeVisible();
|
||||
await expect(page.getByText('Billable Amount')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that stopping timer refreshes dashboard data', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
|
||||
// Start timer
|
||||
await Promise.all([newTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
await page.waitForTimeout(1500);
|
||||
|
||||
// Stop timer and verify dashboard queries are refetched
|
||||
await Promise.all([
|
||||
stoppedTimeEntryResponse(page),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/charts/') &&
|
||||
response.request().method() === 'GET' &&
|
||||
response.status() === 200
|
||||
),
|
||||
startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Dashboard Restrictions', () => {
|
||||
test('employee dashboard loads and timer is functional', async ({ employee }) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Timer should be available
|
||||
await expect(
|
||||
employee.page.getByTestId('dashboard_timer').getByTestId('timer_button')
|
||||
).toBeVisible();
|
||||
await expect(employee.page.getByTestId('time_entry_description')).toBeEditable();
|
||||
});
|
||||
|
||||
test('employee cannot see Team Activity card', async ({ employee }) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Other dashboard cards should be visible
|
||||
await expect(employee.page.getByText('Recent Time Entries', { exact: true })).toBeVisible();
|
||||
|
||||
// Team Activity should NOT be visible for employees
|
||||
await expect(employee.page.getByText('Team Activity', { exact: true })).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee cannot see Cost column in This Week table by default', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
const project = await createPublicProjectViaApi(ctx, {
|
||||
name: 'EmpDashBillProj',
|
||||
is_billable: true,
|
||||
billable_rate: 10000,
|
||||
});
|
||||
await createTimeEntryViaApi(
|
||||
{ ...ctx, memberId: employee.memberId },
|
||||
{
|
||||
description: 'Emp dashboard cost entry',
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
billable: true,
|
||||
}
|
||||
);
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// This Week table should be visible
|
||||
await expect(employee.page.getByText('This Week', { exact: true })).toBeVisible();
|
||||
|
||||
// Duration column should be visible, but Cost column should NOT
|
||||
await expect(employee.page.getByText('Duration', { exact: true })).toBeVisible();
|
||||
await expect(employee.page.getByText('Cost', { exact: true })).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee can see Cost column in This Week table when employees_can_see_billable_rates is enabled', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
await updateOrganizationSettingViaApi(ctx, { employees_can_see_billable_rates: true });
|
||||
|
||||
const project = await createPublicProjectViaApi(ctx, {
|
||||
name: 'EmpDashBillVisProj',
|
||||
is_billable: true,
|
||||
billable_rate: 10000,
|
||||
});
|
||||
await createTimeEntryViaApi(
|
||||
{ ...ctx, memberId: employee.memberId },
|
||||
{
|
||||
description: 'Emp dashboard cost visible entry',
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
billable: true,
|
||||
}
|
||||
);
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Both Duration and Cost columns should be visible
|
||||
await expect(employee.page.getByText('Duration', { exact: true })).toBeVisible();
|
||||
await expect(employee.page.getByText('Cost', { exact: true })).toBeVisible();
|
||||
|
||||
// 1h at 100.00/h = 100.00 EUR cost should be visible
|
||||
await expect(employee.page.getByText('100,00 EUR').first()).toBeVisible();
|
||||
});
|
||||
});
|
||||
154
e2e/import-export.spec.ts
Normal file
154
e2e/import-export.spec.ts
Normal file
@@ -0,0 +1,154 @@
|
||||
import { expect, test } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import type { Page } from '@playwright/test';
|
||||
import path from 'path';
|
||||
|
||||
async function goToImportExport(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/import');
|
||||
}
|
||||
|
||||
test('test that import page loads with type dropdown and file upload', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
await expect(page.getByTestId('import_view')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Import section
|
||||
await expect(page.getByRole('heading', { name: 'Import Data' })).toBeVisible();
|
||||
await expect(page.locator('#importType')).toBeVisible();
|
||||
|
||||
// Export section
|
||||
await expect(page.getByRole('heading', { name: 'Export Data' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Export Organization Data' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that selecting an import type shows instructions', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
|
||||
// Select a Toggl import type
|
||||
await page.getByLabel('Import Type').selectOption({ index: 1 });
|
||||
|
||||
// Instructions should appear
|
||||
await expect(page.getByText('Instructions:')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that importing without selecting type shows error', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
|
||||
// Click Import Data without selecting a type
|
||||
await page.getByRole('button', { name: 'Import Data' }).click();
|
||||
|
||||
// Should show an error notification
|
||||
await expect(page.getByText('Please select the import type')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that importing without selecting file shows error', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
|
||||
// Select an import type first
|
||||
await page.getByLabel('Import Type').selectOption({ index: 1 });
|
||||
|
||||
// Click Import Data without selecting a file
|
||||
await page.getByRole('button', { name: 'Import Data' }).click();
|
||||
|
||||
// Should show an error notification
|
||||
await expect(
|
||||
page.getByText('Please select the CSV or ZIP file that you want to import')
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that export button triggers export and shows success modal', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
await expect(page.getByRole('button', { name: 'Export Organization Data' })).toBeVisible();
|
||||
|
||||
// Override window.open to prevent the page from navigating away to the
|
||||
// download URL (the app uses window.open(url, '_self') which would navigate
|
||||
// away before we can verify the success modal)
|
||||
await page.evaluate(() => {
|
||||
window.open = () => null;
|
||||
});
|
||||
|
||||
// Click Export Organization Data and wait for the API response
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/export') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 200,
|
||||
{ timeout: 60000 }
|
||||
),
|
||||
page.getByRole('button', { name: 'Export Organization Data' }).click(),
|
||||
]);
|
||||
|
||||
// Success modal should appear after export completes
|
||||
await expect(page.getByText('The export was successful!')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that import type dropdown has multiple options', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
|
||||
// The dropdown should load with options from the API
|
||||
await page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/importers') &&
|
||||
response.request().method() === 'GET' &&
|
||||
response.status() === 200
|
||||
);
|
||||
|
||||
// Verify the select has options besides the default placeholder
|
||||
const options = page.getByLabel('Import Type').locator('option');
|
||||
const count = await options.count();
|
||||
// Should have at least the placeholder + some import types
|
||||
expect(count).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
test('test that importing a generic time entries CSV works', async ({ page }) => {
|
||||
await goToImportExport(page);
|
||||
await expect(page.getByTestId('import_view')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Select "Generic Time Entries" import type
|
||||
await page.getByLabel('Import Type').selectOption({ label: 'Generic Time Entries' });
|
||||
await expect(page.getByText('Instructions:')).toBeVisible();
|
||||
|
||||
// Upload the test CSV file
|
||||
const csvPath = path.resolve('resources/testfiles/generic_time_entries_import_test_1.csv');
|
||||
await page.locator('#file-upload').setInputFiles(csvPath);
|
||||
|
||||
// Click Import and wait for the API response
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/import') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 200,
|
||||
{ timeout: 30000 }
|
||||
),
|
||||
page.getByRole('button', { name: 'Import Data' }).click(),
|
||||
]);
|
||||
|
||||
// Verify success modal with import results
|
||||
await expect(page.getByRole('heading', { name: 'Import Result' })).toBeVisible();
|
||||
await expect(page.getByText('The import was successful!')).toBeVisible();
|
||||
|
||||
// The CSV has 2 time entries, 1 client, 2 projects, 1 task
|
||||
await expect(page.getByText('Time entries created:').locator('..')).toContainText('2');
|
||||
await expect(page.getByText('Projects created:').locator('..')).toContainText('2');
|
||||
await expect(page.getByText('Clients created:').locator('..')).toContainText('1');
|
||||
await expect(page.getByText('Tasks created:').locator('..')).toContainText('1');
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Import Restrictions', () => {
|
||||
test('employee does not see Import / Export link in the sidebar', async ({ employee }) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// The Import / Export link should NOT be visible in the sidebar for employees
|
||||
await expect(
|
||||
employee.page.getByRole('link', { name: 'Import / Export' })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -3,53 +3,63 @@
|
||||
// TODO: Remove Invitation
|
||||
import { expect, test } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { inviteAndAcceptMember } from './utils/members';
|
||||
import { createPlaceholderMemberViaImportApi } from './utils/api';
|
||||
|
||||
async function goToMembersPage(page) {
|
||||
// Tests that invite + accept members need more time
|
||||
test.describe.configure({ timeout: 45000 });
|
||||
|
||||
async function goToMembersPage(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/members');
|
||||
}
|
||||
|
||||
async function openInviteMemberModal(page) {
|
||||
async function openInviteMemberModal(page: Page) {
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Invite Member' }).click(),
|
||||
expect(page.getByPlaceholder('Member Email')).toBeVisible(),
|
||||
]);
|
||||
}
|
||||
|
||||
test('test that new manager can be invited', async ({ page }) => {
|
||||
test('test that new manager can be invited and accepted', async ({ page, browser }) => {
|
||||
const memberId = Math.round(Math.random() * 100000);
|
||||
const memberEmail = `manager+${memberId}@invite.test`;
|
||||
|
||||
await inviteAndAcceptMember(page, browser, 'Invited Mgr', memberEmail, 'Manager');
|
||||
|
||||
// Verify the member appears in the members table with the correct role
|
||||
await goToMembersPage(page);
|
||||
await openInviteMemberModal(page);
|
||||
const editorId = Math.round(Math.random() * 10000);
|
||||
await page.getByLabel('Email').fill(`new+${editorId}@editor.test`);
|
||||
await page.getByRole('button', { name: 'Manager' }).click();
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
expect(page.getByRole('main')).toContainText(`new+${editorId}@editor.test`),
|
||||
]);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: 'Invited Mgr' });
|
||||
await expect(memberRow).toBeVisible();
|
||||
await expect(memberRow.getByText('Manager', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that new employee can be invited', async ({ page }) => {
|
||||
test('test that new employee can be invited and accepted', async ({ page, browser }) => {
|
||||
const memberId = Math.round(Math.random() * 100000);
|
||||
const memberEmail = `employee+${memberId}@invite.test`;
|
||||
|
||||
await inviteAndAcceptMember(page, browser, 'Invited Emp', memberEmail, 'Employee');
|
||||
|
||||
// Verify the member appears in the members table with the correct role
|
||||
await goToMembersPage(page);
|
||||
await openInviteMemberModal(page);
|
||||
const editorId = Math.round(Math.random() * 10000);
|
||||
await page.getByLabel('Email').fill(`new+${editorId}@editor.test`);
|
||||
await page.getByRole('button', { name: 'Employee' }).click();
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
await expect(page.getByRole('main')).toContainText(`new+${editorId}@editor.test`),
|
||||
]);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: 'Invited Emp' });
|
||||
await expect(memberRow).toBeVisible();
|
||||
await expect(memberRow.getByText('Employee', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that new admin can be invited', async ({ page }) => {
|
||||
test('test that new admin can be invited and accepted', async ({ page, browser }) => {
|
||||
const memberId = Math.round(Math.random() * 100000);
|
||||
const memberEmail = `admin+${memberId}@invite.test`;
|
||||
|
||||
await inviteAndAcceptMember(page, browser, 'Invited Adm', memberEmail, 'Administrator');
|
||||
|
||||
// Verify the member appears in the members table with the correct role
|
||||
await goToMembersPage(page);
|
||||
await openInviteMemberModal(page);
|
||||
const adminId = Math.round(Math.random() * 10000);
|
||||
await page.getByLabel('Email').fill(`new+${adminId}@admin.test`);
|
||||
await page.getByRole('button', { name: 'Administrator' }).click();
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
expect(page.getByRole('main')).toContainText(`new+${adminId}@admin.test`),
|
||||
]);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: 'Invited Adm' });
|
||||
await expect(memberRow).toBeVisible();
|
||||
await expect(memberRow.getByText('Admin', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that error shows if no role is selected', async ({ page }) => {
|
||||
await goToMembersPage(page);
|
||||
await openInviteMemberModal(page);
|
||||
@@ -91,3 +101,434 @@ test('test that organization billable rate can be updated with all existing time
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that changing role of placeholder member is rejected', async ({ page, ctx }) => {
|
||||
const placeholderName = 'RoleChange ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create a placeholder member via import
|
||||
await createPlaceholderMemberViaImportApi(ctx, placeholderName);
|
||||
|
||||
// Go to members page and verify placeholder exists with role "Placeholder"
|
||||
await goToMembersPage(page);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: placeholderName });
|
||||
await expect(memberRow).toBeVisible();
|
||||
await expect(memberRow.getByText('Placeholder', { exact: true })).toBeVisible();
|
||||
|
||||
// Open the edit modal for the placeholder member
|
||||
await memberRow.getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Update Member' })).toBeVisible();
|
||||
|
||||
// Change role to Employee
|
||||
const roleSelect = page.getByRole('dialog').getByRole('combobox').first();
|
||||
await roleSelect.click();
|
||||
await expect(page.getByRole('option', { name: 'Employee' })).toBeVisible();
|
||||
await page.getByRole('option', { name: 'Employee' }).click();
|
||||
await expect(roleSelect).toContainText('Employee');
|
||||
|
||||
// Submit the change - the API should reject it with 400
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Member' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/members/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 400
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify error notification is shown
|
||||
await expect(page.getByText('Failed to update member')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that changing member role updates the role in the member table', async ({
|
||||
page,
|
||||
browser,
|
||||
}) => {
|
||||
const memberId = Math.floor(Math.random() * 100000);
|
||||
const memberEmail = `member+${memberId}@rolechange.test`;
|
||||
|
||||
// Invite and accept a new Employee member
|
||||
await inviteAndAcceptMember(page, browser, 'Jane Smith', memberEmail, 'Employee');
|
||||
|
||||
// Verify the new member appears with the Employee role
|
||||
await goToMembersPage(page);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: 'Jane Smith' });
|
||||
await expect(memberRow).toBeVisible();
|
||||
await expect(memberRow.getByText('Employee', { exact: true })).toBeVisible();
|
||||
|
||||
// Open the edit modal
|
||||
await memberRow.getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Update Member' })).toBeVisible();
|
||||
|
||||
// Change role to Manager
|
||||
const roleSelect = page.getByRole('dialog').getByRole('combobox').first();
|
||||
await roleSelect.click();
|
||||
await expect(page.getByRole('option', { name: 'Manager' })).toBeVisible();
|
||||
await page.getByRole('option', { name: 'Manager' }).click();
|
||||
await expect(roleSelect).toContainText('Manager');
|
||||
|
||||
// Submit the change and verify the API call succeeds
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Member' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/members/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify dialog closed
|
||||
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||
|
||||
// Verify the role updated in the table
|
||||
await expect(memberRow.getByText('Manager', { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that merging a placeholder member works', async ({ page, ctx }) => {
|
||||
const placeholderName = 'Merge Target ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create a placeholder member via import
|
||||
await createPlaceholderMemberViaImportApi(ctx, placeholderName);
|
||||
|
||||
// Go to members page
|
||||
await goToMembersPage(page);
|
||||
await expect(page.getByText(placeholderName)).toBeVisible();
|
||||
|
||||
// Find the placeholder member row and open actions menu
|
||||
const placeholderRow = page.getByRole('row').filter({ hasText: placeholderName });
|
||||
await placeholderRow.getByRole('button').click();
|
||||
|
||||
// Click Merge
|
||||
await page.getByTestId('member_merge').click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Merge Member' })).toBeVisible();
|
||||
|
||||
// Select the current user (the owner) as merge target via MemberCombobox
|
||||
// The MemberCombobox renders a Button as trigger; clicking it opens the popover with the combobox input
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Select a member...' }).click();
|
||||
|
||||
// Wait for dropdown options to load
|
||||
const firstOption = page.getByRole('option').first();
|
||||
await expect(firstOption).toBeVisible({ timeout: 10000 });
|
||||
await firstOption.click();
|
||||
|
||||
// Submit merge
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Merge Member' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/member/') &&
|
||||
response.url().includes('/merge-into') &&
|
||||
response.ok()
|
||||
),
|
||||
]);
|
||||
|
||||
// Wait for merge dialog to close after successful merge
|
||||
await expect(page.getByRole('dialog').filter({ hasText: 'Merge Member' })).not.toBeVisible();
|
||||
|
||||
// Verify placeholder member is no longer in the members table
|
||||
await expect(page.getByRole('main').getByText(placeholderName)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that deleting a placeholder member works', async ({ page, ctx }) => {
|
||||
const placeholderName = 'Delete Target ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create a placeholder member via import
|
||||
await createPlaceholderMemberViaImportApi(ctx, placeholderName);
|
||||
|
||||
// Go to members page
|
||||
await goToMembersPage(page);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: placeholderName });
|
||||
await expect(memberRow).toBeVisible();
|
||||
|
||||
// Open actions menu and click Delete
|
||||
await memberRow.getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Delete').click();
|
||||
|
||||
// Verify delete modal is shown
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Delete Member' })).toBeVisible();
|
||||
|
||||
// Try to delete without checking the confirmation checkbox
|
||||
await page.getByRole('button', { name: 'Delete Member' }).click();
|
||||
|
||||
// Should show validation error
|
||||
await expect(
|
||||
page.getByText('You must confirm that you understand the consequences of this action')
|
||||
).toBeVisible();
|
||||
|
||||
// Check the confirmation checkbox
|
||||
await page.getByRole('checkbox').click();
|
||||
|
||||
// Click Delete Member button and wait for API response
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Delete Member' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/members/') &&
|
||||
response.request().method() === 'DELETE' &&
|
||||
response.ok()
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify modal is closed
|
||||
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||
|
||||
// Verify member is removed from the table
|
||||
await expect(page.getByRole('main').getByText(placeholderName)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that member delete modal can be cancelled', async ({ page, ctx }) => {
|
||||
const placeholderName = 'Delete Cancel ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
// Create a placeholder member via import
|
||||
await createPlaceholderMemberViaImportApi(ctx, placeholderName);
|
||||
|
||||
// Go to members page
|
||||
await goToMembersPage(page);
|
||||
const memberRow = page.getByRole('row').filter({ hasText: placeholderName });
|
||||
await expect(memberRow).toBeVisible();
|
||||
|
||||
// Open actions menu and click Delete
|
||||
await memberRow.getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Delete').click();
|
||||
|
||||
// Verify delete modal is shown
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Set up listener to verify no DELETE request is sent
|
||||
let deleteRequestSent = false;
|
||||
page.on('request', (request) => {
|
||||
if (request.url().includes('/members/') && request.method() === 'DELETE') {
|
||||
deleteRequestSent = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Click Cancel
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
// Verify modal is closed
|
||||
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||
|
||||
// Verify member is still in the table
|
||||
await expect(memberRow).toBeVisible();
|
||||
|
||||
// Verify no DELETE request was sent
|
||||
expect(deleteRequestSent).toBe(false);
|
||||
});
|
||||
|
||||
test('test that organization owner cannot be deleted', async ({ page }) => {
|
||||
await goToMembersPage(page);
|
||||
|
||||
// Find the owner row (John Doe with Owner role)
|
||||
const ownerRow = page.getByRole('row').filter({ hasText: 'Owner' });
|
||||
await expect(ownerRow).toBeVisible();
|
||||
|
||||
// Open the actions menu for the owner
|
||||
await ownerRow.getByRole('button').click();
|
||||
|
||||
// Click Delete
|
||||
await page.getByRole('menuitem').getByText('Delete').click();
|
||||
|
||||
// Verify delete modal is shown
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Check the confirmation checkbox
|
||||
await page.getByRole('checkbox').click();
|
||||
|
||||
// Try to delete - should fail with 400 error
|
||||
const responsePromise = page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/members/') && response.request().method() === 'DELETE'
|
||||
);
|
||||
await page.getByRole('button', { name: 'Delete Member' }).click();
|
||||
const response = await responsePromise;
|
||||
|
||||
// Verify the API returned an error status
|
||||
expect(response.status()).toBe(400);
|
||||
|
||||
// Close the modal by pressing Escape
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
// Refresh and verify the owner is still there
|
||||
await goToMembersPage(page);
|
||||
await expect(page.getByRole('row').filter({ hasText: 'Owner' })).toBeVisible();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Invitations Tab Tests
|
||||
// =============================================
|
||||
|
||||
test('test that invitation shows in invitations tab and can be revoked', async ({ page }) => {
|
||||
const inviteEmail = `invite+${Math.floor(Math.random() * 100000)}@pending.test`;
|
||||
|
||||
await goToMembersPage(page);
|
||||
await openInviteMemberModal(page);
|
||||
|
||||
await page.getByPlaceholder('Member Email').fill(inviteEmail);
|
||||
await page.getByRole('button', { name: 'Employee' }).click();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/invitations') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 204
|
||||
),
|
||||
page.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
]);
|
||||
|
||||
// Wait for modal to close
|
||||
await expect(page.getByPlaceholder('Member Email')).not.toBeVisible();
|
||||
|
||||
// Switch to Invitations tab and verify the invitation is visible
|
||||
await page.getByText('Invitations', { exact: true }).click();
|
||||
await expect(page.getByText(inviteEmail)).toBeVisible();
|
||||
|
||||
// Find and click the actions menu for this invitation
|
||||
const invitationRow = page.locator('tr, [role="row"]').filter({ hasText: inviteEmail });
|
||||
await invitationRow.getByRole('button').click();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/invitations/') &&
|
||||
response.request().method() === 'DELETE' &&
|
||||
response.status() === 204
|
||||
),
|
||||
page.getByRole('menuitem').getByText('Delete').click(),
|
||||
]);
|
||||
|
||||
// Verify invitation is removed
|
||||
await expect(page.getByText(inviteEmail)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that invitation can be resent', async ({ page }) => {
|
||||
const inviteEmail = `resend+${Math.floor(Math.random() * 100000)}@invite.test`;
|
||||
|
||||
await goToMembersPage(page);
|
||||
await openInviteMemberModal(page);
|
||||
|
||||
await page.getByPlaceholder('Member Email').fill(inviteEmail);
|
||||
await page.getByRole('button', { name: 'Employee' }).click();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/invitations') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 204
|
||||
),
|
||||
page.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
]);
|
||||
|
||||
// Wait for modal to close
|
||||
await expect(page.getByPlaceholder('Member Email')).not.toBeVisible();
|
||||
|
||||
// Switch to Invitations tab
|
||||
await page.getByText('Invitations', { exact: true }).click();
|
||||
await expect(page.getByText(inviteEmail)).toBeVisible();
|
||||
|
||||
// Find and click the actions menu, then resend
|
||||
const invitationRow = page.locator('tr, [role="row"]').filter({ hasText: inviteEmail });
|
||||
await invitationRow.getByRole('button').click();
|
||||
// Wait for dropdown menu to appear
|
||||
await expect(page.getByRole('menuitem').getByText('Resend Invitation')).toBeVisible();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/resend') && response.request().method() === 'POST'
|
||||
),
|
||||
page.getByRole('menuitem').getByText('Resend Invitation').click(),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that admin user cannot transfer ownership', async ({ page, browser }) => {
|
||||
const memberId = Math.floor(Math.random() * 100000);
|
||||
const memberEmail = `admin+${memberId}@perms.test`;
|
||||
|
||||
// Invite and accept an admin member
|
||||
await inviteAndAcceptMember(
|
||||
page,
|
||||
browser,
|
||||
'Admin User ' + memberId,
|
||||
memberEmail,
|
||||
'Administrator'
|
||||
);
|
||||
|
||||
// Go to members page and verify the admin exists
|
||||
await goToMembersPage(page);
|
||||
const adminRow = page.getByRole('row').filter({ hasText: 'Admin User' });
|
||||
await expect(adminRow).toBeVisible();
|
||||
|
||||
// The owner should still be the owner
|
||||
const ownerRow = page.getByRole('row').filter({ hasText: 'Owner' });
|
||||
await expect(ownerRow).toBeVisible();
|
||||
|
||||
// Open actions menu for the admin - should NOT have "Transfer Ownership" option
|
||||
await adminRow.getByRole('button').click();
|
||||
await expect(page.getByRole('menuitem').getByText('Edit')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that accepted invitation disappears from invitations tab', async ({ page, browser }) => {
|
||||
const memberId = Math.round(Math.random() * 100000);
|
||||
const memberEmail = `accepted+${memberId}@invite.test`;
|
||||
|
||||
// Invite and accept the member
|
||||
await inviteAndAcceptMember(page, browser, 'Accepted Member', memberEmail, 'Employee');
|
||||
|
||||
// Go to members page and switch to Invitations tab
|
||||
await goToMembersPage(page);
|
||||
await page.getByRole('tab', { name: 'Invitations' }).click();
|
||||
|
||||
// The accepted invitation should not be visible
|
||||
await expect(page.getByText(memberEmail)).not.toBeVisible();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Sidebar Navigation', () => {
|
||||
test('employee sidebar shows correct navigation links', async ({ employee }) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Visible links
|
||||
await expect(employee.page.getByRole('link', { name: 'Dashboard' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('link', { name: 'Time' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('link', { name: 'Calendar' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('link', { name: 'Projects' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('link', { name: 'Clients' })).toBeVisible();
|
||||
await expect(employee.page.getByRole('link', { name: 'Tags' })).toBeVisible();
|
||||
|
||||
// Hidden links
|
||||
await expect(employee.page.getByRole('link', { name: 'Members' })).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.getByRole('link', { name: 'Settings', exact: true })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee cannot see members list or invite members', async ({ employee }) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/members');
|
||||
|
||||
// Page loads but the members API returns 403 (no members:view permission)
|
||||
await expect(employee.page.getByRole('heading', { name: 'Members' })).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Member table is empty — no rows rendered (only headers)
|
||||
await expect(employee.page.getByTestId('client_table').locator('[role="row"]')).toHaveCount(
|
||||
0
|
||||
);
|
||||
|
||||
// Employee should NOT see the Invite Member button
|
||||
await expect(
|
||||
employee.page.getByRole('button', { name: 'Invite member' })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -223,9 +223,177 @@ test('test that format settings are reflected in the dashboard', async ({ page }
|
||||
|
||||
// check that the current date is displayed in the dd/mm/yyyy format on the time page
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
// Wait for time entries to load so organization data is available for date formatting
|
||||
await page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 200
|
||||
);
|
||||
await expect(
|
||||
page.getByText(new Date().toLocaleDateString('en-GB'), { exact: true }).nth(0)
|
||||
).toBeVisible();
|
||||
).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
// TODO: Test 12-hour clock format
|
||||
test('test that organization time entry settings can be toggled', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
|
||||
const preventOverlappingCheckbox = page.getByLabel(
|
||||
'Prevent overlapping time entries (new entries only)'
|
||||
);
|
||||
const manageTasksCheckbox = page.getByLabel('Allow Employees to manage tasks');
|
||||
|
||||
// Get current states and toggle both
|
||||
const wasOverlappingChecked = await preventOverlappingCheckbox.isChecked();
|
||||
const wasManageTasksChecked = await manageTasksCheckbox.isChecked();
|
||||
|
||||
if (wasOverlappingChecked) {
|
||||
await preventOverlappingCheckbox.uncheck();
|
||||
} else {
|
||||
await preventOverlappingCheckbox.check();
|
||||
}
|
||||
|
||||
if (wasManageTasksChecked) {
|
||||
await manageTasksCheckbox.uncheck();
|
||||
} else {
|
||||
await manageTasksCheckbox.check();
|
||||
}
|
||||
|
||||
// Save
|
||||
const settingsForm = page.locator('form').filter({ hasText: 'Prevent overlapping' });
|
||||
await Promise.all([
|
||||
settingsForm.getByRole('button', { name: 'Save' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/organizations/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.prevent_overlapping_time_entries ===
|
||||
!wasOverlappingChecked
|
||||
),
|
||||
]);
|
||||
|
||||
// Reload and verify both settings persisted
|
||||
await page.reload();
|
||||
await expect(preventOverlappingCheckbox).toBeChecked({ checked: !wasOverlappingChecked });
|
||||
await expect(manageTasksCheckbox).toBeChecked({ checked: !wasManageTasksChecked });
|
||||
|
||||
// Toggle both back to restore original state
|
||||
if (!wasOverlappingChecked) {
|
||||
await preventOverlappingCheckbox.uncheck();
|
||||
} else {
|
||||
await preventOverlappingCheckbox.check();
|
||||
}
|
||||
|
||||
if (!wasManageTasksChecked) {
|
||||
await manageTasksCheckbox.uncheck();
|
||||
} else {
|
||||
await manageTasksCheckbox.check();
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
settingsForm.getByRole('button', { name: 'Save' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/organizations/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.prevent_overlapping_time_entries ===
|
||||
wasOverlappingChecked
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that 12-hour clock format can be set', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
|
||||
await page.getByLabel('Time Format').click();
|
||||
await page.getByRole('option', { name: '12-hour clock' }).click();
|
||||
await Promise.all([
|
||||
page
|
||||
.locator('form')
|
||||
.filter({ hasText: 'Time Format' })
|
||||
.getByRole('button', { name: 'Save' })
|
||||
.click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/organizations/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.time_format === '12-hours'
|
||||
),
|
||||
]);
|
||||
|
||||
// Reload and verify it persisted
|
||||
await page.reload();
|
||||
await expect(page.getByLabel('Time Format')).toContainText('12-hour clock');
|
||||
|
||||
// Reset back to 24-hour
|
||||
await page.getByLabel('Time Format').click();
|
||||
await page.getByRole('option', { name: '24-hour clock' }).click();
|
||||
await Promise.all([
|
||||
page
|
||||
.locator('form')
|
||||
.filter({ hasText: 'Time Format' })
|
||||
.getByRole('button', { name: 'Save' })
|
||||
.click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/organizations/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.time_format === '24-hours'
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that format settings persist after page reload', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
|
||||
// Set a specific date format
|
||||
await page.getByLabel('Date Format').click();
|
||||
await page.getByRole('option', { name: 'DD/MM/YYYY' }).click();
|
||||
await Promise.all([
|
||||
page
|
||||
.locator('form')
|
||||
.filter({ hasText: 'Date Format' })
|
||||
.getByRole('button', { name: 'Save' })
|
||||
.click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/organizations/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Reload and verify it persisted
|
||||
await page.reload();
|
||||
await expect(page.getByLabel('Date Format')).toContainText('DD/MM/YYYY');
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Organization Settings Restrictions', () => {
|
||||
test('employee can see org name but not editable settings', async ({ ctx, employee }) => {
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/teams/' + ctx.orgId);
|
||||
|
||||
// Organization Name section is visible (but inputs are disabled)
|
||||
await expect(
|
||||
employee.page.getByRole('heading', { name: 'Organization Name', level: 3 })
|
||||
).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Editable settings sections should NOT be visible
|
||||
await expect(
|
||||
employee.page.getByRole('heading', { name: 'Billable Rate', level: 3 })
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.getByRole('heading', { name: 'Format Settings', level: 3 })
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.getByRole('heading', { name: 'Organization Settings', level: 3 })
|
||||
).not.toBeVisible();
|
||||
|
||||
// Save button should not be visible (employee cannot update)
|
||||
await expect(employee.page.getByRole('button', { name: 'Save' })).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { test, expect } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { PLAYWRIGHT_BASE_URL, TEST_USER_PASSWORD } from '../playwright/config';
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
async function goToProfilePage(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
}
|
||||
|
||||
test('test that user name can be updated', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
@@ -39,6 +44,28 @@ test('test that user can create an API key', async ({ page }) => {
|
||||
await createNewApiToken(page);
|
||||
});
|
||||
|
||||
test('test that creating an API key with empty name shows validation error', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
|
||||
// Wait for the API Key Name input to be visible before interacting
|
||||
const nameInput = page.getByLabel('API Key Name');
|
||||
await expect(nameInput).toBeVisible();
|
||||
|
||||
// Ensure the API Key Name input is empty
|
||||
await nameInput.fill('');
|
||||
|
||||
// Click the create button and wait for the 422 response
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse('**/users/me/api-tokens'),
|
||||
page.getByRole('button', { name: 'Create API Key' }).click(),
|
||||
]);
|
||||
|
||||
expect(response.status()).toBe(422);
|
||||
|
||||
// Verify that an error notification is shown with validation message about the name field
|
||||
await expect(page.getByText('name field is required')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('test that user can delete an API key', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
await createNewApiToken(page);
|
||||
@@ -68,3 +95,254 @@ test('test that user can revoke an API key', async ({ page }) => {
|
||||
await expect(page.locator('body')).toContainText('NEW API KEY');
|
||||
await expect(page.locator('body')).toContainText('Revoked');
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Update Password Form Tests
|
||||
// =============================================
|
||||
|
||||
test('test that password mismatch shows error', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// Fill in with mismatched passwords
|
||||
await page.getByLabel('Current Password').fill(TEST_USER_PASSWORD);
|
||||
await page.getByLabel('New Password').fill('newSecurePassword456');
|
||||
await page.getByLabel('Confirm Password').fill('differentPassword789');
|
||||
|
||||
// Find the form containing the Confirm Password field and click its Save button
|
||||
const passwordForm = page.getByLabel('Confirm Password').locator('xpath=ancestor::form');
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/user/password') && response.request().method() === 'PUT'
|
||||
),
|
||||
passwordForm.getByRole('button', { name: 'Save' }).click(),
|
||||
]);
|
||||
|
||||
// Verify error message about password confirmation
|
||||
await expect(page.getByText('confirmation does not match')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that short password shows validation error', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// Fill in with a too short password
|
||||
await page.getByLabel('Current Password').fill(TEST_USER_PASSWORD);
|
||||
await page.getByLabel('New Password').fill('short');
|
||||
await page.getByLabel('Confirm Password').fill('short');
|
||||
|
||||
// Find the form containing the Confirm Password field and click its Save button
|
||||
const passwordForm = page.getByLabel('Confirm Password').locator('xpath=ancestor::form');
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/user/password') && response.request().method() === 'PUT'
|
||||
),
|
||||
passwordForm.getByRole('button', { name: 'Save' }).click(),
|
||||
]);
|
||||
|
||||
// Verify error message about password length
|
||||
await expect(page.getByText('must be at least')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that incorrect current password shows validation error', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// Fill in with wrong current password
|
||||
await page.getByLabel('Current Password').fill('wrongCurrentPassword123');
|
||||
await page.getByLabel('New Password').fill('newSecurePassword456');
|
||||
await page.getByLabel('Confirm Password').fill('newSecurePassword456');
|
||||
|
||||
// Find the form containing the Confirm Password field and click its Save button
|
||||
const passwordForm = page.getByLabel('Confirm Password').locator('xpath=ancestor::form');
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/user/password') && response.request().method() === 'PUT'
|
||||
),
|
||||
passwordForm.getByRole('button', { name: 'Save' }).click(),
|
||||
]);
|
||||
|
||||
// Verify error message about incorrect password
|
||||
await expect(page.getByText('does not match')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that password can be updated successfully', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
const newPassword = 'newSecurePassword456';
|
||||
|
||||
// Change password to new password
|
||||
await page.getByLabel('Current Password').fill(TEST_USER_PASSWORD);
|
||||
await page.getByLabel('New Password').fill(newPassword);
|
||||
await page.getByLabel('Confirm Password').fill(newPassword);
|
||||
|
||||
const passwordForm = page.getByLabel('Confirm Password').locator('xpath=ancestor::form');
|
||||
const responsePromise = page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/user/password') && response.request().method() === 'PUT'
|
||||
);
|
||||
await passwordForm.getByRole('button', { name: 'Save' }).click();
|
||||
const response = await responsePromise;
|
||||
|
||||
// Verify successful response (303 is Inertia redirect on success, means password was updated)
|
||||
expect(response.status()).toBe(303);
|
||||
|
||||
// Verify no error messages are displayed
|
||||
await expect(page.getByText('does not match')).not.toBeVisible();
|
||||
await expect(page.getByText('must be at least')).not.toBeVisible();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Theme Selection Tests
|
||||
// =============================================
|
||||
|
||||
test('test that theme can be changed to dark and light', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// The theme select is a Reka UI combobox (button), not a native <select>
|
||||
const themeSelect = page.locator('button[role="combobox"]');
|
||||
|
||||
// Change theme to dark
|
||||
await themeSelect.click();
|
||||
await page.getByRole('option', { name: 'Dark' }).click();
|
||||
|
||||
// Verify the html element has 'dark' class
|
||||
await expect(page.locator('html')).toHaveClass(/dark/);
|
||||
|
||||
// Change theme to light
|
||||
await themeSelect.click();
|
||||
await page.getByRole('option', { name: 'Light' }).click();
|
||||
|
||||
// Verify the html element has 'light' class and no 'dark' class
|
||||
await expect(page.locator('html')).toHaveClass(/light/);
|
||||
await expect(page.locator('html')).not.toHaveClass(/dark/);
|
||||
|
||||
// Verify localStorage persists the setting
|
||||
const storedTheme = await page.evaluate(() => localStorage.getItem('theme'));
|
||||
expect(storedTheme).toContain('light');
|
||||
|
||||
// Reload and verify the theme persists
|
||||
await page.reload();
|
||||
await expect(page.locator('html')).toHaveClass(/light/);
|
||||
|
||||
// Reset to system
|
||||
await page.locator('button[role="combobox"]').click();
|
||||
await page.getByRole('option', { name: 'System' }).click();
|
||||
await expect(page.getByText('System default:')).toBeVisible();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Two Factor Authentication Tests
|
||||
// =============================================
|
||||
|
||||
test('test that password confirmation modal can be cancelled without sending API request', async ({
|
||||
page,
|
||||
}) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// Find the Enable button in the 2FA section
|
||||
const enableButton = page
|
||||
.getByText('You have not enabled two factor authentication.')
|
||||
.locator('..')
|
||||
.getByRole('button', { name: 'Enable' });
|
||||
await enableButton.click();
|
||||
|
||||
// Verify password confirmation modal appears
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Set up listener to verify no POST request is sent to confirm-password
|
||||
let confirmPasswordRequestSent = false;
|
||||
page.on('request', (request) => {
|
||||
if (request.url().includes('/user/confirm-password') && request.method() === 'POST') {
|
||||
confirmPasswordRequestSent = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Click Cancel
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
// Verify modal is closed
|
||||
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||
|
||||
// Verify no confirm-password request was sent
|
||||
expect(confirmPasswordRequestSent).toBe(false);
|
||||
});
|
||||
|
||||
test('test that password confirmation modal shows error for incorrect password', async ({
|
||||
page,
|
||||
}) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// Find the Enable button in the 2FA section
|
||||
const enableButton = page
|
||||
.getByText('You have not enabled two factor authentication.')
|
||||
.locator('..')
|
||||
.getByRole('button', { name: 'Enable' });
|
||||
await enableButton.click();
|
||||
|
||||
// Verify password confirmation modal appears
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Enter incorrect password and confirm
|
||||
await page.getByPlaceholder('Password').fill('wrongpassword123');
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Confirm' }).click();
|
||||
|
||||
// Should show error message (wait longer for API response)
|
||||
await expect(page.getByRole('dialog').getByText('incorrect')).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
test('test that 2FA can be enabled with correct password', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
// Verify 2FA is not enabled
|
||||
await expect(page.getByText('You have not enabled two factor authentication.')).toBeVisible();
|
||||
|
||||
// Find the Enable button in the 2FA section
|
||||
const enableButton = page
|
||||
.getByText('You have not enabled two factor authentication.')
|
||||
.locator('..')
|
||||
.getByRole('button', { name: 'Enable' });
|
||||
await enableButton.click();
|
||||
|
||||
// Verify password confirmation modal appears
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
// Enter correct password and confirm
|
||||
await page.getByPlaceholder('Password').fill(TEST_USER_PASSWORD);
|
||||
await Promise.all([
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Confirm' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/user/two-factor-authentication') &&
|
||||
response.request().method() === 'POST'
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify QR code is shown
|
||||
await expect(page.getByRole('heading', { name: 'Finish enabling two factor' })).toBeVisible();
|
||||
await expect(page.getByText('Setup Key:')).toBeVisible();
|
||||
await expect(page.getByLabel('Code')).toBeVisible();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Logout Other Browser Sessions Tests
|
||||
// =============================================
|
||||
|
||||
test('test that logout other browser sessions works with correct password', async ({ page }) => {
|
||||
await goToProfilePage(page);
|
||||
|
||||
await page.getByRole('button', { name: 'Log Out Other Browser Sessions' }).click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
await page.getByPlaceholder('Password').fill(TEST_USER_PASSWORD);
|
||||
await Promise.all([
|
||||
page
|
||||
.getByRole('dialog')
|
||||
.getByRole('button', { name: 'Log Out Other Browser Sessions' })
|
||||
.click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/user/other-browser-sessions') &&
|
||||
response.request().method() === 'DELETE'
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import { formatCentsWithOrganizationDefaults } from './utils/money';
|
||||
import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money';
|
||||
import { NumberFormat } from '@/packages/ui/src/utils/number';
|
||||
import { createProjectViaApi, createProjectMemberViaApi, type TestContext } from './utils/api';
|
||||
|
||||
async function goToProjectsOverview(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
async function createProjectWithMemberViaApi(ctx: TestContext, page: Page, projectName: string) {
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createProjectMemberViaApi(ctx, project.id, { member_id: ctx.memberId });
|
||||
|
||||
// Navigate to the project detail page
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
|
||||
await expect(page.getByTestId('project_member_table').getByRole('row').first()).toBeVisible();
|
||||
return project;
|
||||
}
|
||||
|
||||
test('test that updating project member billable rate works for existing time entries', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newBillableRate = Math.round(Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||
|
||||
await page.getByText(newProjectName).click();
|
||||
await page.getByRole('button', { name: 'Add Member' }).click();
|
||||
|
||||
await expect(page.getByText('Add Project Member').first()).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Select a member' }).click();
|
||||
await page.keyboard.press('Enter');
|
||||
await page.getByRole('button', { name: 'Add Project Member' }).click();
|
||||
await createProjectWithMemberViaApi(ctx, page, newProjectName);
|
||||
|
||||
await page
|
||||
.getByTestId('project_member_table')
|
||||
@@ -62,3 +56,197 @@ test('test that updating project member billable rate works for existing time en
|
||||
.getByText(formatCentsWithOrganizationDefaults(newBillableRate * 100))
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that project member edit modal can be cancelled without sending API request', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'Cancel Test ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createProjectWithMemberViaApi(ctx, page, projectName);
|
||||
|
||||
// Open the edit modal
|
||||
await page
|
||||
.getByTestId('project_member_table')
|
||||
.getByRole('row')
|
||||
.first()
|
||||
.getByRole('button')
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Edit Project Member' }).click();
|
||||
|
||||
// Verify the modal is open and shows the member name
|
||||
await expect(page.getByRole('heading', { name: 'Edit Project Member' })).toBeVisible();
|
||||
await expect(page.getByRole('dialog').getByText('John Doe')).toBeVisible();
|
||||
|
||||
// Enter a new billable rate
|
||||
await page.getByLabel('Billable Rate').fill('999');
|
||||
|
||||
// Set up listener to verify no PUT request is sent
|
||||
let putRequestSent = false;
|
||||
page.on('request', (request) => {
|
||||
if (request.url().includes('/project-members/') && request.method() === 'PUT') {
|
||||
putRequestSent = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Click Cancel
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
// Verify the modal is closed
|
||||
await expect(page.getByRole('heading', { name: 'Edit Project Member' })).not.toBeVisible();
|
||||
|
||||
// Verify no PUT request was sent
|
||||
expect(putRequestSent).toBe(false);
|
||||
});
|
||||
|
||||
test('test that project member update without billable rate change skips confirmation and completes', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'No Change ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createProjectWithMemberViaApi(ctx, page, projectName);
|
||||
|
||||
// Open the edit modal
|
||||
await page
|
||||
.getByTestId('project_member_table')
|
||||
.getByRole('row')
|
||||
.first()
|
||||
.getByRole('button')
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Edit Project Member' }).click();
|
||||
|
||||
// Click Update without changing anything - no confirmation modal since rate didn't change
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/project-members/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Project Member' }).click(),
|
||||
]);
|
||||
|
||||
// Verify the edit modal is closed (confirmation modal was skipped)
|
||||
await expect(page.getByRole('heading', { name: 'Edit Project Member' })).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that billable rate confirmation modal can be cancelled without sending API request', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'Rate Cancel ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newBillableRate = Math.round(Math.random() * 10000);
|
||||
|
||||
await createProjectWithMemberViaApi(ctx, page, projectName);
|
||||
|
||||
// Open the edit modal
|
||||
await page
|
||||
.getByTestId('project_member_table')
|
||||
.getByRole('row')
|
||||
.first()
|
||||
.getByRole('button')
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Edit Project Member' }).click();
|
||||
|
||||
// Change the billable rate
|
||||
await page.getByLabel('Billable Rate').fill(newBillableRate.toString());
|
||||
|
||||
// Set up listener to verify no PUT request is sent
|
||||
let putRequestSent = false;
|
||||
page.on('request', (request) => {
|
||||
if (request.url().includes('/project-members/') && request.method() === 'PUT') {
|
||||
putRequestSent = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Click Update - this should show the confirmation modal
|
||||
await page.getByRole('button', { name: 'Update Project Member' }).click();
|
||||
|
||||
// Verify the confirmation modal is shown
|
||||
await expect(page.getByText('update all existing time entries')).toBeVisible();
|
||||
|
||||
// Click Cancel to close the confirmation modal without updating
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
// Verify the confirmation modal is closed but edit modal is still open
|
||||
await expect(page.getByText('update all existing time entries')).not.toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Edit Project Member' })).toBeVisible();
|
||||
|
||||
// Close the edit modal
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
// Verify the edit modal is closed
|
||||
await expect(page.getByRole('heading', { name: 'Edit Project Member' })).not.toBeVisible();
|
||||
|
||||
// Verify no PUT request was sent
|
||||
expect(putRequestSent).toBe(false);
|
||||
});
|
||||
|
||||
test('test that clearing billable rate reverts to project default', async ({ page, ctx }) => {
|
||||
const projectName = 'Revert Default ' + Math.floor(1 + Math.random() * 10000);
|
||||
const customRate = Math.round(100 + Math.random() * 10000);
|
||||
|
||||
await createProjectWithMemberViaApi(ctx, page, projectName);
|
||||
|
||||
// Verify the billable rate shows "--" (project default) initially
|
||||
await expect(
|
||||
page.getByTestId('project_member_table').getByRole('row').first().getByText('--')
|
||||
).toBeVisible();
|
||||
|
||||
// Set a custom billable rate
|
||||
await page
|
||||
.getByTestId('project_member_table')
|
||||
.getByRole('row')
|
||||
.first()
|
||||
.getByRole('button')
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Edit Project Member' }).click();
|
||||
await page.getByLabel('Billable Rate').fill(customRate.toString());
|
||||
await page.getByRole('button', { name: 'Update Project Member' }).click();
|
||||
|
||||
// Confirm the billable rate update
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Yes, update existing time' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/project-members/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify the custom rate is shown in the table (not "--")
|
||||
await expect(
|
||||
page.getByTestId('project_member_table').getByRole('row').first().getByText('--')
|
||||
).not.toBeVisible();
|
||||
|
||||
// Now clear the billable rate to revert to project default
|
||||
await page
|
||||
.getByTestId('project_member_table')
|
||||
.getByRole('row')
|
||||
.first()
|
||||
.getByRole('button')
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Edit Project Member' }).click();
|
||||
|
||||
// Set billable rate to 0 to revert to project default
|
||||
await page.getByLabel('Billable Rate').fill('0');
|
||||
await page.getByRole('button', { name: 'Update Project Member' }).click();
|
||||
|
||||
// Confirm the billable rate update
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Yes, update existing time' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/project-members/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify the billable rate shows "--" again (project default)
|
||||
await expect(
|
||||
page.getByTestId('project_member_table').getByRole('row').first().getByText('--')
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import { formatCentsWithOrganizationDefaults } from './utils/money';
|
||||
import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money';
|
||||
import {
|
||||
createProjectViaApi,
|
||||
createPublicProjectViaApi,
|
||||
createTaskViaApi,
|
||||
updateOrganizationSettingViaApi,
|
||||
} from './utils/api';
|
||||
|
||||
async function goToProjectsOverview(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
@@ -37,7 +44,7 @@ test('test that creating and deleting a new project via the modal works', async
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
const moreButton = page.locator("[aria-label='Actions for Project " + newProjectName + "']");
|
||||
moreButton.click();
|
||||
await moreButton.click();
|
||||
const deleteButton = page.locator("[aria-label='Delete Project " + newProjectName + "']");
|
||||
|
||||
await Promise.all([
|
||||
@@ -69,17 +76,14 @@ async function removeStatusFilter(page: Page) {
|
||||
await statusBadge.locator('button').last().click();
|
||||
}
|
||||
|
||||
test('test that archiving and unarchiving projects works', async ({ page }) => {
|
||||
test('test that archiving and unarchiving projects works', async ({ page, ctx }) => {
|
||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await createProjectViaApi(ctx, { name: newProjectName });
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await clearProjectTableState(page);
|
||||
await page.reload();
|
||||
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Archive the project
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
@@ -110,20 +114,25 @@ test('test that archiving and unarchiving projects works', async ({ page }) => {
|
||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that updating billable rate works with existing time entries', async ({ page }) => {
|
||||
test('test that updating billable rate works with existing time entries', async ({ page, ctx }) => {
|
||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newBillableRate = Math.round(Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
await createProjectViaApi(ctx, { name: newProjectName });
|
||||
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
await page.getByText('Non-Billable').click();
|
||||
await page.getByText('Custom Rate').click();
|
||||
|
||||
// Set billable default to Billable
|
||||
await page.getByRole('dialog').locator('#billable').click();
|
||||
await page.getByRole('option', { name: 'Billable', exact: true }).click();
|
||||
|
||||
// Set billable rate to Custom Rate
|
||||
await page.getByRole('dialog').locator('#billableRateType').click();
|
||||
await page.getByRole('option', { name: 'Custom Rate' }).click();
|
||||
|
||||
await page.getByPlaceholder('Billable Rate').fill(newBillableRate.toString());
|
||||
await page.getByRole('button', { name: 'Update Project' }).click();
|
||||
|
||||
@@ -151,6 +160,180 @@ test('test that updating billable rate works with existing time entries', async
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that creating a project with default billable rate works', async ({ page }) => {
|
||||
const newProjectName = 'Default Rate Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
// Set billable default to Billable (leaves rate type as Default Rate)
|
||||
await page.getByRole('dialog').locator('#billable').click();
|
||||
await page.getByRole('option', { name: 'Billable', exact: true }).click();
|
||||
|
||||
// Verify rate type is "Default Rate" and the rate input is disabled
|
||||
await expect(page.getByRole('dialog').locator('#billableRateType')).toContainText(
|
||||
'Default Rate'
|
||||
);
|
||||
await expect(page.getByPlaceholder('Billable Rate')).toBeDisabled();
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
(await response.json()).data.is_billable === true &&
|
||||
(await response.json()).data.billable_rate === null
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
});
|
||||
|
||||
test('test that creating a non-billable project works', async ({ page }) => {
|
||||
const newProjectName = 'Non-Billable Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
// Billable default should already be "Non-billable" by default
|
||||
await expect(page.getByRole('dialog').locator('#billable')).toContainText('Non-billable');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
(await response.json()).data.is_billable === false &&
|
||||
(await response.json()).data.billable_rate === null
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
});
|
||||
|
||||
test('test that switching from custom rate to default rate clears billable rate', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const newProjectName = 'Rate Switch Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
// Create a project with an existing custom billable rate
|
||||
await createProjectViaApi(ctx, {
|
||||
name: newProjectName,
|
||||
is_billable: true,
|
||||
billable_rate: 15000,
|
||||
});
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
|
||||
// Verify it loaded as Billable with Custom Rate
|
||||
await expect(page.getByRole('dialog').locator('#billable')).toContainText('Billable');
|
||||
await expect(page.getByRole('dialog').locator('#billableRateType')).toContainText(
|
||||
'Custom Rate'
|
||||
);
|
||||
|
||||
// Switch to Default Rate
|
||||
await page.getByRole('dialog').locator('#billableRateType').click();
|
||||
await page.getByRole('option', { name: 'Default Rate' }).click();
|
||||
|
||||
// Rate input should now be disabled
|
||||
await expect(page.getByPlaceholder('Billable Rate')).toBeDisabled();
|
||||
|
||||
// Submit — billable_rate changes from 15000 to null, so confirmation dialog appears
|
||||
await page.getByRole('button', { name: 'Update Project' }).click();
|
||||
await Promise.all([
|
||||
page.locator('button').filter({ hasText: 'Yes, update existing time' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.is_billable === true &&
|
||||
(await response.json()).data.billable_rate === null
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that switching from billable to non-billable preserves rate settings', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const newProjectName = 'Billable Reset Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
// Create a project with a custom billable rate
|
||||
await createProjectViaApi(ctx, {
|
||||
name: newProjectName,
|
||||
is_billable: true,
|
||||
billable_rate: 20000,
|
||||
});
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
|
||||
// Verify it loaded correctly as Billable with Custom Rate
|
||||
await expect(page.getByRole('dialog').locator('#billable')).toContainText('Billable');
|
||||
await expect(page.getByRole('dialog').locator('#billableRateType')).toContainText(
|
||||
'Custom Rate'
|
||||
);
|
||||
|
||||
// Switch to Non-billable
|
||||
await page.getByRole('dialog').locator('#billable').click();
|
||||
await page.getByRole('option', { name: 'Non-billable' }).click();
|
||||
|
||||
// Rate type should still be Custom Rate (not reset)
|
||||
await expect(page.getByRole('dialog').locator('#billableRateType')).toContainText(
|
||||
'Custom Rate'
|
||||
);
|
||||
|
||||
// Submit and verify project is non-billable but keeps its custom rate
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
(await response.json()).data.is_billable === false &&
|
||||
(await response.json()).data.billable_rate === 20000
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that editing an existing billable project with default rate loads correctly', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const newProjectName = 'Default Rate Edit Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
// Create a project that is billable but has no custom rate (= default rate)
|
||||
await createProjectViaApi(ctx, {
|
||||
name: newProjectName,
|
||||
is_billable: true,
|
||||
billable_rate: null,
|
||||
});
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
|
||||
// Verify it loaded as Billable with Default Rate
|
||||
await expect(page.getByRole('dialog').locator('#billable')).toContainText('Billable');
|
||||
await expect(page.getByRole('dialog').locator('#billableRateType')).toContainText(
|
||||
'Default Rate'
|
||||
);
|
||||
await expect(page.getByPlaceholder('Billable Rate')).toBeDisabled();
|
||||
});
|
||||
|
||||
// Sorting tests
|
||||
test('test that sorting projects by name works', async ({ page }) => {
|
||||
await goToProjectsOverview(page);
|
||||
@@ -183,15 +366,14 @@ test('test that sorting projects by name works', async ({ page }) => {
|
||||
const nameHeader = page.getByText('Name').first();
|
||||
await nameHeader.click();
|
||||
|
||||
// Wait for sort to apply
|
||||
await page.waitForTimeout(100);
|
||||
// Wait for sort indicator to appear
|
||||
await expect(nameHeader.locator('svg')).toBeVisible();
|
||||
|
||||
// Click again to sort descending
|
||||
await nameHeader.click();
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
// Verify the sort indicator is showing descending
|
||||
await expect(page.locator('svg').first()).toBeVisible();
|
||||
// Verify the sort indicator is still visible (showing descending)
|
||||
await expect(nameHeader.locator('svg')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that sorting projects by status works', async ({ page }) => {
|
||||
@@ -206,25 +388,19 @@ test('test that sorting projects by status works', async ({ page }) => {
|
||||
const statusHeader = page.getByText('Status').first();
|
||||
await statusHeader.click();
|
||||
|
||||
// Wait for sort to apply
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
// Sort indicator should be visible
|
||||
await expect(statusHeader.locator('svg')).toBeVisible();
|
||||
});
|
||||
|
||||
// Filter tests
|
||||
test('test that filtering projects by status works', async ({ page }) => {
|
||||
test('test that filtering projects by status works', async ({ page, ctx }) => {
|
||||
const newProjectName = 'Filter Test Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await createProjectViaApi(ctx, { name: newProjectName });
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await clearProjectTableState(page);
|
||||
await page.reload();
|
||||
|
||||
// Create a new project
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Archive the project
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
@@ -262,9 +438,6 @@ test('test that filter state persists after page reload', async ({ page }) => {
|
||||
// Verify the filter badge is visible
|
||||
await expect(page.getByTestId('status-filter-badge')).toBeVisible();
|
||||
|
||||
// Wait for the state to be saved
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
// Reload the page
|
||||
await page.reload();
|
||||
|
||||
@@ -280,11 +453,9 @@ test('test that sort state persists after page reload', async ({ page }) => {
|
||||
// Click on Name header twice to sort descending
|
||||
const nameHeader = page.getByText('Name').first();
|
||||
await nameHeader.click();
|
||||
await expect(nameHeader.locator('svg')).toBeVisible();
|
||||
await nameHeader.click();
|
||||
|
||||
// Wait for the state to be saved
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
// Reload the page
|
||||
await page.reload();
|
||||
|
||||
@@ -292,6 +463,185 @@ test('test that sort state persists after page reload', async ({ page }) => {
|
||||
await expect(page.getByTestId('project_table')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that custom billable rate is displayed correctly on project detail page', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const newProjectName = 'Billable Rate Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newBillableRate = Math.round(10 + Math.random() * 1000);
|
||||
await createProjectViaApi(ctx, { name: newProjectName });
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Edit the project to set a custom billable rate
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
|
||||
// Set billable default to Billable
|
||||
await page.getByRole('dialog').locator('#billable').click();
|
||||
await page.getByRole('option', { name: 'Billable', exact: true }).click();
|
||||
|
||||
// Set billable rate to Custom Rate
|
||||
await page.getByRole('dialog').locator('#billableRateType').click();
|
||||
await page.getByRole('option', { name: 'Custom Rate' }).click();
|
||||
|
||||
await page.getByPlaceholder('Billable Rate').fill(newBillableRate.toString());
|
||||
await page.getByRole('button', { name: 'Update Project' }).click();
|
||||
|
||||
await Promise.all([
|
||||
page.locator('button').filter({ hasText: 'Yes, update existing time' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Navigate to the project detail page by clicking the project name
|
||||
await page.getByText(newProjectName).first().click();
|
||||
await page.waitForURL(/\/projects\/[a-f0-9-]+/);
|
||||
|
||||
// Verify the badge displays the correctly formatted billable rate
|
||||
const expectedFormattedRate = formatCentsWithOrganizationDefaults(newBillableRate * 100);
|
||||
await expect(page.locator('nav[aria-label="Breadcrumb"]').locator('..')).toContainText(
|
||||
expectedFormattedRate
|
||||
);
|
||||
});
|
||||
|
||||
// Tests for estimated time input (Issue #460)
|
||||
test('test that creating a project with estimated time in human-readable format works', async ({
|
||||
page,
|
||||
}) => {
|
||||
const newProjectName = 'Estimated Time Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
// Fill in estimated time using human-readable format
|
||||
const estimatedTimeInput = page.getByPlaceholder('e.g. 2h 30m or 1.5');
|
||||
await estimatedTimeInput.fill('2h 30m');
|
||||
await estimatedTimeInput.press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
// 2h 30m = 9000 seconds
|
||||
(await response.json()).data.estimated_time === 9000
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
});
|
||||
|
||||
test('test that creating a project with estimated time using decimal notation works', async ({
|
||||
page,
|
||||
}) => {
|
||||
const newProjectName = 'Decimal Estimated Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
// Fill in estimated time using decimal notation (1.5 hours = 1h 30m)
|
||||
const estimatedTimeInput = page.getByPlaceholder('e.g. 2h 30m or 1.5');
|
||||
await estimatedTimeInput.fill('1.5');
|
||||
await estimatedTimeInput.press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
// 1.5 hours = 5400 seconds
|
||||
(await response.json()).data.estimated_time === 5400
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
});
|
||||
|
||||
test('test that creating a project with estimated time using comma decimal notation works', async ({
|
||||
page,
|
||||
}) => {
|
||||
const newProjectName = 'Comma Decimal Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
// Fill in estimated time using comma decimal notation (2,5 hours = 2h 30m)
|
||||
const estimatedTimeInput = page.getByPlaceholder('e.g. 2h 30m or 1.5');
|
||||
await estimatedTimeInput.fill('2,5');
|
||||
await estimatedTimeInput.press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
// 2.5 hours = 9000 seconds
|
||||
(await response.json()).data.estimated_time === 9000
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
});
|
||||
|
||||
test('test that updating estimated time on existing project works', async ({ page, ctx }) => {
|
||||
const newProjectName = 'Update Estimated Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await createProjectViaApi(ctx, { name: newProjectName });
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(newProjectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Edit the project to add estimated time
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||
|
||||
// Fill in estimated time
|
||||
const estimatedTimeInput = page.getByPlaceholder('e.g. 2h 30m or 1.5');
|
||||
await estimatedTimeInput.fill('4h 15m');
|
||||
await estimatedTimeInput.press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200 &&
|
||||
// 4h 15m = 15300 seconds
|
||||
(await response.json()).data.estimated_time === 15300
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('test that estimated time input displays formatted value after blur', async ({ page }) => {
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
|
||||
const estimatedTimeInput = page.getByPlaceholder('e.g. 2h 30m or 1.5');
|
||||
|
||||
// Enter time in various formats and check the displayed value
|
||||
await estimatedTimeInput.fill('90');
|
||||
await estimatedTimeInput.press('Tab');
|
||||
// 90 hours should be displayed as "90h 00min" (default format)
|
||||
await expect(estimatedTimeInput).toHaveValue(/90h/);
|
||||
|
||||
await estimatedTimeInput.fill('1:30');
|
||||
await estimatedTimeInput.press('Tab');
|
||||
// 1:30 should be displayed as "1h 30min"
|
||||
await expect(estimatedTimeInput).toHaveValue(/1h.*30/);
|
||||
});
|
||||
|
||||
// Create new project with new Client
|
||||
|
||||
// Create new project with existing Client
|
||||
@@ -308,4 +658,133 @@ test('test that sort state persists after page reload', async ({ page }) => {
|
||||
|
||||
// Edit Project Member Billable Rate
|
||||
|
||||
// Edit Task Name
|
||||
test('test that editing a task name on the project detail page works', async ({ page, ctx }) => {
|
||||
const projectName = 'Task Edit Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const originalTaskName = 'Original Task ' + Math.floor(1 + Math.random() * 10000);
|
||||
const updatedTaskName = 'Updated Task ' + Math.floor(1 + Math.random() * 10000);
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTaskViaApi(ctx, { name: originalTaskName, project_id: project.id });
|
||||
|
||||
// Navigate to the project detail page
|
||||
await goToProjectsOverview(page);
|
||||
await expect(page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
await page.getByText(projectName).first().click();
|
||||
await page.waitForURL(/\/projects\/[a-f0-9-]+/);
|
||||
|
||||
// Verify task is visible
|
||||
await expect(page.getByTestId('task_table')).toContainText(originalTaskName);
|
||||
|
||||
// Open edit modal via actions menu
|
||||
const moreButton = page.locator("[aria-label='Actions for Task " + originalTaskName + "']");
|
||||
await moreButton.click();
|
||||
await page.getByTestId('task_edit').click();
|
||||
|
||||
// Update the task name
|
||||
await page.locator('#taskName').fill(updatedTaskName);
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Task' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/tasks') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify updated name is shown and old name is gone
|
||||
await expect(page.getByTestId('task_table')).toContainText(updatedTaskName);
|
||||
await expect(page.getByTestId('task_table')).not.toContainText(originalTaskName);
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Projects Restrictions', () => {
|
||||
test('employee can view public projects but cannot create', async ({ ctx, employee }) => {
|
||||
const projectName = 'EmpViewProj ' + Math.floor(Math.random() * 10000);
|
||||
await createPublicProjectViaApi(ctx, { name: projectName });
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(employee.page.getByTestId('projects_view')).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Employee can see the public project
|
||||
await expect(employee.page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Employee cannot see Create Project button
|
||||
await expect(
|
||||
employee.page.getByRole('button', { name: 'Create Project' })
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee cannot see edit/delete/archive actions on projects', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
const projectName = 'EmpActionsProj ' + Math.floor(Math.random() * 10000);
|
||||
await createPublicProjectViaApi(ctx, { name: projectName });
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(employee.page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Click the actions dropdown trigger to open the menu
|
||||
const actionsButton = employee.page.locator(
|
||||
`[aria-label='Actions for Project ${projectName}']`
|
||||
);
|
||||
await actionsButton.click();
|
||||
|
||||
// The dropdown menu items (Edit, Archive, Delete) should NOT be visible
|
||||
await expect(
|
||||
employee.page.locator(`[aria-label='Edit Project ${projectName}']`)
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.locator(`[aria-label='Archive Project ${projectName}']`)
|
||||
).not.toBeVisible();
|
||||
await expect(
|
||||
employee.page.locator(`[aria-label='Delete Project ${projectName}']`)
|
||||
).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Employee Billable Rate Visibility', () => {
|
||||
test('employee cannot see billable rate column by default', async ({ ctx, employee }) => {
|
||||
const projectName = 'EmpBillableProj ' + Math.floor(Math.random() * 10000);
|
||||
await createPublicProjectViaApi(ctx, {
|
||||
name: projectName,
|
||||
is_billable: true,
|
||||
billable_rate: 15000,
|
||||
});
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(employee.page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Billable Rate column should not be visible to employee by default
|
||||
await expect(employee.page.getByText('Billable Rate')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee can see billable rate column when employees_can_see_billable_rates is enabled', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
await updateOrganizationSettingViaApi(ctx, { employees_can_see_billable_rates: true });
|
||||
|
||||
const projectName = 'EmpBillableVisProj ' + Math.floor(Math.random() * 10000);
|
||||
await createPublicProjectViaApi(ctx, {
|
||||
name: projectName,
|
||||
is_billable: true,
|
||||
billable_rate: 20000,
|
||||
});
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(employee.page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Billable Rate column header should be visible
|
||||
await expect(employee.page.getByText('Billable Rate')).toBeVisible();
|
||||
|
||||
// The project row should show the formatted billable rate
|
||||
const projectRow = employee.page.getByRole('row').filter({ hasText: projectName });
|
||||
await expect(projectRow).toContainText('200');
|
||||
});
|
||||
});
|
||||
|
||||
719
e2e/reporting-detailed.spec.ts
Normal file
719
e2e/reporting-detailed.spec.ts
Normal file
@@ -0,0 +1,719 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import { goToReportingDetailed, waitForDetailedReportingUpdate } from './utils/reporting';
|
||||
import {
|
||||
createProjectViaApi,
|
||||
createClientViaApi,
|
||||
createTaskViaApi,
|
||||
createTimeEntryViaApi,
|
||||
createTimeEntryWithTagViaApi,
|
||||
createBareTimeEntryViaApi,
|
||||
} from './utils/api';
|
||||
|
||||
// Each test registers a new user and creates test data via API
|
||||
test.describe.configure({ timeout: 30000 });
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Basic Detailed View Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that detailed view shows time entries correctly', async ({ page, ctx }) => {
|
||||
const projectName = 'Detailed View Project ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
// Go to detailed reporting view
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
// Verify the time entry is shown with all details
|
||||
await expect(page.getByText(projectName, { exact: true }).first()).toBeVisible();
|
||||
await expect(page.locator('input[name="Duration"]').first()).toHaveValue('1h 00min');
|
||||
await expect(page.getByText('Entry for ' + projectName, { exact: true }).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that updating duration in detailed view works correctly', async ({ page, ctx }) => {
|
||||
const projectName = 'Duration Update Project ' + Math.floor(Math.random() * 10000);
|
||||
const initialDuration = '1h';
|
||||
const updatedDuration = '2h 30min';
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: initialDuration,
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
// Go to detailed reporting view
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
// Find and update the duration
|
||||
const durationInput = page.locator('input[name="Duration"]').first();
|
||||
await durationInput.click();
|
||||
await durationInput.fill(updatedDuration);
|
||||
await Promise.all([
|
||||
durationInput.press('Enter'),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Verify the new duration is displayed
|
||||
await expect(durationInput).toHaveValue(updatedDuration);
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Project Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that project multiselect filters work on detailed reporting page', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const project1 = 'DetailProj1 ' + Math.floor(Math.random() * 10000);
|
||||
const project2 = 'DetailProj2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1 });
|
||||
const p2 = await createProjectViaApi(ctx, { name: project2 });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project2}`,
|
||||
duration: '2h',
|
||||
projectId: p2.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
// Wait for initial data load
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project2}`).first()).toBeVisible();
|
||||
|
||||
// Open project multiselect and select project1
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: project1 }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Verify only project1 entry is shown
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project2}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Client Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that client multiselect filters work on detailed reporting page', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const client1 = 'DetailClient1 ' + Math.floor(Math.random() * 10000);
|
||||
const project1 = 'DetailClientProj1 ' + Math.floor(Math.random() * 10000);
|
||||
const project2 = 'DetailClientProj2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const c1 = await createClientViaApi(ctx, { name: client1 });
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1, client_id: c1.id });
|
||||
const p2 = await createProjectViaApi(ctx, { name: project2 });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project2}`,
|
||||
duration: '2h',
|
||||
projectId: p2.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project2}`).first()).toBeVisible();
|
||||
|
||||
// Filter by client1
|
||||
await page.getByRole('button', { name: 'Clients' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: client1 }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Only entries for project1 (with client1) should be visible
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project2}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Task Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that task multiselect dropdown filters reporting by task', async ({ page, ctx }) => {
|
||||
const projectName = 'TaskFilterProj ' + Math.floor(Math.random() * 10000);
|
||||
const task1 = 'TaskFilter1 ' + Math.floor(Math.random() * 10000);
|
||||
const task2 = 'TaskFilter2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
const t1 = await createTaskViaApi(ctx, { name: task1, project_id: project.id });
|
||||
const t2 = await createTaskViaApi(ctx, { name: task2, project_id: project.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task1}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
taskId: t1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task2}`,
|
||||
duration: '2h',
|
||||
projectId: project.id,
|
||||
taskId: t2.id,
|
||||
});
|
||||
|
||||
// Use the detailed view to verify task filtering (shows individual entries)
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task2}`).first()).toBeVisible();
|
||||
|
||||
// Open task multiselect dropdown
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
|
||||
// Verify both tasks appear
|
||||
await expect(page.getByRole('option').filter({ hasText: task1 })).toBeVisible();
|
||||
await expect(page.getByRole('option').filter({ hasText: task2 })).toBeVisible();
|
||||
|
||||
// Select task1
|
||||
await page.getByRole('option').filter({ hasText: task1 }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Verify badge shows count of 1
|
||||
await expect(page.getByRole('button', { name: 'Tasks' }).first().getByText('1')).toBeVisible();
|
||||
|
||||
// Verify only task1 entry is shown
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task2}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that selecting multiple tasks shows correct badge count', async ({ page, ctx }) => {
|
||||
const projectName = 'MultiTaskProj ' + Math.floor(Math.random() * 10000);
|
||||
const task1 = 'MultiTask1 ' + Math.floor(Math.random() * 10000);
|
||||
const task2 = 'MultiTask2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
const t1 = await createTaskViaApi(ctx, { name: task1, project_id: project.id });
|
||||
const t2 = await createTaskViaApi(ctx, { name: task2, project_id: project.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task1}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
taskId: t1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task2}`,
|
||||
duration: '2h',
|
||||
projectId: project.id,
|
||||
taskId: t2.id,
|
||||
});
|
||||
|
||||
// Use the detailed view to verify task filtering
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task2}`).first()).toBeVisible();
|
||||
|
||||
// Select both tasks
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: task1 }).click();
|
||||
await page.getByRole('option').filter({ hasText: task2 }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Verify badge shows count of 2
|
||||
await expect(page.getByRole('button', { name: 'Tasks' }).first().getByText('2')).toBeVisible();
|
||||
|
||||
// Verify both task entries are shown
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task2}`).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that deselecting a task removes the filter', async ({ page, ctx }) => {
|
||||
const projectName = 'TaskDeselectProj ' + Math.floor(Math.random() * 10000);
|
||||
const task1 = 'TaskDeselect1 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
const t1 = await createTaskViaApi(ctx, { name: task1, project_id: project.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task1}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
taskId: t1.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
|
||||
// Select task
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: task1 }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
await expect(page.getByRole('button', { name: 'Tasks' }).first().getByText('1')).toBeVisible();
|
||||
|
||||
// Deselect task
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: task1 }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Tasks' }).first().getByText(/^\d+$/)
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Member Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that member multiselect filters work on detailed reporting page', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'DetailMemberProj ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
await expect(page.getByText(`Entry for ${projectName}`).first()).toBeVisible();
|
||||
|
||||
// Filter by the current member
|
||||
await page.getByRole('button', { name: 'Members' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: 'John Doe' }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Data should still be visible since all entries belong to this member
|
||||
await expect(page.getByText(`Entry for ${projectName}`).first()).toBeVisible();
|
||||
|
||||
// Verify badge shows count of 1
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Members' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Tag Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that tag filter works on detailed reporting page', async ({ page, ctx }) => {
|
||||
const tag1 = 'DetailTag1 ' + Math.floor(Math.random() * 10000);
|
||||
const tag2 = 'DetailTag2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
await createTimeEntryWithTagViaApi(ctx, tag1, '1h');
|
||||
await createTimeEntryWithTagViaApi(ctx, tag2, '2h');
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry with tag ${tag1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry with tag ${tag2}`).first()).toBeVisible();
|
||||
|
||||
// Filter by tag1
|
||||
await page.getByRole('button', { name: 'Tags' }).click();
|
||||
await page.getByRole('option').filter({ hasText: tag1 }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
await expect(page.getByText(`Entry with tag ${tag1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry with tag ${tag2}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Billable Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that billable filter works on detailed reporting page', async ({ page, ctx }) => {
|
||||
const projectName = 'DetailBillProj ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
await expect(page.getByText(`Entry for ${projectName}`).first()).toBeVisible();
|
||||
|
||||
// Filter by billable only
|
||||
await page.getByRole('combobox').filter({ hasText: 'Billable' }).click();
|
||||
await Promise.all([
|
||||
page.getByRole('option', { name: 'Billable', exact: true }).click(),
|
||||
waitForDetailedReportingUpdate(page),
|
||||
]);
|
||||
|
||||
// Switch to Non Billable
|
||||
await page.getByRole('combobox').filter({ hasText: 'Billable' }).click();
|
||||
await Promise.all([
|
||||
page.getByRole('option', { name: 'Non Billable', exact: true }).click(),
|
||||
waitForDetailedReportingUpdate(page),
|
||||
]);
|
||||
|
||||
// Switch back to Both
|
||||
await page.getByRole('combobox').filter({ hasText: 'Non Billable' }).click();
|
||||
await Promise.all([
|
||||
page.getByRole('option', { name: 'Both' }).click(),
|
||||
waitForDetailedReportingUpdate(page),
|
||||
]);
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Combined Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that combining project and task filters narrows results', async ({ page, ctx }) => {
|
||||
const projectName = 'CombinedProj ' + Math.floor(Math.random() * 10000);
|
||||
const otherProject = 'OtherCombProj ' + Math.floor(Math.random() * 10000);
|
||||
const task1 = 'CombinedTask1 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const p1 = await createProjectViaApi(ctx, { name: projectName });
|
||||
const p2 = await createProjectViaApi(ctx, { name: otherProject });
|
||||
const t1 = await createTaskViaApi(ctx, { name: task1, project_id: p1.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
taskId: t1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${otherProject}`,
|
||||
duration: '2h',
|
||||
projectId: p2.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${otherProject}`).first()).toBeVisible();
|
||||
|
||||
// Filter by project
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: projectName }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Additionally filter by task
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: task1 }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Verify both badges show count of 1
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Projects' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Tasks' }).first().getByText('1')).toBeVisible();
|
||||
|
||||
// Verify only the combined entry is shown
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${otherProject}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that combining client and member filters narrows results on detailed page', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const client1 = 'CombClient ' + Math.floor(Math.random() * 10000);
|
||||
const project1 = 'CombClientProj ' + Math.floor(Math.random() * 10000);
|
||||
const project2 = 'CombNoClientProj ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const c1 = await createClientViaApi(ctx, { name: client1 });
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1, client_id: c1.id });
|
||||
const p2 = await createProjectViaApi(ctx, { name: project2 });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project2}`,
|
||||
duration: '2h',
|
||||
projectId: p2.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project2}`).first()).toBeVisible();
|
||||
|
||||
// Filter by client
|
||||
await page.getByRole('button', { name: 'Clients' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: client1 }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Additionally filter by member
|
||||
await page.getByRole('button', { name: 'Members' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: 'John Doe' }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Only project1 entry should be visible (filtered by client + member)
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project2}`).first()).not.toBeVisible();
|
||||
|
||||
// Both badges should show count of 1
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Clients' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Members' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that combining tag and project filters narrows results', async ({ page, ctx }) => {
|
||||
const tag1 = 'CombTag ' + Math.floor(Math.random() * 10000);
|
||||
const project1 = 'CombTagProj ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1 });
|
||||
|
||||
// Create a time entry with a project (no tag)
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
|
||||
// Create a time entry with a tag (no specific project)
|
||||
await createTimeEntryWithTagViaApi(ctx, tag1, '2h');
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry with tag ${tag1}`).first()).toBeVisible();
|
||||
|
||||
// Filter by project
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: project1 }).click();
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Only the project entry should be visible (tagged entry has no project)
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry with tag ${tag1}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// "No X" Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that "No Project" filter shows entries without a project', async ({ page, ctx }) => {
|
||||
const project1 = 'NoProj1 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1 });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
await createBareTimeEntryViaApi(ctx, 'Bare entry no project', '30min');
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText('Bare entry no project').first()).toBeVisible();
|
||||
|
||||
// Open project dropdown and select "No Project"
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: 'No Project' }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Verify badge shows 1
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Projects' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
|
||||
// Only the bare entry (no project) should be visible
|
||||
await expect(page.getByText('Bare entry no project').first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that "No Task" filter shows entries without a task', async ({ page, ctx }) => {
|
||||
const projectName = 'NoTaskProj ' + Math.floor(Math.random() * 10000);
|
||||
const task1 = 'NoTaskFilter1 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
const t1 = await createTaskViaApi(ctx, { name: task1, project_id: project.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${task1}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
taskId: t1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '30min',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectName}`).first()).toBeVisible();
|
||||
|
||||
// Open task dropdown and select "No Task"
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: 'No Task' }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
await expect(page.getByRole('button', { name: 'Tasks' }).first().getByText('1')).toBeVisible();
|
||||
|
||||
// Only the entry without a task should be visible
|
||||
await expect(page.getByText(`Entry for ${projectName} - ${task1}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that "No Tag" filter shows entries without tags', async ({ page, ctx }) => {
|
||||
const tag1 = 'NoTagFilter1 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
await createTimeEntryWithTagViaApi(ctx, tag1, '1h');
|
||||
await createBareTimeEntryViaApi(ctx, 'Entry without any tag', '30min');
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry with tag ${tag1}`).first()).toBeVisible();
|
||||
await expect(page.getByText('Entry without any tag').first()).toBeVisible();
|
||||
|
||||
// Open tag dropdown and select "No Tag"
|
||||
await page.getByRole('button', { name: 'Tags' }).click();
|
||||
await page.getByRole('option').filter({ hasText: 'No Tag' }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
await expect(page.getByRole('button', { name: 'Tags' }).getByText('1')).toBeVisible();
|
||||
|
||||
await expect(page.getByText('Entry without any tag').first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry with tag ${tag1}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that "No Client" filter shows entries without a client', async ({ page, ctx }) => {
|
||||
const client1 = 'NoClientFilter ' + Math.floor(Math.random() * 10000);
|
||||
const projectWithClient = 'NoClientProj1 ' + Math.floor(Math.random() * 10000);
|
||||
const projectNoClient = 'NoClientProj2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const c1 = await createClientViaApi(ctx, { name: client1 });
|
||||
const pWithClient = await createProjectViaApi(ctx, {
|
||||
name: projectWithClient,
|
||||
client_id: c1.id,
|
||||
});
|
||||
const pNoClient = await createProjectViaApi(ctx, { name: projectNoClient });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectWithClient}`,
|
||||
duration: '1h',
|
||||
projectId: pWithClient.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectNoClient}`,
|
||||
duration: '30min',
|
||||
projectId: pNoClient.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${projectWithClient}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectNoClient}`).first()).toBeVisible();
|
||||
|
||||
// Open client dropdown and select "No Client"
|
||||
await page.getByRole('button', { name: 'Clients' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: 'No Client' }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Clients' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
|
||||
await expect(page.getByText(`Entry for ${projectNoClient}`).first()).toBeVisible();
|
||||
await expect(page.getByText(`Entry for ${projectWithClient}`).first()).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that combining "No Project" with a project ID shows both', async ({ page, ctx }) => {
|
||||
const project1 = 'CombNoProj ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1 });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
await createBareTimeEntryViaApi(ctx, 'Bare combined entry', '30min');
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText('Bare combined entry').first()).toBeVisible();
|
||||
|
||||
// Select both "No Project" and the specific project
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await page.getByRole('option').filter({ hasText: 'No Project' }).click();
|
||||
await page.getByRole('option').filter({ hasText: project1 }).click();
|
||||
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Badge should show 2
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Projects' }).first().getByText('2')
|
||||
).toBeVisible();
|
||||
|
||||
// Both entries should be visible
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
await expect(page.getByText('Bare combined entry').first()).toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Keyboard Navigation Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that keyboard navigation works in multiselect dropdown', async ({ page, ctx }) => {
|
||||
const project1 = 'KbNavProj1 ' + Math.floor(Math.random() * 10000);
|
||||
const project2 = 'KbNavProj2 ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const p1 = await createProjectViaApi(ctx, { name: project1 });
|
||||
const p2 = await createProjectViaApi(ctx, { name: project2 });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project1}`,
|
||||
duration: '1h',
|
||||
projectId: p1.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${project2}`,
|
||||
duration: '2h',
|
||||
projectId: p2.id,
|
||||
});
|
||||
|
||||
await goToReportingDetailed(page);
|
||||
await expect(page.getByText(`Entry for ${project1}`).first()).toBeVisible();
|
||||
|
||||
// Open project dropdown
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
|
||||
// The search input should be focused, first item ("No Project") highlighted
|
||||
await expect(page.getByPlaceholder('Search for a Project...')).toBeFocused();
|
||||
|
||||
// Press ArrowDown to move to first project, then Enter to select it
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
// Close dropdown and verify filter applied
|
||||
await Promise.all([page.keyboard.press('Escape'), waitForDetailedReportingUpdate(page)]);
|
||||
|
||||
// Badge should show 1
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Projects' }).first().getByText('1')
|
||||
).toBeVisible();
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
579
e2e/shared-reports.spec.ts
Normal file
579
e2e/shared-reports.spec.ts
Normal file
@@ -0,0 +1,579 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import {
|
||||
createProjectViaApi,
|
||||
createClientViaApi,
|
||||
createTaskViaApi,
|
||||
createTimeEntryViaApi,
|
||||
createTimeEntryWithTagViaApi,
|
||||
createBareTimeEntryViaApi,
|
||||
} from './utils/api';
|
||||
import {
|
||||
goToReporting,
|
||||
goToReportingShared,
|
||||
waitForReportingUpdate,
|
||||
saveAsSharedReport,
|
||||
} from './utils/reporting';
|
||||
|
||||
// Each test registers a new user and creates test data via API
|
||||
test.describe.configure({ timeout: 30000 });
|
||||
|
||||
// Date picker button name patterns for different date formats
|
||||
const DATE_PICKER_BUTTON_PATTERN =
|
||||
/^Pick a date$|^\d{4}-\d{2}-\d{2}$|^\d{2}\/\d{2}\/\d{4}$|^\d{2}\.\d{2}\.\d{4}$/;
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Shared Report Lifecycle Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that saving a report creates a shared report and its shareable link shows correct data', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'SharedProject ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'SharedReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
const { shareableLink } = await saveAsSharedReport(page, reportName);
|
||||
|
||||
// Verify report appears on shared tab
|
||||
await goToReportingShared(page);
|
||||
await expect(page.getByTestId('report_table')).toBeVisible();
|
||||
await expect(page.getByText(reportName)).toBeVisible();
|
||||
await expect(page.getByText('Public', { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Copy URL' })).toBeVisible();
|
||||
|
||||
// Navigate to shareable link and verify report data
|
||||
await page.goto(shareableLink);
|
||||
await expect(page.getByText('Reporting')).toBeVisible();
|
||||
await expect(page.getByText(projectName)).toBeVisible();
|
||||
await expect(page.getByText('Total')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that shared report with invalid secret shows no data', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/shared-report#invalid-secret-value');
|
||||
await expect(page.getByText('No time entries found').first()).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that a shared report can be edited to toggle public/private and then deleted', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'EditDelProject ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'EditDelReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
await saveAsSharedReport(page, reportName);
|
||||
|
||||
await goToReportingShared(page);
|
||||
await expect(page.getByText(reportName)).toBeVisible();
|
||||
await expect(page.getByText('Public', { exact: true })).toBeVisible();
|
||||
|
||||
// Click more options and edit
|
||||
await page
|
||||
.getByRole('button', { name: new RegExp('Actions for Project ' + reportName) })
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: /^Edit Report/ }).click();
|
||||
|
||||
// Uncheck public and save
|
||||
await page.getByLabel('Public').click();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Report' }).click(),
|
||||
]);
|
||||
|
||||
// Verify status changed to private
|
||||
await expect(page.getByText('Private')).toBeVisible();
|
||||
await expect(page.getByText('--')).toBeVisible();
|
||||
|
||||
// Delete the report
|
||||
await page
|
||||
.getByRole('button', { name: new RegExp('Actions for Project ' + reportName) })
|
||||
.click();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports/') &&
|
||||
response.request().method() === 'DELETE' &&
|
||||
response.status() === 204
|
||||
),
|
||||
page.getByRole('menuitem', { name: /^Delete Report/ }).click(),
|
||||
]);
|
||||
|
||||
await expect(page.getByText('No shared reports found')).toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Shared Report Filter Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that shared report respects project filter', async ({ page, ctx }) => {
|
||||
const projectA = 'FilterProjA ' + Math.floor(Math.random() * 10000);
|
||||
const projectB = 'FilterProjB ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'FilterProjReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const projA = await createProjectViaApi(ctx, { name: projectA });
|
||||
const projB = await createProjectViaApi(ctx, { name: projectB });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectA}`,
|
||||
duration: '1h',
|
||||
projectId: projA.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectB}`,
|
||||
duration: '2h',
|
||||
projectId: projB.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectA)).toBeVisible();
|
||||
|
||||
// Filter by project A
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await Promise.all([
|
||||
page.getByRole('option').filter({ hasText: projectA }).click(),
|
||||
waitForReportingUpdate(page),
|
||||
]);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const { shareableLink } = await saveAsSharedReport(page, reportName);
|
||||
|
||||
// View the shared report
|
||||
await page.goto(shareableLink);
|
||||
await expect(page.getByText('Reporting')).toBeVisible();
|
||||
await expect(page.getByText(projectA)).toBeVisible();
|
||||
await expect(page.getByText(projectB)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that shared report with No Project filter shows entries without a project', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'NoProjFilter ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'NoProjReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
await createBareTimeEntryViaApi(ctx, 'Bare entry no project', '2h');
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Filter by "No Project"
|
||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
||||
await Promise.all([
|
||||
page.getByRole('option').filter({ hasText: 'No Project' }).click(),
|
||||
waitForReportingUpdate(page),
|
||||
]);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const { shareableLink } = await saveAsSharedReport(page, reportName);
|
||||
|
||||
// View the shared report
|
||||
await page.goto(shareableLink);
|
||||
await expect(page.getByText('Reporting')).toBeVisible();
|
||||
// The "No Project" group should show, but the project name should not appear as a group
|
||||
await expect(page.getByText('Total')).toBeVisible();
|
||||
await expect(page.getByText(projectName)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that shared report with No Task filter shows entries without a task', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'NoTaskProj ' + Math.floor(Math.random() * 10000);
|
||||
const taskName = 'NoTaskFilter ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'NoTaskReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
const task = await createTaskViaApi(ctx, { name: taskName, project_id: project.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${taskName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
taskId: task.id,
|
||||
});
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '2h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Filter by "No Task"
|
||||
await page.getByRole('button', { name: 'Tasks' }).first().click();
|
||||
await Promise.all([
|
||||
page.getByRole('option').filter({ hasText: 'No Task' }).click(),
|
||||
waitForReportingUpdate(page),
|
||||
]);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const { shareableLink } = await saveAsSharedReport(page, reportName);
|
||||
|
||||
// View the shared report
|
||||
await page.goto(shareableLink);
|
||||
await expect(page.getByText('Reporting')).toBeVisible();
|
||||
await expect(page.getByText('Total')).toBeVisible();
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Report Date Picker Tests
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
test('test that creating a report with an expiration date works', async ({ page, ctx }) => {
|
||||
const projectName = 'DatePickerProj ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'DatePickerReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Open the save report modal
|
||||
await page.getByRole('button', { name: 'Save Report' }).click();
|
||||
await page.getByLabel('Name').fill(reportName);
|
||||
|
||||
// The "Public" checkbox should be checked by default, showing the date picker
|
||||
const datePicker = page
|
||||
.getByRole('dialog')
|
||||
.getByRole('button', { name: DATE_PICKER_BUTTON_PATTERN });
|
||||
await expect(datePicker).toBeVisible();
|
||||
await datePicker.click();
|
||||
|
||||
// Select a date in the next month
|
||||
const calendarGrid = page.getByRole('grid');
|
||||
await expect(calendarGrid).toBeVisible({ timeout: 5000 });
|
||||
await page.getByRole('button', { name: /Next/i }).click();
|
||||
await page.getByRole('gridcell').filter({ hasText: /^15$/ }).first().click();
|
||||
|
||||
// Wait for the calendar to close
|
||||
await expect(calendarGrid).not.toBeVisible();
|
||||
|
||||
// Create the report and verify it includes the public_until date
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Report' }).click(),
|
||||
]);
|
||||
const responseBody = await response.json();
|
||||
expect(responseBody.data.public_until).toBeTruthy();
|
||||
});
|
||||
|
||||
test('test that editing a report to make it public with expiration date works', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'EditDateProj ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'EditDateReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Open the save report modal and create a private report
|
||||
await page.getByRole('button', { name: 'Save Report' }).click();
|
||||
await page.getByLabel('Name').fill(reportName);
|
||||
|
||||
// Uncheck "Public" to create a private report
|
||||
await page.getByLabel('Public').click();
|
||||
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Report' }).click(),
|
||||
]);
|
||||
|
||||
// Go to shared reports and edit
|
||||
await goToReportingShared(page);
|
||||
await expect(page.getByText(reportName)).toBeVisible();
|
||||
await expect(page.getByText('Private')).toBeVisible();
|
||||
|
||||
// Click more options and edit
|
||||
await page
|
||||
.getByRole('button', { name: new RegExp('Actions for Project ' + reportName) })
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: /^Edit Report/ }).click();
|
||||
|
||||
// Check "Public" to make it public - this should show the date picker
|
||||
await page.getByLabel('Public').click();
|
||||
|
||||
// The date picker should now be visible
|
||||
const datePicker = page
|
||||
.getByRole('dialog')
|
||||
.getByRole('button', { name: DATE_PICKER_BUTTON_PATTERN });
|
||||
await expect(datePicker).toBeVisible();
|
||||
await datePicker.click();
|
||||
|
||||
// Select a date in the next month
|
||||
const calendarGrid = page.getByRole('grid');
|
||||
await expect(calendarGrid).toBeVisible({ timeout: 5000 });
|
||||
await page.getByRole('button', { name: /Next/i }).click();
|
||||
await page.getByRole('gridcell').filter({ hasText: /^20$/ }).first().click();
|
||||
|
||||
// Wait for the calendar to close
|
||||
await expect(calendarGrid).not.toBeVisible();
|
||||
|
||||
// Update the report and verify it includes the public_until date
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Report' }).click(),
|
||||
]);
|
||||
const responseBody = await response.json();
|
||||
expect(responseBody.data.public_until).toBeTruthy();
|
||||
expect(responseBody.data.is_public).toBe(true);
|
||||
});
|
||||
|
||||
test('test that shared report with No Client filter shows entries without a client', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const clientName = 'NoClientCli ' + Math.floor(Math.random() * 10000);
|
||||
const projectName = 'NoClientProj ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'NoClientReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const client = await createClientViaApi(ctx, { name: clientName });
|
||||
const project = await createProjectViaApi(ctx, { name: projectName, client_id: client.id });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
await createBareTimeEntryViaApi(ctx, 'Entry without client', '2h');
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Filter by "No Client"
|
||||
await page.getByRole('button', { name: 'Clients' }).first().click();
|
||||
await Promise.all([
|
||||
page.getByRole('option').filter({ hasText: 'No Client' }).click(),
|
||||
waitForReportingUpdate(page),
|
||||
]);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const { shareableLink } = await saveAsSharedReport(page, reportName);
|
||||
|
||||
// View the shared report
|
||||
await page.goto(shareableLink);
|
||||
await expect(page.getByText('Reporting')).toBeVisible();
|
||||
await expect(page.getByText('Total')).toBeVisible();
|
||||
await expect(page.getByText(projectName)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that shared report with No Tag filter shows entries without tags', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const tagName = 'NoTagFilter ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'NoTagReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
await createTimeEntryWithTagViaApi(ctx, tagName, '1h');
|
||||
await createBareTimeEntryViaApi(ctx, 'Entry without tags', '2h');
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByText('Total')).toBeVisible();
|
||||
|
||||
// Filter by "No Tag"
|
||||
await page.getByRole('button', { name: 'Tags' }).first().click();
|
||||
await Promise.all([
|
||||
page.getByRole('option').filter({ hasText: 'No Tag' }).click(),
|
||||
waitForReportingUpdate(page),
|
||||
]);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const { shareableLink } = await saveAsSharedReport(page, reportName);
|
||||
|
||||
// View the shared report
|
||||
await page.goto(shareableLink);
|
||||
await expect(page.getByText('Reporting')).toBeVisible();
|
||||
await expect(page.getByText('Total')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that creating a report with empty name shows validation error', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const projectName = 'EmptyNameProj ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Open the save report modal
|
||||
await page.getByRole('button', { name: 'Save Report' }).click();
|
||||
|
||||
// Leave name empty and try to create
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Create Report' }).click();
|
||||
|
||||
// Should show validation error
|
||||
await expect(page.getByText('The name field is required')).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that updating report name works', async ({ page, ctx }) => {
|
||||
const projectName = 'UpdateNameProj ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'OriginalName ' + Math.floor(Math.random() * 10000);
|
||||
const newReportName = 'UpdatedName ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
await saveAsSharedReport(page, reportName);
|
||||
|
||||
await goToReportingShared(page);
|
||||
await expect(page.getByText(reportName)).toBeVisible();
|
||||
|
||||
// Click more options and edit
|
||||
await page
|
||||
.getByRole('button', { name: new RegExp('Actions for Project ' + reportName) })
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: /^Edit Report/ }).click();
|
||||
|
||||
// Update the name
|
||||
await page.getByLabel('Name', { exact: true }).fill(newReportName);
|
||||
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Report' }).click(),
|
||||
]);
|
||||
|
||||
// Verify the name was updated in the table
|
||||
await expect(page.getByText(newReportName)).toBeVisible();
|
||||
await expect(page.getByText(reportName)).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('test that updating expiration date on already-public report works', async ({ page, ctx }) => {
|
||||
const projectName = 'UpdateExpDateProj ' + Math.floor(Math.random() * 10000);
|
||||
const reportName = 'UpdateExpDateReport ' + Math.floor(Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration: '1h',
|
||||
projectId: project.id,
|
||||
});
|
||||
|
||||
await goToReporting(page);
|
||||
await expect(page.getByTestId('reporting_view').getByText(projectName)).toBeVisible();
|
||||
|
||||
// Create a public report (already public by default)
|
||||
await saveAsSharedReport(page, reportName);
|
||||
|
||||
// Go to shared reports and edit
|
||||
await goToReportingShared(page);
|
||||
await expect(page.getByText(reportName)).toBeVisible();
|
||||
|
||||
// Click more options and edit
|
||||
await page
|
||||
.getByRole('button', { name: new RegExp('Actions for Project ' + reportName) })
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: /^Edit Report/ }).click();
|
||||
|
||||
// The date picker should be visible (report is already public)
|
||||
const datePicker = page
|
||||
.getByRole('dialog')
|
||||
.getByRole('button', { name: DATE_PICKER_BUTTON_PATTERN });
|
||||
await expect(datePicker).toBeVisible();
|
||||
await datePicker.click();
|
||||
|
||||
// Select the 25th of next month
|
||||
const calendarGrid = page.getByRole('grid');
|
||||
await expect(calendarGrid).toBeVisible({ timeout: 5000 });
|
||||
await page.getByRole('button', { name: /Next/i }).click();
|
||||
await page.getByRole('gridcell').filter({ hasText: /^25$/ }).first().click();
|
||||
|
||||
// Wait for the calendar to close
|
||||
await expect(calendarGrid).not.toBeVisible();
|
||||
|
||||
// Update the report and verify it includes the correct public_until date
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Report' }).click(),
|
||||
]);
|
||||
const responseBody = await response.json();
|
||||
expect(responseBody.data.public_until).toBeTruthy();
|
||||
|
||||
// Verify the date is the 25th of a future month
|
||||
const returnedDate = new Date(responseBody.data.public_until);
|
||||
expect(returnedDate.getUTCDate()).toBe(25);
|
||||
|
||||
// The returned date should be in the future
|
||||
const now = new Date();
|
||||
expect(returnedDate.getTime()).toBeGreaterThan(now.getTime());
|
||||
});
|
||||
@@ -1,13 +1,14 @@
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import { createTagViaApi } from './utils/api';
|
||||
|
||||
async function goToTagsOverview(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/tags');
|
||||
}
|
||||
|
||||
// Create new project via modal
|
||||
test('test that creating and deleting a new client via the modal works', async ({ page }) => {
|
||||
test('test that creating and deleting a new tag via the modal works', async ({ page }) => {
|
||||
const newTagName = 'New Tag ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToTagsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Tag' }).click();
|
||||
@@ -40,3 +41,82 @@ test('test that creating and deleting a new client via the modal works', async (
|
||||
]);
|
||||
await expect(page.getByTestId('tag_table')).not.toContainText(newTagName);
|
||||
});
|
||||
|
||||
test('test that editing a tag name works', async ({ page, ctx }) => {
|
||||
const originalTagName = 'Original Tag ' + Math.floor(1 + Math.random() * 10000);
|
||||
const updatedTagName = 'Updated Tag ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createTagViaApi(ctx, { name: originalTagName });
|
||||
|
||||
await goToTagsOverview(page);
|
||||
await expect(page.getByTestId('tag_table')).toContainText(originalTagName);
|
||||
|
||||
// Open actions menu and click Edit
|
||||
const moreButton = page.locator("[aria-label='Actions for Tag " + originalTagName + "']");
|
||||
await moreButton.click();
|
||||
await page.getByRole('menuitem').getByText('Edit').click();
|
||||
|
||||
// Update the tag name in the edit modal
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await page.getByPlaceholder('Tag Name').fill(updatedTagName);
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/tags/') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
page.getByRole('button', { name: 'Update Tag' }).click(),
|
||||
]);
|
||||
|
||||
// Verify the table shows the updated name
|
||||
await expect(page.getByTestId('tag_table')).toContainText(updatedTagName);
|
||||
await expect(page.getByTestId('tag_table')).not.toContainText(originalTagName);
|
||||
});
|
||||
|
||||
test('test that multiple tags can be created via API and displayed in the table', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const tagName1 = 'TagA ' + Math.floor(1 + Math.random() * 10000);
|
||||
const tagName2 = 'TagB ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createTagViaApi(ctx, { name: tagName1 });
|
||||
await createTagViaApi(ctx, { name: tagName2 });
|
||||
|
||||
await goToTagsOverview(page);
|
||||
await expect(page.getByTestId('tag_table')).toContainText(tagName1);
|
||||
await expect(page.getByTestId('tag_table')).toContainText(tagName2);
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Tags Restrictions', () => {
|
||||
test('employee can view tags but cannot create', async ({ ctx, employee }) => {
|
||||
const tagName = 'EmpViewTag ' + Math.floor(Math.random() * 10000);
|
||||
await createTagViaApi(ctx, { name: tagName });
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/tags');
|
||||
await expect(employee.page.getByTestId('tags_view')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Employee can see the tag (tags are visible to all members with tags:view)
|
||||
await expect(employee.page.getByText(tagName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Employee cannot see Create Tag button
|
||||
await expect(employee.page.getByRole('button', { name: 'Create Tag' })).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee cannot see edit/delete actions on tags', async ({ ctx, employee }) => {
|
||||
const tagName = 'EmpActionsTag ' + Math.floor(Math.random() * 10000);
|
||||
await createTagViaApi(ctx, { name: tagName });
|
||||
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/tags');
|
||||
await expect(employee.page.getByText(tagName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Actions button should not be visible for employee
|
||||
const actionsButton = employee.page.locator(`[aria-label='Actions for Tag ${tagName}']`);
|
||||
await expect(actionsButton).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
import { test } from '../playwright/fixtures';
|
||||
import {
|
||||
createProjectViaApi,
|
||||
createPublicProjectViaApi,
|
||||
createTaskViaApi,
|
||||
createClientViaApi,
|
||||
updateOrganizationSettingViaApi,
|
||||
} from './utils/api';
|
||||
|
||||
async function goToProjectsOverview(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
}
|
||||
|
||||
// Create new project via modal
|
||||
test('test that creating and deleting a new tag in a new project works', async ({ page }) => {
|
||||
test('test that creating and deleting a new task in a new project works', async ({ page }) => {
|
||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
@@ -27,11 +34,9 @@ test('test that creating and deleting a new tag in a new project works', async (
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
|
||||
|
||||
await page.getByText(newProjectName).click();
|
||||
|
||||
const newTaskName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
const newTaskName = 'New Task ' + Math.floor(1 + Math.random() * 10000);
|
||||
await page.getByRole('button', { name: 'Create Task' }).click();
|
||||
await page.getByPlaceholder('Task Name').fill(newTaskName);
|
||||
|
||||
@@ -83,23 +88,14 @@ test('test that creating and deleting a new tag in a new project works', async (
|
||||
await expect(page.getByTestId('project_table')).not.toContainText(newProjectName);
|
||||
});
|
||||
|
||||
test('test that archiving and unarchiving tasks works', async ({ page }) => {
|
||||
test('test that archiving and unarchiving tasks works', async ({ page, ctx }) => {
|
||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newTaskName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newTaskName = 'New Task ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(newProjectName);
|
||||
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||
|
||||
await page.getByText(newProjectName).click();
|
||||
|
||||
await page.getByRole('button', { name: 'Create Task' }).click();
|
||||
await page.getByPlaceholder('Task Name').fill(newTaskName);
|
||||
await page.getByRole('button', { name: 'Create Task' }).click();
|
||||
const project = await createProjectViaApi(ctx, { name: newProjectName });
|
||||
await createTaskViaApi(ctx, { name: newTaskName, project_id: project.id });
|
||||
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
|
||||
await expect(page.getByRole('table')).toContainText(newTaskName);
|
||||
|
||||
await page.getByRole('row').first().getByRole('button').click();
|
||||
@@ -123,14 +119,194 @@ test('test that archiving and unarchiving tasks works', async ({ page }) => {
|
||||
]);
|
||||
});
|
||||
|
||||
// Create new project with new Client
|
||||
test('test that editing a task name works', async ({ page, ctx }) => {
|
||||
const projectName = 'TaskEdit Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const originalTaskName = 'Original Task ' + Math.floor(1 + Math.random() * 10000);
|
||||
const updatedTaskName = 'Updated Task ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
// Create new project with existing Client
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTaskViaApi(ctx, { name: originalTaskName, project_id: project.id });
|
||||
|
||||
// Delete project via More Options
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
|
||||
await expect(page.getByTestId('task_table')).toContainText(originalTaskName);
|
||||
|
||||
// Test that project task count is displayed correctly
|
||||
// Open actions menu and click Edit
|
||||
const moreButton = page.locator("[aria-label='Actions for Task " + originalTaskName + "']");
|
||||
await moreButton.click();
|
||||
await page.getByRole('menuitem').getByText('Edit').click();
|
||||
|
||||
// Test that active / archive / all filter works (once implemented)
|
||||
// Update the task name
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await page.getByPlaceholder('Task Name').fill(updatedTaskName);
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Update Task' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/tasks') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
]);
|
||||
|
||||
// Test update task name
|
||||
await expect(page.getByTestId('task_table')).toContainText(updatedTaskName);
|
||||
await expect(page.getByTestId('task_table')).not.toContainText(originalTaskName);
|
||||
});
|
||||
|
||||
test('test that creating a project with an existing client works', async ({ page, ctx }) => {
|
||||
const clientName = 'Existing Client ' + Math.floor(1 + Math.random() * 10000);
|
||||
const projectName = 'Project With Client ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
await createClientViaApi(ctx, { name: clientName });
|
||||
|
||||
await goToProjectsOverview(page);
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project Name').fill(projectName);
|
||||
|
||||
// Select the existing client
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'No Client' }).click();
|
||||
await page.getByRole('option', { name: clientName }).click();
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
(await response.json()).data.client_id !== null
|
||||
),
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('project_table')).toContainText(projectName);
|
||||
await expect(page.getByTestId('project_table')).toContainText(clientName);
|
||||
});
|
||||
|
||||
test('test that multiple tasks are displayed on project detail page', async ({ page, ctx }) => {
|
||||
const projectName = 'TaskCount Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const taskName1 = 'CountTask A ' + Math.floor(1 + Math.random() * 10000);
|
||||
const taskName2 = 'CountTask B ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
await createTaskViaApi(ctx, { name: taskName1, project_id: project.id });
|
||||
await createTaskViaApi(ctx, { name: taskName2, project_id: project.id });
|
||||
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
|
||||
await expect(page.getByText(taskName1)).toBeVisible();
|
||||
await expect(page.getByText(taskName2)).toBeVisible();
|
||||
});
|
||||
|
||||
test('test that creating a new project from the task create modal project dropdown works', async ({
|
||||
page,
|
||||
ctx,
|
||||
}) => {
|
||||
const existingProjectName = 'Existing Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newProjectName = 'Dropdown Created Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
const newTaskName = 'Task With New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||
|
||||
const project = await createProjectViaApi(ctx, { name: existingProjectName });
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
|
||||
|
||||
// Open the Create Task modal
|
||||
await page.getByRole('button', { name: 'Create Task' }).click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
await page.getByPlaceholder('Task Name').fill(newTaskName);
|
||||
|
||||
// Open the project dropdown (it should show the current project)
|
||||
await page.getByRole('dialog').getByRole('button', { name: existingProjectName }).click();
|
||||
|
||||
// Click "Create new Project" at the bottom of the dropdown
|
||||
await page.getByText('Create new Project').click();
|
||||
|
||||
// The ProjectCreateModal should appear
|
||||
await expect(page.getByLabel('Project name')).toBeVisible();
|
||||
await page.getByLabel('Project name').fill(newProjectName);
|
||||
|
||||
// Submit the project creation
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
(await response.json()).data.name === newProjectName
|
||||
),
|
||||
]);
|
||||
|
||||
// The project dropdown trigger should now show the new project name
|
||||
await expect(
|
||||
page.getByRole('dialog').getByRole('button', { name: newProjectName })
|
||||
).toBeVisible();
|
||||
|
||||
// Submit the task and capture the response to get the new project ID
|
||||
const [taskResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
async (response) =>
|
||||
response.url().includes('/tasks') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201 &&
|
||||
(await response.json()).data.name === newTaskName
|
||||
),
|
||||
page.getByRole('button', { name: 'Create Task' }).click(),
|
||||
]);
|
||||
|
||||
const taskData = await taskResponse.json();
|
||||
const newProjectId = taskData.data.project_id;
|
||||
|
||||
// Navigate to the new project's page and verify the task is there
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + newProjectId);
|
||||
await expect(page.getByTestId('task_table')).toContainText(newTaskName);
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Employee Permission Tests
|
||||
// =============================================
|
||||
|
||||
test.describe('Employee Tasks Restrictions', () => {
|
||||
test('employee cannot see task management actions when employees_can_manage_tasks is disabled', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
// Create a public project with a task
|
||||
const projectName = 'EmpTaskProj ' + Math.floor(Math.random() * 10000);
|
||||
const taskName = 'EmpTask ' + Math.floor(Math.random() * 10000);
|
||||
const project = await createPublicProjectViaApi(ctx, { name: projectName });
|
||||
await createTaskViaApi(ctx, { name: taskName, project_id: project.id });
|
||||
|
||||
// Navigate to the project detail page
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(employee.page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
await employee.page.getByText(projectName).first().click();
|
||||
await employee.page.waitForURL(/\/projects\/[a-f0-9-]+/);
|
||||
|
||||
// Task should be visible
|
||||
await expect(employee.page.getByText(taskName)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Create Task button should not be visible
|
||||
await expect(employee.page.getByRole('button', { name: 'Create Task' })).not.toBeVisible();
|
||||
|
||||
// Task actions button should not be visible
|
||||
const actionsButton = employee.page.locator(`[aria-label='Actions for Task ${taskName}']`);
|
||||
await expect(actionsButton).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('employee can manage tasks when employees_can_manage_tasks is enabled', async ({
|
||||
ctx,
|
||||
employee,
|
||||
}) => {
|
||||
// Enable the setting
|
||||
await updateOrganizationSettingViaApi(ctx, { employees_can_manage_tasks: true });
|
||||
|
||||
const projectName = 'EmpTaskMgmtProj ' + Math.floor(Math.random() * 10000);
|
||||
await createPublicProjectViaApi(ctx, { name: projectName });
|
||||
|
||||
// Navigate to the project detail page
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(employee.page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
||||
await employee.page.getByText(projectName).first().click();
|
||||
await employee.page.waitForURL(/\/projects\/[a-f0-9-]+/);
|
||||
|
||||
// Create Task button SHOULD be visible
|
||||
await expect(employee.page.getByRole('button', { name: 'Create Task' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
1257
e2e/time.spec.ts
1257
e2e/time.spec.ts
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,12 @@ import {
|
||||
startOrStopTimerWithButton,
|
||||
stoppedTimeEntryResponse,
|
||||
} from './utils/currentTimeEntry';
|
||||
import { Page } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { newTagResponse } from './utils/tags';
|
||||
import { updateOrganizationCurrencyViaWeb } from './utils/api';
|
||||
|
||||
// Date picker button name patterns for different date formats
|
||||
const DATE_DISPLAY_PATTERN = /^\d{4}-\d{2}-\d{2}$|^\d{2}\/\d{2}\/\d{4}$|^\d{2}\.\d{2}\.\d{4}$/;
|
||||
|
||||
async function goToDashboard(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
@@ -18,20 +22,35 @@ test('test that starting and stopping a timer without description and project wo
|
||||
page,
|
||||
}) => {
|
||||
await goToDashboard(page);
|
||||
await Promise.all([
|
||||
newTimeEntryResponse(page),
|
||||
startOrStopTimerWithButton(page),
|
||||
assertThatTimerHasStarted(page),
|
||||
]);
|
||||
await Promise.all([newTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
await page.waitForTimeout(1500);
|
||||
await Promise.all([stoppedTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that billable icon shows dollar sign for USD currency', async ({ page, ctx }) => {
|
||||
await updateOrganizationCurrencyViaWeb(ctx, 'USD');
|
||||
await goToDashboard(page);
|
||||
await page.waitForLoadState('networkidle');
|
||||
const billableButton = page.getByRole('button', { name: 'Non Billable' }).first();
|
||||
await expect(billableButton).toBeVisible();
|
||||
await expect(billableButton.locator('svg')).toHaveAttribute('viewBox', '0 0 8 14');
|
||||
});
|
||||
|
||||
test('test that billable icon shows euro sign for EUR currency', async ({ page, ctx }) => {
|
||||
await updateOrganizationCurrencyViaWeb(ctx, 'EUR');
|
||||
await goToDashboard(page);
|
||||
await page.waitForLoadState('networkidle');
|
||||
const billableButton = page.getByRole('button', { name: 'Non Billable' }).first();
|
||||
await expect(billableButton).toBeVisible();
|
||||
await expect(billableButton.locator('svg')).toHaveAttribute('viewBox', '0 0 12 12');
|
||||
});
|
||||
|
||||
test('test that starting and stopping a timer with a description works', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
// TODO: Fix flakyness by disabling description input field until timer is loaded
|
||||
await page.waitForTimeout(500);
|
||||
// Wait for the description input to be editable before filling
|
||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
||||
await page.getByTestId('time_entry_description').fill('New Time Entry Description');
|
||||
await Promise.all([
|
||||
newTimeEntryResponse(page, {
|
||||
@@ -57,13 +76,12 @@ test('test that starting the time entry starts the live timer and that it keeps
|
||||
|
||||
await Promise.all([newTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
await page.waitForTimeout(500);
|
||||
const beforeTimerValue = await page.getByTestId('time_entry_time').inputValue();
|
||||
await page.waitForTimeout(2000);
|
||||
const afterWaitTimeValue = await page.getByTestId('time_entry_time').inputValue();
|
||||
expect(afterWaitTimeValue).not.toEqual(beforeTimerValue);
|
||||
await page.reload();
|
||||
await page.waitForTimeout(500);
|
||||
await expect(page.getByTestId('time_entry_time')).toBeVisible();
|
||||
|
||||
const afterReloadTimerValue = await page.getByTestId('time_entry_time').inputValue();
|
||||
await page.waitForTimeout(2000);
|
||||
@@ -76,7 +94,7 @@ test('test that starting and updating the description while running works', asyn
|
||||
|
||||
await Promise.all([newTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
await page.waitForTimeout(500);
|
||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
||||
await page.getByTestId('time_entry_description').fill('New Time Entry Description');
|
||||
|
||||
await Promise.all([
|
||||
@@ -86,7 +104,6 @@ test('test that starting and updating the description while running works', asyn
|
||||
}),
|
||||
page.getByTestId('time_entry_description').press('Tab'),
|
||||
]);
|
||||
await page.waitForTimeout(500);
|
||||
await Promise.all([
|
||||
stoppedTimeEntryResponse(page, {
|
||||
description: 'New Time Entry Description',
|
||||
@@ -103,7 +120,7 @@ test('test that starting and updating the time while running works', async ({ pa
|
||||
await startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
await page.waitForTimeout(500);
|
||||
await expect(page.getByTestId('time_entry_time')).toBeEditable();
|
||||
await page.getByTestId('time_entry_time').fill('20min');
|
||||
|
||||
await Promise.all([
|
||||
@@ -127,7 +144,6 @@ test('test that starting and updating the time while running works', async ({ pa
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId('time_entry_time')).toHaveValue(/00:20/);
|
||||
await page.waitForTimeout(500);
|
||||
await Promise.all([stoppedTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
@@ -143,9 +159,7 @@ test('test that entering a human readable time starts the timer on blur', async
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
await Promise.all([stoppedTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await page.locator(
|
||||
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-accent-300/70'
|
||||
);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that entering a number in the time range starts the timer on blur', async ({ page }) => {
|
||||
@@ -159,9 +173,7 @@ test('test that entering a number in the time range starts the timer on blur', a
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
await Promise.all([stoppedTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await page.locator(
|
||||
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-accent-300/70'
|
||||
);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that entering a value with the format hh:mm in the time range starts the timer on blur', async ({
|
||||
@@ -177,9 +189,7 @@ test('test that entering a value with the format hh:mm in the time range starts
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
await Promise.all([stoppedTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await page.locator(
|
||||
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-accent-300/70'
|
||||
);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that entering a random value in the time range does not start the timer on blur', async ({
|
||||
@@ -187,10 +197,8 @@ test('test that entering a random value in the time range does not start the tim
|
||||
}) => {
|
||||
await goToDashboard(page);
|
||||
await page.getByTestId('time_entry_time').fill('asdasdasd');
|
||||
await page.getByTestId('time_entry_time').press('Tab'),
|
||||
await page.locator(
|
||||
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-accent-300/70'
|
||||
);
|
||||
await page.getByTestId('time_entry_time').press('Tab');
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that entering a time starts the timer on enter', async ({ page }) => {
|
||||
@@ -218,6 +226,11 @@ test('test that adding a new tag works', async ({ page }) => {
|
||||
page.getByRole('button', { name: 'Create Tag' }).click(),
|
||||
]);
|
||||
|
||||
// Wait for tags query refetch after invalidation
|
||||
await page.waitForResponse(
|
||||
(response) => response.url().includes('/tags') && response.status() === 200
|
||||
);
|
||||
|
||||
await page.getByTestId('tag_dropdown').click();
|
||||
await expect(page.getByRole('option', { name: newTagName })).toBeVisible();
|
||||
});
|
||||
@@ -240,7 +253,7 @@ test('test that adding a new tag when the timer is running', async ({ page }) =>
|
||||
await page.getByTestId('tag_dropdown').click();
|
||||
await expect(page.getByRole('option', { name: newTagName })).toBeVisible();
|
||||
await page.getByTestId('tag_dropdown_search').press('Escape');
|
||||
await page.waitForTimeout(1000);
|
||||
await expect(page.getByTestId('tag_dropdown_search')).not.toBeVisible();
|
||||
|
||||
await Promise.all([
|
||||
stoppedTimeEntryResponse(page, { tags: [tagId] }),
|
||||
@@ -249,18 +262,140 @@ test('test that adding a new tag when the timer is running', async ({ page }) =>
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
// test that search is working
|
||||
test('test that setting an end time with a different date via the timetracker range selector works', async ({
|
||||
page,
|
||||
}) => {
|
||||
await goToDashboard(page);
|
||||
|
||||
// test that adding a tag and project and starting the timer afterwards works and sets the project and tag correctly
|
||||
// Start a timer
|
||||
await Promise.all([newTimeEntryResponse(page), startOrStopTimerWithButton(page)]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
// test that changing the project works
|
||||
// Open the time range dropdown by clicking on the time display
|
||||
await page.getByTestId('time_entry_time').click();
|
||||
const rangeStart = page.getByTestId('time_entry_range_start');
|
||||
await expect(rangeStart).toBeVisible();
|
||||
|
||||
// test that sidebar timetracker starts and stops timer
|
||||
// Click "Set End Time" button
|
||||
await page.getByRole('button', { name: 'Set End Time' }).click();
|
||||
|
||||
// test that sidebar timetracker changes state when tmer on dashboard is started
|
||||
// The end time picker should now be visible with a Confirm button
|
||||
const rangeEnd = page.getByTestId('time_entry_range_end');
|
||||
await expect(rangeEnd).toBeVisible();
|
||||
const confirmButton = page.getByRole('button', { name: 'Confirm' });
|
||||
await expect(confirmButton).toBeVisible();
|
||||
|
||||
// test billable toggle
|
||||
// Click the end date picker to change the date
|
||||
const endDatePickers = page.getByRole('button', { name: DATE_DISPLAY_PATTERN });
|
||||
// The second date picker is the end date (first is the start date)
|
||||
const endDatePicker = endDatePickers.nth(1);
|
||||
await expect(endDatePicker).toBeVisible();
|
||||
await endDatePicker.click();
|
||||
|
||||
// TODO: Test that project can be created in the time tracker row
|
||||
// Calendar should appear
|
||||
const calendarGrid = page.getByRole('grid');
|
||||
await expect(calendarGrid).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Add Test that time tracker starts on enter with description
|
||||
// Navigate to the next month and select a day to ensure end > start
|
||||
await page.getByRole('button', { name: /Next/i }).click();
|
||||
await page.getByRole('gridcell').filter({ hasText: /^15$/ }).first().click();
|
||||
|
||||
// The dropdown should still be open after selecting a date (not auto-closed)
|
||||
await expect(rangeEnd).toBeVisible();
|
||||
await expect(confirmButton).toBeVisible();
|
||||
|
||||
// Click Confirm to finalize and verify the API call
|
||||
const [updateResponse] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries') &&
|
||||
response.request().method() === 'PUT' &&
|
||||
response.status() === 200
|
||||
),
|
||||
confirmButton.click(),
|
||||
]);
|
||||
const updateBody = await updateResponse.json();
|
||||
expect(updateBody.data.start).toBeTruthy();
|
||||
expect(updateBody.data.end).toBeTruthy();
|
||||
});
|
||||
|
||||
test('test that timer starts on enter with description', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
||||
await page.getByTestId('time_entry_description').fill('Start on Enter');
|
||||
|
||||
await Promise.all([
|
||||
newTimeEntryResponse(page, { description: 'Start on Enter' }),
|
||||
page.getByTestId('time_entry_description').press('Enter'),
|
||||
]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
await Promise.all([
|
||||
stoppedTimeEntryResponse(page, { description: 'Start on Enter' }),
|
||||
startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that timer started on dashboard is visible on time page', async ({ page }) => {
|
||||
await goToDashboard(page);
|
||||
|
||||
// Start timer on dashboard
|
||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
||||
await page.getByTestId('time_entry_description').fill('Sync test');
|
||||
await Promise.all([
|
||||
newTimeEntryResponse(page, { description: 'Sync test' }),
|
||||
startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
// Navigate to time page
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
|
||||
// Timer should still be running (the timer button should be red/active)
|
||||
await expect(
|
||||
page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]')
|
||||
).toHaveClass(/bg-red-400\/80/);
|
||||
|
||||
// Stop the timer
|
||||
await Promise.all([
|
||||
stoppedTimeEntryResponse(page, { description: 'Sync test' }),
|
||||
startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
test('test that adding a project and tag before starting timer works', async ({ page }) => {
|
||||
const newTagName = 'TimerTag ' + Math.floor(Math.random() * 10000);
|
||||
await goToDashboard(page);
|
||||
|
||||
// Create and select a tag first
|
||||
await page.getByTestId('tag_dropdown').click();
|
||||
await page.getByText('Create new tag').click();
|
||||
await page.getByPlaceholder('Tag Name').fill(newTagName);
|
||||
|
||||
const [tagCreateResponse] = await Promise.all([
|
||||
newTagResponse(page, { name: newTagName }),
|
||||
page.getByRole('button', { name: 'Create Tag' }).click(),
|
||||
]);
|
||||
const tagId = (await tagCreateResponse.json()).data.id;
|
||||
|
||||
// Wait for tags query refetch (tag is auto-selected after creation)
|
||||
await page.waitForResponse(
|
||||
(response) => response.url().includes('/tags') && response.status() === 200
|
||||
);
|
||||
|
||||
// Fill description and start
|
||||
await page.getByTestId('time_entry_description').fill('Entry with tag');
|
||||
await Promise.all([
|
||||
newTimeEntryResponse(page, { description: 'Entry with tag', tags: [tagId] }),
|
||||
startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerHasStarted(page);
|
||||
|
||||
await Promise.all([
|
||||
stoppedTimeEntryResponse(page, { description: 'Entry with tag', tags: [tagId] }),
|
||||
startOrStopTimerWithButton(page),
|
||||
]);
|
||||
await assertThatTimerIsStopped(page);
|
||||
});
|
||||
|
||||
474
e2e/utils/api.ts
Normal file
474
e2e/utils/api.ts
Normal file
@@ -0,0 +1,474 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import type { APIRequestContext, Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../../playwright/config';
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Types
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export interface TestContext {
|
||||
request: APIRequestContext;
|
||||
orgId: string;
|
||||
memberId: string;
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Auth helpers
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
async function getApiHeaders(page: Page): Promise<Record<string, string>> {
|
||||
const cookies = await page.context().cookies();
|
||||
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
||||
return {
|
||||
Accept: 'application/json',
|
||||
...(xsrfCookie ? { 'X-XSRF-TOKEN': decodeURIComponent(xsrfCookie.value) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Context setup
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function setupTestContext(page: Page): Promise<TestContext> {
|
||||
const request = page.request;
|
||||
const headers = await getApiHeaders(page);
|
||||
const orgId = await getOrganizationId(request, headers);
|
||||
const memberId = await getCurrentMemberId(request, orgId, headers);
|
||||
return { request: createAuthenticatedRequest(request, headers), orgId, memberId };
|
||||
}
|
||||
|
||||
function createAuthenticatedRequest(
|
||||
request: APIRequestContext,
|
||||
headers: Record<string, string>
|
||||
): APIRequestContext {
|
||||
// Wrap the request to always include auth headers
|
||||
return new Proxy(request, {
|
||||
get(target, prop) {
|
||||
if (
|
||||
prop === 'get' ||
|
||||
prop === 'post' ||
|
||||
prop === 'put' ||
|
||||
prop === 'delete' ||
|
||||
prop === 'patch'
|
||||
) {
|
||||
return (url: string, options?: Record<string, unknown>) => {
|
||||
return target[prop as 'get'](url, {
|
||||
...options,
|
||||
headers: {
|
||||
...headers,
|
||||
...((options?.headers as Record<string, string>) || {}),
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
return target[prop as keyof APIRequestContext];
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function getOrganizationId(
|
||||
request: APIRequestContext,
|
||||
headers: Record<string, string>
|
||||
): Promise<string> {
|
||||
const response = await request.get(`${PLAYWRIGHT_BASE_URL}/api/v1/users/me/memberships`, {
|
||||
headers,
|
||||
});
|
||||
expect(response.status()).toBe(200);
|
||||
const body = await response.json();
|
||||
return body.data[0].organization.id;
|
||||
}
|
||||
|
||||
async function getCurrentMemberId(
|
||||
request: APIRequestContext,
|
||||
orgId: string,
|
||||
headers: Record<string, string>
|
||||
): Promise<string> {
|
||||
const response = await request.get(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${orgId}/members`,
|
||||
{ headers }
|
||||
);
|
||||
expect(response.status()).toBe(200);
|
||||
const body = await response.json();
|
||||
return body.data[0].id;
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Duration parsing
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
function parseDurationToSeconds(duration: string): number {
|
||||
let totalSeconds = 0;
|
||||
|
||||
// Match patterns like "1h", "30min", "2h 30min", "1h 7min"
|
||||
const hourMatch = duration.match(/(\d+)\s*h/);
|
||||
const minMatch = duration.match(/(\d+)\s*min/);
|
||||
|
||||
if (hourMatch) {
|
||||
totalSeconds += parseInt(hourMatch[1], 10) * 3600;
|
||||
}
|
||||
if (minMatch) {
|
||||
totalSeconds += parseInt(minMatch[1], 10) * 60;
|
||||
}
|
||||
|
||||
// If no h/min pattern matched, try plain number as minutes
|
||||
if (!hourMatch && !minMatch) {
|
||||
const plainNumber = parseInt(duration, 10);
|
||||
if (!isNaN(plainNumber)) {
|
||||
totalSeconds = plainNumber * 60;
|
||||
}
|
||||
}
|
||||
|
||||
return totalSeconds;
|
||||
}
|
||||
|
||||
function createTimestamps(duration: string): { start: string; end: string } {
|
||||
const durationSeconds = parseDurationToSeconds(duration);
|
||||
const now = new Date();
|
||||
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 9, 0, 0);
|
||||
const end = new Date(start.getTime() + durationSeconds * 1000);
|
||||
|
||||
return {
|
||||
start: formatTimestamp(start),
|
||||
end: formatTimestamp(end),
|
||||
};
|
||||
}
|
||||
|
||||
function formatTimestamp(date: Date): string {
|
||||
return date.toISOString().replace(/\.\d{3}Z$/, 'Z');
|
||||
}
|
||||
|
||||
function randomColor(): string {
|
||||
const colors = [
|
||||
'#ef5350',
|
||||
'#ab47bc',
|
||||
'#5c6bc0',
|
||||
'#29b6f6',
|
||||
'#26a69a',
|
||||
'#9ccc65',
|
||||
'#ffa726',
|
||||
'#8d6e63',
|
||||
];
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Entity creation
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function createPublicProjectViaApi(
|
||||
ctx: TestContext,
|
||||
data: {
|
||||
name: string;
|
||||
is_billable?: boolean;
|
||||
billable_rate?: number | null;
|
||||
client_id?: string | null;
|
||||
}
|
||||
) {
|
||||
return createProjectViaApi(ctx, {
|
||||
...data,
|
||||
is_public: true,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createProjectViaApi(
|
||||
ctx: TestContext,
|
||||
data: {
|
||||
name: string;
|
||||
color?: string;
|
||||
is_billable?: boolean;
|
||||
billable_rate?: number | null;
|
||||
client_id?: string | null;
|
||||
estimated_time?: number | null;
|
||||
is_public?: boolean;
|
||||
}
|
||||
) {
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/projects`,
|
||||
{
|
||||
data: {
|
||||
name: data.name,
|
||||
color: data.color ?? randomColor(),
|
||||
is_billable: data.is_billable ?? false,
|
||||
billable_rate: data.billable_rate ?? null,
|
||||
client_id: data.client_id ?? null,
|
||||
estimated_time: data.estimated_time ?? null,
|
||||
is_public: data.is_public ?? false,
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response.status()).toBe(201);
|
||||
const body = await response.json();
|
||||
return body.data as { id: string; name: string; color: string; is_billable: boolean };
|
||||
}
|
||||
|
||||
export async function createBillableProjectViaApi(
|
||||
ctx: TestContext,
|
||||
data: { name: string; billable_rate?: number | null }
|
||||
) {
|
||||
return createProjectViaApi(ctx, {
|
||||
name: data.name,
|
||||
is_billable: true,
|
||||
billable_rate: data.billable_rate ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createClientViaApi(ctx: TestContext, data: { name: string }) {
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/clients`,
|
||||
{ data: { name: data.name } }
|
||||
);
|
||||
expect(response.status()).toBe(201);
|
||||
const body = await response.json();
|
||||
return body.data as { id: string; name: string };
|
||||
}
|
||||
|
||||
export async function createProjectWithClientViaApi(
|
||||
ctx: TestContext,
|
||||
projectName: string,
|
||||
clientName: string
|
||||
) {
|
||||
const client = await createClientViaApi(ctx, { name: clientName });
|
||||
const project = await createProjectViaApi(ctx, {
|
||||
name: projectName,
|
||||
client_id: client.id,
|
||||
});
|
||||
return { project, client };
|
||||
}
|
||||
|
||||
export async function createTaskViaApi(
|
||||
ctx: TestContext,
|
||||
data: { name: string; project_id: string }
|
||||
) {
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/tasks`,
|
||||
{
|
||||
data: {
|
||||
name: data.name,
|
||||
project_id: data.project_id,
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response.status()).toBe(201);
|
||||
const body = await response.json();
|
||||
return body.data as { id: string; name: string; project_id: string };
|
||||
}
|
||||
|
||||
export async function createTagViaApi(ctx: TestContext, data: { name: string }) {
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/tags`,
|
||||
{ data: { name: data.name } }
|
||||
);
|
||||
expect(response.status()).toBe(201);
|
||||
const body = await response.json();
|
||||
return body.data as { id: string; name: string };
|
||||
}
|
||||
|
||||
export async function createTimeEntryViaApi(
|
||||
ctx: TestContext,
|
||||
data: {
|
||||
description?: string;
|
||||
duration: string;
|
||||
projectId?: string | null;
|
||||
taskId?: string | null;
|
||||
tags?: string[];
|
||||
billable?: boolean;
|
||||
}
|
||||
) {
|
||||
const { start, end } = createTimestamps(data.duration);
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/time-entries`,
|
||||
{
|
||||
data: {
|
||||
member_id: ctx.memberId,
|
||||
start,
|
||||
end,
|
||||
description: data.description ?? '',
|
||||
project_id: data.projectId ?? null,
|
||||
task_id: data.taskId ?? null,
|
||||
tags: data.tags ?? [],
|
||||
billable: data.billable ?? false,
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response.status()).toBe(201);
|
||||
const body = await response.json();
|
||||
return body.data as { id: string; start: string; end: string; description: string };
|
||||
}
|
||||
|
||||
export async function createProjectMemberViaApi(
|
||||
ctx: TestContext,
|
||||
projectId: string,
|
||||
data: { member_id: string; billable_rate?: number | null }
|
||||
) {
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/projects/${projectId}/project-members`,
|
||||
{
|
||||
data: {
|
||||
member_id: data.member_id,
|
||||
billable_rate: data.billable_rate ?? null,
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response.status()).toBe(201);
|
||||
const body = await response.json();
|
||||
return body.data as { id: string; billable_rate: number | null };
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Composite helpers (matching existing UI helper signatures)
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function createTimeEntryWithProjectViaApi(
|
||||
ctx: TestContext,
|
||||
projectName: string,
|
||||
duration: string
|
||||
) {
|
||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
||||
const entry = await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName}`,
|
||||
duration,
|
||||
projectId: project.id,
|
||||
});
|
||||
return { project, entry };
|
||||
}
|
||||
|
||||
export async function createTimeEntryWithProjectAndTaskViaApi(
|
||||
ctx: TestContext,
|
||||
projectId: string,
|
||||
taskName: string,
|
||||
projectName: string,
|
||||
duration: string
|
||||
) {
|
||||
const task = await createTaskViaApi(ctx, { name: taskName, project_id: projectId });
|
||||
const entry = await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry for ${projectName} - ${taskName}`,
|
||||
duration,
|
||||
projectId,
|
||||
taskId: task.id,
|
||||
});
|
||||
return { task, entry };
|
||||
}
|
||||
|
||||
export async function createTimeEntryWithTagViaApi(
|
||||
ctx: TestContext,
|
||||
tagName: string,
|
||||
duration: string
|
||||
) {
|
||||
const tag = await createTagViaApi(ctx, { name: tagName });
|
||||
const entry = await createTimeEntryViaApi(ctx, {
|
||||
description: `Entry with tag ${tagName}`,
|
||||
duration,
|
||||
tags: [tag.id],
|
||||
});
|
||||
return { tag, entry };
|
||||
}
|
||||
|
||||
export async function createBareTimeEntryViaApi(
|
||||
ctx: TestContext,
|
||||
description: string,
|
||||
duration: string
|
||||
) {
|
||||
return createTimeEntryViaApi(ctx, { description, duration });
|
||||
}
|
||||
|
||||
export async function createTimeEntryWithBillableStatusViaApi(
|
||||
ctx: TestContext,
|
||||
isBillable: boolean,
|
||||
duration: string
|
||||
) {
|
||||
return createTimeEntryViaApi(ctx, {
|
||||
description: `Time entry ${isBillable ? 'billable' : 'non-billable'}`,
|
||||
duration,
|
||||
billable: isBillable,
|
||||
});
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Import helper (for placeholder member creation)
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function createPlaceholderMemberViaImportApi(
|
||||
ctx: TestContext,
|
||||
placeholderName: string
|
||||
) {
|
||||
const placeholderEmail = `placeholder+${Math.floor(Math.random() * 100000)}@solidtime-import.test`;
|
||||
const csvContent = [
|
||||
'User,Email,Client,Project,Task,Description,Billable,Start date,Start time,End date,End time,Tags',
|
||||
`${placeholderName},${placeholderEmail},,,,Imported entry,No,2024-01-01,09:00:00,2024-01-01,10:00:00,`,
|
||||
].join('\n');
|
||||
|
||||
const base64Data = Buffer.from(csvContent).toString('base64');
|
||||
|
||||
const response = await ctx.request.post(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/import`,
|
||||
{
|
||||
data: {
|
||||
type: 'toggl_time_entries',
|
||||
data: base64Data,
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response.status()).toBe(200);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Organization settings helpers
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function updateOrganizationSettingViaApi(
|
||||
ctx: TestContext,
|
||||
settings: Record<string, unknown>
|
||||
) {
|
||||
const response = await ctx.request.put(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}`,
|
||||
{ data: settings }
|
||||
);
|
||||
expect(response.status()).toBe(200);
|
||||
const body = await response.json();
|
||||
return body.data;
|
||||
}
|
||||
|
||||
export async function updateOrganizationCurrencyViaWeb(
|
||||
ctx: TestContext,
|
||||
currency: string,
|
||||
name: string = 'Test Organization'
|
||||
) {
|
||||
const response = await ctx.request.put(`${PLAYWRIGHT_BASE_URL}/teams/${ctx.orgId}`, {
|
||||
data: { name, currency },
|
||||
});
|
||||
expect(response.status()).toBe(200);
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Bulk helpers
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function createMultipleTimeEntriesViaApi(
|
||||
ctx: TestContext,
|
||||
count: number,
|
||||
data: { description?: string; duration?: string } = {}
|
||||
) {
|
||||
const entries = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const entry = await createTimeEntryViaApi(ctx, {
|
||||
description: data.description ?? `Bulk entry ${i + 1}`,
|
||||
duration: data.duration ?? '30min',
|
||||
});
|
||||
entries.push(entry);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Invitation helpers
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function getInvitationsViaApi(ctx: TestContext) {
|
||||
const response = await ctx.request.get(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/invitations`
|
||||
);
|
||||
expect(response.status()).toBe(200);
|
||||
const body = await response.json();
|
||||
return body.data as Array<{ id: string; email: string; role: string }>;
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
import { expect, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
export async function startOrStopTimerWithButton(page: Page) {
|
||||
await page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]').click();
|
||||
}
|
||||
|
||||
export async function assertThatTimerHasStarted(page: Page) {
|
||||
await page.locator(
|
||||
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-red-400/80'
|
||||
);
|
||||
await expect(
|
||||
page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]')
|
||||
).toHaveClass(/bg-red-400\/80/);
|
||||
}
|
||||
|
||||
export function newTimeEntryResponse(
|
||||
|
||||
81
e2e/utils/mailpit.ts
Normal file
81
e2e/utils/mailpit.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import type { APIRequestContext } from '@playwright/test';
|
||||
import { MAILPIT_BASE_URL } from '../../playwright/config';
|
||||
|
||||
/**
|
||||
* Search for emails in Mailpit matching the given query.
|
||||
*/
|
||||
export async function searchEmails(
|
||||
request: APIRequestContext,
|
||||
query: string
|
||||
): Promise<{ messages: Array<{ ID: string; Subject: string }> }> {
|
||||
const response = await request.get(`${MAILPIT_BASE_URL}/api/v1/search?query=${query}`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full email message from Mailpit by ID.
|
||||
*/
|
||||
export async function getMessage(
|
||||
request: APIRequestContext,
|
||||
messageId: string
|
||||
): Promise<{ HTML: string; Text: string }> {
|
||||
const response = await request.get(`${MAILPIT_BASE_URL}/api/v1/message/${messageId}`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the invitation acceptance URL from a Mailpit email sent to the given address.
|
||||
* Retries a few times to allow for email delivery delay.
|
||||
*/
|
||||
export async function getInvitationAcceptUrl(
|
||||
request: APIRequestContext,
|
||||
recipientEmail: string
|
||||
): Promise<string> {
|
||||
let searchResult: { messages: Array<{ ID: string }> } = { messages: [] };
|
||||
|
||||
// Retry up to 5 times with 500ms delay to allow for email delivery
|
||||
for (let attempt = 0; attempt < 5; attempt++) {
|
||||
searchResult = await searchEmails(
|
||||
request,
|
||||
`to:${encodeURIComponent(recipientEmail)} subject:"Organization Invitation"`
|
||||
);
|
||||
if (searchResult.messages.length > 0) break;
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
expect(searchResult.messages.length).toBeGreaterThan(0);
|
||||
|
||||
const message = await getMessage(request, searchResult.messages[0].ID);
|
||||
const acceptUrlMatch = message.HTML.match(/href="([^"]*team-invitations[^"]*)"/);
|
||||
expect(acceptUrlMatch).toBeTruthy();
|
||||
|
||||
return acceptUrlMatch![1].replace(/&/g, '&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the password reset URL from a Mailpit email sent to the given address.
|
||||
* Retries a few times to allow for email delivery delay.
|
||||
*/
|
||||
export async function getPasswordResetUrl(
|
||||
request: APIRequestContext,
|
||||
recipientEmail: string
|
||||
): Promise<string> {
|
||||
let searchResult: { messages: Array<{ ID: string }> } = { messages: [] };
|
||||
|
||||
// Retry up to 5 times with 500ms delay to allow for email delivery
|
||||
for (let attempt = 0; attempt < 5; attempt++) {
|
||||
searchResult = await searchEmails(
|
||||
request,
|
||||
`to:${encodeURIComponent(recipientEmail)} subject:"Reset Password"`
|
||||
);
|
||||
if (searchResult.messages.length > 0) break;
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
expect(searchResult.messages.length).toBeGreaterThan(0);
|
||||
|
||||
const message = await getMessage(request, searchResult.messages[0].ID);
|
||||
const resetUrlMatch = message.HTML.match(/href="([^"]*reset-password[^"]*)"/);
|
||||
expect(resetUrlMatch).toBeTruthy();
|
||||
|
||||
return resetUrlMatch![1].replace(/&/g, '&');
|
||||
}
|
||||
164
e2e/utils/members.ts
Normal file
164
e2e/utils/members.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Browser, Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../../playwright/config';
|
||||
import { getInvitationAcceptUrl } from './mailpit';
|
||||
import type { TestContext } from './api';
|
||||
|
||||
/**
|
||||
* Register a new user in a fresh browser context and return the page + context.
|
||||
*/
|
||||
export async function registerUser(
|
||||
browser: Browser,
|
||||
name: string,
|
||||
email: string
|
||||
): Promise<{ page: Page; close: () => Promise<void> }> {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/register');
|
||||
await page.getByLabel('Name').fill(name);
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password', { exact: true }).fill('amazingpassword123');
|
||||
await page.getByLabel('Confirm Password').fill('amazingpassword123');
|
||||
await page.getByLabel('I agree to the Terms of').click();
|
||||
await page.getByRole('button', { name: 'Register' }).click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
|
||||
return { page, close: () => context.close() };
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite a user by email from the members page and accept the invitation
|
||||
* through a second browser session, returning the accepted member to the
|
||||
* members table as a real (non-placeholder) member.
|
||||
*
|
||||
* @param ownerPage – The page of the organization owner who sends the invite
|
||||
* @param browser – Browser instance used to create a second context
|
||||
* @param memberName – Display name for the new user
|
||||
* @param memberEmail – Email address (must not be registered yet)
|
||||
* @param role – Role button label: 'Employee' | 'Manager' | 'Administrator'
|
||||
*/
|
||||
export async function inviteAndAcceptMember(
|
||||
ownerPage: Page,
|
||||
browser: Browser,
|
||||
memberName: string,
|
||||
memberEmail: string,
|
||||
role: 'Employee' | 'Manager' | 'Administrator'
|
||||
): Promise<void> {
|
||||
// 1. Register the second user
|
||||
const secondUser = await registerUser(browser, memberName, memberEmail);
|
||||
|
||||
// 2. Send invitation from the owner
|
||||
await ownerPage.goto(PLAYWRIGHT_BASE_URL + '/members');
|
||||
await ownerPage.getByRole('button', { name: 'Invite Member' }).click();
|
||||
await expect(ownerPage.getByPlaceholder('Member Email')).toBeVisible();
|
||||
await ownerPage.getByLabel('Email').fill(memberEmail);
|
||||
await ownerPage.getByRole('button', { name: role }).click();
|
||||
await Promise.all([
|
||||
ownerPage.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
expect(ownerPage.getByRole('main')).toContainText(memberEmail),
|
||||
]);
|
||||
|
||||
// 3. Retrieve the acceptance link from Mailpit and accept
|
||||
const acceptUrl = await getInvitationAcceptUrl(secondUser.page.request, memberEmail);
|
||||
await secondUser.page.goto(acceptUrl);
|
||||
await secondUser.page.waitForURL(/dashboard/);
|
||||
|
||||
// 4. Clean up
|
||||
await secondUser.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up an employee member in the owner's organization.
|
||||
* Returns the employee's page, their member ID, and a cleanup function.
|
||||
*
|
||||
* The owner page (from the fixture) is used to invite the employee.
|
||||
* Test data should be created via the owner's ctx.
|
||||
*
|
||||
* IMPORTANT: Projects must be created with is_public: true for the employee to see them,
|
||||
* or the employee must be added as a project member via createProjectMemberViaApi.
|
||||
* Clients are only visible to employees if they have at least one visible project.
|
||||
* Tags are visible to all org members with tags:view permission.
|
||||
*/
|
||||
export async function setupEmployeeUser(
|
||||
ownerPage: Page,
|
||||
ownerCtx: TestContext,
|
||||
browser: Browser
|
||||
): Promise<{
|
||||
employeePage: Page;
|
||||
employeeMemberId: string;
|
||||
closeEmployee: () => Promise<void>;
|
||||
}> {
|
||||
const memberId = Math.floor(Math.random() * 100000);
|
||||
const memberEmail = `employee+${memberId}@emp-perms.test`;
|
||||
const memberName = 'Emp ' + memberId;
|
||||
|
||||
// Register the employee user first
|
||||
const employee = await registerUser(browser, memberName, memberEmail);
|
||||
|
||||
// Send invitation from the owner
|
||||
await ownerPage.goto(PLAYWRIGHT_BASE_URL + '/members');
|
||||
await ownerPage.getByRole('button', { name: 'Invite Member' }).click();
|
||||
await expect(ownerPage.getByPlaceholder('Member Email')).toBeVisible();
|
||||
await ownerPage.getByPlaceholder('Member Email').fill(memberEmail);
|
||||
await ownerPage.getByRole('button', { name: 'Employee' }).click();
|
||||
await Promise.all([
|
||||
ownerPage.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/invitations') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 204
|
||||
),
|
||||
ownerPage.getByRole('button', { name: 'Invite Member', exact: true }).click(),
|
||||
]);
|
||||
|
||||
// Accept the invitation
|
||||
const acceptUrl = await getInvitationAcceptUrl(employee.page.request, memberEmail);
|
||||
await employee.page.goto(acceptUrl);
|
||||
await employee.page.waitForURL(/dashboard/);
|
||||
|
||||
// Navigate to dashboard explicitly and wait for it to load to ensure the correct org context.
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({ timeout: 15000 });
|
||||
|
||||
// Verify we're on the correct organization (John's Organization).
|
||||
const orgSwitcherText = await employee.page
|
||||
.getByTestId('organization_switcher')
|
||||
.first()
|
||||
.textContent();
|
||||
if (!orgSwitcherText?.includes("John's Organization")) {
|
||||
// Switch to the owner's org using the PUT /current-team endpoint
|
||||
const cookies = await employee.page.context().cookies();
|
||||
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
||||
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
||||
|
||||
await employee.page.request.put(`${PLAYWRIGHT_BASE_URL}/current-team`, {
|
||||
headers: {
|
||||
'X-XSRF-TOKEN': xsrfToken,
|
||||
Accept: 'text/html',
|
||||
},
|
||||
data: { team_id: ownerCtx.orgId },
|
||||
});
|
||||
|
||||
// Reload to pick up the new org
|
||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await expect(employee.page.getByTestId('dashboard_view')).toBeVisible({ timeout: 15000 });
|
||||
}
|
||||
|
||||
// Find the employee's member ID in the owner's organization
|
||||
const membersResponse = await ownerCtx.request.get(
|
||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ownerCtx.orgId}/members`
|
||||
);
|
||||
expect(membersResponse.status()).toBe(200);
|
||||
const membersBody = await membersResponse.json();
|
||||
const employeeMember = membersBody.data.find(
|
||||
(m: { role: string; name: string }) => m.role === 'employee' && m.name === memberName
|
||||
);
|
||||
expect(employeeMember).toBeTruthy();
|
||||
|
||||
return {
|
||||
employeePage: employee.page,
|
||||
employeeMemberId: employeeMember.id,
|
||||
closeEmployee: employee.close,
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { formatCents } from '../../resources/js/packages/ui/src/utils/money';
|
||||
import type { CurrencyFormat } from '../../resources/js/packages/ui/src/utils/money';
|
||||
import { NumberFormat } from '../../resources/js/packages/ui/src/utils/number';
|
||||
import type { NumberFormat } from '../../resources/js/packages/ui/src/utils/number';
|
||||
|
||||
export function formatCentsWithOrganizationDefaults(
|
||||
cents: number,
|
||||
|
||||
320
e2e/utils/reporting.ts
Normal file
320
e2e/utils/reporting.ts
Normal file
@@ -0,0 +1,320 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../../playwright/config';
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Navigation
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function goToReporting(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/reporting');
|
||||
}
|
||||
|
||||
export async function goToReportingDetailed(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/reporting/detailed');
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Entity creation
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function createProject(page: Page, projectName: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(page.getByRole('button', { name: 'Create Project' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project name').fill(projectName);
|
||||
await Promise.all([
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
]);
|
||||
await expect(page.getByText(projectName)).toBeVisible();
|
||||
}
|
||||
|
||||
export async function createBillableProject(page: Page, projectName: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(page.getByRole('button', { name: 'Create Project' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project name').fill(projectName);
|
||||
await page.getByText('Non-Billable').click();
|
||||
await page.getByText('Default Rate').click();
|
||||
await Promise.all([
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
]);
|
||||
await expect(page.getByText(projectName)).toBeVisible();
|
||||
}
|
||||
|
||||
export async function createClient(page: Page, clientName: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/clients');
|
||||
await expect(page.getByRole('button', { name: 'Create Client' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Create Client' }).click();
|
||||
await page.getByPlaceholder('Client Name').fill(clientName);
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Client' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/clients') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
]);
|
||||
await expect(page.getByText(clientName)).toBeVisible();
|
||||
}
|
||||
|
||||
export async function createProjectWithClient(page: Page, projectName: string, clientName: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(page.getByRole('button', { name: 'Create Project' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Create Project' }).click();
|
||||
await page.getByLabel('Project name').fill(projectName);
|
||||
|
||||
// Select client in the project create modal
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'No Client' }).click();
|
||||
await page.getByRole('option', { name: clientName }).click();
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Project' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/projects') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
]);
|
||||
await expect(page.getByText(projectName)).toBeVisible();
|
||||
}
|
||||
|
||||
export async function createTask(page: Page, projectName: string, taskName: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||
await expect(page.getByText(projectName)).toBeVisible();
|
||||
await page.getByText(projectName).click();
|
||||
await page.getByRole('button', { name: 'Create Task' }).click();
|
||||
await page.getByPlaceholder('Task Name').fill(taskName);
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Task' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/tasks') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
]);
|
||||
await expect(page.getByText(taskName)).toBeVisible();
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Time entry creation
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function createTimeEntryWithProject(
|
||||
page: Page,
|
||||
projectName: string,
|
||||
duration: string
|
||||
) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
await expect(page.getByRole('button', { name: 'Time entry actions' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Manual time entry' }).click();
|
||||
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByRole('textbox', { name: 'Description' })
|
||||
.fill(`Entry for ${projectName}`);
|
||||
|
||||
await page.getByRole('button', { name: 'No Project' }).click();
|
||||
await page.getByRole('option').filter({ hasText: projectName }).click();
|
||||
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').fill(duration);
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Time Entry' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 201
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function createTimeEntryWithProjectAndTask(
|
||||
page: Page,
|
||||
projectName: string,
|
||||
taskName: string,
|
||||
duration: string
|
||||
) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
await expect(page.getByRole('button', { name: 'Time entry actions' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Manual time entry' }).click();
|
||||
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByRole('textbox', { name: 'Description' })
|
||||
.fill(`Entry for ${projectName} - ${taskName}`);
|
||||
|
||||
// Open the project/task dropdown
|
||||
await page.getByRole('button', { name: 'No Project' }).click();
|
||||
|
||||
// Expand the project's tasks by clicking the "Tasks" button
|
||||
const projectOption = page.getByRole('option').filter({ hasText: projectName });
|
||||
await projectOption.getByText(/Tasks/).click();
|
||||
|
||||
// Select the task (this also selects the project and closes the dropdown)
|
||||
await page.getByText(taskName, { exact: true }).click();
|
||||
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').fill(duration);
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Time Entry' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 201
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function createTimeEntryWithTag(page: Page, tagName: string, duration: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
await expect(page.getByRole('button', { name: 'Time entry actions' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Manual time entry' }).click();
|
||||
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByRole('textbox', { name: 'Description' })
|
||||
.fill(`Entry with tag ${tagName}`);
|
||||
|
||||
// Add tag
|
||||
await page.getByRole('button', { name: 'Tags' }).click();
|
||||
await page.getByText('Create new tag').click();
|
||||
await page.getByPlaceholder('Tag Name').fill(tagName);
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Tag' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/tags') && response.status() === 201
|
||||
),
|
||||
]);
|
||||
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').fill(duration);
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Time Entry' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 201
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function createBareTimeEntry(page: Page, description: string, duration: string) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
await expect(page.getByRole('button', { name: 'Time entry actions' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Manual time entry' }).click();
|
||||
|
||||
await page.getByRole('dialog').getByRole('textbox', { name: 'Description' }).fill(description);
|
||||
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').fill(duration);
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Time Entry' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 201
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function createTimeEntryWithBillableStatus(
|
||||
page: Page,
|
||||
isBillable: boolean,
|
||||
duration: string
|
||||
) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
||||
await expect(page.getByRole('button', { name: 'Time entry actions' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Manual time entry' }).click();
|
||||
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByRole('textbox', { name: 'Description' })
|
||||
.fill(`Time entry ${isBillable ? 'billable' : 'non-billable'}`);
|
||||
|
||||
if (isBillable) {
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByRole('combobox')
|
||||
.filter({ hasText: 'Non-Billable' })
|
||||
.click();
|
||||
await page.getByRole('option', { name: 'Billable', exact: true }).click();
|
||||
}
|
||||
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').fill(duration);
|
||||
await page.locator('[role="dialog"] input[name="Duration"]').press('Tab');
|
||||
|
||||
await Promise.all([
|
||||
page.getByRole('button', { name: 'Create Time Entry' }).click(),
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes('/time-entries') && response.status() === 201
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Wait helpers
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function waitForReportingUpdate(page: Page) {
|
||||
await page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries/aggregate') && response.status() === 200
|
||||
);
|
||||
}
|
||||
|
||||
export async function waitForDetailedReportingUpdate(page: Page) {
|
||||
await page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/time-entries') &&
|
||||
!response.url().includes('/aggregate') &&
|
||||
response.request().method() === 'GET' &&
|
||||
response.status() === 200
|
||||
);
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────
|
||||
// Shared report helpers
|
||||
// ──────────────────────────────────────────────────
|
||||
|
||||
export async function goToReportingShared(page: Page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/reporting/shared');
|
||||
}
|
||||
|
||||
export async function saveAsSharedReport(
|
||||
page: Page,
|
||||
reportName: string
|
||||
): Promise<{ shareableLink: string }> {
|
||||
await page.getByRole('button', { name: 'Save Report' }).click();
|
||||
await page.getByLabel('Name').fill(reportName);
|
||||
// "Public" checkbox is checked by default
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/reports') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
),
|
||||
page.getByRole('dialog').getByRole('button', { name: 'Create Report' }).click(),
|
||||
]);
|
||||
const responseBody = await response.json();
|
||||
// Wait for navigation to shared reports page
|
||||
await page.waitForURL('**/reporting/shared');
|
||||
return { shareableLink: responseBody.data.shareable_link };
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Page } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
export function newTagResponse(page: Page, { name = '' } = {}) {
|
||||
return page.waitForResponse(async (response) => {
|
||||
|
||||
4198
package-lock.json
generated
4198
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@@ -1,6 +1,10 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
"resources/js/packages/ui",
|
||||
"resources/js/packages/api"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
@@ -15,27 +19,28 @@
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.19.0",
|
||||
"@inertiajs/vue3": "^1.0.0",
|
||||
"@inertiajs/vue3": "^2.0.0",
|
||||
"@playwright/test": "^1.41.1",
|
||||
"@tailwindcss/forms": "^0.5.9",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@types/chroma-js": "2.4.5",
|
||||
"@types/chroma-js": "^3.1.0",
|
||||
"@types/node": "^22.10.10",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"@vue/tsconfig": "^0.5.1",
|
||||
"@vitejs/plugin-vue": "^6.0.3",
|
||||
"@vue/tsconfig": "^0.8.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"axios": "^1.6.4",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"laravel-vite-plugin": "^1.0.0",
|
||||
"laravel-vite-plugin": "^2.1.0",
|
||||
"openapi-zod-client": "^1.16.2",
|
||||
"postcss": "^8.4.47",
|
||||
"postcss-import": "^15.1.0",
|
||||
"postcss-nesting": "^12.1.5",
|
||||
"tailwindcss": "^3.4.13",
|
||||
"typescript": "^5.7.3",
|
||||
"vite": "^6.0.11",
|
||||
"vite-plugin-checker": "^0.8.0",
|
||||
"vite": "^7.0.0",
|
||||
"vite-plugin-checker": "^0.12.0",
|
||||
"vue": "^3.5.0",
|
||||
"vue-tsc": "^2.2.0"
|
||||
"vue-tsc": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@floating-ui/core": "^1.6.0",
|
||||
@@ -54,22 +59,24 @@
|
||||
"@tanstack/vue-table": "^8.21.2",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.3.0",
|
||||
"@vueuse/core": "^12.8.2",
|
||||
"@vueuse/integrations": "^12.5.0",
|
||||
"@vueuse/core": "^14.2.0",
|
||||
"@vueuse/integrations": "^14.0.0",
|
||||
"@zodios/core": "^10.9.6",
|
||||
"chroma-js": "3.1.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.11",
|
||||
"echarts": "^5.5.0",
|
||||
"focus-trap": "^7.6.0",
|
||||
"echarts": "^6.0.0",
|
||||
"focus-trap": "^8.0.0",
|
||||
"lucide-vue-next": "^0.487.0",
|
||||
"parse-duration": "^2.0.1",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia": "^3.0.0",
|
||||
"radix-vue": "^1.9.6",
|
||||
"reka-ui": "^2.2.0",
|
||||
"reka-ui": "^2.8.0",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"vue-echarts": "^7.0.3"
|
||||
"vue-echarts": "^8.0.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"overrides": {
|
||||
"vite-plugin-checker": {
|
||||
|
||||
@@ -17,10 +17,10 @@ export default defineConfig({
|
||||
forbidOnly: !!process.env.CI,
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 1 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: 1,
|
||||
/* Run tests in parallel */
|
||||
workers: 4,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: process.env.CI ? 'line' : 'html',
|
||||
reporter: process.env.CI ? 'blob' : 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
@@ -39,35 +39,15 @@ export default defineConfig({
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] },
|
||||
},
|
||||
|
||||
// {
|
||||
// name: 'webkit',
|
||||
// use: { ...devices['Desktop Safari'] },
|
||||
// },
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: { ...devices['Pixel 5'] },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: { ...devices['iPhone 12'] },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
// name: 'Microsoft Edge',
|
||||
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||
// },
|
||||
// {
|
||||
// name: 'Google Chrome',
|
||||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
// },
|
||||
// Firefox only in CI to keep local runs fast
|
||||
...(process.env.CI
|
||||
? [
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] },
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export const PLAYWRIGHT_BASE_URL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://solidtime.test';
|
||||
export const MAILPIT_BASE_URL = process.env.MAILPIT_BASE_URL ?? 'http://mailpit:8025';
|
||||
export const TEST_USER_PASSWORD = 'amazingpassword123';
|
||||
|
||||
@@ -1,27 +1,103 @@
|
||||
import { test as baseTest } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from './config';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL, TEST_USER_PASSWORD } from './config';
|
||||
import { type TestContext, setupTestContext } from '../e2e/utils/api';
|
||||
import { setupEmployeeUser } from '../e2e/utils/members';
|
||||
|
||||
export * from '@playwright/test';
|
||||
export const test = baseTest.extend<object, { workerStorageState: string }>({
|
||||
// Use the same storage state for all tests in this worker.
|
||||
export type { TestContext };
|
||||
|
||||
export interface EmployeeFixture {
|
||||
page: Page;
|
||||
memberId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* API-based authentication fixture - creates a new user via HTTP requests instead of UI interactions.
|
||||
* This is ~10-25x faster than UI-based authentication (~100-200ms vs ~3-5s).
|
||||
*
|
||||
* Uses page.context().request() to ensure cookies are shared between the API request and page.
|
||||
*/
|
||||
export const test = baseTest.extend<
|
||||
{ ctx: TestContext; employee: EmployeeFixture },
|
||||
{ workerStorageState: string }
|
||||
>({
|
||||
page: async ({ page }, use) => {
|
||||
// Perform authentication steps. Replace these actions with your own.
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/register');
|
||||
await page.getByLabel('Name').fill('John Doe');
|
||||
await page.getByLabel('Email').fill(`john+${Math.round(Math.random() * 1000000)}@doe.com`);
|
||||
await page.getByLabel('Password', { exact: true }).fill('amazingpassword123');
|
||||
await page.getByLabel('Confirm Password').fill('amazingpassword123');
|
||||
await page.getByLabel('I agree to the Terms of').click();
|
||||
await page.getByRole('button', { name: 'Register' }).click();
|
||||
// Generate unique email for this test
|
||||
const email = `john+${Date.now()}_${Math.floor(Math.random() * 10000)}@doe.com`;
|
||||
const password = TEST_USER_PASSWORD;
|
||||
const name = 'John Doe';
|
||||
|
||||
// Wait until the page receives the cookies.
|
||||
//
|
||||
// Sometimes login flow sets cookies in the process of several redirects.
|
||||
// Wait for the final URL to ensure that the cookies are actually set.
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
// Use page.context().request() so cookies are automatically shared with the page
|
||||
const request = page.context().request;
|
||||
|
||||
// End of authentication steps.
|
||||
// Step 1: Visit the register page to get CSRF token and initial session
|
||||
const csrfResponse = await request.get(`${PLAYWRIGHT_BASE_URL}/register`, {
|
||||
maxRedirects: 0,
|
||||
});
|
||||
|
||||
// Extract XSRF-TOKEN from cookies
|
||||
const cookies = csrfResponse.headers()['set-cookie'];
|
||||
let xsrfToken = '';
|
||||
if (cookies) {
|
||||
const xsrfMatch = cookies.match(/XSRF-TOKEN=([^;]+)/);
|
||||
if (xsrfMatch) {
|
||||
xsrfToken = decodeURIComponent(xsrfMatch[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Register via API (Laravel Fortify web routes)
|
||||
const registerResponse = await request.post(`${PLAYWRIGHT_BASE_URL}/register`, {
|
||||
headers: {
|
||||
'X-XSRF-TOKEN': xsrfToken,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Accept': 'text/html',
|
||||
},
|
||||
form: {
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
password_confirmation: password,
|
||||
terms: 'on',
|
||||
},
|
||||
maxRedirects: 0,
|
||||
});
|
||||
|
||||
// Check if registration was successful (should redirect to dashboard)
|
||||
if (registerResponse.status() !== 302) {
|
||||
console.error('API registration failed, falling back to UI-based registration');
|
||||
|
||||
// Fall back to UI-based registration
|
||||
await page.goto(`${PLAYWRIGHT_BASE_URL}/register`);
|
||||
await page.getByLabel('Name').fill(name);
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password', { exact: true }).fill(password);
|
||||
await page.getByLabel('Confirm Password').fill(password);
|
||||
await page.getByLabel('I agree to the Terms of').click();
|
||||
await page.getByRole('button', { name: 'Register' }).click();
|
||||
await page.waitForURL(`${PLAYWRIGHT_BASE_URL}/dashboard`);
|
||||
} else {
|
||||
// Registration succeeded - cookies are already set in the context from the request
|
||||
// Just navigate to dashboard to verify
|
||||
await page.goto(`${PLAYWRIGHT_BASE_URL}/dashboard`);
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
}
|
||||
|
||||
await use(page);
|
||||
},
|
||||
|
||||
ctx: async ({ page }, use) => {
|
||||
const ctx = await setupTestContext(page);
|
||||
await use(ctx);
|
||||
},
|
||||
|
||||
employee: async ({ page, ctx, browser }, use) => {
|
||||
const { employeePage, employeeMemberId, closeEmployee } = await setupEmployeeUser(
|
||||
page,
|
||||
ctx,
|
||||
browser
|
||||
);
|
||||
await use({ page: employeePage, memberId: employeeMemberId });
|
||||
await closeEmployee();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, computed } from 'vue';
|
||||
import { router, usePage } from '@inertiajs/vue3';
|
||||
import { CommandPalette } from '@/packages/ui/src/CommandPalette';
|
||||
import { useCommandPalette } from '@/utils/useCommandPalette';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useTimeEntriesMutations } from '@/utils/useTimeEntriesMutations';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import { canCreateProjects } from '@/utils/permissions';
|
||||
import type {
|
||||
CreateClientBody,
|
||||
CreateProjectBody,
|
||||
CreateTimeEntryBody,
|
||||
Project,
|
||||
Client,
|
||||
Tag,
|
||||
} from '@/packages/api/src';
|
||||
import type { User } from '@/types/models';
|
||||
import type { Role } from '@/types/jetstream';
|
||||
|
||||
// Import modals
|
||||
import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue';
|
||||
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
||||
import TaskCreateModal from '@/Components/Common/Task/TaskCreateModal.vue';
|
||||
import TagCreateModal from '@/packages/ui/src/Tag/TagCreateModal.vue';
|
||||
import MemberInviteModal from '@/Components/Common/Member/MemberInviteModal.vue';
|
||||
import TimeEntryCreateModal from '@/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue';
|
||||
|
||||
// Import dropdowns for active timer selectors
|
||||
import TimeTrackerProjectTaskDropdown from '@/packages/ui/src/TimeTracker/TimeTrackerProjectTaskDropdown.vue';
|
||||
import TagDropdown from '@/packages/ui/src/Tag/TagDropdown.vue';
|
||||
|
||||
// Dialog components for selectors
|
||||
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
|
||||
const {
|
||||
isOpen,
|
||||
searchTerm,
|
||||
groups,
|
||||
entityResults,
|
||||
togglePalette,
|
||||
showCreateProjectModal,
|
||||
showCreateClientModal,
|
||||
showCreateTaskModal,
|
||||
showCreateTagModal,
|
||||
showInviteMemberModal,
|
||||
showCreateTimeEntryModal,
|
||||
showProjectSelector,
|
||||
showTaskSelector,
|
||||
showTagsSelector,
|
||||
currentTimeEntry,
|
||||
updateTimer,
|
||||
projects,
|
||||
clients,
|
||||
tasks,
|
||||
tags,
|
||||
} = useCommandPalette();
|
||||
|
||||
// Stores for creating entities
|
||||
const projectsStore = useProjectsStore();
|
||||
const clientsStore = useClientsStore();
|
||||
const tagsStore = useTagsStore();
|
||||
|
||||
// Time entry mutations
|
||||
const { createTimeEntry: createTimeEntryMutation } = useTimeEntriesMutations();
|
||||
|
||||
// Get available roles from page props (for member invite modal)
|
||||
const page = usePage<{
|
||||
availableRoles?: Role[];
|
||||
auth: {
|
||||
user: User;
|
||||
};
|
||||
}>();
|
||||
|
||||
const availableRoles = computed(() => page.props.availableRoles ?? []);
|
||||
|
||||
// Active clients for dropdowns
|
||||
const activeClients = computed(() => clients.value.filter((c) => !c.is_archived));
|
||||
|
||||
// Keyboard shortcut handler
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
|
||||
e.preventDefault();
|
||||
togglePalette();
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
});
|
||||
|
||||
// Project creation
|
||||
async function createProject(project: CreateProjectBody): Promise<Project | undefined> {
|
||||
const openedFromCommandPalette = showCreateProjectModal.value;
|
||||
const newProject = await projectsStore.createProject(project);
|
||||
showCreateProjectModal.value = false;
|
||||
if (newProject && openedFromCommandPalette) {
|
||||
router.visit(route('projects.show', { project: newProject.id }));
|
||||
}
|
||||
return newProject;
|
||||
}
|
||||
|
||||
async function createClient(client: CreateClientBody): Promise<Client | undefined> {
|
||||
const openedFromCommandPalette = showCreateClientModal.value;
|
||||
const newClient = await clientsStore.createClient(client);
|
||||
if (newClient && openedFromCommandPalette) {
|
||||
showCreateClientModal.value = false;
|
||||
router.visit(route('clients'));
|
||||
}
|
||||
return newClient;
|
||||
}
|
||||
|
||||
async function createTag(name: string): Promise<Tag | undefined> {
|
||||
const openedFromCommandPalette = showCreateTagModal.value;
|
||||
const newTag = await tagsStore.createTag(name);
|
||||
if (newTag && openedFromCommandPalette) {
|
||||
showCreateTagModal.value = false;
|
||||
router.visit(route('tags'));
|
||||
}
|
||||
return newTag;
|
||||
}
|
||||
|
||||
async function createTimeEntry(timeEntry: Omit<CreateTimeEntryBody, 'member_id'>) {
|
||||
await createTimeEntryMutation(timeEntry);
|
||||
showCreateTimeEntryModal.value = false;
|
||||
}
|
||||
|
||||
async function handleProjectTaskSelect() {
|
||||
showProjectSelector.value = false;
|
||||
showTaskSelector.value = false;
|
||||
await updateTimer();
|
||||
}
|
||||
|
||||
async function handleTagsSelect() {
|
||||
showTagsSelector.value = false;
|
||||
await updateTimer();
|
||||
}
|
||||
|
||||
const firstProjectId = computed(() => projects.value[0]?.id ?? '');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Command Palette Dialog -->
|
||||
<CommandPalette
|
||||
v-model:open="isOpen"
|
||||
v-model:search-term="searchTerm"
|
||||
:groups="groups"
|
||||
:entity-results="entityResults" />
|
||||
|
||||
<!-- Project Create Modal -->
|
||||
<ProjectCreateModal
|
||||
v-model:show="showCreateProjectModal"
|
||||
:create-project="createProject"
|
||||
:create-client="createClient"
|
||||
:clients="activeClients"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()" />
|
||||
|
||||
<!-- Client Create Modal -->
|
||||
<ClientCreateModal v-model:show="showCreateClientModal" />
|
||||
|
||||
<!-- Task Create Modal -->
|
||||
<TaskCreateModal
|
||||
v-if="firstProjectId"
|
||||
v-model:show="showCreateTaskModal"
|
||||
:project-id="firstProjectId" />
|
||||
|
||||
<!-- Tag Create Modal -->
|
||||
<TagCreateModal v-model:show="showCreateTagModal" :create-tag="createTag" />
|
||||
|
||||
<!-- Member Invite Modal -->
|
||||
<MemberInviteModal v-model:show="showInviteMemberModal" :available-roles="availableRoles" />
|
||||
|
||||
<!-- Time Entry Create Modal -->
|
||||
<TimeEntryCreateModal
|
||||
v-model:show="showCreateTimeEntryModal"
|
||||
:create-time-entry="createTimeEntry"
|
||||
:create-project="createProject"
|
||||
:create-client="createClient"
|
||||
:create-tag="createTag"
|
||||
:projects="projects"
|
||||
:tasks="tasks"
|
||||
:tags="tags"
|
||||
:clients="activeClients"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()"
|
||||
:can-create-project="canCreateProjects()" />
|
||||
|
||||
<!-- Project Selector Dialog for Active Timer -->
|
||||
<DialogModal :show="showProjectSelector" closeable @close="showProjectSelector = false">
|
||||
<template #title>Set Project</template>
|
||||
<template #content>
|
||||
<TimeTrackerProjectTaskDropdown
|
||||
v-model:project="currentTimeEntry.project_id"
|
||||
v-model:task="currentTimeEntry.task_id"
|
||||
variant="outline"
|
||||
:projects="projects"
|
||||
:tasks="tasks"
|
||||
:clients="activeClients"
|
||||
:create-project="createProject"
|
||||
:create-client="createClient"
|
||||
:can-create-project="canCreateProjects()"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()"
|
||||
class="w-full" />
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="showProjectSelector = false"> Cancel </SecondaryButton>
|
||||
<SecondaryButton class="ms-3" @click="handleProjectTaskSelect"> Save </SecondaryButton>
|
||||
</template>
|
||||
</DialogModal>
|
||||
|
||||
<!-- Task Selector Dialog for Active Timer -->
|
||||
<DialogModal :show="showTaskSelector" closeable @close="showTaskSelector = false">
|
||||
<template #title>Set Task</template>
|
||||
<template #content>
|
||||
<TimeTrackerProjectTaskDropdown
|
||||
v-model:project="currentTimeEntry.project_id"
|
||||
v-model:task="currentTimeEntry.task_id"
|
||||
variant="outline"
|
||||
:projects="projects"
|
||||
:tasks="tasks"
|
||||
:clients="activeClients"
|
||||
:create-project="createProject"
|
||||
:create-client="createClient"
|
||||
:can-create-project="canCreateProjects()"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()"
|
||||
class="w-full" />
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="showTaskSelector = false"> Cancel </SecondaryButton>
|
||||
<SecondaryButton class="ms-3" @click="handleProjectTaskSelect"> Save </SecondaryButton>
|
||||
</template>
|
||||
</DialogModal>
|
||||
|
||||
<!-- Tags Selector Dialog for Active Timer -->
|
||||
<DialogModal :show="showTagsSelector" closeable @close="showTagsSelector = false">
|
||||
<template #title>Set Tags</template>
|
||||
<template #content>
|
||||
<TagDropdown v-model="currentTimeEntry.tags" :tags="tags" :create-tag="createTag">
|
||||
<template #trigger>
|
||||
<div
|
||||
class="w-full p-3 border border-card-border rounded-lg cursor-pointer hover:bg-tertiary transition">
|
||||
<span
|
||||
v-if="currentTimeEntry.tags.length === 0"
|
||||
class="text-muted-foreground">
|
||||
Click to select tags...
|
||||
</span>
|
||||
<span v-else> {{ currentTimeEntry.tags.length }} tag(s) selected </span>
|
||||
</div>
|
||||
</template>
|
||||
</TagDropdown>
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="showTagsSelector = false"> Cancel </SecondaryButton>
|
||||
<SecondaryButton class="ms-3" @click="handleTagsSelect"> Save </SecondaryButton>
|
||||
</template>
|
||||
</DialogModal>
|
||||
</template>
|
||||
1
resources/js/Components/CommandPalette/index.ts
Normal file
1
resources/js/Components/CommandPalette/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as CommandPaletteProvider } from './CommandPaletteProvider.vue';
|
||||
@@ -7,7 +7,7 @@ import type { CreateClientBody } from '@/packages/api/src';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import InputLabel from '../../../packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldLabel } from '@/packages/ui/src/field';
|
||||
|
||||
const { createClient } = useClientsStore();
|
||||
const show = defineModel('show', { default: false });
|
||||
@@ -37,19 +37,19 @@ useFocus(clientNameInput, { initialValue: true });
|
||||
|
||||
<template #content>
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="col-span-6 sm:col-span-4 flex-1">
|
||||
<InputLabel for="clientName" value="Client Name" />
|
||||
<Field class="col-span-6 sm:col-span-4 flex-1">
|
||||
<FieldLabel for="clientName">Client Name</FieldLabel>
|
||||
<TextInput
|
||||
id="clientName"
|
||||
ref="clientNameInput"
|
||||
v-model="client.name"
|
||||
type="text"
|
||||
placeholder="Client Name"
|
||||
class="mt-1 block w-full"
|
||||
class="block w-full"
|
||||
required
|
||||
autocomplete="clientName"
|
||||
@keydown.enter="submit" />
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import type { Client } from '@/packages/api/src';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
|
||||
const clientsStore = useClientsStore();
|
||||
const { clients } = storeToRefs(clientsStore);
|
||||
const { clients } = useClientsQuery();
|
||||
|
||||
function getKeyFromItem(item: Client) {
|
||||
return item.id;
|
||||
@@ -14,6 +12,10 @@ function getKeyFromItem(item: Client) {
|
||||
function getNameForItem(item: Client) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +23,9 @@ function getNameForItem(item: Client) {
|
||||
search-placeholder="Search for a Client..."
|
||||
:items="clients"
|
||||
:get-key-from-item="getKeyFromItem"
|
||||
:get-name-for-item="getNameForItem">
|
||||
:get-name-for-item="getNameForItem"
|
||||
no-item-label="No Client"
|
||||
@submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<slot name="trigger"></slot>
|
||||
</template>
|
||||
|
||||
@@ -3,13 +3,12 @@ import type { Client } from '@/packages/api/src';
|
||||
import { computed, ref } from 'vue';
|
||||
import { CheckCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import ClientMoreOptionsDropdown from '@/Components/Common/Client/ClientMoreOptionsDropdown.vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import TableRow from '@/Components/TableRow.vue';
|
||||
import ClientEditModal from '@/Components/Common/Client/ClientEditModal.vue';
|
||||
|
||||
const { projects } = storeToRefs(useProjectsStore());
|
||||
const { projects } = useProjectsQuery();
|
||||
|
||||
const props = defineProps<{
|
||||
client: Client;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import SelectDropdown from '@/packages/ui/src/Input/SelectDropdown.vue';
|
||||
import Badge from '@/packages/ui/src/Badge.vue';
|
||||
import { ChevronDownIcon } from '@heroicons/vue/20/solid';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/Components/ui/select';
|
||||
import type { BillableKey } from '@/types/projects';
|
||||
|
||||
const model = defineModel<BillableKey>({
|
||||
@@ -21,38 +25,26 @@ const options: Option[] = [
|
||||
},
|
||||
];
|
||||
|
||||
function getKeyFromItem(item: Option) {
|
||||
return item.key;
|
||||
}
|
||||
|
||||
function getNameFromItem(item: Option) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
function getNameForKey(key: BillableKey | undefined) {
|
||||
const item = options.find((item) => getKeyFromItem(item) === key);
|
||||
const item = options.find((item) => item.key === key);
|
||||
if (item) {
|
||||
return getNameFromItem(item);
|
||||
return item.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectDropdown
|
||||
v-model="model"
|
||||
:get-key-from-item="getKeyFromItem"
|
||||
:get-name-for-item="getNameFromItem"
|
||||
:items="options">
|
||||
<template #trigger>
|
||||
<Badge size="xlarge" class="bg-input-background cursor-pointer">
|
||||
<span>
|
||||
{{ getNameForKey(model) }}
|
||||
</span>
|
||||
<ChevronDownIcon class="text-text-secondary w-5"></ChevronDownIcon>
|
||||
</Badge>
|
||||
</template>
|
||||
</SelectDropdown>
|
||||
<Select v-model="model">
|
||||
<SelectTrigger>
|
||||
<SelectValue>{{ getNameForKey(model) }}</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="option in options" :key="option.key" :value="option.key">
|
||||
{{ option.name }}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { UserIcon, ChevronDownIcon } from '@heroicons/vue/24/solid';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { useMembersQuery } from '@/utils/useMembersQuery';
|
||||
import { UserIcon } from '@heroicons/vue/24/solid';
|
||||
import { ChevronDown } from 'lucide-vue-next';
|
||||
import type { ProjectMember } from '@/packages/api/src';
|
||||
import { Badge, SelectDropdown } from '@/packages/ui/src';
|
||||
import type { Member } from '@/packages/api/src';
|
||||
import {
|
||||
ComboboxAnchor,
|
||||
ComboboxContent,
|
||||
ComboboxInput,
|
||||
ComboboxItem,
|
||||
ComboboxRoot,
|
||||
ComboboxViewport,
|
||||
} from 'radix-vue';
|
||||
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
|
||||
import { Button } from '@/packages/ui/src/Buttons';
|
||||
|
||||
const membersStore = useMembersStore();
|
||||
const { members } = storeToRefs(membersStore);
|
||||
const { members } = useMembersQuery();
|
||||
|
||||
const model = defineModel<string>({
|
||||
default: '',
|
||||
@@ -26,16 +33,24 @@ const props = withDefaults(
|
||||
}
|
||||
);
|
||||
|
||||
const searchInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
const open = ref(false);
|
||||
const searchValue = ref('');
|
||||
const searchInput = ref<HTMLElement | null>(null);
|
||||
|
||||
useFocus(searchInput, { initialValue: true });
|
||||
watch(open, (isOpen) => {
|
||||
if (isOpen) {
|
||||
searchValue.value = '';
|
||||
nextTick(() => {
|
||||
// @ts-expect-error We need to access the actual HTML Element to focus
|
||||
searchInput.value?.$el?.focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const filteredMembers = computed<Member[]>(() => {
|
||||
return members.value.filter((member) => {
|
||||
return (
|
||||
member.name.toLowerCase().includes(searchValue.value?.toLowerCase()?.trim() || '') &&
|
||||
member.name.toLowerCase().includes(searchValue.value.toLowerCase().trim() || '') &&
|
||||
!props.hiddenMembers.some((hiddenMember) => hiddenMember.member_id === member.id) &&
|
||||
member.is_placeholder === false
|
||||
);
|
||||
@@ -46,29 +61,64 @@ const currentValue = computed(() => {
|
||||
if (model.value) {
|
||||
return members.value.find((member) => member.id === model.value)?.name;
|
||||
}
|
||||
return searchValue.value;
|
||||
return '';
|
||||
});
|
||||
|
||||
function selectMember(member: Member) {
|
||||
model.value = member.id;
|
||||
open.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectDropdown
|
||||
v-model="model"
|
||||
:items="filteredMembers"
|
||||
:get-key-from-item="(member) => member.id"
|
||||
:get-name-for-item="(member) => member.name">
|
||||
<Dropdown v-model="open" align="start" :close-on-content-click="false">
|
||||
<template #trigger>
|
||||
<Badge
|
||||
tag="button"
|
||||
class="flex w-full text-base text-left space-x-3 px-3 text-text-secondary bg-input-background font-normal cursor py-1.5">
|
||||
<UserIcon class="relative z-10 w-4 text-text-secondary"></UserIcon>
|
||||
<div v-if="currentValue" class="flex-1 truncate">
|
||||
{{ currentValue }}
|
||||
<Button
|
||||
:disabled="disabled"
|
||||
type="button"
|
||||
variant="input"
|
||||
class="w-full justify-between text-start font-normal">
|
||||
<div class="flex items-center gap-3 truncate">
|
||||
<UserIcon class="w-4 text-text-secondary shrink-0" />
|
||||
<span v-if="currentValue" class="truncate text-text-primary">{{
|
||||
currentValue
|
||||
}}</span>
|
||||
<span v-else class="text-muted-foreground">Select a member...</span>
|
||||
</div>
|
||||
<div v-else class="flex-1">Select a member...</div>
|
||||
<ChevronDownIcon class="w-4 text-text-secondary"></ChevronDownIcon>
|
||||
</Badge>
|
||||
<ChevronDown class="w-4 h-4 text-icon-default shrink-0" />
|
||||
</Button>
|
||||
</template>
|
||||
</SelectDropdown>
|
||||
<template #content>
|
||||
<ComboboxRoot
|
||||
v-model:search-term="searchValue"
|
||||
v-model:open="open"
|
||||
class="relative"
|
||||
:filter-function="(val: string[]) => val">
|
||||
<ComboboxAnchor>
|
||||
<ComboboxInput
|
||||
ref="searchInput"
|
||||
class="bg-card-background border-0 placeholder-text-tertiary text-sm text-text-primary py-2.5 focus:ring-0 border-b border-card-background-separator focus:border-card-background-separator w-full"
|
||||
placeholder="Search for a member..." />
|
||||
</ComboboxAnchor>
|
||||
<ComboboxContent
|
||||
:dismiss-able="false"
|
||||
position="inline"
|
||||
class="w-60 max-h-60 overflow-y-auto">
|
||||
<ComboboxViewport>
|
||||
<ComboboxItem
|
||||
v-for="member in filteredMembers"
|
||||
:key="member.id"
|
||||
:value="member.id"
|
||||
class="flex items-center gap-3 px-3 py-2.5 text-sm text-text-primary data-[highlighted]:bg-card-background-active cursor-default"
|
||||
@select.prevent="selectMember(member)">
|
||||
<UserIcon class="w-4 text-text-secondary shrink-0" />
|
||||
<span class="truncate">{{ member.name }}</span>
|
||||
</ComboboxItem>
|
||||
</ComboboxViewport>
|
||||
</ComboboxContent>
|
||||
</ComboboxRoot>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
import type { Member } from '@/packages/api/src';
|
||||
import { api } from '@/packages/api/src';
|
||||
import { useForm } from '@tanstack/vue-form';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query';
|
||||
import Modal from '@/packages/ui/src/Modal.vue';
|
||||
import DangerButton from '@/packages/ui/src/Buttons/DangerButton.vue';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import Checkbox from '@/packages/ui/src/Input/Checkbox.vue';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
||||
import InputError from '@/packages/ui/src/Input/InputError.vue';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { Field, FieldLabel, FieldError } from '@/packages/ui/src/field';
|
||||
|
||||
const props = defineProps<{
|
||||
show: boolean;
|
||||
@@ -23,6 +21,7 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
@@ -43,7 +42,7 @@ const deleteMutation = useMutation({
|
||||
},
|
||||
onSuccess: () => {
|
||||
close();
|
||||
useMembersStore().fetchMembers();
|
||||
queryClient.invalidateQueries({ queryKey: ['members'] });
|
||||
},
|
||||
});
|
||||
|
||||
@@ -113,25 +112,21 @@ const close = () => {
|
||||
},
|
||||
}">
|
||||
<template #default="{ field }">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex items-center space-x-3 text-sm">
|
||||
<Checkbox
|
||||
:id="field.name"
|
||||
:name="field.name"
|
||||
:checked="field.state.value"
|
||||
@update:checked="field.handleChange"
|
||||
@blur="field.handleBlur" />
|
||||
<InputLabel
|
||||
:for="field.name"
|
||||
class="font-medium text-text-primary">
|
||||
I understand that this will permanently delete all data
|
||||
related to this member
|
||||
</InputLabel>
|
||||
</div>
|
||||
<InputError
|
||||
class="pl-7 pt-2"
|
||||
:message="field.state.meta.errors[0]" />
|
||||
</div>
|
||||
<Field orientation="horizontal">
|
||||
<Checkbox
|
||||
:id="field.name"
|
||||
:name="field.name"
|
||||
:checked="field.state.value"
|
||||
@update:checked="field.handleChange"
|
||||
@blur="field.handleBlur" />
|
||||
<FieldLabel :for="field.name" class="font-medium text-text-primary">
|
||||
I understand that this will permanently delete all data related
|
||||
to this member
|
||||
</FieldLabel>
|
||||
<FieldError v-if="field.state.meta.errors[0]" class="pl-7 pt-2">
|
||||
{{ field.state.meta.errors[0] }}
|
||||
</FieldError>
|
||||
</Field>
|
||||
</template>
|
||||
</form.Field>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Member, UpdateMemberBody } from '@/packages/api/src';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import { type MemberBillableKey, useMembersStore } from '@/utils/useMembers';
|
||||
import BillableRateInput from '@/packages/ui/src/Input/BillableRateInput.vue';
|
||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldLabel } from '@/packages/ui/src/field';
|
||||
import MemberBillableRateModal from '@/Components/Common/Member/MemberBillableRateModal.vue';
|
||||
import MemberBillableSelect from '@/Components/Common/Member/MemberBillableSelect.vue';
|
||||
import { onMounted, watch } from 'vue';
|
||||
@@ -121,28 +121,24 @@ const roleDescription = computed(() => {
|
||||
<template #content>
|
||||
<div class="pb-5 pt-2 divide-y divide-border-secondary">
|
||||
<div class="pb-5 flex space-x-6">
|
||||
<div>
|
||||
<InputLabel for="role" value="Role" />
|
||||
<MemberRoleSelect
|
||||
v-model="memberBody.role"
|
||||
class="mt-2"
|
||||
name="role"></MemberRoleSelect>
|
||||
</div>
|
||||
<Field>
|
||||
<FieldLabel for="role">Role</FieldLabel>
|
||||
<MemberRoleSelect v-model="memberBody.role" name="role"></MemberRoleSelect>
|
||||
</Field>
|
||||
<div class="flex-1 text-xs flex items-center pt-6">
|
||||
<p>{{ roleDescription }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4 pt-5">
|
||||
<div class="col-span-6 sm:col-span-4 flex-1 flex space-x-5">
|
||||
<div>
|
||||
<InputLabel for="billableType" value="Billable" />
|
||||
<Field>
|
||||
<FieldLabel for="billableType">Billable</FieldLabel>
|
||||
<MemberBillableSelect
|
||||
v-model="billableRateSelect"
|
||||
class="mt-2"
|
||||
name="billableType"></MemberBillableSelect>
|
||||
</div>
|
||||
<div v-if="billableRateSelect === 'custom-rate'" class="flex-1">
|
||||
<InputLabel for="memberBillableRate" value="Billable Rate" />
|
||||
</Field>
|
||||
<Field v-if="billableRateSelect === 'custom-rate'" class="flex-1">
|
||||
<FieldLabel for="memberBillableRate">Billable Rate</FieldLabel>
|
||||
<BillableRateInput
|
||||
v-model="memberBody.billable_rate"
|
||||
focus
|
||||
@@ -150,7 +146,7 @@ const roleDescription = computed(() => {
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
name="memberBillableRate"
|
||||
@keydown.enter="saveWithChecks()"></BillableRateInput>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,8 +5,7 @@ import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import { ref } from 'vue';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
||||
import InputError from '@/packages/ui/src/Input/InputError.vue';
|
||||
import { Field, FieldLabel, FieldError } from '@/packages/ui/src/field';
|
||||
import type { Role } from '@/types/jetstream';
|
||||
import { Link, useForm } from '@inertiajs/vue3';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
@@ -111,8 +110,8 @@ useFocus(clientNameInput, { initialValue: true });
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="space-y-4">
|
||||
<div class="col-span-6 sm:col-span-4 flex-1">
|
||||
<InputLabel for="email" value="Email" />
|
||||
<Field class="col-span-6 sm:col-span-4 flex-1">
|
||||
<FieldLabel for="email">Email</FieldLabel>
|
||||
<TextInput
|
||||
id="email"
|
||||
ref="memberEmailInput"
|
||||
@@ -120,16 +119,16 @@ useFocus(clientNameInput, { initialValue: true });
|
||||
name="email"
|
||||
type="text"
|
||||
placeholder="Member Email"
|
||||
class="mt-1 block w-full"
|
||||
class="block w-full"
|
||||
required
|
||||
autocomplete="memberName"
|
||||
@keydown.enter="submit" />
|
||||
<InputError :message="errors.email" class="mt-2" />
|
||||
</div>
|
||||
<FieldError v-if="errors.email">{{ errors.email }}</FieldError>
|
||||
</Field>
|
||||
|
||||
<div v-if="availableRoles.length > 0">
|
||||
<InputLabel for="roles" value="Role" />
|
||||
<InputError :message="errors.role" class="mt-2" />
|
||||
<Field v-if="availableRoles.length > 0">
|
||||
<FieldLabel for="roles">Role</FieldLabel>
|
||||
<FieldError v-if="errors.role">{{ errors.role }}</FieldError>
|
||||
|
||||
<div
|
||||
class="relative z-0 mt-1 border border-card-border rounded-lg bg-card-background cursor-pointer">
|
||||
@@ -182,7 +181,7 @@ useFocus(clientNameInput, { initialValue: true });
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
|
||||
@@ -4,12 +4,12 @@ import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import { ref } from 'vue';
|
||||
import { api, type Member } from '@/packages/api/src';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
@@ -41,7 +41,7 @@ async function submit() {
|
||||
'There was an error deactivating the user.',
|
||||
() => {
|
||||
show.value = false;
|
||||
useMembersStore().fetchMembers();
|
||||
queryClient.invalidateQueries({ queryKey: ['members'] });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@ import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import MemberCombobox from '@/Components/Common/Member/MemberCombobox.vue';
|
||||
import { UserIcon, ArrowRightIcon } from '@heroicons/vue/24/solid';
|
||||
import { Badge } from '@/packages/ui/src';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
const queryClient = useQueryClient();
|
||||
const { handleApiRequestNotifications, addNotification } = useNotificationsStore();
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
@@ -50,6 +51,7 @@ async function submit() {
|
||||
'Members successfully merged!',
|
||||
'There was an error merging the members.',
|
||||
() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['members'] });
|
||||
show.value = false;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useMembersQuery } from '@/utils/useMembersQuery';
|
||||
import type { Member } from '@/packages/api/src';
|
||||
|
||||
const membersStore = useMembersStore();
|
||||
const { members } = storeToRefs(membersStore);
|
||||
const { members } = useMembersQuery();
|
||||
|
||||
function getKeyFromItem(item: Member) {
|
||||
return item.id;
|
||||
@@ -14,6 +12,10 @@ function getKeyFromItem(item: Member) {
|
||||
function getNameForItem(item: Member) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +23,8 @@ function getNameForItem(item: Member) {
|
||||
search-placeholder="Search for a Member..."
|
||||
:items="members"
|
||||
:get-key-from-item="getKeyFromItem"
|
||||
:get-name-for-item="getNameForItem">
|
||||
:get-name-for-item="getNameForItem"
|
||||
@submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<slot name="trigger"></slot>
|
||||
</template>
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import SelectDropdown from '@/packages/ui/src/Input/SelectDropdown.vue';
|
||||
import Badge from '@/packages/ui/src/Badge.vue';
|
||||
import { ChevronDownIcon } from '@heroicons/vue/20/solid';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/Components/ui/select';
|
||||
import type { Role } from '@/types/jetstream';
|
||||
import { usePage } from '@inertiajs/vue3';
|
||||
|
||||
@@ -13,38 +17,26 @@ const page = usePage<{
|
||||
availableRoles: Role[];
|
||||
}>();
|
||||
|
||||
function getKeyFromItem(item: Role) {
|
||||
return item.key;
|
||||
}
|
||||
|
||||
function getNameFromItem(item: Role) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
function getNameForKey(key: string | undefined) {
|
||||
const item = page.props.availableRoles.find((item) => getKeyFromItem(item) === key);
|
||||
const item = page.props.availableRoles.find((item) => item.key === key);
|
||||
if (item) {
|
||||
return getNameFromItem(item);
|
||||
return item.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectDropdown
|
||||
v-model="model"
|
||||
:get-key-from-item="getKeyFromItem"
|
||||
:get-name-for-item="getNameFromItem"
|
||||
:items="page.props.availableRoles">
|
||||
<template #trigger>
|
||||
<Badge size="xlarge" class="bg-input-background cursor-pointer">
|
||||
<span>
|
||||
{{ getNameForKey(model) }}
|
||||
</span>
|
||||
<ChevronDownIcon class="text-text-secondary w-5"></ChevronDownIcon>
|
||||
</Badge>
|
||||
</template>
|
||||
</SelectDropdown>
|
||||
<Select v-model="model">
|
||||
<SelectTrigger>
|
||||
<SelectValue>{{ getNameForKey(model) }}</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="role in page.props.availableRoles" :key="role.key" :value="role.key">
|
||||
{{ role.name }}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import MemberTableHeading from '@/Components/Common/Member/MemberTableHeading.vue';
|
||||
import MemberTableRow from '@/Components/Common/Member/MemberTableRow.vue';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { useMembersQuery } from '@/utils/useMembersQuery';
|
||||
|
||||
const { members } = storeToRefs(useMembersStore());
|
||||
|
||||
onMounted(async () => {
|
||||
await useMembersStore().fetchMembers();
|
||||
});
|
||||
const { members } = useMembersQuery();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -15,14 +15,12 @@ import MemberMakePlaceholderModal from '@/Components/Common/Member/MemberMakePla
|
||||
import MemberDeleteModal from '@/Components/Common/Member/MemberDeleteModal.vue';
|
||||
import { capitalizeFirstLetter } from '../../../utils/format';
|
||||
import { formatCents } from '../../../packages/ui/src/utils/money';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
|
||||
const props = defineProps<{
|
||||
member: Member;
|
||||
}>();
|
||||
|
||||
const organization = inject<ComputedRef<Organization>>('organization');
|
||||
const memberStore = useMembersStore();
|
||||
|
||||
const showEditMemberModal = ref(false);
|
||||
const showMergeMemberModal = ref(false);
|
||||
@@ -31,7 +29,6 @@ const showDeleteMemberModal = ref(false);
|
||||
|
||||
function removeMember() {
|
||||
showDeleteMemberModal.value = true;
|
||||
memberStore.fetchMembers();
|
||||
}
|
||||
|
||||
async function invitePlaceholder(id: string) {
|
||||
|
||||
@@ -10,7 +10,7 @@ defineProps<{
|
||||
<template>
|
||||
<h3
|
||||
class="text-text-primary font-semibold text-sm sm:text-base flex items-center space-x-2 sm:space-x-2.5">
|
||||
<component :is="icon" class="w-5 sm:w-6 text-icon-default"></component>
|
||||
<component :is="icon" class="w-5 text-icon-default"></component>
|
||||
<span> {{ title }} </span>
|
||||
</h3>
|
||||
</template>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import ProjectBadge from '@/packages/ui/src/Project/ProjectBadge.vue';
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
|
||||
import {
|
||||
ComboboxAnchor,
|
||||
@@ -11,14 +10,16 @@ import {
|
||||
ComboboxRoot,
|
||||
ComboboxViewport,
|
||||
} from 'radix-vue';
|
||||
import { PlusCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { api } from '@/packages/api/src';
|
||||
import { usePage } from '@inertiajs/vue3';
|
||||
import { getRandomColor } from '@/packages/ui/src/utils/color';
|
||||
import type { Project } from '@/packages/api/src';
|
||||
import ProjectDropdownItem from '@/packages/ui/src/Project/ProjectDropdownItem.vue';
|
||||
import { Check, Plus } from 'lucide-vue-next';
|
||||
import type { CreateClientBody, CreateProjectBody, Project } from '@/packages/api/src';
|
||||
import { UseFocusTrap } from '@vueuse/integrations/useFocusTrap/component';
|
||||
import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import { canCreateProjects } from '@/utils/permissions';
|
||||
|
||||
const searchValue = ref('');
|
||||
const searchInput = ref<HTMLElement | null>(null);
|
||||
@@ -26,49 +27,32 @@ const model = defineModel<string | null>({
|
||||
default: null,
|
||||
});
|
||||
const open = ref(false);
|
||||
const projectsStore = useProjectsStore();
|
||||
const showCreateProject = ref(false);
|
||||
const { projects } = useProjectsQuery();
|
||||
const { clients } = useClientsQuery();
|
||||
const emit = defineEmits(['update:modelValue', 'changed']);
|
||||
|
||||
const { projects } = storeToRefs(projectsStore);
|
||||
const projectDropdownTrigger = ref<HTMLElement | null>(null);
|
||||
const activeClients = computed(() => clients.value.filter((c) => !c.is_archived));
|
||||
|
||||
const sortedProjects = ref<Project[]>([]);
|
||||
|
||||
const shownProjects = computed(() => {
|
||||
return projects.value.filter((project) => {
|
||||
return sortedProjects.value.filter((project) => {
|
||||
return project.name.toLowerCase().includes(searchValue.value?.toLowerCase()?.trim() || '');
|
||||
});
|
||||
});
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
border?: boolean;
|
||||
}>(),
|
||||
{
|
||||
border: true,
|
||||
async function handleCreateProject(projectBody: CreateProjectBody) {
|
||||
const newProject = await useProjectsStore().createProject(projectBody);
|
||||
if (newProject) {
|
||||
model.value = newProject.id;
|
||||
emit('changed');
|
||||
}
|
||||
);
|
||||
return newProject;
|
||||
}
|
||||
|
||||
const page = usePage<{
|
||||
auth: {
|
||||
user: {
|
||||
current_team_id: string;
|
||||
};
|
||||
};
|
||||
}>();
|
||||
|
||||
async function addProjectIfNoneExists() {
|
||||
if (searchValue.value.length > 0 && shownProjects.value.length === 0) {
|
||||
const response = await api.createProject(
|
||||
{
|
||||
name: searchValue.value,
|
||||
color: getRandomColor(),
|
||||
is_billable: false,
|
||||
},
|
||||
{ params: { organization: page.props.auth.user.current_team_id } }
|
||||
);
|
||||
projects.value.unshift(response.data);
|
||||
model.value = response.data.id;
|
||||
searchValue.value = '';
|
||||
open.value = false;
|
||||
}
|
||||
async function handleCreateClient(clientBody: CreateClientBody) {
|
||||
return await useClientsStore().createClient(clientBody);
|
||||
}
|
||||
|
||||
watch(open, (isOpen) => {
|
||||
@@ -78,7 +62,7 @@ watch(open, (isOpen) => {
|
||||
searchInput.value?.$el?.focus();
|
||||
});
|
||||
|
||||
projects.value.sort((iteratingProject) => {
|
||||
sortedProjects.value = [...projects.value].sort((iteratingProject) => {
|
||||
return model.value === iteratingProject.id ? -1 : 1;
|
||||
});
|
||||
}
|
||||
@@ -107,63 +91,72 @@ function updateValue(project: Project) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dropdown v-model="open" align="start" width="60">
|
||||
<Dropdown v-model="open" align="start">
|
||||
<template #trigger>
|
||||
<ProjectBadge
|
||||
ref="projectDropdownTrigger"
|
||||
:color="selectedProjectColor"
|
||||
size="xlarge"
|
||||
:border
|
||||
tag="button"
|
||||
:name="selectedProjectName"
|
||||
class="focus:border-input-border-active bg-input-background focus:outline-0 focus:bg-card-background-separator hover:bg-card-background-separator"></ProjectBadge>
|
||||
<slot
|
||||
name="trigger"
|
||||
:selected-project-name="selectedProjectName"
|
||||
:selected-project-color="selectedProjectColor"></slot>
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<UseFocusTrap v-if="open" :options="{ immediate: true, allowOutsideClick: true }">
|
||||
<ComboboxRoot
|
||||
v-model:search-term="searchValue"
|
||||
:open="open"
|
||||
v-model:open="open"
|
||||
:model-value="currentProject"
|
||||
class="relative"
|
||||
@update:model-value="updateValue">
|
||||
<ComboboxAnchor>
|
||||
<ComboboxInput
|
||||
ref="searchInput"
|
||||
class="bg-card-background border-0 placeholder-text-tertiary text-sm text-text-primary py-2.5 focus:ring-0 border-b border-card-background-separator focus:border-card-background-separator w-full"
|
||||
placeholder="Search for a project..."
|
||||
@keydown.enter="addProjectIfNoneExists" />
|
||||
class="bg-transparent border-0 placeholder-muted-foreground text-sm text-popover-foreground py-2 px-3 focus:ring-0 border-b border-popover-border focus:border-popover-border w-full"
|
||||
placeholder="Search for a project..." />
|
||||
</ComboboxAnchor>
|
||||
<ComboboxContent>
|
||||
<ComboboxViewport
|
||||
ref="dropdownViewport"
|
||||
class="w-60 max-h-60 overflow-y-scroll">
|
||||
class="w-[--reka-popper-anchor-width] max-h-60 overflow-y-scroll p-1">
|
||||
<ComboboxItem
|
||||
v-for="project in shownProjects"
|
||||
:key="project.id"
|
||||
:value="project"
|
||||
class="data-[highlighted]:bg-card-background-active"
|
||||
class="relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground"
|
||||
:data-project-id="project.id">
|
||||
<ProjectDropdownItem
|
||||
:selected="isProjectSelected(project)"
|
||||
:color="project.color"
|
||||
:name="project.name"></ProjectDropdownItem>
|
||||
<span class="flex items-center gap-2">
|
||||
<span
|
||||
:style="{ backgroundColor: project.color }"
|
||||
class="w-3 h-3 rounded-full shrink-0"></span>
|
||||
<span>{{ project.name }}</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="isProjectSelected(project)"
|
||||
class="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<Check class="h-4 w-4" />
|
||||
</span>
|
||||
</ComboboxItem>
|
||||
<div
|
||||
v-if="searchValue.length > 0 && shownProjects.length === 0"
|
||||
class="bg-card-background-active">
|
||||
<div
|
||||
class="flex space-x-3 items-center px-4 py-3 text-xs font-medium border-t rounded-b-lg border-card-background-separator">
|
||||
<PlusCircleIcon class="w-5 flex-shrink-0"></PlusCircleIcon>
|
||||
<span>Add "{{ searchValue }}" as a new Project</span>
|
||||
</div>
|
||||
</div>
|
||||
</ComboboxViewport>
|
||||
<div
|
||||
v-if="canCreateProjects()"
|
||||
class="flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-accent hover:text-accent-foreground border-t border-popover-border"
|
||||
@click="
|
||||
open = false;
|
||||
showCreateProject = true;
|
||||
">
|
||||
<Plus class="h-4 w-4 shrink-0" />
|
||||
<span>Create new Project</span>
|
||||
</div>
|
||||
</ComboboxContent>
|
||||
</ComboboxRoot>
|
||||
</UseFocusTrap>
|
||||
</template>
|
||||
</Dropdown>
|
||||
<ProjectCreateModal
|
||||
v-model:show="showCreateProject"
|
||||
:create-project="handleCreateProject"
|
||||
:create-client="handleCreateClient"
|
||||
:clients="activeClients"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()" />
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -6,22 +6,23 @@ import { computed, ref } from 'vue';
|
||||
import type { CreateClientBody, CreateProjectBody, Project } from '@/packages/api/src';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import ClientDropdown from '@/packages/ui/src/Client/ClientDropdown.vue';
|
||||
import Badge from '@/packages/ui/src/Badge.vue';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import ProjectColorSelector from '@/packages/ui/src/Project/ProjectColorSelector.vue';
|
||||
import { Button } from '@/packages/ui/src/Buttons';
|
||||
import { ChevronDown } from 'lucide-vue-next';
|
||||
import { UserCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import EstimatedTimeSection from '@/packages/ui/src/EstimatedTimeSection.vue';
|
||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldGroup, FieldLabel } from '@/packages/ui/src/field';
|
||||
import ProjectBillableRateModal from '@/packages/ui/src/Project/ProjectBillableRateModal.vue';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import ProjectEditBillableSection from '@/packages/ui/src/Project/ProjectEditBillableSection.vue';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
|
||||
const { updateProject } = useProjectsStore();
|
||||
const { clients } = storeToRefs(useClientsStore());
|
||||
const { clients } = useClientsQuery();
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
const showBillableRateModal = ref(false);
|
||||
@@ -81,65 +82,47 @@ async function submitBillableRate() {
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<div class="sm:flex items-center space-y-2 sm:space-y-0 sm:space-x-5">
|
||||
<div class="flex-1 flex items-center">
|
||||
<div class="text-center">
|
||||
<InputLabel for="color" value="Color" />
|
||||
<ProjectColorSelector
|
||||
v-model="project.color"
|
||||
class="mt-1"></ProjectColorSelector>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<InputLabel for="projectName" value="Project name" />
|
||||
<TextInput
|
||||
id="projectName"
|
||||
ref="projectNameInput"
|
||||
v-model="project.name"
|
||||
type="text"
|
||||
placeholder="Project Name"
|
||||
class="mt-1 block w-full"
|
||||
required
|
||||
autocomplete="projectName"
|
||||
@keydown.enter="submit()" />
|
||||
</div>
|
||||
<div class="">
|
||||
<InputLabel for="client" value="Client" />
|
||||
<ClientDropdown
|
||||
v-model="project.client_id"
|
||||
:create-client
|
||||
:clients="clients"
|
||||
class="mt-1">
|
||||
<FieldGroup>
|
||||
<FieldGroup class="flex-row items-end">
|
||||
<Field class="w-auto text-center">
|
||||
<FieldLabel for="color">Color</FieldLabel>
|
||||
<ProjectColorSelector v-model="project.color"></ProjectColorSelector>
|
||||
</Field>
|
||||
<Field class="w-full">
|
||||
<FieldLabel for="projectName">Project name</FieldLabel>
|
||||
<TextInput
|
||||
id="projectName"
|
||||
ref="projectNameInput"
|
||||
v-model="project.name"
|
||||
type="text"
|
||||
placeholder="Project Name"
|
||||
class="block w-full"
|
||||
required
|
||||
autocomplete="projectName"
|
||||
@keydown.enter="submit()" />
|
||||
</Field>
|
||||
</FieldGroup>
|
||||
<Field>
|
||||
<FieldLabel for="client" :icon="UserCircleIcon">Client</FieldLabel>
|
||||
<ClientDropdown v-model="project.client_id" :create-client :clients="clients">
|
||||
<template #trigger>
|
||||
<Badge
|
||||
class="bg-input-background cursor-pointer hover:bg-tertiary"
|
||||
size="xlarge">
|
||||
<div class="flex items-center space-x-2">
|
||||
<UserCircleIcon class="w-5 text-icon-default"></UserCircleIcon>
|
||||
<span class="whitespace-nowrap">
|
||||
{{ currentClientName }}
|
||||
</span>
|
||||
</div>
|
||||
</Badge>
|
||||
<Button variant="input" class="w-full justify-between">
|
||||
<span class="truncate">{{ currentClientName }}</span>
|
||||
<ChevronDown class="w-4 h-4 text-icon-default" />
|
||||
</Button>
|
||||
</template>
|
||||
</ClientDropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<ProjectEditBillableSection
|
||||
v-model:is-billable="project.is_billable"
|
||||
v-model:billable-rate="project.billable_rate"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
@submit="submit"></ProjectEditBillableSection>
|
||||
</div>
|
||||
<div>
|
||||
<EstimatedTimeSection
|
||||
v-if="isAllowedToPerformPremiumAction()"
|
||||
v-model="project.estimated_time"
|
||||
@submit="submit()"></EstimatedTimeSection>
|
||||
</div>
|
||||
</div>
|
||||
</Field>
|
||||
<ProjectEditBillableSection
|
||||
v-model:is-billable="project.is_billable"
|
||||
v-model:billable-rate="project.billable_rate"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
@submit="submit"></ProjectEditBillableSection>
|
||||
<EstimatedTimeSection
|
||||
v-if="isAllowedToPerformPremiumAction()"
|
||||
v-model="project.estimated_time"
|
||||
@submit="submit()"></EstimatedTimeSection>
|
||||
</FieldGroup>
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="show = false"> Cancel</SecondaryButton>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import type { Project } from '@/packages/api/src';
|
||||
|
||||
const projectsStore = useProjectsStore();
|
||||
const { projects } = storeToRefs(projectsStore);
|
||||
const { projects } = useProjectsQuery();
|
||||
|
||||
function getKeyFromItem(item: Project) {
|
||||
return item.id;
|
||||
@@ -14,6 +12,10 @@ function getKeyFromItem(item: Project) {
|
||||
function getNameForItem(item: Project) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +23,9 @@ function getNameForItem(item: Project) {
|
||||
search-placeholder="Search for a Project..."
|
||||
:items="projects"
|
||||
:get-key-from-item="getKeyFromItem"
|
||||
:get-name-for-item="getNameForItem">
|
||||
:get-name-for-item="getNameForItem"
|
||||
no-item-label="No Project"
|
||||
@submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<slot name="trigger"></slot>
|
||||
</template>
|
||||
|
||||
@@ -13,7 +13,7 @@ import { canCreateProjects } from '@/utils/permissions';
|
||||
import type { CreateProjectBody, Project, Client, CreateClientBody } from '@/packages/api/src';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import {
|
||||
@@ -34,7 +34,7 @@ const emit = defineEmits<{
|
||||
sort: [column: SortColumn];
|
||||
}>();
|
||||
|
||||
const { clients } = storeToRefs(useClientsStore());
|
||||
const { clients } = useClientsQuery();
|
||||
|
||||
// Create a map of client names for sorting
|
||||
const clientNameMap = computed(() => {
|
||||
@@ -125,7 +125,7 @@ const gridTemplate = computed(() => {
|
||||
:create-client
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:clients="clients"
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction"></ProjectCreateModal>
|
||||
:enable-estimated-time="isAllowedToPerformPremiumAction()"></ProjectCreateModal>
|
||||
<div class="flow-root max-w-[100vw] overflow-x-auto">
|
||||
<div class="inline-block min-w-full align-middle">
|
||||
<div data-testid="project_table" class="grid min-w-full" :style="gridTemplate">
|
||||
|
||||
@@ -3,9 +3,8 @@ import ProjectMoreOptionsDropdown from '@/Components/Common/Project/ProjectMoreO
|
||||
import type { Project } from '@/packages/api/src';
|
||||
import { computed, ref, inject, type ComputedRef } from 'vue';
|
||||
import { CheckCircleIcon, ArchiveBoxIcon } from '@heroicons/vue/24/outline';
|
||||
import { useClientsStore } from '@/utils/useClients';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useClientsQuery } from '@/utils/useClientsQuery';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import TableRow from '@/Components/TableRow.vue';
|
||||
import ProjectEditModal from '@/Components/Common/Project/ProjectEditModal.vue';
|
||||
@@ -17,8 +16,8 @@ import { formatHumanReadableDuration } from '../../../packages/ui/src/utils/time
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import type { Organization } from '@/packages/api/src';
|
||||
|
||||
const { clients } = storeToRefs(useClientsStore());
|
||||
const { tasks } = storeToRefs(useTasksStore());
|
||||
const { clients } = useClientsQuery();
|
||||
const { tasks } = useTasksQuery();
|
||||
|
||||
const props = defineProps<{
|
||||
project: Project;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useProjectMembersStore } from '@/utils/useProjectMembers';
|
||||
import BillableRateInput from '@/packages/ui/src/Input/BillableRateInput.vue';
|
||||
import { UserIcon } from '@heroicons/vue/24/solid';
|
||||
import ProjectMemberBillableRateModal from '@/Components/Common/ProjectMember/ProjectMemberBillableRateModal.vue';
|
||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldLabel } from '@/packages/ui/src/field';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
const { updateProjectMember } = useProjectMembersStore();
|
||||
|
||||
@@ -82,14 +82,14 @@ useFocus(projectNameInput, { initialValue: true });
|
||||
<UserIcon class="w-4 text-text-secondary"></UserIcon>
|
||||
<span>{{ props.name }}</span>
|
||||
</div>
|
||||
<div class="col-span-3 sm:col-span-1 flex-1">
|
||||
<InputLabel for="billable_rate" class="mb-2" value="Billable Rate"></InputLabel>
|
||||
<Field class="col-span-3 sm:col-span-1 flex-1">
|
||||
<FieldLabel for="billable_rate">Billable Rate</FieldLabel>
|
||||
<BillableRateInput
|
||||
v-model="projectMemberBody.billable_rate"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
name="billable_rate"
|
||||
@keydown.enter="submit"></BillableRateInput>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { TrashIcon, PencilSquareIcon } from '@heroicons/vue/20/solid';
|
||||
import type { ProjectMember } from '@/packages/api/src';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useMembersQuery } from '@/utils/useMembersQuery';
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -19,7 +18,7 @@ const props = defineProps<{
|
||||
projectMember: ProjectMember;
|
||||
}>();
|
||||
|
||||
const { members } = storeToRefs(useMembersStore());
|
||||
const { members } = useMembersQuery();
|
||||
|
||||
const currentMember = computed(() => {
|
||||
return members.value.find((member) => member.id === props.projectMember.user_id);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { ProjectMember } from '@/packages/api/src';
|
||||
import { computed, ref, inject, type ComputedRef } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import TableRow from '@/Components/TableRow.vue';
|
||||
import { useMembersStore } from '@/utils/useMembers';
|
||||
import { useMembersQuery } from '@/utils/useMembersQuery';
|
||||
import { useProjectMembersStore } from '@/utils/useProjectMembers';
|
||||
import ProjectMemberMoreOptionsDropdown from '@/Components/Common/ProjectMember/ProjectMemberMoreOptionsDropdown.vue';
|
||||
import { formatCents } from '@/packages/ui/src/utils/money';
|
||||
@@ -29,7 +28,7 @@ function editProjectMember() {
|
||||
showEditModal.value = true;
|
||||
}
|
||||
|
||||
const { members } = storeToRefs(useMembersStore());
|
||||
const { members } = useMembersQuery();
|
||||
const member = computed(() => {
|
||||
return members.value.find((member) => member.id === props.projectMember.member_id);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import SecondaryButton from '../../../packages/ui/src/Buttons/SecondaryButton.vu
|
||||
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import { ref } from 'vue';
|
||||
import PrimaryButton from '../../../packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import InputLabel from '../../../packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldLabel } from '@/packages/ui/src/field';
|
||||
import type { CreateReportBody, CreateReportBodyProperties } from '@/packages/api/src';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
@@ -12,6 +12,8 @@ import { api } from '@/packages/api/src';
|
||||
import { Checkbox } from '@/packages/ui/src';
|
||||
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import { getDayJsInstance } from '@/packages/ui/src/utils/time';
|
||||
import { router } from '@inertiajs/vue3';
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
@@ -44,10 +46,14 @@ const report = ref({
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
async function submit() {
|
||||
const publicUntil = report.value.public_until
|
||||
? getDayJsInstance()(report.value.public_until).utc().format()
|
||||
: null;
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
createReportMutation.mutateAsync({
|
||||
...report.value,
|
||||
public_until: publicUntil,
|
||||
properties: { ...props.properties },
|
||||
}),
|
||||
'Success',
|
||||
@@ -60,6 +66,7 @@ async function submit() {
|
||||
public_until: null,
|
||||
};
|
||||
show.value = false;
|
||||
router.visit(route('reporting.shared'));
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -75,31 +82,33 @@ async function submit() {
|
||||
|
||||
<template #content>
|
||||
<div class="items-center space-y-4 w-full">
|
||||
<div class="w-full">
|
||||
<InputLabel for="name" value="Name" />
|
||||
<TextInput id="name" v-model="report.name" class="mt-1.5 w-full"></TextInput>
|
||||
</div>
|
||||
<div>
|
||||
<InputLabel for="description" value="Description" />
|
||||
<Field class="w-full">
|
||||
<FieldLabel for="name">Name</FieldLabel>
|
||||
<TextInput id="name" v-model="report.name" class="w-full"></TextInput>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel for="description">Description</FieldLabel>
|
||||
<TextInput
|
||||
id="description"
|
||||
v-model="report.description"
|
||||
class="mt-1.5 w-full"></TextInput>
|
||||
</div>
|
||||
<InputLabel value="Visibility" />
|
||||
<div class="flex items-center space-x-12">
|
||||
<div class="flex items-center space-x-3 px-2 py-3">
|
||||
<Checkbox id="is_public" v-model:checked="report.is_public"></Checkbox>
|
||||
<InputLabel for="is_public" value="Public" />
|
||||
class="w-full"></TextInput>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Visibility</FieldLabel>
|
||||
<div class="flex items-center space-x-12">
|
||||
<Field orientation="horizontal" class="px-2 py-3">
|
||||
<Checkbox id="is_public" v-model:checked="report.is_public"></Checkbox>
|
||||
<FieldLabel for="is_public">Public</FieldLabel>
|
||||
</Field>
|
||||
<Field v-if="report.is_public" class="flex-row items-center space-x-4">
|
||||
<div>
|
||||
<FieldLabel for="public_until">Expires at</FieldLabel>
|
||||
<div class="text-text-tertiary font-medium">(optional)</div>
|
||||
</div>
|
||||
<DatePicker v-model="report.public_until"></DatePicker>
|
||||
</Field>
|
||||
</div>
|
||||
<div v-if="report.is_public" class="flex items-center space-x-4">
|
||||
<div>
|
||||
<InputLabel for="public_until" value="Expires at" />
|
||||
<div class="text-text-tertiary font-medium">(optional)</div>
|
||||
</div>
|
||||
<DatePicker id="public_until"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import TextInput from '../../../packages/ui/src/Input/TextInput.vue';
|
||||
import SecondaryButton from '../../../packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import PrimaryButton from '../../../packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import InputLabel from '../../../packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldLabel } from '@/packages/ui/src/field';
|
||||
import type { UpdateReportBody } from '@/packages/api/src';
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
@@ -13,6 +13,7 @@ import { Checkbox } from '@/packages/ui/src';
|
||||
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import type { Report } from '@/packages/api/src';
|
||||
import { getDayJsInstance, getLocalizedDayJs } from '@/packages/ui/src/utils/time';
|
||||
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
@@ -61,9 +62,21 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
// Intermediate local variable for DatePicker (converts between UTC and localized)
|
||||
const localPublicUntil = computed({
|
||||
get: () => {
|
||||
if (!report.value.public_until) return null;
|
||||
return getLocalizedDayJs(report.value.public_until).format();
|
||||
},
|
||||
set: (value: string | null) => {
|
||||
report.value.public_until = value ? getDayJsInstance()(value).utc().format() : null;
|
||||
},
|
||||
});
|
||||
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
async function submit() {
|
||||
// public_until is already in UTC format from the computed setter
|
||||
await handleApiRequestNotifications(
|
||||
() => updateReportMutation.mutateAsync(report.value),
|
||||
'Success',
|
||||
@@ -92,28 +105,30 @@ async function submit() {
|
||||
|
||||
<template #content>
|
||||
<div class="items-center space-y-4 w-full">
|
||||
<div class="w-full">
|
||||
<InputLabel for="name" value="Name" />
|
||||
<TextInput id="name" v-model="report.name" class="mt-1.5 w-full"></TextInput>
|
||||
</div>
|
||||
<div>
|
||||
<InputLabel for="description" value="Description" />
|
||||
<Field class="w-full">
|
||||
<FieldLabel for="name">Name</FieldLabel>
|
||||
<TextInput id="name" v-model="report.name" class="w-full"></TextInput>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel for="description">Description</FieldLabel>
|
||||
<TextInput
|
||||
id="description"
|
||||
v-model="report.description"
|
||||
class="mt-1.5 w-full"></TextInput>
|
||||
</div>
|
||||
<InputLabel value="Visibility" />
|
||||
<div class="flex items-center space-x-12">
|
||||
<div class="flex items-center space-x-2 px-2 py-3">
|
||||
<Checkbox id="is_public" v-model:checked="report.is_public"></Checkbox>
|
||||
<InputLabel for="is_public" value="Public" />
|
||||
class="w-full"></TextInput>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Visibility</FieldLabel>
|
||||
<div class="flex items-center space-x-12">
|
||||
<Field orientation="horizontal" class="px-2 py-3">
|
||||
<Checkbox id="is_public" v-model:checked="report.is_public"></Checkbox>
|
||||
<FieldLabel for="is_public">Public</FieldLabel>
|
||||
</Field>
|
||||
<Field v-if="report.is_public" orientation="horizontal">
|
||||
<FieldLabel for="public_until">Expires at</FieldLabel>
|
||||
<DatePicker v-model="localPublicUntil"></DatePicker>
|
||||
</Field>
|
||||
</div>
|
||||
<div v-if="report.is_public" class="flex items-center space-x-4">
|
||||
<InputLabel for="public_until" value="Expires at" />
|
||||
<DatePicker id="public_until"></DatePicker>
|
||||
</div>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
|
||||
@@ -14,7 +14,7 @@ defineProps<{
|
||||
}>();
|
||||
|
||||
const gridTemplate = computed(() => {
|
||||
return `grid-template-columns: minmax(150px, auto) minmax(250px, 1fr) minmax(140px, auto) minmax(130px, auto) 80px;`;
|
||||
return `grid-template-columns: minmax(150px, auto) minmax(200px, 1fr) minmax(100px, 120px) minmax(80px, 100px) minmax(100px, 120px) minmax(130px, auto) 80px;`;
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -23,7 +23,7 @@ const gridTemplate = computed(() => {
|
||||
<div class="inline-block min-w-full align-middle">
|
||||
<div data-testid="report_table" class="grid min-w-full" :style="gridTemplate">
|
||||
<ReportTableHeading></ReportTableHeading>
|
||||
<div v-if="reports.length === 0" class="col-span-5 py-24 text-center">
|
||||
<div v-if="reports.length === 0" class="col-span-7 py-24 text-center">
|
||||
<FolderPlusIcon class="w-8 text-icon-default inline pb-2"></FolderPlusIcon>
|
||||
<h3 class="text-text-primary font-semibold">No shared reports found</h3>
|
||||
<p v-if="canCreateProjects()" class="pb-5">
|
||||
|
||||
@@ -8,7 +8,9 @@ import TableHeading from '@/Components/Common/TableHeading.vue';
|
||||
Name
|
||||
</div>
|
||||
<div class="px-3 py-1.5 text-left text-text-tertiary">Description</div>
|
||||
<div class="px-3 py-1.5 text-left text-text-tertiary">Created At</div>
|
||||
<div class="px-3 py-1.5 text-left text-text-tertiary">Visibility</div>
|
||||
<div class="px-3 py-1.5 text-left text-text-tertiary">Expires At</div>
|
||||
<div class="px-3 py-1.5 text-left text-text-tertiary">Public URL</div>
|
||||
<div class="relative py-1.5 pl-3 pr-4 sm:pr-6 lg:pr-8 3xl:pr-12">
|
||||
<span class="sr-only">Edit</span>
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { type ComputedRef, computed, inject, ref } from 'vue';
|
||||
import TableRow from '@/Components/TableRow.vue';
|
||||
import { api, type Report } from '@/packages/api/src';
|
||||
import { api, type Report, type Organization } from '@/packages/api/src';
|
||||
import ReportMoreOptionsDropdown from '@/Components/Common/Report/ReportMoreOptionsDropdown.vue';
|
||||
import ReportEditModal from '@/Components/Common/Report/ReportEditModal.vue';
|
||||
import { SecondaryButton } from '@/packages/ui/src';
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { ArrowTopRightOnSquareIcon } from '@heroicons/vue/24/solid';
|
||||
import { GlobeAltIcon, LockClosedIcon } from '@heroicons/vue/24/outline';
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import { formatDateLocalized } from '@/packages/ui/src/utils/time';
|
||||
|
||||
const props = defineProps<{
|
||||
report: Report;
|
||||
@@ -19,6 +21,8 @@ const showEditReportModal = ref(false);
|
||||
|
||||
const { copy, copied, isSupported } = useClipboard({ legacy: true });
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
const organization = inject<ComputedRef<Organization | undefined>>('organization');
|
||||
const dateFormat = computed(() => organization?.value?.date_format);
|
||||
|
||||
function openSharableLink() {
|
||||
const link = props.report.shareable_link;
|
||||
@@ -71,7 +75,19 @@ async function deleteReport() {
|
||||
</span>
|
||||
</div>
|
||||
<div class="whitespace-nowrap px-3 py-4 text-sm text-text-secondary">
|
||||
{{ report.is_public ? 'Public' : 'Private' }}
|
||||
{{ formatDateLocalized(report.created_at, dateFormat) }}
|
||||
</div>
|
||||
<div
|
||||
class="whitespace-nowrap px-3 py-4 text-sm text-text-secondary flex items-center gap-1.5">
|
||||
<GlobeAltIcon v-if="report.is_public" class="w-4 h-4 shrink-0 text-text-tertiary" />
|
||||
<LockClosedIcon v-else class="w-4 h-4 shrink-0 text-text-tertiary" />
|
||||
<span>{{ report.is_public ? 'Public' : 'Private' }}</span>
|
||||
</div>
|
||||
<div class="whitespace-nowrap px-3 py-4 text-sm text-text-secondary">
|
||||
<span v-if="report.public_until">
|
||||
{{ formatDateLocalized(report.public_until, dateFormat) }}
|
||||
</span>
|
||||
<span v-else>Never</span>
|
||||
</div>
|
||||
<div class="whitespace-nowrap px-3 flex items-center text-sm text-text-secondary">
|
||||
<div v-if="report.shareable_link" class="space-x-2 flex items-center">
|
||||
|
||||
@@ -107,9 +107,7 @@ const option = computed(() => ({
|
||||
},
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'transparent', // Set desired color here
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
axisLabel: {
|
||||
fontSize: 12,
|
||||
@@ -119,16 +117,13 @@ const option = computed(() => ({
|
||||
fontFamily: 'Inter, sans-serif',
|
||||
},
|
||||
axisTick: {
|
||||
lineStyle: {
|
||||
color: 'transparent', // Set desired color here
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
color: labelColor.value,
|
||||
fontFamily: 'Inter, sans-serif',
|
||||
show: false,
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { SecondaryButton } from '@/packages/ui/src';
|
||||
import { ArrowDownTrayIcon, LockClosedIcon } from '@heroicons/vue/20/solid';
|
||||
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/Components/ui/dropdown-menu';
|
||||
import type { ExportFormat } from '@/types/reporting';
|
||||
import { ref } from 'vue';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
@@ -25,32 +30,24 @@ function triggerDownload(format: ExportFormat) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dropdown align="end">
|
||||
<template #trigger>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<SecondaryButton :icon="ArrowDownTrayIcon" :loading> Export </SecondaryButton>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="flex flex-col space-y-1 p-1.5">
|
||||
<SecondaryButton class="border-0 px-2" @click="triggerDownload('pdf')">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span> Export as PDF </span>
|
||||
<LockClosedIcon
|
||||
v-if="!isAllowedToPerformPremiumAction()"
|
||||
class="w-3.5 text-text-tertiary"></LockClosedIcon>
|
||||
</div>
|
||||
</SecondaryButton>
|
||||
<SecondaryButton class="border-0 px-2" @click="triggerDownload('xlsx')"
|
||||
>Export as Excel</SecondaryButton
|
||||
>
|
||||
<SecondaryButton class="border-0 px-2" @click="triggerDownload('csv')"
|
||||
>Export as CSV</SecondaryButton
|
||||
>
|
||||
<SecondaryButton class="border-0 px-2" @click="triggerDownload('ods')"
|
||||
>Export as ODS
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem @click="triggerDownload('pdf')">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span>Export as PDF</span>
|
||||
<LockClosedIcon
|
||||
v-if="!isAllowedToPerformPremiumAction()"
|
||||
class="w-3.5 text-text-tertiary" />
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem @click="triggerDownload('xlsx')"> Export as Excel </DropdownMenuItem>
|
||||
<DropdownMenuItem @click="triggerDownload('csv')"> Export as CSV </DropdownMenuItem>
|
||||
<DropdownMenuItem @click="triggerDownload('ods')"> Export as ODS </DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<UpgradeModal v-model:show="showPremiumModal">
|
||||
<strong>PDF Reports</strong> are only available in solidtime Professional.
|
||||
</UpgradeModal>
|
||||
|
||||
143
resources/js/Components/Common/Reporting/ReportingFilterBar.vue
Normal file
143
resources/js/Components/Common/Reporting/ReportingFilterBar.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<script setup lang="ts">
|
||||
import { CheckCircleIcon, TagIcon, UserGroupIcon } from '@heroicons/vue/20/solid';
|
||||
import { FolderIcon } from '@heroicons/vue/16/solid';
|
||||
import BillableIcon from '@/packages/ui/src/Icons/BillableIcon.vue';
|
||||
import ReportingRoundingControls from '@/Components/Common/Reporting/ReportingRoundingControls.vue';
|
||||
import TaskMultiselectDropdown from '@/Components/Common/Task/TaskMultiselectDropdown.vue';
|
||||
import ClientMultiselectDropdown from '@/Components/Common/Client/ClientMultiselectDropdown.vue';
|
||||
import MemberMultiselectDropdown from '@/Components/Common/Member/MemberMultiselectDropdown.vue';
|
||||
import ReportingFilterBadge from '@/Components/Common/Reporting/ReportingFilterBadge.vue';
|
||||
import ProjectMultiselectDropdown from '@/Components/Common/Project/ProjectMultiselectDropdown.vue';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/Components/ui/select';
|
||||
import MainContainer from '@/packages/ui/src/MainContainer.vue';
|
||||
import DateRangePicker from '@/packages/ui/src/Input/DateRangePicker.vue';
|
||||
import TagDropdown from '@/packages/ui/src/Tag/TagDropdown.vue';
|
||||
import { useTagsQuery } from '@/utils/useTagsQuery';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
|
||||
type TimeEntryRoundingType = 'up' | 'down' | 'nearest';
|
||||
|
||||
const selectedMembers = defineModel<string[]>('selectedMembers', { required: true });
|
||||
const selectedProjects = defineModel<string[]>('selectedProjects', { required: true });
|
||||
const selectedTasks = defineModel<string[]>('selectedTasks', { required: true });
|
||||
const selectedClients = defineModel<string[]>('selectedClients', { required: true });
|
||||
const selectedTags = defineModel<string[]>('selectedTags', { required: true });
|
||||
const billable = defineModel<'true' | 'false' | null>('billable', { required: true });
|
||||
const roundingEnabled = defineModel<boolean>('roundingEnabled', { required: true });
|
||||
const roundingType = defineModel<TimeEntryRoundingType>('roundingType', { required: true });
|
||||
const roundingMinutes = defineModel<number>('roundingMinutes', { required: true });
|
||||
const startDate = defineModel<string>('startDate', { required: true });
|
||||
const endDate = defineModel<string>('endDate', { required: true });
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [];
|
||||
}>();
|
||||
|
||||
const { tags } = useTagsQuery();
|
||||
|
||||
async function createTag(name: string) {
|
||||
return await useTagsStore().createTag(name);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="py-2.5 w-full border-b border-default-background-separator">
|
||||
<MainContainer class="sm:flex space-y-4 sm:space-y-0 justify-between">
|
||||
<div class="flex flex-wrap items-center space-y-2 sm:space-y-0 space-x-3">
|
||||
<div class="text-sm font-medium">Filters</div>
|
||||
<MemberMultiselectDropdown v-model="selectedMembers" @submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedMembers.length"
|
||||
:active="selectedMembers.length > 0"
|
||||
title="Members"
|
||||
:icon="UserGroupIcon" />
|
||||
</template>
|
||||
</MemberMultiselectDropdown>
|
||||
<ProjectMultiselectDropdown v-model="selectedProjects" @submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedProjects.length"
|
||||
:active="selectedProjects.length > 0"
|
||||
title="Projects"
|
||||
:icon="FolderIcon" />
|
||||
</template>
|
||||
</ProjectMultiselectDropdown>
|
||||
<TaskMultiselectDropdown v-model="selectedTasks" @submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedTasks.length"
|
||||
:active="selectedTasks.length > 0"
|
||||
title="Tasks"
|
||||
:icon="CheckCircleIcon" />
|
||||
</template>
|
||||
</TaskMultiselectDropdown>
|
||||
<ClientMultiselectDropdown v-model="selectedClients" @submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedClients.length"
|
||||
:active="selectedClients.length > 0"
|
||||
title="Clients"
|
||||
:icon="FolderIcon" />
|
||||
</template>
|
||||
</ClientMultiselectDropdown>
|
||||
<TagDropdown
|
||||
v-model="selectedTags"
|
||||
:create-tag
|
||||
:tags="tags"
|
||||
@submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedTags.length"
|
||||
:active="selectedTags.length > 0"
|
||||
title="Tags"
|
||||
:icon="TagIcon" />
|
||||
</template>
|
||||
</TagDropdown>
|
||||
|
||||
<Select v-model="billable" @update:model-value="emit('submit')">
|
||||
<SelectTrigger
|
||||
size="sm"
|
||||
variant="outline"
|
||||
:active="billable !== null"
|
||||
:show-chevron="false">
|
||||
<SelectValue class="flex items-center gap-2">
|
||||
<BillableIcon
|
||||
class="h-4"
|
||||
:class="
|
||||
billable !== null
|
||||
? 'dark:text-accent-300/80 text-accent-400/80'
|
||||
: 'text-text-quaternary'
|
||||
" />
|
||||
<span class="text-text-secondary">{{
|
||||
billable === 'false' ? 'Non Billable' : 'Billable'
|
||||
}}</span>
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem :value="null">Both</SelectItem>
|
||||
<SelectItem value="true">Billable</SelectItem>
|
||||
<SelectItem value="false">Non Billable</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<ReportingRoundingControls
|
||||
v-model:enabled="roundingEnabled"
|
||||
v-model:type="roundingType"
|
||||
v-model:minutes="roundingMinutes"
|
||||
@change="emit('submit')" />
|
||||
</div>
|
||||
<div>
|
||||
<DateRangePicker
|
||||
v-model:start="startDate"
|
||||
v-model:end="endDate"
|
||||
@submit="emit('submit')" />
|
||||
</div>
|
||||
</MainContainer>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import SelectDropdown from '@/packages/ui/src/Input/SelectDropdown.vue';
|
||||
import Badge from '@/packages/ui/src/Badge.vue';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/Components/ui/select';
|
||||
import { type Component, computed } from 'vue';
|
||||
|
||||
const model = defineModel<string | null>({ default: null });
|
||||
const props = defineProps<{
|
||||
groupByOptions: { value: string; label: string; icon: Component }[];
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
changed: [];
|
||||
}>();
|
||||
const icon = computed(() => {
|
||||
return props.groupByOptions.find((option) => option.value === model.value)?.icon;
|
||||
});
|
||||
@@ -16,21 +24,19 @@ const title = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectDropdown
|
||||
v-model="model"
|
||||
:get-key-from-item="(item) => item.value"
|
||||
:get-name-for-item="(item) => item.label"
|
||||
:items="groupByOptions">
|
||||
<template #trigger>
|
||||
<Badge
|
||||
size="large"
|
||||
tag="button"
|
||||
class="cursor-pointer hover:bg-card-background transition space-x-5 flex">
|
||||
<component :is="icon" class="h-4 text-text-secondary"></component>
|
||||
<span> {{ title }} </span>
|
||||
</Badge>
|
||||
</template>
|
||||
</SelectDropdown>
|
||||
<Select v-model="model" @update:model-value="emit('changed')">
|
||||
<SelectTrigger size="sm" :show-chevron="false">
|
||||
<SelectValue class="flex items-center gap-2">
|
||||
<component :is="icon" class="h-4 text-icon-default" />
|
||||
<span>{{ title }}</span>
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="option in groupByOptions" :key="option.value" :value="option.value">
|
||||
{{ option.label }}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ChartBarIcon, CheckCircleIcon, TagIcon, UserGroupIcon } from '@heroicons/vue/20/solid';
|
||||
import { FolderIcon } from '@heroicons/vue/16/solid';
|
||||
import BillableIcon from '@/packages/ui/src/Icons/BillableIcon.vue';
|
||||
import { ChartBarIcon } from '@heroicons/vue/20/solid';
|
||||
import { getOrganizationCurrencyString } from '@/utils/money';
|
||||
import {
|
||||
formatHumanReadableDuration,
|
||||
@@ -11,42 +9,33 @@ import {
|
||||
import { formatCents } from '@/packages/ui/src/utils/money';
|
||||
import ReportingTabNavbar from '@/Components/Common/Reporting/ReportingTabNavbar.vue';
|
||||
import ReportingExportButton from '@/Components/Common/Reporting/ReportingExportButton.vue';
|
||||
import ReportingRoundingControls from '@/Components/Common/Reporting/ReportingRoundingControls.vue';
|
||||
import TaskMultiselectDropdown from '@/Components/Common/Task/TaskMultiselectDropdown.vue';
|
||||
import ClientMultiselectDropdown from '@/Components/Common/Client/ClientMultiselectDropdown.vue';
|
||||
import ReportingRow from '@/Components/Common/Reporting/ReportingRow.vue';
|
||||
import MemberMultiselectDropdown from '@/Components/Common/Member/MemberMultiselectDropdown.vue';
|
||||
import ReportingFilterBadge from '@/Components/Common/Reporting/ReportingFilterBadge.vue';
|
||||
import PageTitle from '@/Components/Common/PageTitle.vue';
|
||||
import ProjectMultiselectDropdown from '@/Components/Common/Project/ProjectMultiselectDropdown.vue';
|
||||
import ReportingChart from '@/Components/Common/Reporting/ReportingChart.vue';
|
||||
import SelectDropdown from '../../../packages/ui/src/Input/SelectDropdown.vue';
|
||||
import ReportingGroupBySelect from '@/Components/Common/Reporting/ReportingGroupBySelect.vue';
|
||||
import MainContainer from '@/packages/ui/src/MainContainer.vue';
|
||||
import DateRangePicker from '@/packages/ui/src/Input/DateRangePicker.vue';
|
||||
import ReportingExportModal from '@/Components/Common/Reporting/ReportingExportModal.vue';
|
||||
import ReportSaveButton from '@/Components/Common/Report/ReportSaveButton.vue';
|
||||
import TagDropdown from '@/packages/ui/src/Tag/TagDropdown.vue';
|
||||
import ReportingPieChart from '@/Components/Common/Reporting/ReportingPieChart.vue';
|
||||
import ReportingFilterBar from '@/Components/Common/Reporting/ReportingFilterBar.vue';
|
||||
|
||||
import { computed, type ComputedRef, inject, onMounted, ref, watch } from 'vue';
|
||||
import { computed, type ComputedRef, inject, ref, watch } from 'vue';
|
||||
import { type GroupingOption, useReportingStore } from '@/utils/useReporting';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import {
|
||||
type AggregatedTimeEntries,
|
||||
type AggregatedTimeEntriesQueryParams,
|
||||
api,
|
||||
type CreateReportBodyProperties,
|
||||
type Organization,
|
||||
} from '@/packages/api/src';
|
||||
import { getCurrentMembershipId, getCurrentOrganizationId, getCurrentRole } from '@/utils/useUser';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useSessionStorage, useStorage } from '@vueuse/core';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import type { ExportFormat } from '@/types/reporting';
|
||||
import { getRandomColorWithSeed } from '@/packages/ui/src/utils/color';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import { useAggregatedTimeEntriesQuery } from '@/utils/useAggregatedTimeEntriesQuery';
|
||||
|
||||
// TimeEntryRoundingType is now defined in ReportingRoundingControls component
|
||||
type TimeEntryRoundingType = 'up' | 'down' | 'nearest';
|
||||
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
@@ -74,71 +63,32 @@ const group = useStorage<GroupingOption>('reporting-group', 'project');
|
||||
const subGroup = useStorage<GroupingOption>('reporting-sub-group', 'task');
|
||||
|
||||
const reportingStore = useReportingStore();
|
||||
|
||||
const { aggregatedGraphTimeEntries, aggregatedTableTimeEntries } = storeToRefs(reportingStore);
|
||||
|
||||
const { groupByOptions } = reportingStore;
|
||||
const { groupByOptions, getNameForReportingRowEntry, emptyPlaceholder } = reportingStore;
|
||||
|
||||
const organization = inject<ComputedRef<Organization>>('organization');
|
||||
|
||||
// Watch rounding enabled state to trigger updates
|
||||
watch(roundingEnabled, () => {
|
||||
updateReporting();
|
||||
const showBillableRate = computed(() => {
|
||||
return !!(
|
||||
getCurrentRole() !== 'employee' || organization?.value?.employees_can_see_billable_rates
|
||||
);
|
||||
});
|
||||
|
||||
function getFilterAttributes(): AggregatedTimeEntriesQueryParams {
|
||||
let params: AggregatedTimeEntriesQueryParams = {
|
||||
start: getLocalizedDayJs(startDate.value).startOf('day').utc().format(),
|
||||
end: getLocalizedDayJs(endDate.value).endOf('day').utc().format(),
|
||||
};
|
||||
params = {
|
||||
...params,
|
||||
member_ids: selectedMembers.value.length > 0 ? selectedMembers.value : undefined,
|
||||
project_ids: selectedProjects.value.length > 0 ? selectedProjects.value : undefined,
|
||||
task_ids: selectedTasks.value.length > 0 ? selectedTasks.value : undefined,
|
||||
client_ids: selectedClients.value.length > 0 ? selectedClients.value : undefined,
|
||||
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
|
||||
billable: billable.value !== null ? billable.value : undefined,
|
||||
member_id: getCurrentRole() === 'employee' ? getCurrentMembershipId() : undefined,
|
||||
rounding_type: roundingEnabled.value ? roundingType.value : undefined,
|
||||
rounding_minutes: roundingEnabled.value ? roundingMinutes.value : undefined,
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
function updateGraphReporting() {
|
||||
const params = getFilterAttributes();
|
||||
if (getCurrentRole() === 'employee') {
|
||||
params.member_id = getCurrentMembershipId();
|
||||
}
|
||||
params.fill_gaps_in_time_groups = 'true';
|
||||
params.group = getOptimalGroupingOption(startDate.value, endDate.value);
|
||||
useReportingStore().fetchGraphReporting(params);
|
||||
}
|
||||
|
||||
function updateTableReporting() {
|
||||
const params = getFilterAttributes();
|
||||
if (group.value === subGroup.value) {
|
||||
const fallbackOption = groupByOptions.find((el) => el.value !== group.value);
|
||||
if (fallbackOption?.value) {
|
||||
subGroup.value = fallbackOption.value;
|
||||
// Ensure sub-group falls back when it collides with group
|
||||
watch(
|
||||
group,
|
||||
() => {
|
||||
if (group.value === subGroup.value) {
|
||||
const fallbackOption = groupByOptions.find((el) => el.value !== group.value);
|
||||
if (fallbackOption?.value) {
|
||||
subGroup.value = fallbackOption.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getCurrentRole() === 'employee') {
|
||||
params.member_id = getCurrentMembershipId();
|
||||
}
|
||||
params.group = group.value;
|
||||
params.sub_group = subGroup.value;
|
||||
useReportingStore().fetchTableReporting(params);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
function updateReporting() {
|
||||
updateGraphReporting();
|
||||
updateTableReporting();
|
||||
}
|
||||
|
||||
function getOptimalGroupingOption(startDate: string, endDate: string): 'day' | 'week' | 'month' {
|
||||
const diffInDays = getDayJsInstance()(endDate).diff(getDayJsInstance()(startDate), 'd');
|
||||
function getOptimalGroupingOption(start: string, end: string): 'day' | 'week' | 'month' {
|
||||
const diffInDays = getDayJsInstance()(end).diff(getDayJsInstance()(start), 'd');
|
||||
|
||||
if (diffInDays <= 31) {
|
||||
return 'day';
|
||||
@@ -149,20 +99,52 @@ function getOptimalGroupingOption(startDate: string, endDate: string): 'day' | '
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateGraphReporting();
|
||||
updateTableReporting();
|
||||
const filterParams = computed<AggregatedTimeEntriesQueryParams>(() => {
|
||||
return {
|
||||
start: getLocalizedDayJs(startDate.value).startOf('day').utc().format(),
|
||||
end: getLocalizedDayJs(endDate.value).endOf('day').utc().format(),
|
||||
member_ids: selectedMembers.value.length > 0 ? selectedMembers.value : undefined,
|
||||
project_ids: selectedProjects.value.length > 0 ? selectedProjects.value : undefined,
|
||||
task_ids: selectedTasks.value.length > 0 ? selectedTasks.value : undefined,
|
||||
client_ids: selectedClients.value.length > 0 ? selectedClients.value : undefined,
|
||||
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
|
||||
billable: billable.value !== null ? billable.value : undefined,
|
||||
member_id: getCurrentRole() === 'employee' ? getCurrentMembershipId() : undefined,
|
||||
rounding_type: roundingEnabled.value ? roundingType.value : undefined,
|
||||
rounding_minutes: roundingEnabled.value ? roundingMinutes.value : undefined,
|
||||
};
|
||||
});
|
||||
|
||||
const { tags } = storeToRefs(useTagsStore());
|
||||
const graphQueryParams = computed<AggregatedTimeEntriesQueryParams>(() => {
|
||||
return {
|
||||
...filterParams.value,
|
||||
fill_gaps_in_time_groups: 'true',
|
||||
group: getOptimalGroupingOption(startDate.value, endDate.value),
|
||||
};
|
||||
});
|
||||
|
||||
async function createTag(tag: string) {
|
||||
return await useTagsStore().createTag(tag);
|
||||
}
|
||||
const tableQueryParams = computed<AggregatedTimeEntriesQueryParams>(() => {
|
||||
return {
|
||||
...filterParams.value,
|
||||
group: group.value,
|
||||
sub_group: subGroup.value,
|
||||
};
|
||||
});
|
||||
|
||||
const { data: graphResponse } = useAggregatedTimeEntriesQuery('graph', graphQueryParams);
|
||||
const { data: tableResponse } = useAggregatedTimeEntriesQuery('table', tableQueryParams);
|
||||
|
||||
const aggregatedGraphTimeEntries = computed<AggregatedTimeEntries | undefined>(() => {
|
||||
return graphResponse.value?.data as AggregatedTimeEntries | undefined;
|
||||
});
|
||||
|
||||
const aggregatedTableTimeEntries = computed<AggregatedTimeEntries | undefined>(() => {
|
||||
return tableResponse.value?.data as AggregatedTimeEntries | undefined;
|
||||
});
|
||||
|
||||
const reportProperties = computed(() => {
|
||||
return {
|
||||
...getFilterAttributes(),
|
||||
...filterParams.value,
|
||||
group: group.value,
|
||||
sub_group: subGroup.value,
|
||||
history_group: getOptimalGroupingOption(startDate.value, endDate.value),
|
||||
@@ -179,7 +161,7 @@ async function downloadExport(format: ExportFormat) {
|
||||
organization: organizationId,
|
||||
},
|
||||
queries: {
|
||||
...getFilterAttributes(),
|
||||
...filterParams.value,
|
||||
group: group.value,
|
||||
sub_group: subGroup.value,
|
||||
history_group: getOptimalGroupingOption(startDate.value, endDate.value),
|
||||
@@ -197,10 +179,7 @@ async function downloadExport(format: ExportFormat) {
|
||||
}
|
||||
}
|
||||
|
||||
const { getNameForReportingRowEntry, emptyPlaceholder } = useReportingStore();
|
||||
|
||||
const projectsStore = useProjectsStore();
|
||||
const { projects } = storeToRefs(projectsStore);
|
||||
const { projects } = useProjectsQuery();
|
||||
const showExportModal = ref(false);
|
||||
const exportUrl = ref<string | null>(null);
|
||||
|
||||
@@ -209,13 +188,13 @@ const groupedPieChartData = computed(() => {
|
||||
aggregatedTableTimeEntries.value?.grouped_data?.map((entry) => {
|
||||
const name = getNameForReportingRowEntry(
|
||||
entry.key,
|
||||
aggregatedTableTimeEntries.value?.grouped_type
|
||||
aggregatedTableTimeEntries.value?.grouped_type ?? null
|
||||
);
|
||||
let color = getRandomColorWithSeed(entry.key ?? 'none');
|
||||
if (
|
||||
name &&
|
||||
aggregatedTableTimeEntries.value?.grouped_type &&
|
||||
emptyPlaceholder[aggregatedTableTimeEntries.value?.grouped_type] === name
|
||||
emptyPlaceholder[aggregatedTableTimeEntries.value.grouped_type] === name
|
||||
) {
|
||||
color = '#CCCCCC';
|
||||
} else if (aggregatedTableTimeEntries.value?.grouped_type === 'project') {
|
||||
@@ -227,7 +206,7 @@ const groupedPieChartData = computed(() => {
|
||||
name:
|
||||
getNameForReportingRowEntry(
|
||||
entry.key,
|
||||
aggregatedTableTimeEntries.value?.grouped_type
|
||||
aggregatedTableTimeEntries.value?.grouped_type ?? null
|
||||
) ?? '',
|
||||
color: color,
|
||||
};
|
||||
@@ -242,7 +221,7 @@ const tableData = computed(() => {
|
||||
cost: entry.cost,
|
||||
description: getNameForReportingRowEntry(
|
||||
entry.key,
|
||||
aggregatedTableTimeEntries.value?.grouped_type
|
||||
aggregatedTableTimeEntries.value?.grouped_type ?? null
|
||||
),
|
||||
grouped_data:
|
||||
entry.grouped_data?.map((el) => {
|
||||
@@ -272,129 +251,51 @@ const tableData = computed(() => {
|
||||
<ReportSaveButton :report-properties="reportProperties"></ReportSaveButton>
|
||||
</div>
|
||||
</MainContainer>
|
||||
<div class="py-2.5 w-full border-b border-default-background-separator">
|
||||
<MainContainer class="sm:flex space-y-4 sm:space-y-0 justify-between">
|
||||
<div class="flex flex-wrap items-center space-y-2 sm:space-y-0 space-x-3">
|
||||
<div class="text-sm font-medium">Filters</div>
|
||||
<MemberMultiselectDropdown v-model="selectedMembers" @submit="updateReporting">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedMembers.length"
|
||||
:active="selectedMembers.length > 0"
|
||||
title="Members"
|
||||
:icon="UserGroupIcon"></ReportingFilterBadge>
|
||||
</template>
|
||||
</MemberMultiselectDropdown>
|
||||
<ProjectMultiselectDropdown v-model="selectedProjects" @submit="updateReporting">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedProjects.length"
|
||||
:active="selectedProjects.length > 0"
|
||||
title="Projects"
|
||||
:icon="FolderIcon"></ReportingFilterBadge>
|
||||
</template>
|
||||
</ProjectMultiselectDropdown>
|
||||
<TaskMultiselectDropdown v-model="selectedTasks" @submit="updateReporting">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedTasks.length"
|
||||
:active="selectedTasks.length > 0"
|
||||
title="Tasks"
|
||||
:icon="CheckCircleIcon"></ReportingFilterBadge>
|
||||
</template>
|
||||
</TaskMultiselectDropdown>
|
||||
<ClientMultiselectDropdown v-model="selectedClients" @submit="updateReporting">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedClients.length"
|
||||
:active="selectedClients.length > 0"
|
||||
title="Clients"
|
||||
:icon="FolderIcon"></ReportingFilterBadge>
|
||||
</template>
|
||||
</ClientMultiselectDropdown>
|
||||
<TagDropdown
|
||||
v-model="selectedTags"
|
||||
:create-tag
|
||||
:tags="tags"
|
||||
@submit="updateReporting">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:count="selectedTags.length"
|
||||
:active="selectedTags.length > 0"
|
||||
title="Tags"
|
||||
:icon="TagIcon"></ReportingFilterBadge>
|
||||
</template>
|
||||
</TagDropdown>
|
||||
|
||||
<SelectDropdown
|
||||
v-model="billable"
|
||||
:get-key-from-item="(item) => item.value"
|
||||
:get-name-for-item="(item) => item.label"
|
||||
:items="[
|
||||
{
|
||||
label: 'Both',
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
label: 'Billable',
|
||||
value: 'true',
|
||||
},
|
||||
{
|
||||
label: 'Non Billable',
|
||||
value: 'false',
|
||||
},
|
||||
]"
|
||||
@changed="updateReporting">
|
||||
<template #trigger>
|
||||
<ReportingFilterBadge
|
||||
:active="billable !== null"
|
||||
:title="billable === 'false' ? 'Non Billable' : 'Billable'"
|
||||
:icon="BillableIcon"></ReportingFilterBadge>
|
||||
</template>
|
||||
</SelectDropdown>
|
||||
<ReportingRoundingControls
|
||||
v-model:enabled="roundingEnabled"
|
||||
v-model:type="roundingType"
|
||||
v-model:minutes="roundingMinutes"
|
||||
@change="updateReporting"></ReportingRoundingControls>
|
||||
</div>
|
||||
<div>
|
||||
<DateRangePicker
|
||||
v-model:start="startDate"
|
||||
v-model:end="endDate"
|
||||
@submit="updateReporting"></DateRangePicker>
|
||||
</div>
|
||||
</MainContainer>
|
||||
</div>
|
||||
<ReportingFilterBar
|
||||
v-model:selected-members="selectedMembers"
|
||||
v-model:selected-projects="selectedProjects"
|
||||
v-model:selected-tasks="selectedTasks"
|
||||
v-model:selected-clients="selectedClients"
|
||||
v-model:selected-tags="selectedTags"
|
||||
v-model:billable="billable"
|
||||
v-model:rounding-enabled="roundingEnabled"
|
||||
v-model:rounding-type="roundingType"
|
||||
v-model:rounding-minutes="roundingMinutes"
|
||||
v-model:start-date="startDate"
|
||||
v-model:end-date="endDate" />
|
||||
<MainContainer>
|
||||
<div class="pt-10 w-full px-3 relative">
|
||||
<ReportingChart
|
||||
:grouped-type="aggregatedGraphTimeEntries?.grouped_type"
|
||||
:grouped-data="aggregatedGraphTimeEntries?.grouped_data"></ReportingChart>
|
||||
:grouped-type="aggregatedGraphTimeEntries?.grouped_type ?? null"
|
||||
:grouped-data="aggregatedGraphTimeEntries?.grouped_data ?? null"></ReportingChart>
|
||||
</div>
|
||||
</MainContainer>
|
||||
<MainContainer>
|
||||
<div class="sm:grid grid-cols-4 pt-6 items-start">
|
||||
<div class="col-span-3 bg-card-background rounded-lg border border-card-border pt-3">
|
||||
<div class="col-span-3 bg-secondary rounded-lg border border-card-border pt-3">
|
||||
<div
|
||||
class="text-sm flex text-text-primary items-center space-x-3 font-medium px-6 border-b border-card-background-separator pb-3">
|
||||
<span>Group by</span>
|
||||
<ReportingGroupBySelect
|
||||
v-model="group"
|
||||
:group-by-options="groupByOptions"
|
||||
@changed="updateTableReporting"></ReportingGroupBySelect>
|
||||
:group-by-options="groupByOptions"></ReportingGroupBySelect>
|
||||
<span>and</span>
|
||||
<ReportingGroupBySelect
|
||||
v-model="subGroup"
|
||||
:group-by-options="groupByOptions.filter((el) => el.value !== group)"
|
||||
@changed="updateTableReporting"></ReportingGroupBySelect>
|
||||
:group-by-options="
|
||||
groupByOptions.filter((el) => el.value !== group)
|
||||
"></ReportingGroupBySelect>
|
||||
</div>
|
||||
<div class="grid items-center" style="grid-template-columns: 1fr 100px 150px">
|
||||
<div
|
||||
class="grid items-center"
|
||||
:style="`grid-template-columns: 1fr 100px ${showBillableRate ? '150px' : ''}`">
|
||||
<div
|
||||
class="contents [&>*]:border-card-background-separator [&>*]:border-b [&>*]:bg-tertiary [&>*]:pb-1.5 [&>*]:pt-1 text-text-secondary text-sm">
|
||||
class="contents [&>*]:border-card-background-separator [&>*]:border-b [&>*]:bg-secondary [&>*]:pb-1.5 [&>*]:pt-1 text-text-tertiary text-sm">
|
||||
<div class="pl-6">Name</div>
|
||||
<div class="text-right">Duration</div>
|
||||
<div class="text-right pr-6">Cost</div>
|
||||
<div class="text-right" :class="!showBillableRate ? 'pr-6' : ''">
|
||||
Duration
|
||||
</div>
|
||||
<div v-if="showBillableRate" class="text-right pr-6">Cost</div>
|
||||
</div>
|
||||
<template
|
||||
v-if="
|
||||
@@ -406,12 +307,15 @@ const tableData = computed(() => {
|
||||
:key="entry.description ?? 'none'"
|
||||
:currency="getOrganizationCurrencyString()"
|
||||
:type="aggregatedTableTimeEntries.grouped_type"
|
||||
:show-cost="showBillableRate"
|
||||
:entry="entry"></ReportingRow>
|
||||
<div class="contents [&>*]:transition text-text-tertiary [&>*]:h-[50px]">
|
||||
<div class="flex items-center pl-6 font-medium">
|
||||
<span>Total</span>
|
||||
</div>
|
||||
<div class="justify-end flex items-center font-medium">
|
||||
<div
|
||||
class="justify-end flex items-center font-medium"
|
||||
:class="!showBillableRate ? 'pr-6' : ''">
|
||||
{{
|
||||
formatHumanReadableDuration(
|
||||
aggregatedTableTimeEntries.seconds,
|
||||
@@ -420,9 +324,12 @@ const tableData = computed(() => {
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
<div class="justify-end pr-6 flex items-center font-medium">
|
||||
<div
|
||||
v-if="showBillableRate"
|
||||
class="justify-end pr-6 flex items-center font-medium">
|
||||
{{
|
||||
aggregatedTableTimeEntries.cost
|
||||
aggregatedTableTimeEntries.cost !== null &&
|
||||
aggregatedTableTimeEntries.cost !== undefined
|
||||
? formatCents(
|
||||
aggregatedTableTimeEntries.cost,
|
||||
getOrganizationCurrencyString(),
|
||||
@@ -437,7 +344,8 @@ const tableData = computed(() => {
|
||||
</template>
|
||||
<div
|
||||
v-else
|
||||
class="chart flex flex-col items-center justify-center py-12 col-span-3">
|
||||
class="chart flex flex-col items-center justify-center py-12"
|
||||
:class="showBillableRate ? 'col-span-3' : 'col-span-2'">
|
||||
<p class="text-lg text-text-primary font-medium">No time entries found</p>
|
||||
<p>Try to change the filters and time range</p>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/Components/ui/select';
|
||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
||||
import { Field, FieldLabel } from '@/packages/ui/src/field';
|
||||
import {
|
||||
NumberField,
|
||||
NumberFieldInput,
|
||||
@@ -162,7 +162,7 @@ const iconClass = computed(() => {
|
||||
>Rounding is a premium feature. Upgrade to unlock this feature.</span
|
||||
>
|
||||
<Link href="/billing">
|
||||
<Button size="sm" variant="input" class="items-center space-x-1">
|
||||
<Button size="sm" variant="outline" class="items-center space-x-1">
|
||||
<CreditCardIcon class="w-3.5 h-3.5 text-text-tertiary mr-1" />
|
||||
Go to Billing
|
||||
</Button>
|
||||
@@ -170,14 +170,14 @@ const iconClass = computed(() => {
|
||||
</div>
|
||||
<div v-else class="space-y-4">
|
||||
<div>
|
||||
<div class="flex items-center justify-between">
|
||||
<InputLabel for="enable-rounding" value="Enable Rounding" />
|
||||
<Field orientation="horizontal" class="justify-between">
|
||||
<FieldLabel for="enable-rounding">Enable Rounding</FieldLabel>
|
||||
<Switch
|
||||
id="enable-rounding"
|
||||
:model-value="enabled"
|
||||
class="data-[state=checked]:bg-accent-500"
|
||||
@update:model-value="updateEnabled" />
|
||||
</div>
|
||||
</Field>
|
||||
<div
|
||||
class="mb-3 pb-2 pt-1 text-xs text-muted-foreground border-b border-border-secondary text-text-tertiary">
|
||||
Rounding is applied to each individual time entry, not to the accumulated
|
||||
@@ -185,15 +185,15 @@ const iconClass = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<InputLabel for="rounding-type" value="Rounding Type" class="mb-2" />
|
||||
<Field>
|
||||
<FieldLabel for="rounding-type">Rounding Type</FieldLabel>
|
||||
<Select
|
||||
:model-value="type"
|
||||
:disabled="!enabled"
|
||||
@update:model-value="(value) => updateType(value as TimeEntryRoundingType)">
|
||||
<SelectTrigger
|
||||
id="rounding-type"
|
||||
size="small"
|
||||
size="sm"
|
||||
class="w-full"
|
||||
:disabled="!enabled">
|
||||
<SelectValue placeholder="Select rounding type" />
|
||||
@@ -204,16 +204,16 @@ const iconClass = computed(() => {
|
||||
<SelectItem value="nearest">Round Nearest</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<InputLabel for="minutes-interval" value="Minutes Interval" class="mb-2" />
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel for="minutes-interval">Minutes Interval</FieldLabel>
|
||||
<Select
|
||||
:model-value="selectedInterval"
|
||||
:disabled="!enabled"
|
||||
@update:model-value="(value) => handleIntervalChange(value as string)">
|
||||
<SelectTrigger
|
||||
id="minutes-interval"
|
||||
size="small"
|
||||
size="sm"
|
||||
class="w-full"
|
||||
:disabled="!enabled">
|
||||
<SelectValue placeholder="Select interval" />
|
||||
@@ -232,7 +232,6 @@ const iconClass = computed(() => {
|
||||
<NumberField
|
||||
id="custom-minutes"
|
||||
:model-value="customMinutes"
|
||||
size="small"
|
||||
:min="1"
|
||||
:max="1440"
|
||||
:disabled="!enabled"
|
||||
@@ -247,7 +246,7 @@ const iconClass = computed(() => {
|
||||
</NumberFieldContent>
|
||||
</NumberField>
|
||||
</div>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
@@ -20,6 +20,7 @@ const props = defineProps<{
|
||||
entry: AggregatedGroupedData;
|
||||
indent?: boolean;
|
||||
currency: string;
|
||||
showCost?: boolean;
|
||||
}>();
|
||||
|
||||
const expanded = ref(false);
|
||||
@@ -41,7 +42,7 @@ const organization = inject<ComputedRef<Organization>>('organization');
|
||||
{{ entry.description }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="justify-end flex items-center">
|
||||
<div class="justify-end flex items-center" :class="!showCost ? 'pr-6' : ''">
|
||||
{{
|
||||
formatHumanReadableDuration(
|
||||
entry.seconds,
|
||||
@@ -50,7 +51,7 @@ const organization = inject<ComputedRef<Organization>>('organization');
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
<div class="justify-end pr-6 flex items-center">
|
||||
<div v-if="showCost" class="justify-end pr-6 flex items-center">
|
||||
{{
|
||||
entry.cost
|
||||
? formatCents(
|
||||
@@ -66,12 +67,14 @@ const organization = inject<ComputedRef<Organization>>('organization');
|
||||
</div>
|
||||
<div
|
||||
v-if="expanded && entry.grouped_data"
|
||||
class="col-span-3 grid bg-quaternary"
|
||||
style="grid-template-columns: 1fr 150px 150px">
|
||||
:class="showCost ? 'col-span-3' : 'col-span-2'"
|
||||
class="grid bg-tertiary"
|
||||
:style="`grid-template-columns: 1fr 150px ${showCost ? '150px' : ''}`">
|
||||
<ReportingRow
|
||||
v-for="subEntry in entry.grouped_data"
|
||||
:key="subEntry.description ?? 'none'"
|
||||
:currency="props.currency"
|
||||
:show-cost="showCost"
|
||||
indent
|
||||
:entry="subEntry"></ReportingRow>
|
||||
</div>
|
||||
|
||||
@@ -1,31 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { router } from '@inertiajs/vue3';
|
||||
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||
import { canViewReport } from '@/utils/permissions';
|
||||
import { computed } from 'vue';
|
||||
defineProps<{
|
||||
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
active: 'reporting' | 'detailed' | 'shared';
|
||||
}>();
|
||||
|
||||
const showSharedReports = computed(() => canViewReport());
|
||||
|
||||
const tabs = computed(() => {
|
||||
const items = [
|
||||
{ value: 'reporting', label: 'Overview', href: route('reporting') },
|
||||
{ value: 'detailed', label: 'Detailed', href: route('reporting.detailed') },
|
||||
];
|
||||
if (showSharedReports.value) {
|
||||
items.push({
|
||||
value: 'shared',
|
||||
label: 'Shared',
|
||||
href: route('reporting.shared'),
|
||||
});
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
function hrefForTab(value: string) {
|
||||
return tabs.value.find((tab) => tab.value === value)?.href;
|
||||
}
|
||||
|
||||
function onTabChange(value: string | number) {
|
||||
const href = hrefForTab(String(value));
|
||||
if (href) {
|
||||
router.visit(href);
|
||||
}
|
||||
}
|
||||
|
||||
function onTabHover(value: string) {
|
||||
const href = hrefForTab(value);
|
||||
if (href) {
|
||||
router.prefetch(href, {}, { cacheFor: '1m' });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabBar :model-value="active">
|
||||
<TabBarItem value="reporting" @click="router.visit(route('reporting'))"
|
||||
>Overview</TabBarItem
|
||||
>
|
||||
<TabBarItem value="detailed" @click="router.visit(route('reporting.detailed'))"
|
||||
>Detailed</TabBarItem
|
||||
>
|
||||
<TabBar :default-value="props.active" @update:model-value="onTabChange">
|
||||
<TabBarItem
|
||||
v-if="showSharedReports"
|
||||
value="shared"
|
||||
@click="router.visit(route('reporting.shared'))"
|
||||
>Shared</TabBarItem
|
||||
>
|
||||
v-for="tab in tabs"
|
||||
:key="tab.value"
|
||||
:value="tab.value"
|
||||
@mouseenter="onTabHover(tab.value)">
|
||||
{{ tab.label }}
|
||||
</TabBarItem>
|
||||
</TabBar>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
75
resources/js/Components/Common/Tag/TagEditModal.vue
Normal file
75
resources/js/Components/Common/Tag/TagEditModal.vue
Normal file
@@ -0,0 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import { ref } from 'vue';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import type { Tag, UpdateTagBody } from '@/packages/api/src';
|
||||
|
||||
const { updateTag } = useTagsStore();
|
||||
const show = defineModel('show', { default: false });
|
||||
const saving = ref(false);
|
||||
|
||||
const props = defineProps<{
|
||||
tag: Tag;
|
||||
}>();
|
||||
|
||||
const tagBody = ref<UpdateTagBody>({
|
||||
name: props.tag.name,
|
||||
});
|
||||
|
||||
async function submit() {
|
||||
saving.value = true;
|
||||
try {
|
||||
await updateTag({ tagId: props.tag.id, tagBody: tagBody.value });
|
||||
show.value = false;
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const tagNameInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
useFocus(tagNameInput, { initialValue: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogModal closeable :show="show" @close="show = false">
|
||||
<template #title>
|
||||
<div class="flex space-x-2">
|
||||
<span> Update Tag </span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="col-span-6 sm:col-span-4 flex-1">
|
||||
<TextInput
|
||||
id="tagName"
|
||||
ref="tagNameInput"
|
||||
v-model="tagBody.name"
|
||||
type="text"
|
||||
placeholder="Tag Name"
|
||||
class="mt-1 block w-full"
|
||||
required
|
||||
autocomplete="tagName"
|
||||
@keydown.enter="submit()" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="show = false"> Cancel </SecondaryButton>
|
||||
<PrimaryButton
|
||||
class="ms-3"
|
||||
:class="{ 'opacity-25': saving }"
|
||||
:disabled="saving"
|
||||
@click="submit">
|
||||
Update Tag
|
||||
</PrimaryButton>
|
||||
</template>
|
||||
</DialogModal>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { TrashIcon } from '@heroicons/vue/20/solid';
|
||||
import { TrashIcon, PencilSquareIcon } from '@heroicons/vue/20/solid';
|
||||
import { canDeleteTags, canUpdateTags } from '@/utils/permissions';
|
||||
import type { Tag } from '@/packages/api/src';
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
} from '@/Components/ui/dropdown-menu';
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [];
|
||||
delete: [];
|
||||
}>();
|
||||
const props = defineProps<{
|
||||
@@ -38,6 +40,16 @@ const props = defineProps<{
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent class="min-w-[150px]" align="end">
|
||||
<DropdownMenuItem
|
||||
v-if="canUpdateTags()"
|
||||
:aria-label="'Edit Tag ' + props.tag.name"
|
||||
data-testid="tag_edit"
|
||||
class="flex items-center space-x-3 cursor-pointer"
|
||||
@click="emit('edit')">
|
||||
<PencilSquareIcon class="w-5 text-icon-active" />
|
||||
<span>Edit</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
v-if="canDeleteTags()"
|
||||
:aria-label="'Delete Tag ' + props.tag.name"
|
||||
data-testid="tag_delete"
|
||||
class="flex items-center space-x-3 cursor-pointer text-destructive focus:text-destructive"
|
||||
|
||||
@@ -3,8 +3,7 @@ import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import { FolderPlusIcon } from '@heroicons/vue/24/solid';
|
||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||
import { ref } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import { useTagsQuery } from '@/utils/useTagsQuery';
|
||||
import TagTableRow from '@/Components/Common/Tag/TagTableRow.vue';
|
||||
import TagCreateModal from '@/packages/ui/src/Tag/TagCreateModal.vue';
|
||||
import TagTableHeading from '@/Components/Common/Tag/TagTableHeading.vue';
|
||||
@@ -13,7 +12,7 @@ import type { Tag } from '@/packages/api/src';
|
||||
defineProps<{
|
||||
createTag: (name: string) => Promise<Tag | undefined>;
|
||||
}>();
|
||||
const { tags } = storeToRefs(useTagsStore());
|
||||
const { tags } = useTagsQuery();
|
||||
const showCreateTagModal = ref(false);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
import type { Tag } from '@/packages/api/src';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import TagMoreOptionsDropdown from '@/Components/Common/Tag/TagMoreOptionsDropdown.vue';
|
||||
import TagEditModal from '@/Components/Common/Tag/TagEditModal.vue';
|
||||
import TableRow from '@/Components/TableRow.vue';
|
||||
import { canDeleteTags } from '@/utils/permissions';
|
||||
import { canDeleteTags, canUpdateTags } from '@/utils/permissions';
|
||||
import { ref } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
tag: Tag;
|
||||
}>();
|
||||
|
||||
const showTagEditModal = ref(false);
|
||||
|
||||
function deleteTag() {
|
||||
useTagsStore().deleteTag(props.tag.id);
|
||||
}
|
||||
@@ -25,10 +29,12 @@ function deleteTag() {
|
||||
<div
|
||||
class="relative whitespace-nowrap flex items-center pl-3 text-right text-sm font-medium sm:pr-0 pr-4 sm:pr-6 lg:pr-8 3xl:pr-12">
|
||||
<TagMoreOptionsDropdown
|
||||
v-if="canDeleteTags()"
|
||||
v-if="canDeleteTags() || canUpdateTags()"
|
||||
:tag="tag"
|
||||
@edit="showTagEditModal = true"
|
||||
@delete="deleteTag"></TagMoreOptionsDropdown>
|
||||
</div>
|
||||
<TagEditModal v-model:show="showTagEditModal" :tag="tag"></TagEditModal>
|
||||
</TableRow>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ import { useTasksStore } from '@/utils/useTasks';
|
||||
import ProjectDropdown from '@/Components/Common/Project/ProjectDropdown.vue';
|
||||
import EstimatedTimeSection from '@/packages/ui/src/EstimatedTimeSection.vue';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import { Field, FieldGroup, FieldLabel } from '@/packages/ui/src/field';
|
||||
import { Button } from '@/packages/ui/src/Buttons';
|
||||
import { ChevronDown } from 'lucide-vue-next';
|
||||
import { FolderIcon } from '@heroicons/vue/20/solid';
|
||||
|
||||
const { createTask } = useTasksStore();
|
||||
const show = defineModel('show', { default: false });
|
||||
@@ -54,8 +58,9 @@ useFocus(taskNameInput, { initialValue: true });
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="col-span-6 sm:col-span-4 flex-1">
|
||||
<FieldGroup>
|
||||
<Field class="w-full">
|
||||
<FieldLabel for="taskName">Task name</FieldLabel>
|
||||
<TextInput
|
||||
id="taskName"
|
||||
ref="taskNameInput"
|
||||
@@ -66,15 +71,28 @@ useFocus(taskNameInput, { initialValue: true });
|
||||
required
|
||||
autocomplete="taskName"
|
||||
@keydown.enter="submit()" />
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-4">
|
||||
<ProjectDropdown v-model="taskProjectId"></ProjectDropdown>
|
||||
</div>
|
||||
</div>
|
||||
<EstimatedTimeSection
|
||||
v-if="isAllowedToPerformPremiumAction()"
|
||||
v-model="estimatedTime"
|
||||
@submit="submit()"></EstimatedTimeSection>
|
||||
</Field>
|
||||
<Field class="w-auto">
|
||||
<FieldLabel :icon="FolderIcon" for="project">Project</FieldLabel>
|
||||
<ProjectDropdown v-model="taskProjectId">
|
||||
<template #trigger="{ selectedProjectName, selectedProjectColor }">
|
||||
<Button variant="input" class="w-full justify-between">
|
||||
<span class="flex items-center gap-2 truncate">
|
||||
<span
|
||||
:style="{ backgroundColor: selectedProjectColor }"
|
||||
class="w-3 h-3 rounded-full shrink-0"></span>
|
||||
<span class="truncate">{{ selectedProjectName }}</span>
|
||||
</span>
|
||||
<ChevronDown class="w-4 h-4 text-icon-default" />
|
||||
</Button>
|
||||
</template>
|
||||
</ProjectDropdown>
|
||||
</Field>
|
||||
<EstimatedTimeSection
|
||||
v-if="isAllowedToPerformPremiumAction()"
|
||||
v-model="estimatedTime"
|
||||
@submit="submit()"></EstimatedTimeSection>
|
||||
</FieldGroup>
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="show = false"> Cancel </SecondaryButton>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useTasksStore } from '@/utils/useTasks';
|
||||
import type { Task, UpdateTaskBody } from '@/packages/api/src';
|
||||
import EstimatedTimeSection from '@/packages/ui/src/EstimatedTimeSection.vue';
|
||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||
import { Field, FieldGroup, FieldLabel } from '@/packages/ui/src/field';
|
||||
|
||||
const { updateTask } = useTasksStore();
|
||||
const show = defineModel('show', { default: false });
|
||||
@@ -42,24 +43,25 @@ useFocus(taskNameInput, { initialValue: true });
|
||||
</template>
|
||||
|
||||
<template #content>
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="col-span-6 sm:col-span-4 flex-1">
|
||||
<FieldGroup>
|
||||
<Field>
|
||||
<FieldLabel for="taskName">Task name</FieldLabel>
|
||||
<TextInput
|
||||
id="taskName"
|
||||
ref="taskNameInput"
|
||||
v-model="taskBody.name"
|
||||
type="text"
|
||||
placeholder="Task Name"
|
||||
class="mt-1 block w-full"
|
||||
class="block w-full"
|
||||
required
|
||||
autocomplete="taskName"
|
||||
@keydown.enter="submit()" />
|
||||
</div>
|
||||
</div>
|
||||
<EstimatedTimeSection
|
||||
v-if="isAllowedToPerformPremiumAction()"
|
||||
v-model="taskBody.estimated_time"
|
||||
@submit="submit()"></EstimatedTimeSection>
|
||||
</Field>
|
||||
<EstimatedTimeSection
|
||||
v-if="isAllowedToPerformPremiumAction()"
|
||||
v-model="taskBody.estimated_time"
|
||||
@submit="submit()"></EstimatedTimeSection>
|
||||
</FieldGroup>
|
||||
</template>
|
||||
<template #footer>
|
||||
<SecondaryButton @click="show = false"> Cancel </SecondaryButton>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import type { Task } from '@/packages/api/src';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
|
||||
const tasksStore = useTasksStore();
|
||||
const { tasks } = storeToRefs(tasksStore);
|
||||
const { tasks } = useTasksQuery();
|
||||
|
||||
function getKeyFromItem(item: Task) {
|
||||
return item.id;
|
||||
@@ -14,6 +12,10 @@ function getKeyFromItem(item: Task) {
|
||||
function getNameForItem(item: Task) {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +23,9 @@ function getNameForItem(item: Task) {
|
||||
search-placeholder="Search for a Task..."
|
||||
:items="tasks"
|
||||
:get-key-from-item="getKeyFromItem"
|
||||
:get-name-for-item="getNameForItem">
|
||||
:get-name-for-item="getNameForItem"
|
||||
no-item-label="No Task"
|
||||
@submit="emit('submit')">
|
||||
<template #trigger>
|
||||
<slot name="trigger"></slot>
|
||||
</template>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick } from 'vue';
|
||||
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||
import InputError from '@/packages/ui/src/Input/InputError.vue';
|
||||
import { Field, FieldError } from '@/packages/ui/src/field';
|
||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
||||
@@ -87,18 +87,18 @@ const closeModal = () => {
|
||||
<template #content>
|
||||
{{ content }}
|
||||
|
||||
<div class="mt-4">
|
||||
<Field class="mt-4">
|
||||
<TextInput
|
||||
ref="passwordInput"
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
class="mt-1 block w-3/4"
|
||||
class="block w-3/4"
|
||||
placeholder="Password"
|
||||
autocomplete="current-password"
|
||||
@keyup.enter="confirmPassword" />
|
||||
|
||||
<InputError :message="form.error" class="mt-2" />
|
||||
</div>
|
||||
<FieldError v-if="form.error">{{ form.error }}</FieldError>
|
||||
</Field>
|
||||
</template>
|
||||
|
||||
<template #footer>
|
||||
|
||||
@@ -51,6 +51,7 @@ const isRunningInDifferentOrganization = computed(() => {
|
||||
<TimeTrackerStartStop
|
||||
:active="isActive"
|
||||
size="base"
|
||||
variant="secondary"
|
||||
@changed="setActiveState"></TimeTrackerStartStop>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import VChart, { THEME_KEY } from 'vue-echarts';
|
||||
import { provide, computed, inject, type ComputedRef } from 'vue';
|
||||
import { provide, computed, inject, ref, type ComputedRef } from 'vue';
|
||||
import { use } from 'echarts/core';
|
||||
import { useElementSize } from '@vueuse/core';
|
||||
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
|
||||
import { BoltIcon } from '@heroicons/vue/20/solid';
|
||||
import { HeatmapChart } from 'echarts/charts';
|
||||
@@ -12,13 +13,13 @@ import {
|
||||
VisualMapComponent,
|
||||
} from 'echarts/components';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
firstDayIndex,
|
||||
formatDate,
|
||||
formatHumanReadableDuration,
|
||||
getDayJsInstance,
|
||||
} from '@/packages/ui/src/utils/time';
|
||||
import chroma from 'chroma-js';
|
||||
import { useCssVariable } from '@/utils/useCssVariable';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
@@ -62,8 +63,44 @@ const max = computed(() => {
|
||||
});
|
||||
|
||||
const backgroundColor = useCssVariable('--theme-color-card-background');
|
||||
const itemBackgroundColor = useCssVariable('--color-bg-tertiary');
|
||||
const borderColor = useCssVariable('--color-border');
|
||||
const labelColor = useCssVariable('--color-text-secondary');
|
||||
const chartColorRaw = useCssVariable('--theme-color-chart');
|
||||
|
||||
const chartEmptyColorRaw = useCssVariable('--color-bg-tertiary');
|
||||
const chartEmptyColor = computed(() => {
|
||||
if (!chartEmptyColorRaw.value) return '#2a2c32';
|
||||
return chroma(chartEmptyColorRaw.value).hex();
|
||||
});
|
||||
const chartColor = computed(() => {
|
||||
if (!chartColorRaw.value) return '#bae6fd';
|
||||
return `rgb(${chartColorRaw.value})`;
|
||||
});
|
||||
|
||||
// Track chart container size
|
||||
const chartContainer = ref<HTMLElement | null>(null);
|
||||
const { width: containerWidth } = useElementSize(chartContainer);
|
||||
|
||||
// Calculate number of weeks based on available width
|
||||
// Rough estimate: 40px per cell + 80px for labels = ~360px for 7 weeks
|
||||
const numberOfWeeks = computed(() => {
|
||||
const availableWidth = containerWidth.value || 400;
|
||||
const minCellSize = 25; // Minimum cell size in pixels
|
||||
const labelSpace = 80; // Space for day labels
|
||||
const usableWidth = availableWidth - labelSpace;
|
||||
const maxWeeks = Math.floor(usableWidth / minCellSize);
|
||||
// Clamp between 4 and 12 weeks for reasonable display
|
||||
return Math.max(4, Math.min(12, maxWeeks));
|
||||
});
|
||||
|
||||
// Calculate date range based on dynamic number of weeks
|
||||
const dateRange = computed(() => {
|
||||
const today = getDayJsInstance()();
|
||||
const startOfWeek = today.startOf('week');
|
||||
// Go back (numberOfWeeks - 1) weeks from the start of current week
|
||||
const rangeStart = startOfWeek.subtract(numberOfWeeks.value - 1, 'week');
|
||||
return [today.format('YYYY-MM-DD'), rangeStart.format('YYYY-MM-DD')];
|
||||
});
|
||||
|
||||
const option = computed(() => {
|
||||
return {
|
||||
@@ -76,26 +113,30 @@ const option = computed(() => {
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
inRange: {
|
||||
color: [itemBackgroundColor.value, '#2DBE45'],
|
||||
color: [chartEmptyColor.value, chartColor.value],
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
calendar: {
|
||||
top: 40,
|
||||
top: 35,
|
||||
bottom: 20,
|
||||
left: 40,
|
||||
right: 10,
|
||||
cellSize: [40, 40],
|
||||
left: 35,
|
||||
right: 5,
|
||||
cellSize: 'auto',
|
||||
orient: 'horizontal',
|
||||
dayLabel: {
|
||||
firstDay: firstDayIndex.value,
|
||||
color: labelColor.value,
|
||||
fontFamily: 'Inter, sans-serif',
|
||||
},
|
||||
monthLabel: {
|
||||
color: labelColor.value,
|
||||
fontFamily: 'Inter, sans-serif',
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
},
|
||||
range: [
|
||||
dayjs().format('YYYY-MM-DD'),
|
||||
getDayJsInstance()().subtract(50, 'day').startOf('week').format('YYYY-MM-DD'),
|
||||
],
|
||||
range: dateRange.value,
|
||||
itemStyle: {
|
||||
color: 'transparent',
|
||||
borderWidth: 8,
|
||||
@@ -117,7 +158,7 @@ const option = computed(() => {
|
||||
if (dailyHoursTracked?.value) {
|
||||
return (
|
||||
formatDate(
|
||||
dailyHoursTracked?.value[dataIndex].date,
|
||||
dailyHoursTracked?.value[dataIndex]?.date ?? '',
|
||||
organization?.value?.date_format
|
||||
) +
|
||||
': ' +
|
||||
@@ -144,7 +185,7 @@ const option = computed(() => {
|
||||
<div v-if="isLoading" class="flex justify-center items-center h-40">
|
||||
<LoadingSpinner />
|
||||
</div>
|
||||
<div v-else-if="dailyHoursTracked">
|
||||
<div v-else-if="dailyHoursTracked" ref="chartContainer">
|
||||
<v-chart
|
||||
class="chart"
|
||||
:autoresize="true"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<section class="flex flex-col">
|
||||
<section class="flex overflow-hidden flex-col gap-1.5">
|
||||
<CardTitle :title="title" :icon="icon"></CardTitle>
|
||||
<div class="rounded-lg border border-card-border flex-1 flex items-stretch">
|
||||
|
||||
<div
|
||||
class="flex-1 flex items-stretch rounded-lg bg-card-background border border-card-border">
|
||||
<div class="w-full flex flex-col">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,6 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const accentColor = useCssVariable('--theme-color-chart');
|
||||
const markLineColor = useCssVariable('--color-border-secondary');
|
||||
|
||||
const seriesData = computed(() =>
|
||||
props.history.map((el) => {
|
||||
@@ -36,36 +35,11 @@ const option = computed(() => ({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
markLine: {
|
||||
lineStyle: {
|
||||
color: markLineColor.value,
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'transparent', // Set desired color here
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
fontSize: 16,
|
||||
fontWeight: 600,
|
||||
margin: 24,
|
||||
fontFamily: 'Inter, sans-serif',
|
||||
},
|
||||
axisTick: {
|
||||
lineStyle: {
|
||||
color: 'transparent', // Set desired color here
|
||||
},
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: 'transparent', // Set desired color here
|
||||
},
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
|
||||
@@ -14,17 +14,16 @@ defineProps<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-3.5 py-2 flex justify-between @container border-b border-b-background-separator">
|
||||
<div class="px-3.5 py-2 flex justify-between @container">
|
||||
<div class="flex items-center min-w-[70px]">
|
||||
<p class="font-medium text-sm text-text-primary">
|
||||
<p class="text-sm text-text-primary">
|
||||
{{ formatHumanReadableDate(date) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="items-center justify-center flex-1 hidden @2xs:flex">
|
||||
<DayOverviewCardChart :history="history"></DayOverviewCardChart>
|
||||
</div>
|
||||
<div
|
||||
class="flex text-sm items-center justify-center text-text-secondary min-w-[65px] font-medium">
|
||||
<div class="flex text-sm items-center justify-center text-text-secondary min-w-[65px]">
|
||||
{{
|
||||
formatHumanReadableDuration(
|
||||
duration,
|
||||
|
||||
@@ -23,9 +23,9 @@ const { data: last7Days, isLoading } = useQuery({
|
||||
},
|
||||
enabled: computed(() => !!organizationId.value),
|
||||
placeholderData: Array.from({ length: 7 }, (_, i) => ({
|
||||
date: new Date(Date.now() - i * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
||||
date: new Date(Date.now() - i * 24 * 60 * 60 * 1000).toISOString().split('T')[0]!,
|
||||
duration: 0,
|
||||
history: Array(8).fill(0),
|
||||
history: Array(8).fill(0) as number[],
|
||||
})),
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/vue-query';
|
||||
import { computed } from 'vue';
|
||||
import RecentlyTrackedTasksCardEntry from '@/Components/Dashboard/RecentlyTrackedTasksCardEntry.vue';
|
||||
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
|
||||
import { CheckCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import { CheckCircleIcon } from '@heroicons/vue/24/solid';
|
||||
import { PlusCircleIcon } from '@heroicons/vue/24/solid';
|
||||
import { getCurrentMembershipId, getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { api } from '@/packages/api/src';
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import ProjectBadge from '@/packages/ui/src/Project/ProjectBadge.vue';
|
||||
import TimeTrackerStartStop from '@/packages/ui/src/TimeTrackerStartStop.vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import { computed } from 'vue';
|
||||
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getDayJsInstance } from '@/packages/ui/src/utils/time';
|
||||
import type { TimeEntry } from '@/packages/api/src';
|
||||
import { useTasksStore } from '@/utils/useTasks';
|
||||
import { useTasksQuery } from '@/utils/useTasksQuery';
|
||||
import { ChevronRightIcon } from '@heroicons/vue/16/solid';
|
||||
|
||||
const props = defineProps<{
|
||||
timeEntry: TimeEntry;
|
||||
}>();
|
||||
|
||||
const { projects } = storeToRefs(useProjectsStore());
|
||||
const { projects } = useProjectsQuery();
|
||||
|
||||
const project = computed(() => {
|
||||
return projects.value.find((project) => project.id === props.timeEntry.project_id);
|
||||
});
|
||||
|
||||
const { tasks } = storeToRefs(useTasksStore());
|
||||
const { tasks } = useTasksQuery();
|
||||
|
||||
const task = computed(() => {
|
||||
return tasks.value.find((task) => task.id === props.timeEntry.task_id);
|
||||
@@ -45,11 +45,11 @@ async function startTaskTimer() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-3.5 py-2 grid grid-cols-5 border-b border-b-background-separator">
|
||||
<div class="px-3.5 py-2 grid grid-cols-5">
|
||||
<div class="col-span-4">
|
||||
<p class="font-medium text-text-primary text-sm pb-1 truncate">
|
||||
<p class="text-text-secondary text-sm pb-1.5 truncate">
|
||||
<span v-if="timeEntry.description"> {{ timeEntry.description }}</span>
|
||||
<span v-else class="text-text-tertiary">No description</span>
|
||||
<span v-else>No description</span>
|
||||
</p>
|
||||
<ProjectBadge size="base" class="min-w-0 max-w-full" :color="project?.color">
|
||||
<div class="flex items-center lg:space-x-0.5 min-w-0">
|
||||
@@ -65,8 +65,12 @@ async function startTaskTimer() {
|
||||
</div>
|
||||
</ProjectBadge>
|
||||
</div>
|
||||
<div class="flex items-center justify-center">
|
||||
<TimeTrackerStartStop @changed="startTaskTimer"></TimeTrackerStartStop>
|
||||
<div class="flex items-center justify-end pr-1">
|
||||
<TimeTrackerStartStop
|
||||
variant="secondary"
|
||||
size="base"
|
||||
class="w-9 h-9"
|
||||
@changed="startTaskTimer"></TimeTrackerStartStop>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -7,11 +7,11 @@ defineProps<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-4 py-2 2xl:py-3 border-b border-b-background-separator">
|
||||
<div class="px-3.5 py-2 2xl:py-3">
|
||||
<div class="col-span-2">
|
||||
<div class="flex justify-between">
|
||||
<p
|
||||
class="font-semibold text-sm min-w-0 overflow-ellipsis overflow-hidden flex-1 text-text-primary">
|
||||
class="text-xs min-w-0 overflow-ellipsis overflow-hidden flex-1 text-text-secondary">
|
||||
{{ name }}
|
||||
</p>
|
||||
<div v-if="working" class="flex space-x-1.5 items-center justify-end">
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user