Compare commits

..

No commits in common. "master" and "feature/defensive-mutation-constraints" have entirely different histories.

71 changed files with 956 additions and 2428 deletions

4
.gitignore vendored
View File

@ -29,7 +29,3 @@ yarn-error.log
/.zed
/public/sw.js
/public/workbox-*.js
/tests/Browser/console
/tests/Browser/screenshots
/tests/Browser/source
/storage/debugbar/

View File

@ -19,7 +19,6 @@ This application is a Laravel application and its main Laravel ecosystems packag
- tightenco/ziggy (ZIGGY) - v2
- larastan/larastan (LARASTAN) - v3
- laravel/boost (BOOST) - v2
- laravel/dusk (DUSK) - v8
- laravel/mcp (MCP) - v0
- laravel/pail (PAIL) - v1
- laravel/pint (PINT) - v1

View File

@ -30,12 +30,3 @@ Welcome to the Ledgerrz codebase! This file defines the persistent guidelines, a
})
});
```
---
## 3. Advanced Browser Testing & Architectural Guidelines (Laravel Dusk)
* **Dusk Database Locks on SQLite:** Never use the `DatabaseTransactions` trait in Laravel Dusk tests if the project is backed by a SQLite database file. Since Dusk runs in concurrent, separate processes (the CLI runner and the web server), an active uncommitted database transaction in the CLI will hold a SQLite write lock. This causes the web server to fail with `SQLSTATE[HY000]: General error: 5 database is locked`. Instead, dynamically create and clean up models during test execution or use sequential DB seeds.
* **Inertia/Vue SPA Testing:** Browser tests targeting asynchronously rendered Single Page Applications must **always** use explicit `waitForText()` or `waitFor()` selectors before executing assertions. Direct assertions like `assertSee()` are immediate and will fail if the JavaScript has not finished compiling and mounting the DOM.
* **Synchronous Queue for WebSockets:** Running real-time WebSocket / Echo Dusk tests locally requires setting `QUEUE_CONNECTION=sync` and `BROADCAST_CONNECTION=reverb` in your `.env` file. This ensures broadcast jobs execute immediately on the web server rather than buffering in the database (which fails without a running background queue worker).
* **Automatic ID-to-UUID Serialization:** All models carrying a `uuid` column (such as `User`, `Dynamic`, `Ledger`, `Mutation`, and `PredefinedMutation`) must use the `App\Concerns\SerializesIdToUuid` trait. This guarantees that any raw model or relationship array/JSON conversion automatically replaces the integer `id` with the secure `uuid` under the `'id'` key.
* **UUID Controller Inputs:** When the frontend submits relationship parameters (such as `predefined_mutation_id` in requests), it only knows and passes the secure UUID. The receiving backend controller must explicitly resolve this UUID to its internal database integer ID before inserting the record (e.g. `PredefinedMutation::where('uuid', $uuid)->value('id')`), maintaining column type safety and foreign key constraints without exposing integer IDs to the client.

View File

@ -50,7 +50,7 @@ During this session, we successfully built out and verified several core archite
* Created a dynamic user detail page (`dynamics.users.show`) scoped to each dynamic. It displays a participant's role, custom display name, fallback real name, and a clean chronological listing of their 10 most recent mutations (activities) in that dynamic.
8. **Polymorphic System Message placeholders & Dynamic Client-Side Linking**:
* Refactored system log activity messages to use native `<user:userUuid>` placeholders and associated them with polymorphic `subject_id` and `subject_type` objects.
* Refactored system log activity messages to use native `<user:userId>` placeholders and associated them with polymorphic `subject_id` and `subject_type` objects.
* On the client-side, the chat component parses these placeholders into rich, clickable links to User Profiles, and dynamically matches and wraps referenced ledger names into links pointing directly to the ledger show page.
* Added backend-side placeholder resolution inside `ActivityService` for the dashboard, ensuring unread system logs translate cleanly to real names across multiple dynamics.

View File

@ -1,23 +0,0 @@
<?php
namespace App\Concerns;
trait SerializesIdToUuid
{
/**
* Convert the model's attributes to an array.
* Overrides the default model toArray method to replace 'id' with 'uuid'.
*
* @return array<string, mixed>
*/
public function toArray(): array
{
$array = parent::toArray();
if (isset($this->uuid)) {
$array['id'] = $this->uuid;
}
return $array;
}
}

View File

@ -11,7 +11,7 @@ class DashboardController extends Controller
public function index(Request $request, ActivityService $activityService)
{
$user = $request->user();
$unreadDynamics = $activityService->getUnreadEntitiesGrouped($user);
$unreadDynamics = $activityService->getUnreadDynamicsGrouped($user);
return Inertia::render('Dashboard', [
'unreadDynamics' => $unreadDynamics,

View File

@ -3,6 +3,10 @@
namespace App\Http\Controllers;
use App\Http\Requests\UpdateDynamicRequest;
use App\Http\Resources\DynamicResource;
use App\Http\Resources\LedgerResource;
use App\Http\Resources\MessageResource;
use App\Http\Resources\UserResource;
use App\Models\Dynamic;
use App\Services\ActivityService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
@ -19,7 +23,7 @@ class DynamicController extends Controller
public function index(Request $request)
{
return Inertia::render('Dynamics/Index', [
'dynamics' => $request->user()->dynamics()->get(),
'dynamics' => DynamicResource::collection($request->user()->dynamics()->get()),
]);
}
@ -55,10 +59,10 @@ class DynamicController extends Controller
$dynamic->load(['ledgers.media', 'participants', 'chat']);
return Inertia::render('Dynamics/Show', [
'dynamic' => $dynamic,
'ledgers' => $dynamic->ledgers,
'participants' => $dynamic->participants,
'messages' => $dynamic->getOrCreateChat()->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT),
'dynamic' => new DynamicResource($dynamic),
'ledgers' => LedgerResource::collection($dynamic->ledgers),
'participants' => UserResource::collection($dynamic->participants),
'messages' => MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT)),
'can' => [
'update' => $request->user()->can('update', $dynamic),
],
@ -69,7 +73,7 @@ class DynamicController extends Controller
{
$this->authorize('view', $dynamic);
return $dynamic->getOrCreateChat()->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT);
return MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT));
}
/**
@ -80,7 +84,7 @@ class DynamicController extends Controller
$this->authorize('update', $dynamic);
return Inertia::render('Dynamics/Settings', [
'dynamic' => $dynamic,
'dynamic' => new DynamicResource($dynamic),
]);
}

View File

@ -118,7 +118,7 @@ class DynamicInvitationController extends Controller
// Log to Dynamic chat activity log!
$dynamic->chat->messages()->create([
'user_id' => null,
'content' => "<user:{$request->user()->uuid}> joined the Dynamic as a ".strtoupper($invitation->role),
'content' => "<user:{$request->user()->id}> joined the Dynamic as a ".strtoupper($invitation->role),
'subject_id' => $request->user()->id,
'subject_type' => User::class,
]);

View File

@ -3,6 +3,11 @@
namespace App\Http\Controllers;
use App\Http\Requests\StoreLedgerRequest;
use App\Http\Resources\DynamicResource;
use App\Http\Resources\LedgerResource;
use App\Http\Resources\MessageResource;
use App\Http\Resources\MutationResource;
use App\Http\Resources\UserResource;
use App\Models\Dynamic;
use App\Models\Ledger;
use App\Services\ActivityService;
@ -30,7 +35,7 @@ class LedgerController extends Controller
$this->authorize('update', $dynamic);
return Inertia::render('Ledgers/Create', [
'dynamic' => $dynamic,
'dynamic' => new DynamicResource($dynamic),
]);
}
@ -69,7 +74,6 @@ class LedgerController extends Controller
$ledger->load([
'media',
'predefinedMutations',
'mutations' => function ($query) {
$query->latest();
},
@ -79,9 +83,11 @@ class LedgerController extends Controller
]);
return Inertia::render('Ledgers/Show', [
'dynamic' => $dynamic,
'ledger' => $ledger,
'messages' => $dynamic->getOrCreateChat()->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT),
'dynamic' => new DynamicResource($dynamic),
'ledger' => new LedgerResource($ledger),
'mutations' => MutationResource::collection($ledger->mutations),
'participants' => UserResource::collection($dynamic->participants),
'messages' => MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT)),
'can' => [
'update' => $request->user()->can('update', $ledger),
'close' => $request->user()->can('close', $ledger),
@ -93,7 +99,7 @@ class LedgerController extends Controller
{
$this->authorize('view', $ledger);
return $dynamic->getOrCreateChat()->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT);
return MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT));
}
/**
@ -104,8 +110,8 @@ class LedgerController extends Controller
$this->authorize('update', $ledger);
return Inertia::render('Ledgers/Edit', [
'dynamic' => $dynamic,
'ledger' => $ledger,
'dynamic' => new DynamicResource($dynamic),
'ledger' => new LedgerResource($ledger),
]);
}

View File

@ -6,34 +6,47 @@ use App\Events\MessageSent;
use App\Events\MutationCreated;
use App\Events\MutationUpdated;
use App\Http\Requests\StoreMutationRequest;
use App\Http\Resources\MutationResource;
use App\Models\Dynamic;
use App\Models\Ledger;
use App\Models\Mutation;
use App\Notifications\NewActivityNotification;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Notification;
class MutationController extends Controller
{
use AuthorizesRequests;
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreMutationRequest $request, Dynamic $dynamic, Ledger $ledger)
{
$this->authorize('create', [Mutation::class, $ledger]);
// If the user is an owner, default status to 'approved'. Otherwise default to 'pending'.
$status = $request->user()->can('update', $ledger) ? 'approved' : 'pending';
$mutation = DB::transaction(function () use ($request, $ledger, $status) {
$predefinedId = null;
if ($request->filled('predefined_mutation_id')) {
$predefinedId = \App\Models\PredefinedMutation::where('uuid', $request->input('predefined_mutation_id'))->value('id');
}
$mutation = $ledger->mutations()->create([
...$request->except(['media', 'type', 'status', 'predefined_mutation_id']),
'predefined_mutation_id' => $predefinedId,
...$request->except(['media', 'type', 'status']),
'user_id' => $request->user()->id,
'type' => $request->input('type', $request->input('amount') >= 0 ? 'addition' : 'subtraction'),
'status' => $status,
@ -50,6 +63,7 @@ class MutationController extends Controller
}
}
// Only increment score if the status is approved!
if ($status === 'approved') {
$ledger->increment('score', $request->validated('amount'));
}
@ -57,46 +71,40 @@ class MutationController extends Controller
return $mutation;
});
$recipients = $dynamic->participants()->where('users.id', '!=', $request->user()->id)->get();
$message = $status === 'approved'
? "{$request->user()->name} added a new entry: \"{$mutation->description}\"."
: "{$request->user()->name} suggested a new entry: \"{$mutation->description}\".";
if ($recipients->isNotEmpty()) {
Notification::send($recipients, new NewActivityNotification([
'content' => $message,
'url' => route('dynamics.ledgers.show', [$dynamic, $ledger]),
]));
}
// Broadcast the real-time creation event!
broadcast(new MutationCreated($mutation));
return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]);
}
public function show(Request $request, Dynamic $dynamic, Ledger $ledger, Mutation $mutation)
/**
* Display the specified resource.
*/
public function show(Dynamic $dynamic, Ledger $ledger, Mutation $mutation)
{
$this->authorize('view', $mutation);
$mutation->load('user', 'ledger', 'media', 'chat.messages.user');
$dynamic = $mutation->ledger->dynamic;
$dynamic->load('participants');
$user = $request->user();
return inertia('Mutations/Show', [
'mutation' => $mutation,
'dynamic' => $dynamic,
'can' => [
'update' => $user->can('update', $dynamic),
],
]);
return new MutationResource($mutation);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Dynamic $dynamic, Ledger $ledger, Mutation $mutation)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Dynamic $dynamic, Ledger $ledger, Mutation $mutation)
{
$this->authorize('update', $mutation);
$request->validate(['status' => ['required', 'string', 'in:approved,rejected']]);
$request->validate([
'status' => ['required', 'string', 'in:approved,rejected'],
]);
$oldStatus = $mutation->status;
$newStatus = $request->input('status');
@ -104,6 +112,7 @@ class MutationController extends Controller
DB::transaction(function () use ($mutation, $ledger, $oldStatus, $newStatus) {
$mutation->update(['status' => $newStatus]);
// Adjust the ledger score if status transitions to approved or from approved!
if ($oldStatus !== 'approved' && $newStatus === 'approved') {
$ledger->increment('score', $mutation->amount);
} elseif ($oldStatus === 'approved' && $newStatus !== 'approved') {
@ -111,17 +120,37 @@ class MutationController extends Controller
}
});
// Log to Mutation and Dynamic chats
$user = $request->user();
$statusText = strtoupper($newStatus);
// Notify the suggester
$suggester = $mutation->user;
if ($suggester && $suggester->id !== $user->id) {
Notification::send($suggester, new NewActivityNotification([
'content' => "Your suggestion \"{$mutation->description}\" was {$statusText} by {$user->name}.",
'url' => route('dynamics.ledgers.show', [$dynamic, $ledger]),
]));
$mutationMsg = $mutation->chat->messages()->create([
'user_id' => null,
'content' => "Suggestion was {$statusText} by <user:{$user->id}>.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
broadcast(new MessageSent($mutationMsg));
if ($newStatus === 'approved') {
$dynamicMsg = $dynamic->chat->messages()->create([
'user_id' => null,
'content' => "<user:{$user->id}> APPROVED the suggestion \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
} else {
$dynamicMsg = $dynamic->chat->messages()->create([
'user_id' => null,
'content' => "<user:{$user->id}> REJECTED the suggestion \"{$mutation->description}\" on \"{$ledger->name}\" ledger.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
}
broadcast(new MessageSent($dynamicMsg));
// Broadcast the real-time update event!
broadcast(new MutationUpdated($mutation));
return redirect()->back();
}
@ -130,21 +159,16 @@ class MutationController extends Controller
{
$this->authorize('void', $mutation);
DB::transaction(function() use ($mutation, $ledger) {
if ($mutation->status === 'approved') {
$ledger->decrement('score', $mutation->amount);
}
$mutation->update(['status' => 'voided']);
});
$recipients = $dynamic->participants()->where('users.id', '!=', $request->user()->id)->get();
if ($recipients->isNotEmpty()) {
Notification::send($recipients, new NewActivityNotification([
'content' => "{$request->user()->name} voided an entry: \"{$mutation->description}\".",
'url' => route('dynamics.ledgers.show', [$dynamic, $ledger]),
]));
}
return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]);
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Dynamic $dynamic, Ledger $ledger, Mutation $mutation)
{
//
}
}

View File

@ -46,7 +46,7 @@ class ParticipantController extends Controller
return Inertia::render('Dynamics/Participants/Show', [
'dynamic' => $dynamic,
'participant' => [
'id' => $user->uuid,
'id' => $user->id,
'name' => $user->name,
'display_name' => $participant->pivot->display_name,
'role' => $participant->pivot->role,

View File

@ -50,7 +50,7 @@ class HandleInertiaRequests extends Middleware
$service = app(ActivityService::class);
return count($service->getUnreadEntitiesGrouped($request->user()));
return count($service->getUnreadDynamicsGrouped($request->user()));
},
];
}

View File

@ -29,7 +29,6 @@ class StoreMutationRequest extends FormRequest
'description' => ['required', 'string'],
'type' => ['nullable', 'string'],
'status' => ['nullable', 'string'],
'predefined_mutation_id' => ['nullable', 'exists:predefined_mutations,uuid'],
'media' => ['nullable', 'array'],
'media.*' => ['file', 'mimes:jpg,jpeg,png,gif,mp4,mov,avi,webm', 'max:20480'],
];

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class BaseResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$data = parent::toArray($request);
if (isset($data['id']) && isset($this->uuid)) {
$data['id'] = $this->uuid;
}
return $data;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class DynamicResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$result = parent::toArray($request);
if ($this->ledgers) {
$result['ledgers'] = LedgerResource::collection($this->ledgers);
}
if ($this->participants) {
$result['participants'] = ParticipantResource::collection($this->participants);
}
return $result;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class LedgerResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class MessageResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class MutationResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$data = parent::toArray($request);
$data['can'] = [
'update' => $request->user()?->can('update', $this->resource) ?? false,
'void' => $request->user()?->can('void', $this->resource) ?? false,
];
return $data;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class ParticipantResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class PredefinedMutationResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
class UserResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}

View File

@ -9,13 +9,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Support\Str;
use App\Models\Chat;
use App\Concerns\SerializesIdToUuid;
class Dynamic extends Model
{
/** @use HasFactory<DynamicFactory> */
use HasFactory, SerializesIdToUuid;
use HasFactory;
protected $fillable = [
'name',
@ -66,13 +64,4 @@ class Dynamic extends Model
public function getUrlAttribute(): string {
return route('dynamics.show', $this);
}
public function getOrCreateChat(): Chat
{
if ($this->chat) {
return $this->chat;
}
return $this->chat()->create([]);
}
}

View File

@ -9,12 +9,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Support\Str;
use App\Concerns\SerializesIdToUuid;
class Ledger extends Model
{
/** @use HasFactory<LedgerFactory> */
use HasFactory, SerializesIdToUuid;
use HasFactory;
protected $fillable = [
'dynamic_id',

View File

@ -10,12 +10,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Support\Str;
use App\Concerns\SerializesIdToUuid;
class Mutation extends Model
{
/** @use HasFactory<MutationFactory> */
use HasFactory, SerializesIdToUuid;
use HasFactory;
protected $fillable = [
'ledger_id',
@ -70,8 +69,8 @@ class Mutation extends Model
$mutationMsg = $mutation->chat->messages()->create([
'user_id' => null,
'content' => $status === 'approved'
? "Entry was created by <user:{$user->uuid}>."
: "Suggestion was created by <user:{$user->uuid}>.",
? "Entry was created by <user:{$user->id}>."
: "Suggestion was created by <user:{$user->id}>.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
@ -80,60 +79,20 @@ class Mutation extends Model
if ($status === 'approved') {
$dynamicMsg = $dynamic->chat->messages()->create([
'user_id' => null,
'content' => "<user:{$user->uuid}> added entry \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
'content' => "<user:{$user->id}> added entry \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
} else {
$dynamicMsg = $dynamic->chat->messages()->create([
'user_id' => null,
'content' => "<user:{$user->uuid}> suggested \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
'content' => "<user:{$user->id}> suggested \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
}
broadcast(new MessageSent($dynamicMsg));
// Trigger the real-time creation broadcast dynamically
broadcast(new \App\Events\MutationCreated($mutation));
});
static::updated(function (Mutation $mutation) {
if ($mutation->wasChanged('status')) {
$status = $mutation->getAttribute('status');
$user = request()->user();
$ledger = $mutation->ledger;
$mutationMsg = $mutation->chat->messages()->create([
'user_id' => null,
'content' => $status === 'approved'
? "<user:{$user->uuid}> APPROVED the suggestion \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger."
: "<user:{$user->uuid}> DENIED the suggestion \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
$dynamic = $ledger->dynamic;
$dynamic->chat->messages()->create([
'user_id' => null,
'content' => $mutationMsg->content,
'subject_id' => $mutation->id,
'subject_type' => Mutation::class,
]);
broadcast(new \App\Events\MutationUpdated($mutation));
}
});
}
protected $appends = ['can'];
public function getCanAttribute(): array
{
return [
'update' => auth()->user()?->can('update', $this) ?? false,
'void' => auth()->user()?->can('void', $this) ?? false,
];
}
public function getRouteKeyName()

View File

@ -6,11 +6,10 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
use App\Concerns\SerializesIdToUuid;
class PredefinedMutation extends Model
{
use HasFactory, SerializesIdToUuid;
use HasFactory;
protected $fillable = [
'ledger_id',

View File

@ -15,7 +15,6 @@ use Laravel\Fortify\Contracts\PasskeyUser;
use Laravel\Fortify\PasskeyAuthenticatable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use NotificationChannels\WebPush\HasPushSubscriptions;
use App\Concerns\SerializesIdToUuid;
/**
* @property int $id
@ -35,7 +34,7 @@ use App\Concerns\SerializesIdToUuid;
class User extends Authenticatable implements PasskeyUser
{
/** @use HasFactory<UserFactory> */
use HasFactory, HasPushSubscriptions, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable, SerializesIdToUuid;
use HasFactory, HasPushSubscriptions, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
public function dynamics()
{

View File

@ -2,6 +2,8 @@
namespace App\Notifications;
use App\Models\Chat;
use App\Models\Message;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushChannel;
@ -11,33 +13,60 @@ class NewActivityNotification extends Notification
{
use Queueable;
public array $activity;
public $activity;
public function __construct(array $activity)
/**
* Create a new notification instance.
*/
public function __construct($activity)
{
$this->activity = $activity;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return [WebPushChannel::class, 'database'];
return [WebPushChannel::class];
}
/**
* Get the web push representation of the notification.
*/
public function toWebPush(object $notifiable): WebPushMessage
{
return (new WebPushMessage)
$result = (new WebPushMessage)
->title('New Activity')
->icon('/apple-touch-icon.png')
->body($this->activity['content'])
->action('View', 'view')
->data(['url' => $this->activity['url']]);
switch (get_class($this->activity)) {
case Message::class:
/** @var Chat $chat */
$chat = $this->activity->chat;
$result->data(['url' => $chat->subjectUrl]);
break;
}
return $result;
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'content' => $this->activity['content'],
'url' => $this->activity['url'],
//
];
}
}

View File

@ -1,67 +0,0 @@
<?php
namespace App\Policies;
use App\Models\Chat;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class ChatPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return false;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Chat $chat): bool
{
$chatable = $chat->chatable;
return $user->can('view', $chatable);
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return false;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Chat $chat): bool
{
return $this->view($user, $chat);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Chat $chat): bool
{
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Chat $chat): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Chat $chat): bool
{
return false;
}
}

View File

@ -8,14 +8,6 @@ use App\Models\User;
class MutationPolicy
{
/**
* Determine whether the user can view the mutation.
*/
public function view(User $user, Mutation $mutation): bool
{
return $user->can('view', $mutation->ledger);
}
/**
* Determine whether the user can create mutations.
*/

View File

@ -3,7 +3,6 @@
namespace App\Providers;
use Carbon\CarbonImmutable;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
@ -27,13 +26,6 @@ class AppServiceProvider extends ServiceProvider
{
JsonResource::withoutWrapping();
$this->configureDefaults();
Relation::morphMap([
'user' => \App\Models\User::class,
'dynamic' => \App\Models\Dynamic::class,
'ledger' => \App\Models\Ledger::class,
'mutation' => \App\Models\Mutation::class,
]);
}
/**

View File

@ -45,9 +45,8 @@ class ActivityService
return $cursor ? $cursor->read_at : Carbon::parse('1970-01-01');
}
public function createMessage($dynamic, $user, $content, $subject = null)
public function createMessage($chat, $user, $content, $subject = null)
{
$chat = $dynamic->getOrCreateChat();
$message = $chat->messages()->create([
'user_id' => $user ? $user->id : null,
'content' => $content,
@ -93,19 +92,14 @@ class ActivityService
*/
public function getActivitiesForDynamic(Dynamic $dynamic): array
{
$chat = $dynamic->getOrCreateChat();
if (!$chat) {
return [];
}
$participants = $dynamic->participants()->withPivot('display_name')->get();
$participantsMap = $participants->reduce(function ($acc, $p) {
$acc[$p->uuid] = $p->pivot->display_name ?? $p->name;
$acc[$p->id] = $p->pivot->display_name ?? $p->name;
return $acc;
}, []);
$messages = Message::where('chat_id', $chat->id)
$messages = Message::where('chat_id', $dynamic->chat->id)
->with(['user', 'subject'])
->latest()
->get();
@ -115,7 +109,7 @@ class ActivityService
$messageData['url'] = $this->getUrlForMessage($message);
// Resolve <user:id> placeholders to actual names/display names
$messageData['content'] = preg_replace_callback('/<user:([0-9a-f-]+)>/', function ($matches) use ($participantsMap) {
$messageData['content'] = preg_replace_callback('/<user:(\d+)>/', function ($matches) use ($participantsMap) {
$userId = $matches[1];
return $participantsMap[$userId] ?? "User #{$userId}";
@ -128,10 +122,10 @@ class ActivityService
/**
* Get unread activities grouped by active entities (Dynamics, Ledgers) for the given user.
*/
public function getUnreadEntitiesGrouped(User $user): array
public function getUnreadDynamicsGrouped(User $user): array
{
$groupedDynamics = [];
$participatingDynamics = $user->dynamics()->with(['chat', 'ledgers'])->get();
$participatingDynamics = $user->dynamics()->with('ledgers')->get();
foreach ($participatingDynamics as $dynamic) {
$readAt = $this->getCursorReadAt($user, $dynamic);

View File

@ -22,10 +22,8 @@
},
"require-dev": {
"fakerphp/faker": "^1.24",
"fruitcake/laravel-debugbar": "^4.4",
"larastan/larastan": "^3.9",
"laravel/boost": "^2.2",
"laravel/dusk": "^8.6",
"laravel/pail": "^1.2.5",
"laravel/pao": "^1.0.6",
"laravel/pint": "^1.27",

413
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "349232eb2e405a447b06a60c3c01fe4c",
"content-hash": "f4c79dcf0b7f9f54487404715d1085c1",
"packages": [
{
"name": "bacon/bacon-qr-code",
@ -9344,109 +9344,6 @@
],
"time": "2025-08-08T12:00:00+00:00"
},
{
"name": "fruitcake/laravel-debugbar",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/fruitcake/laravel-debugbar.git",
"reference": "80ef956bda9e1a5824037d6f2cd06e73092e5634"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fruitcake/laravel-debugbar/zipball/80ef956bda9e1a5824037d6f2cd06e73092e5634",
"reference": "80ef956bda9e1a5824037d6f2cd06e73092e5634",
"shasum": ""
},
"require": {
"illuminate/routing": "^11|^12|^13.0",
"illuminate/session": "^11|^12|^13.0",
"illuminate/support": "^11|^12|^13.0",
"php": "^8.2",
"php-debugbar/php-debugbar": "^3.8.0",
"php-debugbar/symfony-bridge": "^1.1"
},
"replace": {
"barryvdh/laravel-debugbar": "self.version"
},
"require-dev": {
"larastan/larastan": "^3",
"laravel/ai": "^0.8",
"laravel/octane": "^2",
"laravel/pennant": "^1",
"laravel/pint": "^1",
"laravel/telescope": "^5.16",
"livewire/livewire": "^3.7|^4",
"mockery/mockery": "^1.3.3",
"orchestra/testbench-dusk": "^9|^10|^11",
"php-debugbar/twig-bridge": "^2.0",
"phpstan/phpstan-phpunit": "^2",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11",
"shipmonk/phpstan-rules": "^4.3"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Debugbar": "Fruitcake\\LaravelDebugbar\\Facades\\Debugbar"
},
"providers": [
"Fruitcake\\LaravelDebugbar\\ServiceProvider"
]
},
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Fruitcake\\LaravelDebugbar\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fruitcake",
"homepage": "https://fruitcake.nl"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "PHP Debugbar integration for Laravel",
"keywords": [
"barryvdh",
"debug",
"debugbar",
"dev",
"laravel",
"profiler",
"webprofiler"
],
"support": {
"issues": "https://github.com/fruitcake/laravel-debugbar/issues",
"source": "https://github.com/fruitcake/laravel-debugbar/tree/v4.4.0"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2026-07-04T08:30:57+00:00"
},
{
"name": "hamcrest/hamcrest-php",
"version": "v2.1.1",
@ -9817,80 +9714,6 @@
},
"time": "2026-06-09T10:21:08+00:00"
},
{
"name": "laravel/dusk",
"version": "v8.6.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/dusk.git",
"reference": "e7fd48762c6a82ad2cd311db07587aa2a97ce143"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/dusk/zipball/e7fd48762c6a82ad2cd311db07587aa2a97ce143",
"reference": "e7fd48762c6a82ad2cd311db07587aa2a97ce143",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-zip": "*",
"guzzlehttp/guzzle": "^7.5",
"illuminate/console": "^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^10.0|^11.0|^12.0|^13.0",
"php": "^8.1",
"php-webdriver/webdriver": "^1.15.2",
"symfony/console": "^6.2|^7.0|^8.0",
"symfony/finder": "^6.2|^7.0|^8.0",
"symfony/process": "^6.2|^7.0|^8.0",
"vlucas/phpdotenv": "^5.2"
},
"require-dev": {
"laravel/framework": "^10.0|^11.0|^12.0|^13.0",
"mockery/mockery": "^1.6",
"orchestra/testbench-core": "^8.19|^9.17|^10.8|^11.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.1|^11.0|^12.0.1",
"psy/psysh": "^0.11.12|^0.12",
"symfony/yaml": "^6.2|^7.0|^8.0"
},
"suggest": {
"ext-pcntl": "Used to gracefully terminate Dusk when tests are running."
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Dusk\\DuskServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Dusk\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel Dusk provides simple end-to-end testing and browser automation.",
"keywords": [
"laravel",
"testing",
"webdriver"
],
"support": {
"issues": "https://github.com/laravel/dusk/issues",
"source": "https://github.com/laravel/dusk/tree/v8.6.0"
},
"time": "2026-04-15T14:50:40+00:00"
},
{
"name": "laravel/mcp",
"version": "v0.8.1",
@ -11144,240 +10967,6 @@
},
"time": "2022-02-21T01:04:05+00:00"
},
{
"name": "php-debugbar/php-debugbar",
"version": "v3.8.0",
"source": {
"type": "git",
"url": "https://github.com/php-debugbar/php-debugbar.git",
"reference": "18ced90d4b882ed449b2278fea8692f8f7d1c13c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/18ced90d4b882ed449b2278fea8692f8f7d1c13c",
"reference": "18ced90d4b882ed449b2278fea8692f8f7d1c13c",
"shasum": ""
},
"require": {
"php": "^8.2",
"psr/log": "^1|^2|^3",
"symfony/var-dumper": "^5.4|^6|^7|^8"
},
"replace": {
"maximebf/debugbar": "self.version"
},
"require-dev": {
"dbrekelmans/bdi": "^1.4",
"friendsofphp/php-cs-fixer": "^3.92",
"monolog/monolog": "^3.9",
"php-debugbar/doctrine-bridge": "^3@dev",
"php-debugbar/monolog-bridge": "^1@dev",
"php-debugbar/symfony-bridge": "^1@dev",
"php-debugbar/twig-bridge": "^2@dev",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^10",
"predis/predis": "^3.3",
"shipmonk/phpstan-rules": "^4.3",
"symfony/browser-kit": "^6.4|7.0",
"symfony/dom-crawler": "^6.4|^7",
"symfony/event-dispatcher": "^5.4|^6.4|^7.3|^8.0",
"symfony/http-foundation": "^5.4|^6.4|^7.3|^8.0",
"symfony/mailer": "^5.4|^6.4|^7.3|^8.0",
"symfony/panther": "^1|^2.1",
"twig/twig": "^3.11.2"
},
"suggest": {
"php-debugbar/doctrine-bridge": "To integrate Doctrine with php-debugbar.",
"php-debugbar/monolog-bridge": "To integrate Monolog with php-debugbar.",
"php-debugbar/symfony-bridge": "To integrate Symfony with php-debugbar.",
"php-debugbar/twig-bridge": "To integrate Twig with php-debugbar."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.8-dev"
}
},
"autoload": {
"psr-4": {
"DebugBar\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Debug bar in the browser for php application",
"homepage": "https://github.com/php-debugbar/php-debugbar",
"keywords": [
"debug",
"debug bar",
"debugbar",
"dev",
"profiler",
"toolbar"
],
"support": {
"issues": "https://github.com/php-debugbar/php-debugbar/issues",
"source": "https://github.com/php-debugbar/php-debugbar/tree/v3.8.0"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2026-07-02T12:38:20+00:00"
},
{
"name": "php-debugbar/symfony-bridge",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-debugbar/symfony-bridge.git",
"reference": "e37d2debe5d316408b00d0ab2688d9c2cf59b5ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-debugbar/symfony-bridge/zipball/e37d2debe5d316408b00d0ab2688d9c2cf59b5ad",
"reference": "e37d2debe5d316408b00d0ab2688d9c2cf59b5ad",
"shasum": ""
},
"require": {
"php": "^8.2",
"php-debugbar/php-debugbar": "^3.1",
"symfony/http-foundation": "^5.4|^6.4|^7.3|^8.0"
},
"require-dev": {
"dbrekelmans/bdi": "^1.4",
"phpunit/phpunit": "^10",
"symfony/browser-kit": "^6|^7",
"symfony/dom-crawler": "^6|^7",
"symfony/mailer": "^5.4|^6.4|^7.3|^8.0",
"symfony/panther": "^1|^2.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"DebugBar\\Bridge\\Symfony\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Symfony bridge for PHP Debugbar",
"homepage": "https://github.com/php-debugbar/php-debugbar",
"keywords": [
"debugbar",
"dev",
"symfony"
],
"support": {
"issues": "https://github.com/php-debugbar/symfony-bridge/issues",
"source": "https://github.com/php-debugbar/symfony-bridge/tree/v1.1.0"
},
"time": "2026-01-15T14:47:34+00:00"
},
{
"name": "php-webdriver/webdriver",
"version": "1.16.0",
"source": {
"type": "git",
"url": "https://github.com/php-webdriver/php-webdriver.git",
"reference": "ac0662863aa120b4f645869f584013e4c4dba46a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/ac0662863aa120b4f645869f584013e4c4dba46a",
"reference": "ac0662863aa120b4f645869f584013e4c4dba46a",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-zip": "*",
"php": "^7.3 || ^8.0",
"symfony/polyfill-mbstring": "^1.12",
"symfony/process": "^5.0 || ^6.0 || ^7.0 || ^8.0"
},
"replace": {
"facebook/webdriver": "*"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.20.0",
"ondram/ci-detector": "^4.0",
"php-coveralls/php-coveralls": "^2.4",
"php-mock/php-mock-phpunit": "^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpunit/phpunit": "^9.3",
"squizlabs/php_codesniffer": "^3.5",
"symfony/var-dumper": "^5.0 || ^6.0 || ^7.0 || ^8.0"
},
"suggest": {
"ext-simplexml": "For Firefox profile creation"
},
"type": "library",
"autoload": {
"files": [
"lib/Exception/TimeoutException.php"
],
"psr-4": {
"Facebook\\WebDriver\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.",
"homepage": "https://github.com/php-webdriver/php-webdriver",
"keywords": [
"Chromedriver",
"geckodriver",
"php",
"selenium",
"webdriver"
],
"support": {
"issues": "https://github.com/php-webdriver/php-webdriver/issues",
"source": "https://github.com/php-webdriver/php-webdriver/tree/1.16.0"
},
"time": "2025-12-28T23:57:40+00:00"
},
{
"name": "phpstan/phpstan",
"version": "2.2.2",

View File

@ -13,11 +13,10 @@ return new class extends Migration
{
Schema::create('predefined_mutations', function (Blueprint $table) {
$table->id();
$table->foreignId('dynamic_id')->constrained()->cascadeOnDelete();
$table->foreignId('ledger_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->text('description')->nullable();
$table->integer('amount');
$table->string('type')->default('reward');
$table->timestamps();
});
}

View File

@ -1,30 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('messages', function (Blueprint $table) {
DB::table('messages')->where('subject_type', 'App\\Models\\User')->update(['subject_type' => 'user']);
DB::table('messages')->where('subject_type', 'App\\Models\\Mutation')->update(['subject_type' => 'mutation']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('messages', function (Blueprint $table) {
DB::table('messages')->where('subject_type', 'user')->update(['subject_type' => 'App\\Models\\User']);
DB::table('messages')->where('subject_type', 'mutation')->update(['subject_type' => 'App\\Models\\Mutation']);
});
}
};

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropUnique('users_uuid_unique');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->unique('uuid');
});
}
};

View File

@ -1,41 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('predefined_mutations', function (Blueprint $table) {
// Drop old foreign key constraint first
$table->dropForeign(['dynamic_id']);
// Drop old columns
$table->dropColumn(['dynamic_id', 'type']);
// Add new ledger relationship (nullable to support pre-existing entries gracefully)
$table->foreignId('ledger_id')
->after('id')
->nullable()
->constrained()
->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('predefined_mutations', function (Blueprint $table) {
$table->dropConstrainedForeignId('ledger_id');
$table->foreignId('dynamic_id')->after('id')->constrained()->cascadeOnDelete();
$table->string('type')->default('reward');
});
}
};

View File

@ -1,34 +0,0 @@
<?php
use App\Models\Chat;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Chat::unguard();
\App\Models\Chat::all()->each(function (Chat $chat) {
$newType = match($chat->chatable_type) {
\App\Models\Mutation::class => 'mutation',
\App\Models\Ledger::class => 'ledger',
\App\Models\Dynamic::class => 'dynamic',
default => $chat->chatable_type,
};
$chat->update(['chatable_type' => $newType]);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@ -1,31 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};

View File

@ -1,42 +0,0 @@
<?php
use App\Models\Message;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
\App\Models\Message::all()->each(function (Message $message) {
$msg = $message->content;
$msg = preg_replace_callback('/<user:([0-9]+)>/', function ($matches) {
$userId = $matches[1];
$user = \App\Models\User::find($userId);
if($user){
$userId = $user->uuid;
}
return "<user:$userId>";
}, $msg);
if($msg != $message->content) {
$message->update(['content' => $msg]);
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('uuid_base', function (Blueprint $table) {
//
});
}
};

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
beStrictAboutTestsThatDoNotTestAnything="false"
colors="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<testsuites>
<testsuite name="Browser Test Suite">
<directory suffix="Test.php">./tests/Browser</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -23,7 +23,7 @@
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="BROADCAST_CONNECTION" value="null"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="sqlite" />
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_URL" value=""/>
<env name="MAIL_MAILER" value="array"/>

View File

@ -24,7 +24,7 @@
}
.c-chat__message {
@apply p-4 shadow-sm sm:rounded-lg;
@apply overflow-hidden p-4 shadow-sm sm:rounded-lg;
border: 1px solid var(--border);
&.c-chat__message--system {

View File

@ -2,46 +2,17 @@
import { useForm } from '@inertiajs/vue3';
import { route } from 'ziggy-js';
const props = withDefaults(
defineProps<{
const props = defineProps<{
dynamicId: string;
ledgerId: string;
predefinedMutations?: Array<{
id: string;
name: string;
description: string | null;
amount: number;
}>;
}>(),
{
predefinedMutations: () => [],
}
);
}>();
const form = useForm({
amount: 0,
description: '',
predefined_mutation_id: null as string | null,
media: [] as File[],
});
function selectPredefinedMutation(event: Event) {
const select = event.target as HTMLSelectElement;
const selectedId = select.value;
if (!selectedId) {
form.predefined_mutation_id = null;
form.amount = 0;
form.description = '';
return;
}
const mutation = props.predefinedMutations.find(m => m.id === selectedId);
if (mutation) {
form.predefined_mutation_id = mutation.id;
form.amount = mutation.amount;
form.description = mutation.description || mutation.name;
}
}
function handleMutationFileChange(event: Event) {
const files = (event.target as HTMLInputElement).files;
@ -73,28 +44,6 @@ function submit() {
<div class="c-add-mutation-form">
<h4 class="c-add-mutation-form__title">Add Mutation</h4>
<form @submit.prevent="submit" class="c-add-mutation-form__form">
<!-- Predefined Templates Selection -->
<div v-if="predefinedMutations && predefinedMutations.length > 0" class="c-add-mutation-form__field">
<label for="predefined_mutation" class="c-add-mutation-form__label"
>Apply Predefined Template</label
>
<select
id="predefined_mutation"
class="c-add-mutation-form__select"
@change="selectPredefinedMutation"
>
<option value="">-- Choose a predefined template (optional) --</option>
<option
v-for="item in predefinedMutations"
:key="item.id"
:value="item.id"
>
{{ item.name }} ({{ item.amount >= 0 ? '+' : '' }}{{ item.amount }} points)
</option>
</select>
</div>
<div class="c-add-mutation-form__field">
<label for="amount" class="c-add-mutation-form__label"
>Amount</label
@ -104,7 +53,6 @@ function submit() {
id="amount"
type="number"
class="c-add-mutation-form__input"
data-test="amount-input"
/>
<div
v-if="form.errors.amount"
@ -123,7 +71,6 @@ function submit() {
id="description"
rows="4"
class="c-add-mutation-form__textarea"
data-test="description-input"
></textarea>
<div
v-if="form.errors.description"
@ -173,7 +120,6 @@ function submit() {
type="submit"
:disabled="form.processing"
class="c-add-mutation-form__submit-btn"
data-test="add-mutation-button"
>
Add Mutation
</button>
@ -205,10 +151,6 @@ function submit() {
@apply block text-sm font-medium text-gray-700 dark:text-gray-300;
}
.c-add-mutation-form__select {
@apply mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
}
.c-add-mutation-form__input {
@apply mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
}

View File

@ -1,11 +1,9 @@
<script setup lang="ts">
import { usePage } from '@inertiajs/vue3';
import { useForm, usePage, router } from '@inertiajs/vue3';
import { useEcho, echoIsConfigured, configureEcho } from '@laravel/echo-vue';
import { Paperclip, Info } from '@lucide/vue';
import { ref, computed, watch } from 'vue';
import { route } from 'ziggy-js';
import ChatInput from './chat/ChatInput.vue';
import ChatSystemMessage from './chat/ChatSystemMessage.vue';
import ChatUserMessage from './chat/ChatUserMessage.vue';
const props = withDefaults(
defineProps<{
@ -133,10 +131,30 @@ if (!echoIsConfigured()) {
});
}
const fileInput = ref<HTMLInputElement | null>(null);
const form = useForm({
content: '',
media: [] as File[],
});
useEcho(`chats.${props.chat.id}`, 'MessageSent', (e: any) => {
messages.value.push(e.message);
});
function formatTimestamp(isoString: string): { full: string; time: string } {
const date = new Date(isoString);
return {
full: date.toLocaleString(),
time: date.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
hour12: false,
}),
};
}
const participantsById = computed(() => {
const list = props.participants || [];
@ -149,7 +167,7 @@ const participantsById = computed(() => {
{} as Record<
number,
{
id: string;
id: number;
name: string;
pivot?: { display_name: string | null } | null;
}
@ -157,6 +175,83 @@ const participantsById = computed(() => {
);
});
function parseMessageContent(message: {
content: string;
subject_id?: number | null;
subject_type?: string | null;
subject?: any;
}) {
let content = message.content;
// 1. Replace <user:id> placeholders with links to their dynamic profile
const userRegex = /<user:(\d+)>/g;
content = content.replace(userRegex, (match, userId) => {
const user = participantsById.value[Number(userId)];
if (user) {
const url = route('dynamics.users.show', [props.dynamicId, Number(userId)]);
return `<a href="${url}" class="c-chat__user-link font-semibold text-blue-500 hover:underline">${
user.pivot?.display_name ?? user.name
}</a>`;
}
return `User #${userId}`;
});
// 2. Link subjects if found in the text
if (message.subject_id && message.subject_type) {
if (
message.subject_type === 'App\\Models\\Mutation' ||
message.subject_type === 'App\\Models\\Ledger'
) {
const ledgerId =
message.subject_type === 'App\\Models\\Mutation'
? message.subject?.ledger_id
: message.subject?.id;
const ledgerName =
message.subject_type === 'App\\Models\\Mutation'
? message.subject?.ledger?.name
: message.subject?.name;
if (ledgerId && ledgerName) {
const ledgerUrl = route('dynamics.ledgers.show', [
props.dynamicId,
ledgerId,
]);
const escapedName = ledgerName.replace(
/[-\/\\^$*+?.()|[\]{}]/g,
'\\$&',
);
const nameRegex = new RegExp(`"${escapedName}"`, 'g');
content = content.replace(
nameRegex,
`"<a href="${ledgerUrl}" class="c-chat__subject-link font-semibold text-blue-500 hover:underline">${ledgerName}</a>"`,
);
}
}
}
return content;
}
function handleFileChange(event: Event) {
const files = (event.target as HTMLInputElement).files;
if (files) {
for (let i = 0; i < files.length; i++) {
form.media.push(files[i]);
}
}
}
function removeFile(index: number) {
form.media.splice(index, 1);
}
const currentUser = computed(() => usePage().props.auth?.user);
function isOwnMessage(messageUserId: number | null): boolean {
@ -167,6 +262,19 @@ function isOwnMessage(messageUserId: number | null): boolean {
return currentUser.value && currentUser.value.id === messageUserId;
}
function submit() {
form.post(route('chats.messages.store', props.chat.id), {
preserveScroll: true,
onSuccess: () => {
form.reset();
if (fileInput.value) {
fileInput.value.value = '';
}
},
});
}
// Lightbox Modal state
const activeLightboxUrl = ref<string | null>(null);
const activeLightboxType = ref<'image' | 'video' | null>(null);
@ -206,29 +314,138 @@ function closeLightbox() {
]"
>
<!-- Standard User Chat Message -->
<ChatUserMessage
v-if="message.user"
:message="message"
:participants-by-id="participantsById"
:dynamic-id="dynamicId"
@open-lightbox="openLightbox"
<template v-if="message.user">
<div class="c-chat__message-header">
<span class="c-chat__message-author">{{
message.user.name
}}</span>
<span
class="c-chat__message-time"
:title="formatTimestamp(message.created_at).full"
>
{{ formatTimestamp(message.created_at).time }}
</span>
</div>
<p class="c-chat__message-text" v-html="parseMessageContent(message)"></p>
<!-- Attached Media Display -->
<div
v-if="message.media && message.media.length > 0"
class="c-chat__message-media"
>
<div
v-for="item in message.media"
:key="item.id"
class="c-chat__media-item"
>
<img
v-if="item.mime_type.startsWith('image/')"
:src="item.url"
:alt="item.file_name"
class="c-chat__image cursor-pointer transition-opacity hover:opacity-90"
@click="openLightbox(item.url, item.mime_type)"
/>
<div
v-else-if="item.mime_type.startsWith('video/')"
class="relative cursor-pointer transition-opacity hover:opacity-90"
@click="openLightbox(item.url, item.mime_type)"
>
<video
:src="item.url"
class="c-chat__video"
></video>
<div class="c-chat__play-overlay"></div>
</div>
</div>
</div>
</template>
<!-- Subtle Activity Log System Message -->
<ChatSystemMessage
v-else
:message="message"
:participants-by-id="participantsById"
:dynamic-id="dynamicId"
/>
<template v-else>
<div class="c-chat__system-inner">
<Info class="c-chat__system-icon" />
<span
class="c-chat__system-text"
v-html="parseMessageContent(message)"
></span>
<span
class="c-chat__system-time"
:title="formatTimestamp(message.created_at).full"
>
{{ formatTimestamp(message.created_at).time }}
</span>
</div>
</template>
</div>
<div v-if="messages.length === 0" class="c-chat__empty">
No messages yet.
</div>
</div>
<form @submit.prevent="submit" class="c-chat__form">
<div class="c-chat__form-group">
<label for="content" class="c-chat__label">Message</label>
<textarea
v-model="form.content"
id="content"
rows="3"
class="c-chat__textarea"
placeholder="Type a message... (Press Enter to send, Shift+Enter for newline)"
@keydown.enter.exact.prevent="submit"
></textarea>
<div v-if="form.errors.content" class="c-chat__error">
{{ form.errors.content }}
</div>
<!-- Cohesive Chat input Form -->
<ChatInput :chat-id="chat.id" />
<!-- Attachment Button & Hidden Input -->
<div class="c-chat__attachment-container">
<button
type="button"
@click="fileInput?.click()"
class="c-chat__attach-btn"
>
<Paperclip class="c-chat__attach-icon" />
Attach Photos/Videos
</button>
<input
ref="fileInput"
type="file"
multiple
accept="image/*,video/*"
class="hidden"
@change="handleFileChange"
/>
</div>
<!-- Previews List -->
<div v-if="form.media.length > 0" class="c-chat__preview-list">
<div
v-for="(file, index) in form.media"
:key="index"
class="c-chat__preview-item"
>
<span class="c-chat__preview-name">{{
file.name
}}</span>
<button
type="button"
@click="removeFile(index)"
class="c-chat__preview-remove"
>
</button>
</div>
</div>
</div>
<div class="c-chat__submit-box">
<button
type="submit"
:disabled="form.processing"
class="c-chat__button"
>
Send
</button>
</div>
</form>
<!-- Gorgeous Dark Lightbox Modal -->
<div v-if="activeLightboxUrl" class="c-lightbox" @click="closeLightbox">
@ -250,183 +467,3 @@ function closeLightbox() {
</div>
</div>
</template>
<style scoped>
@reference "../../css/app.css";
.c-chat {
@apply flex flex-col h-[500px];
background-color: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
}
.c-chat__title {
@apply p-4 font-bold border-b text-sm;
border-color: var(--border);
color: var(--foreground);
}
.c-chat__list {
@apply flex-1 overflow-y-auto p-4 space-y-4;
}
.c-chat__load-more {
@apply flex justify-center py-2;
}
.c-chat__load-more-btn {
@apply text-xs font-semibold text-blue-500 hover:underline;
}
.c-chat__message {
@apply max-w-[75%] p-3 rounded-lg flex flex-col gap-1;
}
.c-chat__message--own {
@apply self-end;
background-color: var(--primary);
color: var(--primary-foreground);
border-bottom-right-radius: 0;
.c-chat__message-author {
@apply hidden;
}
.c-chat__message-time {
@apply text-blue-100;
}
.c-chat__message-text {
color: var(--primary-foreground);
}
}
.c-chat__message--other {
@apply self-start;
background-color: var(--muted);
color: var(--muted-foreground);
border-bottom-left-radius: 0;
}
.c-chat__message--system {
@apply self-center max-w-full w-full bg-transparent border-0 p-0 text-center gap-0;
}
.c-chat__message-header {
@apply flex items-baseline gap-2 mb-1;
}
.c-chat__message-author {
@apply font-semibold text-xs;
}
.c-chat__message-time {
@apply text-[10px];
color: var(--muted-foreground);
}
.c-chat__message-text {
@apply text-sm break-words whitespace-pre-wrap leading-relaxed;
}
.c-chat__message-media {
@apply mt-2 flex flex-wrap gap-2;
}
.c-chat__media-item {
@apply max-w-[120px] overflow-hidden rounded border border-black dark:border-gray-600 bg-black;
}
.c-chat__image {
@apply h-auto max-h-[80px] w-full object-cover;
}
.c-chat__video {
@apply h-auto max-h-[80px] w-full;
}
.c-chat__play-overlay {
@apply absolute inset-0 flex items-center justify-center bg-black/40 text-lg font-bold text-white;
}
.c-chat__system-inner {
@apply inline-flex items-center gap-2 bg-neutral-100 dark:bg-neutral-900/30 px-3 py-1 rounded-full text-xs text-neutral-500 dark:text-neutral-400;
}
.c-chat__system-icon {
@apply size-3.5;
}
.c-chat__system-text {
@apply font-medium leading-relaxed;
}
.c-chat__system-time {
@apply text-[10px] opacity-75 ml-1;
}
.c-chat__empty {
@apply text-center text-xs py-8;
color: var(--muted-foreground);
}
.c-chat__form {
@apply p-4 border-t flex flex-col gap-2 bg-neutral-50 dark:bg-neutral-900/10;
border-color: var(--border);
}
.c-chat__form-group {
@apply relative flex flex-col gap-1;
}
.c-chat__label {
@apply sr-only;
}
.c-chat__textarea {
@apply w-full rounded border p-2 text-sm resize-none focus:outline-none focus:ring-1 focus:ring-blue-500 dark:bg-neutral-900 dark:border-neutral-800;
color: var(--foreground);
border-color: var(--border);
}
.c-chat__error {
@apply text-xs text-red-500 mt-1;
}
.c-chat__attachment-container {
@apply flex items-center mt-1;
}
.c-chat__attach-btn {
@apply inline-flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors;
}
.c-chat__attach-icon {
@apply size-3.5;
}
.c-chat__preview-list {
@apply mt-2 flex flex-wrap gap-2;
}
.c-chat__preview-item {
@apply inline-flex items-center gap-2 bg-neutral-100 dark:bg-neutral-900/50 px-2 py-1 rounded text-xs;
}
.c-chat__preview-name {
@apply max-w-[150px] truncate text-neutral-600 dark:text-neutral-400;
}
.c-chat__preview-remove {
@apply text-neutral-400 hover:text-red-500 transition-colors;
}
.c-chat__submit-box {
@apply flex justify-end mt-1;
}
.c-chat__button {
@apply inline-flex items-center justify-center rounded-md border border-transparent bg-gray-800 px-4 py-2 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out hover:bg-gray-700 focus:bg-gray-700 focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-none active:bg-gray-900 dark:bg-gray-200 dark:text-gray-800 dark:hover:bg-white dark:focus:bg-white dark:focus:ring-offset-gray-800 dark:active:bg-gray-300;
}
</style>

View File

@ -19,13 +19,10 @@ const props = defineProps<{
}>();
const processedContent = computed(() => {
return props.message.content.replace(
/<user:([0-9a-f-]+)>/g,
(match, userId) => {
return props.message.content.replace(/<user:(\d+)>/g, (match, userId) => {
// This is a placeholder for a more robust user lookup
return `<a href="${route('users.show', userId)}" class="text-blue-500 hover:underline">@user${userId}</a>`;
},
);
});
});
</script>

View File

@ -1,22 +1,64 @@
<script setup lang="ts">
import { Link } from '@inertiajs/vue3';
import { useForm } from '@inertiajs/vue3';
import { route } from 'ziggy-js';
import Chat from '@/components/Chat.vue';
const props = defineProps<{
dynamicId: string;
ledgerId: string;
ledgerAlignment?: string;
mutations: Array<{
id: string; // Now a UUID
id: number;
user_id: number;
user: { name: string };
amount: number;
description: string;
status: string;
created_at: string;
chat: any;
media?: Array<{ id: number; url: string; mime_type: string }>;
can: {
update: boolean;
void: boolean;
};
}>;
participants?: Array<{
id: number;
name: string;
pivot?: { role: string };
}>;
}>();
const emit = defineEmits<{
(e: 'open-lightbox', url: string, mimeType: string): void;
}>();
function updateStatus(mutationId: number, status: 'approved' | 'rejected') {
useForm({ status }).put(
route('dynamics.ledgers.mutations.update', {
dynamic: props.dynamicId,
ledger: props.ledgerId,
mutation: mutationId,
}),
);
}
function voidMutation(mutationId: number) {
useForm({}).put(
route('dynamics.ledgers.mutations.void', {
dynamic: props.dynamicId,
ledger: props.ledgerId,
mutation: mutationId,
}),
);
}
function isOwnerUser(userId: number): boolean {
const participant = props.participants?.find((p) => p.id === userId);
return participant?.pivot?.role === 'owner';
}
function getAmountClass(amount: number): string {
const alignment = props.ledgerAlignment || 'neutral';
@ -45,15 +87,18 @@ function getAmountClass(amount: number): string {
<li
v-for="mutation in mutations"
:key="mutation.id"
class="c-mutation-list__item"
>
<Link
:href="route('dynamics.ledgers.mutations.show', { dynamic: dynamicId, ledger: ledgerId, mutation: mutation.id })"
class="c-mutation-list__item-link"
>
<div class="c-mutation-list__item-content">
<p class="c-mutation-list__item-desc">
{{ mutation.description }}
</p>
<div class="c-mutation-list__item-header">
<div>
<span class="c-mutation-list__item-author">
{{
isOwnerUser(mutation.user_id)
? 'Added by'
: 'Suggested by'
}}
{{ mutation.user.name }}
</span>
<div class="c-mutation-list__item-meta">
<span
:class="getAmountClass(mutation.amount)"
@ -62,7 +107,9 @@ function getAmountClass(amount: number): string {
{{ mutation.amount > 0 ? '+' : ''
}}{{ mutation.amount }}
</span>
<!-- Only show status badge if mutation was NOT auto-approved by an owner -->
<span
v-if="!isOwnerUser(mutation.user_id)"
:class="{
'c-mutation-list__item-status--pending':
mutation.status === 'pending',
@ -77,7 +124,79 @@ function getAmountClass(amount: number): string {
</span>
</div>
</div>
</Link>
<div class="c-mutation-list__item-time">
{{ new Date(mutation.created_at).toLocaleString() }}
</div>
</div>
<p class="c-mutation-list__item-desc">
{{ mutation.description }}
</p>
<!-- Attached Mutation Proof Media -->
<div
v-if="mutation.media && mutation.media.length > 0"
class="c-mutation-list__media-list"
>
<div
v-for="item in mutation.media"
:key="item.id"
class="c-mutation-list__media-item"
>
<img
v-if="item.mime_type.startsWith('image/')"
:src="item.url"
class="c-mutation-list__media-img"
@click="
emit('open-lightbox', item.url, item.mime_type)
"
/>
<div
v-else-if="item.mime_type.startsWith('video/')"
class="c-mutation-list__media-video-wrapper"
@click="
emit('open-lightbox', item.url, item.mime_type)
"
>
<video
:src="item.url"
class="c-mutation-list__media-video"
></video>
<div class="c-mutation-list__media-video-overlay">
</div>
</div>
</div>
</div>
<!-- Owner Approve/Reject Actions -->
<div
v-if="mutation.can?.update || mutation.can?.void"
class="c-mutation-list__actions"
>
<button
v-if="mutation.can?.update"
@click="updateStatus(mutation.id, 'approved')"
class="c-mutation-list__approve-btn"
>
Approve
</button>
<button
v-if="mutation.can?.update"
@click="updateStatus(mutation.id, 'rejected')"
class="c-mutation-list__reject-btn"
>
Reject
</button>
<button
v-if="mutation.can?.void"
@click="voidMutation(mutation.id)"
class="c-mutation-list__void-btn"
>
Void
</button>
</div>
<Chat :chat="mutation.chat" :dynamic-id="dynamicId" :participants="participants" />
</li>
</ul>
<div v-if="mutations.length === 0" class="c-mutation-list__empty">
@ -98,23 +217,23 @@ function getAmountClass(amount: number): string {
}
.c-mutation-list__list {
@apply mt-4 space-y-2;
@apply mt-4 space-y-4;
}
.c-mutation-list__item-link {
@apply block overflow-hidden bg-white p-4 shadow-sm sm:rounded-lg dark:bg-gray-800 transition-all duration-200 hover:shadow-md hover:bg-gray-50 dark:hover:bg-gray-700;
.c-mutation-list__item {
@apply overflow-hidden bg-white p-4 shadow-sm sm:rounded-lg dark:bg-gray-800;
}
.c-mutation-list__item-content {
@apply flex items-center justify-between;
.c-mutation-list__item-header {
@apply flex items-start justify-between;
}
.c-mutation-list__item-desc {
@apply text-sm text-gray-600 dark:text-gray-400;
.c-mutation-list__item-author {
@apply font-semibold;
}
.c-mutation-list__item-meta {
@apply flex items-center gap-2;
@apply mt-1 flex items-center gap-2;
}
.c-mutation-list__item-amount {
@ -149,6 +268,54 @@ function getAmountClass(amount: number): string {
@apply bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400;
}
.c-mutation-list__item-time {
@apply text-xs text-gray-500;
}
.c-mutation-list__item-desc {
@apply mt-3 text-sm text-gray-600 dark:text-gray-400;
}
.c-mutation-list__media-list {
@apply mt-3 flex flex-wrap gap-2;
}
.c-mutation-list__media-item {
@apply max-w-[200px] overflow-hidden rounded-md border border-neutral-200 bg-black dark:border-neutral-700;
}
.c-mutation-list__media-img {
@apply h-auto max-h-[150px] w-full cursor-pointer object-cover transition-opacity hover:opacity-90;
}
.c-mutation-list__media-video-wrapper {
@apply relative cursor-pointer transition-opacity hover:opacity-90;
}
.c-mutation-list__media-video {
@apply h-auto max-h-[150px] w-full;
}
.c-mutation-list__media-video-overlay {
@apply absolute inset-0 flex items-center justify-center bg-black/40 text-2xl font-bold text-white;
}
.c-mutation-list__actions {
@apply mt-3 flex gap-2 border-t border-neutral-100 pt-3 dark:border-neutral-700;
}
.c-mutation-list__approve-btn {
@apply inline-flex cursor-pointer items-center rounded bg-green-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-green-500;
}
.c-mutation-list__reject-btn {
@apply inline-flex cursor-pointer items-center rounded bg-red-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-500;
}
.c-mutation-list__void-btn {
@apply inline-flex cursor-pointer items-center rounded bg-gray-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gray-500;
}
.c-mutation-list__empty {
@apply mt-4 text-gray-500;
}

View File

@ -1,112 +0,0 @@
<script setup lang="ts">
import { useForm } from '@inertiajs/vue3';
import { Paperclip } from '@lucide/vue';
import { ref } from 'vue';
import { route } from 'ziggy-js';
const props = defineProps<{
chatId: number;
}>();
const fileInput = ref<HTMLInputElement | null>(null);
const form = useForm({
content: '',
media: [] as File[],
});
function handleFileChange(event: Event) {
const files = (event.target as HTMLInputElement).files;
if (files) {
for (let i = 0; i < files.length; i++) {
form.media.push(files[i]);
}
}
}
function removeFile(index: number) {
form.media.splice(index, 1);
}
function submit() {
form.post(route('chats.messages.store', props.chatId), {
preserveScroll: true,
onSuccess: () => {
form.reset();
if (fileInput.value) {
fileInput.value.value = '';
}
},
});
}
</script>
<template>
<form @submit.prevent="submit" class="c-chat__form">
<div class="c-chat__form-group">
<label for="content" class="c-chat__label">Message</label>
<textarea
v-model="form.content"
id="content"
rows="3"
class="c-chat__textarea"
placeholder="Type a message... (Press Enter to send, Shift+Enter for newline)"
@keydown.enter.exact.prevent="submit"
></textarea>
<div v-if="form.errors.content" class="c-chat__error">
{{ form.errors.content }}
</div>
<!-- Attachment Button & Hidden Input -->
<div class="c-chat__attachment-container">
<button
type="button"
@click="fileInput?.click()"
class="c-chat__attach-btn"
>
<Paperclip class="c-chat__attach-icon" />
Attach Photos/Videos
</button>
<input
ref="fileInput"
type="file"
multiple
accept="image/*,video/*"
class="hidden"
@change="handleFileChange"
/>
</div>
<!-- Previews List -->
<div v-if="form.media.length > 0" class="c-chat__preview-list">
<div
v-for="(file, index) in form.media"
:key="index"
class="c-chat__preview-item"
>
<span class="c-chat__preview-name">{{
file.name
}}</span>
<button
type="button"
@click="removeFile(index)"
class="c-chat__preview-remove"
>
</button>
</div>
</div>
</div>
<div class="c-chat__submit-box">
<button
type="submit"
:disabled="form.processing"
class="c-chat__button"
>
Send
</button>
</div>
</form>
</template>

View File

@ -1,108 +0,0 @@
<script setup lang="ts">
import { computed } from 'vue';
import { route } from 'ziggy-js';
import { Info } from '@lucide/vue';
const props = defineProps<{
message: {
id: number;
content: string;
created_at: string;
subject_id?: number | null;
subject_type?: string | null;
subject?: any;
};
participantsById: Record<
number,
{
id: number;
name: string;
pivot?: { display_name: string | null } | null;
}
>;
dynamicId: string;
}>();
function formatTimestamp(isoString: string): { full: string; time: string } {
const date = new Date(isoString);
return {
full: date.toLocaleString(),
time: date.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
hour12: false,
}),
};
}
const parsedContent = computed(() => {
let content = props.message.content;
// 1. Replace <user:id> placeholders with links to their dynamic profile
const userRegex = /<user:([0-9a-f-]+)>/g;
content = content.replace(userRegex, (match, userId) => {
const user = props.participantsById[(userId)];
if (user) {
const url = route('dynamics.users.show', [props.dynamicId, (userId)]);
return `<a href="${url}" class="c-chat__user-link font-semibold text-blue-500 hover:underline">${
user.pivot?.display_name ?? user.name
}</a>`;
}
return `User #${userId}`;
});
// 2. Link subjects if found in the text
if (props.message.subject_id && props.message.subject_type) {
if (
props.message.subject_type === 'mutation' ||
props.message.subject_type === 'ledger'
) {
const ledgerId =
props.message.subject_type === 'mutation'
? props.message.subject?.ledger_id
: props.message.subject?.id;
const ledgerName =
props.message.subject_type === 'mutation'
? props.message.subject?.ledger?.name
: props.message.subject?.name;
if (ledgerId && ledgerName) {
const ledgerUrl = route('dynamics.ledgers.show', [
props.dynamicId,
ledgerId,
]);
const escapedName = ledgerName.replace(
/[-\/\\^$*+?.()|[\]{}]/g,
'\\$&',
);
const nameRegex = new RegExp(`"${escapedName}"`, 'g');
content = content.replace(
nameRegex,
`"<a href="${ledgerUrl}" class="c-chat__subject-link font-semibold text-blue-500 hover:underline">${ledgerName}</a>"`,
);
}
}
}
return content;
});
</script>
<template>
<div class="c-chat__system-inner">
<Info class="c-chat__system-icon" />
<span
class="c-chat__system-text"
v-html="parsedContent"
></span>
<span
class="c-chat__system-time"
:title="formatTimestamp(message.created_at).full"
>
{{ formatTimestamp(message.created_at).time }}
</span>
</div>
</template>

View File

@ -1,151 +0,0 @@
<script setup lang="ts">
import { computed } from 'vue';
import { route } from 'ziggy-js';
const props = defineProps<{
message: {
id: number;
user: { id: number; name: string } | null;
content: string;
created_at: string;
subject_id?: number | null;
subject_type?: string | null;
subject?: any;
media?: Array<{
id: number;
url: string;
file_name: string;
mime_type: string;
}>;
};
participantsById: Record<
number,
{
id: number;
name: string;
pivot?: { display_name: string | null } | null;
}
>;
dynamicId: string;
}>();
const emit = defineEmits<{
(e: 'open-lightbox', url: string, mimeType: string): void;
}>();
function formatTimestamp(isoString: string): { full: string; time: string } {
const date = new Date(isoString);
return {
full: date.toLocaleString(),
time: date.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit',
hour12: false,
}),
};
}
const parsedContent = computed(() => {
let content = props.message.content;
// 1. Replace <user:id> placeholders with links to their dynamic profile
const userRegex = /<user:([0-9a-f-]+)>/g;
content = content.replace(userRegex, (match, userId) => {
const user = props.participantsById[(userId)];
if (user) {
const url = route('dynamics.users.show', [
props.dynamicId,
(userId),
]);
return `<a href="${url}" class="c-chat__user-link font-semibold text-blue-500 hover:underline">${
user.pivot?.display_name ?? user.name
}</a>`;
}
return `User #${userId}`;
});
// 2. Link subjects if found in the text
if (props.message.subject_id && props.message.subject_type) {
if (
props.message.subject_type === 'mutation' ||
props.message.subject_type === 'ledger'
) {
const ledgerId =
props.message.subject_type === 'mutation'
? props.message.subject?.ledger_id
: props.message.subject?.id;
const ledgerName =
props.message.subject_type === 'mutation'
? props.message.subject?.ledger?.name
: props.message.subject?.name;
if (ledgerId && ledgerName) {
const ledgerUrl = route('dynamics.ledgers.show', [
props.dynamicId,
ledgerId,
]);
const escapedName = ledgerName.replace(
/[-\/\\^$*+?.()|[\]{}]/g,
'\\$&',
);
const nameRegex = new RegExp(`"${escapedName}"`, 'g');
content = content.replace(
nameRegex,
`"<a href="${ledgerUrl}" class="c-chat__subject-link font-semibold text-blue-500 hover:underline">${ledgerName}</a>"`,
);
}
}
}
return content;
});
</script>
<template>
<div>
<div class="c-chat__message-header">
<span class="c-chat__message-author">{{ message.user?.name }}</span>
<span
class="c-chat__message-time"
:title="formatTimestamp(message.created_at).full"
>
{{ formatTimestamp(message.created_at).time }}
</span>
</div>
<p class="c-chat__message-text" v-html="parsedContent"></p>
<!-- Attached Media Display -->
<div
v-if="message.media && message.media.length > 0"
class="c-chat__message-media"
>
<div
v-for="item in message.media"
:key="item.id"
class="c-chat__media-item"
>
<img
v-if="item.mime_type.startsWith('image/')"
:src="item.url"
:alt="item.file_name"
class="c-chat__image cursor-pointer transition-opacity hover:opacity-90"
@click="emit('open-lightbox', item.url, item.mime_type)"
/>
<div
v-else-if="item.mime_type.startsWith('video/')"
class="relative cursor-pointer transition-opacity hover:opacity-90"
@click="emit('open-lightbox', item.url, item.mime_type)"
>
<video :src="item.url" class="c-chat__video"></video>
<div class="c-chat__play-overlay"></div>
</div>
</div>
</div>
</div>
</template>

View File

@ -58,9 +58,7 @@ function formatTime(isoString: string): string {
>
<div class="c-dashboard__card-header">
<div class="c-dashboard__entity-meta">
<span
class="c-dashboard__badge-type c-dashboard__badge-type--dynamic"
>
<span class="c-dashboard__badge-type c-dashboard__badge-type--dynamic">
Dynamic
</span>
<span class="c-dashboard__unread-count">
@ -104,7 +102,9 @@ function formatTime(isoString: string): string {
v-if="dynamic.new_activities.length > 0"
class="c-dashboard__divider"
>
<span class="c-dashboard__divider-text">NEW</span>
<span class="c-dashboard__divider-text"
>NEW</span
>
</div>
<!-- New / Unread Activities -->

View File

@ -34,14 +34,12 @@ const props = defineProps<{
id: number;
name: string;
rules: string;
alignment: 'positive' | 'neutral' | 'negative';
};
}>();
const form = useForm({
name: props.ledger.name,
rules: props.ledger.rules,
alignment: props.ledger.alignment,
});
function submit() {
@ -71,25 +69,6 @@ function submit() {
<textarea v-model="form.rules" id="rules" rows="4" class="c-ledger-edit__textarea"></textarea>
</div>
<div class="c-ledger-edit__field">
<label for="alignment" class="c-ledger-edit__label">Alignment</label>
<select
v-model="form.alignment"
id="alignment"
class="c-ledger-edit__select"
>
<option value="positive">
Positive (Higher Score is Better)
</option>
<option value="neutral">
Neutral (Frictionless / Standard)
</option>
<option value="negative">
Negative (Lower Score is Better / Demerits)
</option>
</select>
</div>
<div class="c-ledger-edit__actions">
<button type="submit" :disabled="form.processing" class="c-ledger-edit__submit-btn">
Save
@ -150,18 +129,13 @@ function submit() {
}
.c-ledger-edit__textarea {
@apply mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
}
.c-ledger-edit__select {
@apply mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
@apply mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
}
.c-ledger-edit__actions {
@apply mt-6 flex items-center justify-end gap-4;
@apply flex items-center gap-4;
}
.c-ledger-edit__submit-btn {
@apply inline-flex items-center rounded-md border border-transparent bg-gray-800 px-4 py-2 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out hover:bg-gray-700 focus:bg-gray-700 focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-none active:bg-gray-900 dark:bg-gray-200 dark:text-gray-800 dark:hover:bg-white dark:focus:bg-white dark:focus:ring-offset-gray-800 dark:active:bg-gray-300;
}

View File

@ -45,12 +45,6 @@ const props = defineProps<{
alignment: string;
status: string;
media?: Array<{ id: number; url: string; mime_type: string }>;
predefined_mutations?: Array<{
id: string;
name: string;
description: string | null;
amount: number;
}>;
mutations: Array<{
id: number;
user_id: number;
@ -268,7 +262,7 @@ function isOwnerUser(userId: number): boolean {
</div>
<!-- Add Mutation Form Component -->
<AddMutationForm :dynamic-id="dynamic.id" :ledger-id="ledger.id" :predefined-mutations="ledger.predefined_mutations" />
<AddMutationForm :dynamic-id="dynamic.id" :ledger-id="ledger.id" />
<!-- Mutation List Component -->
<MutationList

View File

@ -1,308 +0,0 @@
<script setup lang="ts">
import Chat from '@/components/Chat.vue';
import { defineOptions } from 'vue';
import { useForm } from '@inertiajs/vue3';
import { route } from 'ziggy-js';
const props = defineProps<{
mutation: {
id: string; // Updated to match serialization
user_id: number;
user: { name: string };
amount: number;
description: string;
status: string;
created_at: string;
chat: any;
media?: Array<{ id: number; url: string; mime_type: string }>;
can: {
update: boolean;
void: boolean;
};
ledger: {
id: string;
name: string;
dynamic_id: string;
alignment?: string;
dynamic: {
id: string;
name: string;
}
}
};
dynamic: {
id: string;
participants: any[];
};
can: {
update: boolean;
};
}>();
const dynamicId = props.dynamic.id;
function updateStatus(mutationId: string, status: 'approved' | 'rejected') {
useForm({ status }).put(
route('dynamics.ledgers.mutations.update', {
dynamic: props.dynamic.id,
ledger: props.mutation.ledger.id,
mutation: mutationId,
}),
);
}
function voidMutation(mutationId: string) {
useForm({}).put(
route('dynamics.ledgers.mutations.void', {
dynamic: props.dynamic.id,
ledger: props.mutation.ledger.id,
mutation: mutationId,
}),
);
}
function isOwnerUser(userId: number): boolean {
const participant = props.dynamic.participants?.find((p) => p.id === userId);
return participant?.pivot?.role === 'owner';
}
function getAmountClass(amount: number): string {
const alignment = props.mutation.ledger.alignment || 'neutral';
if (alignment === 'positive') {
return amount > 0
? 'c-mutation-list__item-amount--positive'
: 'c-mutation-list__item-amount--negative';
}
if (alignment === 'negative') {
return amount < 0
? 'c-mutation-list__item-amount--positive'
: 'c-mutation-list__item-amount--negative';
}
return 'c-mutation-list__item-amount--neutral';
}
defineOptions({
layout: (props: any) => ({
breadcrumbs: [
{ title: 'Dynamics', href: route('dynamics.index') },
{ title: props.mutation.ledger.dynamic.name, href: route('dynamics.show', props.mutation.ledger.dynamic.id) },
{ title: props.mutation.ledger.name, href: route('dynamics.ledgers.show', [props.mutation.ledger.dynamic.id, props.mutation.ledger.id]) },
{ title: 'Mutation Details', href: '' },
]
})
});
</script>
<template>
<div class="c-mutation-list__item">
<div class="c-mutation-list__item-header">
<div>
<span class="c-mutation-list__item-author">
{{
isOwnerUser(mutation.user_id)
? 'Added by'
: 'Suggested by'
}}
{{ mutation.user.name }}
</span>
<div class="c-mutation-list__item-meta">
<span
:class="getAmountClass(mutation.amount)"
class="c-mutation-list__item-amount"
>
{{ mutation.amount > 0 ? '+' : ''
}}{{ mutation.amount }}
</span>
<span
v-if="!isOwnerUser(mutation.user_id)"
:class="{
'c-mutation-list__item-status--pending':
mutation.status === 'pending',
'c-mutation-list__item-status--approved':
mutation.status === 'approved',
'c-mutation-list__item-status--rejected':
mutation.status === 'rejected',
}"
class="c-mutation-list__item-status"
>
{{ mutation.status }}
</span>
</div>
</div>
<div class="c-mutation-list__item-time">
{{ new Date(mutation.created_at).toLocaleString() }}
</div>
</div>
<p class="c-mutation-list__item-desc">
{{ mutation.description }}
</p>
<div
v-if="mutation.media && mutation.media.length > 0"
class="c-mutation-list__media-list"
>
<div
v-for="item in mutation.media"
:key="item.id"
class="c-mutation-list__media-item"
>
<img
v-if="item.mime_type.startsWith('image/')"
:src="item.url"
class="c-mutation-list__media-img"
/>
<div
v-else-if="item.mime_type.startsWith('video/')"
class="c-mutation-list__media-video-wrapper"
>
<video
:src="item.url"
class="c-mutation-list__media-video"
></video>
<div class="c-mutation-list__media-video-overlay">
</div>
</div>
</div>
</div>
<!-- Owner Approve/Reject/Void Actions -->
<div
v-if="mutation.can?.update || mutation.can?.void"
class="c-mutation-list__actions"
>
<button
v-if="mutation.can?.update"
@click="updateStatus(mutation.id, 'approved')"
class="c-mutation-list__approve-btn"
>
Approve
</button>
<button
v-if="mutation.can?.update"
@click="updateStatus(mutation.id, 'rejected')"
class="c-mutation-list__reject-btn"
>
Reject
</button>
<button
v-if="mutation.can?.void"
@click="voidMutation(mutation.id)"
class="c-mutation-list__void-btn"
>
Void
</button>
</div>
<Chat v-if="mutation.chat"
:chat="mutation.chat"
:participants="dynamic.participants"
:dynamic-id="dynamicId"
/>
</div>
</template>
<style scoped>
@reference "../../../css/app.css";
.c-mutation-list__item {
@apply overflow-hidden bg-white p-4 shadow-sm sm:rounded-lg dark:bg-gray-800;
}
.c-mutation-list__item-header {
@apply flex items-start justify-between;
}
.c-mutation-list__item-author {
@apply font-semibold;
}
.c-mutation-list__item-meta {
@apply mt-1 flex items-center gap-2;
}
.c-mutation-list__item-amount {
@apply text-sm font-bold;
}
.c-mutation-list__item-amount--positive {
@apply text-green-500;
}
.c-mutation-list__item-amount--negative {
@apply text-red-500;
}
.c-mutation-list__item-amount--neutral {
@apply text-gray-500 dark:text-gray-400;
}
.c-mutation-list__item-status {
@apply rounded px-1.5 py-0.5 text-[10px] font-medium tracking-wider uppercase;
}
.c-mutation-list__item-status--pending {
@apply bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400;
}
.c-mutation-list__item-status--approved {
@apply bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400;
}
.c-mutation-list__item-status--rejected {
@apply bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400;
}
.c-mutation-list__item-time {
@apply text-xs text-gray-500;
}
.c-mutation-list__item-desc {
@apply mt-3 text-sm text-gray-600 dark:text-gray-400;
}
.c-mutation-list__media-list {
@apply mt-3 flex flex-wrap gap-2;
}
.c-mutation-list__media-item {
@apply max-w-[200px] overflow-hidden rounded-md border border-neutral-200 bg-black dark:border-neutral-700;
}
.c-mutation-list__media-img {
@apply h-auto max-h-[150px] w-full cursor-pointer object-cover transition-opacity hover:opacity-90;
}
.c-mutation-list__media-video-wrapper {
@apply relative cursor-pointer transition-opacity hover:opacity-90;
}
.c-mutation-list__media-video {
@apply h-auto max-h-[150px] w-full;
}
.c-mutation-list__media-video-overlay {
@apply absolute inset-0 flex items-center justify-center bg-black/40 text-2xl font-bold text-white;
}
.c-mutation-list__actions {
@apply mt-3 mb-3 flex gap-2 border-t border-neutral-100 pt-3 dark:border-neutral-700;
}
.c-mutation-list__approve-btn {
@apply inline-flex cursor-pointer items-center rounded bg-green-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-green-500;
}
.c-mutation-list__reject-btn {
@apply inline-flex cursor-pointer items-center rounded bg-red-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-500;
}
.c-mutation-list__void-btn {
@apply inline-flex cursor-pointer items-center rounded bg-gray-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gray-500;
}
</style>

View File

@ -8,5 +8,5 @@ Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
});
Broadcast::channel('chats.{chat}', function ($user, Chat $chat) {
return $user?->can('view', $chat);
return $user->can('view', $chat->chatable);
});

View File

@ -0,0 +1,38 @@
<?php
namespace Tests\Browser;
use App\Models\User;
use Laravel\Dusk\Browser;
test('user can register, log in, and log out', function () {
$this->browse(function (Browser $browser) {
// 1. Test Registration
$browser->visit('/register')
->waitForText('Create an account')
->type('name', 'New Browser User')
->type('email', 'newbrowseruser@example.com')
->type('password', 'password')
->type('password_confirmation', 'password')
->press('Create account')
->waitForLocation('/dashboard')
->assertPathIs('/dashboard')
->assertSee('New Browser User');
// 2. Test Logout
// Open the user menu (trigger button shows initials or user name)
$browser->click('button[aria-haspopup="menu"]')
->waitForText('Log out')
->clickLink('Log out')
->waitForLocation('/login') // Fortify logs out and redirects to login or home
->assertPathIs('/login');
// 3. Test Login
$browser->type('email', 'newbrowseruser@example.com')
->type('password', 'password')
->press('Log in')
->waitForLocation('/dashboard')
->assertPathIs('/dashboard')
->assertSee('New Browser User');
});
});

View File

@ -0,0 +1,82 @@
<?php
namespace Tests\Browser;
use App\Models\Dynamic;
use App\Models\Ledger;
use App\Models\Mutation;
use App\Models\User;
use Laravel\Dusk\Browser;
test('access control and actions are enforced for owners and participants', function () {
// Create database state
$owner = User::factory()->create([
'name' => 'Owner Alice',
'email' => 'alice-owner@example.com',
'password' => bcrypt('password'),
]);
$participant = User::factory()->create([
'name' => 'Participant Bob',
'email' => 'bob-sub@example.com',
'password' => bcrypt('password'),
]);
$outsider = User::factory()->create([
'name' => 'Outsider Charlie',
'email' => 'charlie-outsider@example.com',
'password' => bcrypt('password'),
]);
$dynamic = Dynamic::create([
'name' => 'Private Club',
'rules' => 'Strict access control.',
]);
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
$ledger = Ledger::create([
'dynamic_id' => $dynamic->id,
'name' => 'Rules Compliance',
'rules' => 'Score rules.',
'score' => 100,
'alignment' => 'neutral',
]);
$this->browse(function (Browser $sessionOwner, Browser $sessionParticipant, Browser $sessionOutsider) use ($dynamic, $ledger, $owner, $participant, $outsider) {
// 1. Test Outsider trying to access dynamic they DO NOT belong to (should be forbidden / 403)
$sessionOutsider->loginAs($outsider)
->visit(route('dynamics.show', $dynamic))
->assertSee('403') // Laravel / Inertia forbidden page
->assertDontSee('Private Club');
// 2. Test Participant accessing dynamic they DO belong to (should be allowed)
$sessionParticipant->loginAs($participant)
->visit(route('dynamics.show', $dynamic))
->waitForText('Private Club')
->assertSee('Private Club')
->assertSee('Participant Bob');
// 3. Test Participant adding a mutation suggestion
$sessionParticipant->visit(route('dynamics.ledgers.show', [$dynamic, $ledger]))
->waitForText('Add Mutation')
->type('amount', '20')
->type('description', 'Cleaned the main room')
->press('Add Mutation')
->waitForText('PENDING')
->assertSee('PENDING') // Mutation should show up as pending
->assertDontSee('Approve'); // Standard participant should NOT see approve button!
// 4. Test Owner logging in, seeing the pending suggestion, and approving it!
$sessionOwner->loginAs($owner)
->visit(route('dynamics.ledgers.show', [$dynamic, $ledger]))
->waitForText('Cleaned the main room')
->assertSee('PENDING')
->assertSee('Approve') // Owner should see the Approve button!
->press('Approve')
->waitForText('Score: 120') // Score updated from 100 to 120 after approval!
->assertDontSee('PENDING'); // No longer pending!
});
});

View File

@ -1,138 +0,0 @@
<?php
namespace Tests\Browser;
use App\Models\Dynamic;
use App\Models\Ledger;
use App\Models\User;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class BasicViewsTest extends DuskTestCase
{
/**
* Test that guests can visit the welcome page.
*/
public function test_guests_can_visit_the_welcome_page(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->waitForText("Let's get started")
->assertSee("Let's get started");
});
}
/**
* Test that authenticated users can visit the dynamics index and see their dynamics.
*/
public function test_authenticated_users_can_visit_the_dynamics_index(): void
{
$user = User::factory()->create();
$dynamic = Dynamic::factory()->create([
'name' => 'Dusk Automated Dynamic Index Test',
]);
$dynamic->participants()->attach($user->id, ['role' => 'owner']);
$this->browse(function (Browser $browser) use ($user, $dynamic) {
$browser->loginAs($user)
->visit('/dynamics')
->waitForText('Your Dynamics')
->assertSee('Your Dynamics')
->assertSee($dynamic->name);
});
// Clean up
$dynamic->participants()->detach();
$dynamic->delete();
$user->delete();
}
/**
* Test that authenticated users can visit a dynamic show page.
*/
public function test_authenticated_users_can_visit_a_dynamic_show_page(): void
{
$user = User::factory()->create();
$dynamic = Dynamic::factory()->create([
'name' => 'Dusk Dynamic Show Test',
'rules' => 'Rule 1: Always obey the automation.',
]);
$dynamic->participants()->attach($user->id, ['role' => 'owner']);
$this->browse(function (Browser $browser) use ($user, $dynamic) {
$browser->loginAs($user)
->visit('/dynamics/' . $dynamic->uuid)
->waitForText($dynamic->name)
->assertSee($dynamic->name)
->assertSee($dynamic->rules);
});
// Clean up
$dynamic->participants()->detach();
$dynamic->delete();
$user->delete();
}
/**
* Test that authenticated users can visit a ledger show page.
*/
public function test_authenticated_users_can_visit_a_ledger_show_page(): void
{
$user = User::factory()->create();
$dynamic = Dynamic::factory()->create([
'name' => 'Dusk Dynamic Ledger Show Test',
]);
$dynamic->participants()->attach($user->id, ['role' => 'owner']);
$ledger = Ledger::factory()->create([
'dynamic_id' => $dynamic->id,
'name' => 'Dusk Ledger Test',
'score' => 42,
'rules' => 'Scores are tracked for Dusk automated verification.',
]);
$this->browse(function (Browser $browser) use ($user, $dynamic, $ledger) {
$browser->loginAs($user)
->visit('/dynamics/' . $dynamic->uuid . '/ledgers/' . $ledger->uuid)
->waitForText($ledger->name)
->assertSee($ledger->name)
->assertSee('Score: 42')
->assertSee($ledger->rules);
});
// Clean up
$ledger->delete();
$dynamic->participants()->detach();
$dynamic->delete();
$user->delete();
}
/**
* Test that authenticated users can visit a participant profile page.
*/
public function test_authenticated_users_can_visit_a_participant_profile_page(): void
{
$user = User::factory()->create();
$dynamic = Dynamic::factory()->create([
'name' => 'Dusk Participant Profile Test',
]);
$dynamic->participants()->attach($user->id, ['role' => 'owner', 'display_name' => 'The Master']);
$otherUser = User::factory()->create();
$dynamic->participants()->attach($otherUser->id, ['role' => 'participant', 'display_name' => 'Bitch Bob']);
$this->browse(function (Browser $browser) use ($user, $dynamic, $otherUser) {
$browser->loginAs($user)
->visit('/dynamics/' . $dynamic->uuid . '/users/' . $otherUser->uuid)
->waitForText('Bitch Bob')
->assertSee('Bitch Bob')
->assertSee('participant');
});
// Clean up
$dynamic->participants()->detach();
$dynamic->delete();
$user->delete();
$otherUser->delete();
}
}

View File

@ -1,19 +0,0 @@
<?php
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use App\Models\User;
class DashboardTest extends DuskTestCase
{
public function test_authenticated_users_can_visit_the_dashboard(): void
{
$user = User::factory()->create();
$this->browse(function (Browser $browser) use ($user) {
$browser->loginAs($user)
->visit('/dashboard')
->assertSee('Recent Activity');
});
}
}

View File

@ -1,27 +0,0 @@
<?php
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use App\Models\User;
class LoginTest extends DuskTestCase
{
public function test_a_user_can_log_in(): void
{
User::where('email', 'dusk@example.com')->delete();
$user = User::factory()->create([
'email' => 'dusk@example.com',
]);
$this->browse(function (Browser $browser) use ($user) {
$browser->visit('/login')
->waitFor('#email')
->type('email', $user->email)
->type('password', 'wrong-password')
->press('[data-test="login-button"]')
->assertPathIs('/login')
->screenshot('login-error');
});
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class HomePage extends Page
{
/**
* Get the URL for the page.
*/
public function url(): string
{
return '/';
}
/**
* Assert that the browser is on the page.
*/
public function assert(Browser $browser): void
{
//
}
/**
* Get the element shortcuts for the page.
*
* @return array<string, string>
*/
public function elements(): array
{
return [
'@element' => '#selector',
];
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Page as BasePage;
abstract class Page extends BasePage
{
/**
* Get the global element shortcuts for the site.
*
* @return array<string, string>
*/
public static function siteElements(): array
{
return [
'@element' => '#selector',
];
}
}

View File

@ -5,30 +5,23 @@ namespace Tests\Browser;
use App\Models\Dynamic;
use App\Models\User;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class RealtimeChatTest extends DuskTestCase
{
/**
* Test that multiple browser sessions can communicate in real time through websockets.
*/
public function test_multiple_sessions_can_communicate_in_real_time(): void
{
test('multiple sessions can communicate in real time through websockets', function () {
// 1. Create realistic database state
$owner = User::factory()->create([
'name' => 'Owner Alice',
'email' => 'alice-owner-' . uniqid() . '@example.com',
'name' => 'TU Test User',
'email' => 'test-owner@example.com',
'password' => bcrypt('password'),
]);
$participant = User::factory()->create([
'name' => 'Submissive Bob',
'email' => 'bob-participant-' . uniqid() . '@example.com',
'email' => 'test-sub@example.com',
'password' => bcrypt('password'),
]);
$dynamic = Dynamic::create([
'name' => 'The Velvet Realtime Test Sanctuary',
'name' => 'The Test Sanctuary',
'rules' => 'Rules for realtime testing.',
]);
@ -37,50 +30,36 @@ class RealtimeChatTest extends DuskTestCase
// 2. Spawn two separate browser sessions/browsers in parallel
$this->browse(function (Browser $sessionA, Browser $sessionB) use ($dynamic, $owner, $participant) {
try {
// --- SESSION A: Owner ---
$sessionA->loginAs($owner)
->visit('/dynamics/' . $dynamic->uuid)
->waitForText('The Velvet Realtime Test Sanctuary')
->assertSee('Owner Alice');
->visit(route('dynamics.show', $dynamic))
->waitForText('The Test Sanctuary')
->assertSee('TU Test User'); // Verify loaded in as Owner
// --- SESSION B: Participant ---
$sessionB->loginAs($participant)
->visit('/dynamics/' . $dynamic->uuid)
->waitForText('The Velvet Realtime Test Sanctuary')
->assertSee('Submissive Bob');
->visit(route('dynamics.show', $dynamic))
->waitForText('The Test Sanctuary')
->assertSee('Submissive Bob'); // Verify loaded in as Submissive/Participant
// --- REAL-TIME COMMUNICATING ---
// Owner types and sends a message in chat
$sessionA->type('#content', 'Hello Submissive Bob, did you complete your daily chores?')
->click('.c-chat__button')
->waitForText('Hello Submissive Bob, did you complete your daily chores?');
->waitForText('Hello Submissive Bob');
// Since websockets broadcast in real-time, Session B receives it without reloading
$sessionB->waitForText('Hello Submissive Bob, did you complete your daily chores?', 10)
$sessionB->waitForText('Hello Submissive Bob', 5)
->assertSee('Hello Submissive Bob, did you complete your daily chores?');
// Participant replies in real-time
$sessionB->type('#content', 'Yes Master, everything is complete and logged!')
$sessionB->type('#content', 'Yes Master, everything is complete and logged in the ledger!')
->click('.c-chat__button')
->waitForText('Yes Master, everything is complete and logged!');
->waitForText('Yes Master, everything is complete');
// Session A receives the reply in real-time without reloading
$sessionA->waitForText('Yes Master, everything is complete and logged!', 10)
->assertSee('Yes Master, everything is complete and logged!');
} catch (\Exception $e) {
echo "\n=== SESSION A CONSOLE LOGS ===\n";
print_r($sessionA->driver->manage()->getLog('browser'));
echo "\n=== SESSION B CONSOLE LOGS ===\n";
print_r($sessionB->driver->manage()->getLog('browser'));
throw $e;
}
$sessionA->waitForText('Yes Master, everything is complete', 5)
->assertSee('Yes Master, everything is complete and logged in the ledger!');
});
// Clean up
$dynamic->participants()->detach();
$dynamic->delete();
$owner->delete();
$participant->delete();
}
}
});

View File

@ -7,8 +7,6 @@ use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
use Illuminate\Support\Collection;
abstract class DuskTestCase extends BaseTestCase
{
/**
@ -28,13 +26,13 @@ abstract class DuskTestCase extends BaseTestCase
*/
protected function driver(): RemoteWebDriver
{
$options = (new ChromeOptions)->addArguments((new Collection([
$options = (new ChromeOptions)->addArguments(collect([
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
'--disable-gpu',
// '--headless=new',
'--headless=new',
'--no-sandbox',
'--disable-dev-shm-usage',
]))->unless(static::runningInSail(), function (Collection $arguments) {
])->unless(static::runningInSail(), function (collect $arguments) {
return $arguments->push('--disable-smooth-scrolling');
})->all());

View File

@ -99,5 +99,5 @@ test('only the user with the specified email address can accept the link', funct
// Verify system notification is added to Dynamic activity chat
$chatMessages = $dynamic->chat->messages;
expect($chatMessages)->not->toBeEmpty();
expect($chatMessages->last()->content)->toBe("<user:{$invitee->uuid}> joined the Dynamic as a EDITOR");
expect($chatMessages->last()->content)->toBe("<user:{$invitee->id}> joined the Dynamic as a EDITOR");
});

View File

@ -55,25 +55,3 @@ test('non-owners cannot view ledger creation form or store ledgers', function ()
'name' => 'Illegal Ledger',
]);
});
test('owner can edit a ledger', function () {
$owner = User::factory()->create();
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
$this->actingAs($owner);
$response = $this->put(route('dynamics.ledgers.update', [$dynamic->uuid, $ledger->uuid]), [
'name' => 'Updated Ledger Name',
'rules' => 'Updated rules.',
'alignment' => 'negative',
]);
$response->assertRedirect(route('dynamics.ledgers.show', [$dynamic->uuid, $ledger->uuid]));
$ledger->refresh();
expect($ledger->name)->toBe('Updated Ledger Name');
expect($ledger->rules)->toBe('Updated rules.');
expect($ledger->alignment)->toBe('negative');
});

View File

@ -33,12 +33,12 @@ test('owner can create a mutation which is automatically approved and does not s
$mutationChatMessages = $mutation->chat->messages;
expect($mutationChatMessages)->toHaveCount(1);
expect($mutationChatMessages->first()->user_id)->toBeNull();
expect($mutationChatMessages->first()->content)->toBe("Entry was created by <user:{$owner->uuid}>.");
expect($mutationChatMessages->first()->content)->toBe("Entry was created by <user:{$owner->id}>.");
$dynamicChatMessages = $dynamic->chat->messages;
expect($dynamicChatMessages)->toHaveCount(1);
expect($dynamicChatMessages->first()->user_id)->toBeNull();
expect($dynamicChatMessages->first()->content)->toBe("<user:{$owner->uuid}> added entry \"Direct point reward\" for +15 points on \"{$ledger->name}\" ledger.");
expect($dynamicChatMessages->first()->content)->toBe("<user:{$owner->id}> added entry \"Direct point reward\" for +15 points on \"{$ledger->name}\" ledger.");
});
test('non-owner participant creates a suggestion which defaults to pending and says suggested', function () {
@ -71,12 +71,12 @@ test('non-owner participant creates a suggestion which defaults to pending and s
$mutationChatMessages = $mutation->chat->messages;
expect($mutationChatMessages)->toHaveCount(1);
expect($mutationChatMessages->first()->user_id)->toBeNull();
expect($mutationChatMessages->first()->content)->toBe("Suggestion was created by <user:{$participant->uuid}>.");
expect($mutationChatMessages->first()->content)->toBe("Suggestion was created by <user:{$participant->id}>.");
$dynamicChatMessages = $dynamic->chat->messages;
expect($dynamicChatMessages)->toHaveCount(1);
expect($dynamicChatMessages->first()->user_id)->toBeNull();
expect($dynamicChatMessages->first()->content)->toBe("<user:{$participant->uuid}> suggested \"Suggested point reward\" for +10 points on \"{$ledger->name}\" ledger.");
expect($dynamicChatMessages->first()->content)->toBe("<user:{$participant->id}> suggested \"Suggested point reward\" for +10 points on \"{$ledger->name}\" ledger.");
});
test('owner can approve a pending suggestion and it is updated and logged', function () {
@ -115,11 +115,11 @@ test('owner can approve a pending suggestion and it is updated and logged', func
// Note: one from boot created (empty or via seeder, but in our factory it starts with 0 messages if not manually logged,
// actually our model booted hook creates the chat but doesn't log on boot, the update method creates 1 message)
expect($mutationChatMessages->last()->user_id)->toBeNull();
expect($mutationChatMessages->last()->content)->toBe("<user:{$owner->uuid}> APPROVED the suggestion \"Polished dungeon floors\" for +20 points on \"{$ledger->name}\" ledger.");
expect($mutationChatMessages->last()->content)->toBe("Suggestion was APPROVED by <user:{$owner->id}>.");
$dynamicChatMessages = $dynamic->chat->messages;
expect($dynamicChatMessages->last()->user_id)->toBeNull();
expect($dynamicChatMessages->last()->content)->toBe("<user:{$owner->uuid}> APPROVED the suggestion \"Polished dungeon floors\" for +20 points on \"{$ledger->name}\" ledger.");
expect($dynamicChatMessages->last()->content)->toBe("<user:{$owner->id}> APPROVED the suggestion \"Polished dungeon floors\" for +20 points on \"{$ledger->name}\" ledger.");
});
test('creating a mutation with 0 points fails validation', function () {
@ -172,39 +172,3 @@ test('creating a mutation with less than -1000 points fails validation', functio
$response->assertSessionHasErrors(['amount']);
expect(Mutation::where('description', 'Abusive negative point demerit')->exists())->toBeFalse();
});
test('participant can choose and request a predefined mutation', function () {
$owner = User::factory()->create();
$participant = User::factory()->create();
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id, 'score' => 100]);
$predefined = \App\Models\PredefinedMutation::create([
'ledger_id' => $ledger->id,
'name' => 'Wash the Motorbunny',
'amount' => 50,
'description' => 'Must be fully cleaned and dried.',
]);
$this->actingAs($participant);
$response = $this->post(route('dynamics.ledgers.mutations.store', [$dynamic, $ledger]), [
'amount' => 50,
'description' => 'Completed Wash the Motorbunny template chore.',
'predefined_mutation_id' => $predefined->uuid,
]);
$response->assertRedirect(route('dynamics.ledgers.show', [$dynamic, $ledger]));
$mutation = Mutation::firstWhere('description', 'Completed Wash the Motorbunny template chore.');
expect($mutation)->not->toBeNull();
expect($mutation->status)->toBe('pending');
expect($mutation->predefined_mutation_id)->toBe($predefined->id);
// Score should NOT be updated since it is pending!
$ledger->refresh();
expect($ledger->score)->toBe(100);
});

View File

@ -1,110 +0,0 @@
<?php
namespace Tests\Feature;
use App\Models\Dynamic;
use App\Models\Ledger;
use App\Models\Mutation;
use App\Models\User;
use App\Notifications\NewActivityNotification;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class NotificationDispatchTest extends TestCase
{
use RefreshDatabase;
public function test_notification_is_sent_on_mutation_suggestion()
{
Notification::fake();
$owner = User::factory()->create();
$participant = User::factory()->create();
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
$this->actingAs($participant)
->post(route('dynamics.ledgers.mutations.store', [$dynamic, $ledger]), [
'description' => 'A test suggestion',
'amount' => 10,
]);
Notification::assertSentTo($owner, NewActivityNotification::class);
Notification::assertNotSentTo($participant, NewActivityNotification::class);
}
public function test_notification_is_sent_on_mutation_approval()
{
Notification::fake();
$owner = User::factory()->create();
$participant = User::factory()->create();
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
$mutation = Mutation::factory()->create([
'ledger_id' => $ledger->id,
'user_id' => $participant->id,
'status' => 'pending',
]);
$this->actingAs($owner)
->put(route('dynamics.ledgers.mutations.update', [$dynamic, $ledger, $mutation]), [
'status' => 'approved',
]);
Notification::assertSentTo($participant, NewActivityNotification::class);
Notification::assertNotSentTo($owner, NewActivityNotification::class);
}
public function test_notification_is_sent_on_mutation_void()
{
Notification::fake();
$owner = User::factory()->create();
$participant = User::factory()->create();
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
$mutation = Mutation::factory()->create([
'ledger_id' => $ledger->id,
'user_id' => $participant->id,
'status' => 'approved',
]);
$this->actingAs($owner)
->put(route('dynamics.ledgers.mutations.void', [$dynamic, $ledger, $mutation]));
Notification::assertSentTo($participant, NewActivityNotification::class);
Notification::assertNotSentTo($owner, NewActivityNotification::class);
}
public function test_notification_is_sent_to_other_participants_when_owner_adds_mutation()
{
Notification::fake();
$owner = User::factory()->create();
$participant1 = User::factory()->create();
$participant2 = User::factory()->create();
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
$dynamic->participants()->attach($participant1->id, ['role' => 'participant']);
$dynamic->participants()->attach($participant2->id, ['role' => 'participant']);
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
$this->actingAs($owner)
->post(route('dynamics.ledgers.mutations.store', [$dynamic, $ledger]), [
'description' => 'A test mutation from owner',
'amount' => 25,
]);
Notification::assertSentTo($participant1, NewActivityNotification::class);
Notification::assertSentTo($participant2, NewActivityNotification::class);
Notification::assertNotSentTo($owner, NewActivityNotification::class);
}
}

View File

@ -21,7 +21,7 @@ test('authenticated participant can view another participant detail page in dyna
$response->assertInertia(fn ($page) => $page
->component('Dynamics/Participants/Show')
->has('dynamic')
->where('participant.id', $participant->uuid)
->where('participant.id', $participant->id)
->where('participant.name', $participant->name)
->where('participant.display_name', null)
->where('participant.role', 'participant')

View File

@ -25,8 +25,8 @@ test('owner can view predefined mutations for ledger', function () {
$response->assertOk();
$response->assertInertia(fn ($page) => $page
->component('Ledgers/PredefinedMutations/Index')
->where('dynamic.id', $dynamic->uuid)
->where('ledger.id', $ledger->uuid)
->where('dynamic.id', $dynamic->id)
->where('ledger.id', $ledger->id)
->has('predefined_mutations', 1)
->where('predefined_mutations.0.name', 'Weekly Room Cleaning')
);
@ -112,7 +112,7 @@ test('owner can view edit form for predefined mutation', function () {
$response->assertOk();
$response->assertInertia(fn ($page) => $page
->component('Ledgers/PredefinedMutations/Edit')
->where('predefined_mutation.id', $predefined->uuid)
->where('predefined_mutation.id', $predefined->id)
);
});

View File

@ -1,9 +1,5 @@
<?php
pest()->extend(Tests\DuskTestCase::class)
// ->use(Illuminate\Foundation\Testing\DatabaseMigrations::class)
->in('Browser');
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;