Compare commits
2 Commits
d751cd4fdd
...
a35b50bec6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a35b50bec6 | ||
|
|
1e33bfb50b |
3
.gitignore
vendored
3
.gitignore
vendored
@ -29,3 +29,6 @@ yarn-error.log
|
|||||||
/.zed
|
/.zed
|
||||||
/public/sw.js
|
/public/sw.js
|
||||||
/public/workbox-*.js
|
/public/workbox-*.js
|
||||||
|
/tests/Browser/console
|
||||||
|
/tests/Browser/screenshots
|
||||||
|
/tests/Browser/source
|
||||||
@ -19,6 +19,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
|
|||||||
- tightenco/ziggy (ZIGGY) - v2
|
- tightenco/ziggy (ZIGGY) - v2
|
||||||
- larastan/larastan (LARASTAN) - v3
|
- larastan/larastan (LARASTAN) - v3
|
||||||
- laravel/boost (BOOST) - v2
|
- laravel/boost (BOOST) - v2
|
||||||
|
- laravel/dusk (DUSK) - v8
|
||||||
- laravel/mcp (MCP) - v0
|
- laravel/mcp (MCP) - v0
|
||||||
- laravel/pail (PAIL) - v1
|
- laravel/pail (PAIL) - v1
|
||||||
- laravel/pint (PINT) - v1
|
- laravel/pint (PINT) - v1
|
||||||
|
|||||||
@ -11,10 +11,10 @@ class DashboardController extends Controller
|
|||||||
public function index(Request $request, ActivityService $activityService)
|
public function index(Request $request, ActivityService $activityService)
|
||||||
{
|
{
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
$unreadDynamics = $activityService->getUnreadDynamicsGrouped($user);
|
$unreadEntities = $activityService->getUnreadEntitiesGrouped($user);
|
||||||
|
|
||||||
return Inertia::render('Dashboard', [
|
return Inertia::render('Dashboard', [
|
||||||
'unreadDynamics' => $unreadDynamics,
|
'unreadEntities' => $unreadEntities,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,9 +85,7 @@ class LedgerController extends Controller
|
|||||||
return Inertia::render('Ledgers/Show', [
|
return Inertia::render('Ledgers/Show', [
|
||||||
'dynamic' => new DynamicResource($dynamic),
|
'dynamic' => new DynamicResource($dynamic),
|
||||||
'ledger' => new LedgerResource($ledger),
|
'ledger' => new LedgerResource($ledger),
|
||||||
'mutations' => MutationResource::collection($ledger->mutations),
|
'messages' => MessageResource::collection($dynamic->getOrCreateChat()->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT)),
|
||||||
'participants' => UserResource::collection($dynamic->participants),
|
|
||||||
'messages' => MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT)),
|
|
||||||
'can' => [
|
'can' => [
|
||||||
'update' => $request->user()->can('update', $ledger),
|
'update' => $request->user()->can('update', $ledger),
|
||||||
'close' => $request->user()->can('close', $ledger),
|
'close' => $request->user()->can('close', $ledger),
|
||||||
@ -99,7 +97,7 @@ class LedgerController extends Controller
|
|||||||
{
|
{
|
||||||
$this->authorize('view', $ledger);
|
$this->authorize('view', $ledger);
|
||||||
|
|
||||||
return MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT));
|
return MessageResource::collection($dynamic->getOrCreateChat()->messages()->with(['user', 'media'])->latest()->paginate(\App\Models\Message::PAGINATION_COUNT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class HandleInertiaRequests extends Middleware
|
|||||||
|
|
||||||
$service = app(ActivityService::class);
|
$service = app(ActivityService::class);
|
||||||
|
|
||||||
return count($service->getUnreadDynamicsGrouped($request->user()));
|
return count($service->getUnreadEntitiesGrouped($request->user()));
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
24
app/Http/Resources/ChatResource.php
Normal file
24
app/Http/Resources/ChatResource.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ChatResource extends BaseResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
$data = parent::toArray($request);
|
||||||
|
|
||||||
|
if ($this->whenLoaded('messages')) {
|
||||||
|
$data['messages'] = MessageResource::collection($this->messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,9 +17,12 @@ class DynamicResource extends BaseResource
|
|||||||
if ($this->ledgers) {
|
if ($this->ledgers) {
|
||||||
$result['ledgers'] = LedgerResource::collection($this->ledgers);
|
$result['ledgers'] = LedgerResource::collection($this->ledgers);
|
||||||
}
|
}
|
||||||
if ($this->participants) {
|
if ($this->whenLoaded('participants')) {
|
||||||
$result['participants'] = ParticipantResource::collection($this->participants);
|
$result['participants'] = ParticipantResource::collection($this->participants);
|
||||||
}
|
}
|
||||||
|
if ($this->whenLoaded('chat')) {
|
||||||
|
$result['chat'] = new ChatResource($this->chat);
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,10 @@ class LedgerResource extends BaseResource
|
|||||||
*/
|
*/
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
$data = parent::toArray($request);
|
||||||
|
|
||||||
|
$data['mutations'] = MutationResource::collection($this->whenLoaded('mutations'));
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use App\Models\Chat;
|
||||||
|
|
||||||
class Dynamic extends Model
|
class Dynamic extends Model
|
||||||
{
|
{
|
||||||
@ -64,4 +65,13 @@ class Dynamic extends Model
|
|||||||
public function getUrlAttribute(): string {
|
public function getUrlAttribute(): string {
|
||||||
return route('dynamics.show', $this);
|
return route('dynamics.show', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrCreateChat(): Chat
|
||||||
|
{
|
||||||
|
if ($this->chat) {
|
||||||
|
return $this->chat;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->chat()->create([]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,8 +45,9 @@ class ActivityService
|
|||||||
return $cursor ? $cursor->read_at : Carbon::parse('1970-01-01');
|
return $cursor ? $cursor->read_at : Carbon::parse('1970-01-01');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createMessage($chat, $user, $content, $subject = null)
|
public function createMessage($dynamic, $user, $content, $subject = null)
|
||||||
{
|
{
|
||||||
|
$chat = $dynamic->getOrCreateChat();
|
||||||
$message = $chat->messages()->create([
|
$message = $chat->messages()->create([
|
||||||
'user_id' => $user ? $user->id : null,
|
'user_id' => $user ? $user->id : null,
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
@ -92,6 +93,11 @@ class ActivityService
|
|||||||
*/
|
*/
|
||||||
public function getActivitiesForDynamic(Dynamic $dynamic): array
|
public function getActivitiesForDynamic(Dynamic $dynamic): array
|
||||||
{
|
{
|
||||||
|
$chat = $dynamic->getOrCreateChat();
|
||||||
|
if (!$chat) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$participants = $dynamic->participants()->withPivot('display_name')->get();
|
$participants = $dynamic->participants()->withPivot('display_name')->get();
|
||||||
$participantsMap = $participants->reduce(function ($acc, $p) {
|
$participantsMap = $participants->reduce(function ($acc, $p) {
|
||||||
$acc[$p->id] = $p->pivot->display_name ?? $p->name;
|
$acc[$p->id] = $p->pivot->display_name ?? $p->name;
|
||||||
@ -99,7 +105,7 @@ class ActivityService
|
|||||||
return $acc;
|
return $acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
$messages = Message::where('chat_id', $dynamic->chat->id)
|
$messages = Message::where('chat_id', $chat->id)
|
||||||
->with(['user', 'subject'])
|
->with(['user', 'subject'])
|
||||||
->latest()
|
->latest()
|
||||||
->get();
|
->get();
|
||||||
@ -122,10 +128,10 @@ class ActivityService
|
|||||||
/**
|
/**
|
||||||
* Get unread activities grouped by active entities (Dynamics, Ledgers) for the given user.
|
* Get unread activities grouped by active entities (Dynamics, Ledgers) for the given user.
|
||||||
*/
|
*/
|
||||||
public function getUnreadDynamicsGrouped(User $user): array
|
public function getUnreadEntitiesGrouped(User $user): array
|
||||||
{
|
{
|
||||||
$groupedDynamics = [];
|
$groupedDynamics = [];
|
||||||
$participatingDynamics = $user->dynamics()->with('ledgers')->get();
|
$participatingDynamics = $user->dynamics()->with(['chat', 'ledgers'])->get();
|
||||||
|
|
||||||
foreach ($participatingDynamics as $dynamic) {
|
foreach ($participatingDynamics as $dynamic) {
|
||||||
$readAt = $this->getCursorReadAt($user, $dynamic);
|
$readAt = $this->getCursorReadAt($user, $dynamic);
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"fakerphp/faker": "^1.24",
|
"fakerphp/faker": "^1.24",
|
||||||
"larastan/larastan": "^3.9",
|
"larastan/larastan": "^3.9",
|
||||||
"laravel/boost": "^2.2",
|
"laravel/boost": "^2.2",
|
||||||
|
"laravel/dusk": "^8.6",
|
||||||
"laravel/pail": "^1.2.5",
|
"laravel/pail": "^1.2.5",
|
||||||
"laravel/pao": "^1.0.6",
|
"laravel/pao": "^1.0.6",
|
||||||
"laravel/pint": "^1.27",
|
"laravel/pint": "^1.27",
|
||||||
|
|||||||
142
composer.lock
generated
142
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "f4c79dcf0b7f9f54487404715d1085c1",
|
"content-hash": "26618424deaf53a19e8fe992032eef9c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
@ -9714,6 +9714,80 @@
|
|||||||
},
|
},
|
||||||
"time": "2026-06-09T10:21:08+00:00"
|
"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",
|
"name": "laravel/mcp",
|
||||||
"version": "v0.8.1",
|
"version": "v0.8.1",
|
||||||
@ -10967,6 +11041,72 @@
|
|||||||
},
|
},
|
||||||
"time": "2022-02-21T01:04:05+00:00"
|
"time": "2022-02-21T01:04:05+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",
|
"name": "phpstan/phpstan",
|
||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -14,7 +14,7 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
unreadDynamics: Array<{
|
unreadEntities: Array<{
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
@ -50,10 +50,10 @@ function formatTime(isoString: string): string {
|
|||||||
<div class="c-dashboard__container">
|
<div class="c-dashboard__container">
|
||||||
<h2 class="c-dashboard__title">Recent Activity</h2>
|
<h2 class="c-dashboard__title">Recent Activity</h2>
|
||||||
|
|
||||||
<div v-if="unreadDynamics.length > 0" class="c-dashboard__grid">
|
<div v-if="unreadEntities.length > 0" class="c-dashboard__grid">
|
||||||
<div
|
<div
|
||||||
v-for="dynamic in unreadDynamics"
|
v-for="entity in unreadEntities"
|
||||||
:key="dynamic.id"
|
:key="entity.id"
|
||||||
class="c-dashboard__card"
|
class="c-dashboard__card"
|
||||||
>
|
>
|
||||||
<div class="c-dashboard__card-header">
|
<div class="c-dashboard__card-header">
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
<?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');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
<?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!
|
|
||||||
});
|
|
||||||
});
|
|
||||||
138
tests/Browser/BasicViewsTest.php
Normal file
138
tests/Browser/BasicViewsTest.php
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
||||||
19
tests/Browser/DashboardTest.php
Normal file
19
tests/Browser/DashboardTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Browser/LoginTest.php
Normal file
27
tests/Browser/LoginTest.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
36
tests/Browser/Pages/HomePage.php
Normal file
36
tests/Browser/Pages/HomePage.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?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',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
20
tests/Browser/Pages/Page.php
Normal file
20
tests/Browser/Pages/Page.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,23 +5,30 @@ namespace Tests\Browser;
|
|||||||
use App\Models\Dynamic;
|
use App\Models\Dynamic;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Laravel\Dusk\Browser;
|
use Laravel\Dusk\Browser;
|
||||||
|
use Tests\DuskTestCase;
|
||||||
|
|
||||||
test('multiple sessions can communicate in real time through websockets', function () {
|
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
|
||||||
|
{
|
||||||
// 1. Create realistic database state
|
// 1. Create realistic database state
|
||||||
$owner = User::factory()->create([
|
$owner = User::factory()->create([
|
||||||
'name' => 'TU Test User',
|
'name' => 'Owner Alice',
|
||||||
'email' => 'test-owner@example.com',
|
'email' => 'alice-owner-' . uniqid() . '@example.com',
|
||||||
'password' => bcrypt('password'),
|
'password' => bcrypt('password'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$participant = User::factory()->create([
|
$participant = User::factory()->create([
|
||||||
'name' => 'Submissive Bob',
|
'name' => 'Submissive Bob',
|
||||||
'email' => 'test-sub@example.com',
|
'email' => 'bob-participant-' . uniqid() . '@example.com',
|
||||||
'password' => bcrypt('password'),
|
'password' => bcrypt('password'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dynamic = Dynamic::create([
|
$dynamic = Dynamic::create([
|
||||||
'name' => 'The Test Sanctuary',
|
'name' => 'The Velvet Realtime Test Sanctuary',
|
||||||
'rules' => 'Rules for realtime testing.',
|
'rules' => 'Rules for realtime testing.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -30,36 +37,50 @@ test('multiple sessions can communicate in real time through websockets', functi
|
|||||||
|
|
||||||
// 2. Spawn two separate browser sessions/browsers in parallel
|
// 2. Spawn two separate browser sessions/browsers in parallel
|
||||||
$this->browse(function (Browser $sessionA, Browser $sessionB) use ($dynamic, $owner, $participant) {
|
$this->browse(function (Browser $sessionA, Browser $sessionB) use ($dynamic, $owner, $participant) {
|
||||||
|
try {
|
||||||
// --- SESSION A: Owner ---
|
// --- SESSION A: Owner ---
|
||||||
$sessionA->loginAs($owner)
|
$sessionA->loginAs($owner)
|
||||||
->visit(route('dynamics.show', $dynamic))
|
->visit('/dynamics/' . $dynamic->uuid)
|
||||||
->waitForText('The Test Sanctuary')
|
->waitForText('The Velvet Realtime Test Sanctuary')
|
||||||
->assertSee('TU Test User'); // Verify loaded in as Owner
|
->assertSee('Owner Alice');
|
||||||
|
|
||||||
// --- SESSION B: Participant ---
|
// --- SESSION B: Participant ---
|
||||||
$sessionB->loginAs($participant)
|
$sessionB->loginAs($participant)
|
||||||
->visit(route('dynamics.show', $dynamic))
|
->visit('/dynamics/' . $dynamic->uuid)
|
||||||
->waitForText('The Test Sanctuary')
|
->waitForText('The Velvet Realtime Test Sanctuary')
|
||||||
->assertSee('Submissive Bob'); // Verify loaded in as Submissive/Participant
|
->assertSee('Submissive Bob');
|
||||||
|
|
||||||
// --- REAL-TIME COMMUNICATING ---
|
// --- REAL-TIME COMMUNICATING ---
|
||||||
// Owner types and sends a message in chat
|
// Owner types and sends a message in chat
|
||||||
$sessionA->type('#content', 'Hello Submissive Bob, did you complete your daily chores?')
|
$sessionA->type('#content', 'Hello Submissive Bob, did you complete your daily chores?')
|
||||||
->click('.c-chat__button')
|
->click('.c-chat__button')
|
||||||
->waitForText('Hello Submissive Bob');
|
->waitForText('Hello Submissive Bob, did you complete your daily chores?');
|
||||||
|
|
||||||
// Since websockets broadcast in real-time, Session B receives it without reloading
|
// Since websockets broadcast in real-time, Session B receives it without reloading
|
||||||
$sessionB->waitForText('Hello Submissive Bob', 5)
|
$sessionB->waitForText('Hello Submissive Bob, did you complete your daily chores?', 10)
|
||||||
->assertSee('Hello Submissive Bob, did you complete your daily chores?');
|
->assertSee('Hello Submissive Bob, did you complete your daily chores?');
|
||||||
|
|
||||||
// Participant replies in real-time
|
// Participant replies in real-time
|
||||||
$sessionB->type('#content', 'Yes Master, everything is complete and logged in the ledger!')
|
$sessionB->type('#content', 'Yes Master, everything is complete and logged!')
|
||||||
->click('.c-chat__button')
|
->click('.c-chat__button')
|
||||||
->waitForText('Yes Master, everything is complete');
|
->waitForText('Yes Master, everything is complete and logged!');
|
||||||
|
|
||||||
// Session A receives the reply in real-time without reloading
|
// Session A receives the reply in real-time without reloading
|
||||||
$sessionA->waitForText('Yes Master, everything is complete', 5)
|
$sessionA->waitForText('Yes Master, everything is complete and logged!', 10)
|
||||||
->assertSee('Yes Master, everything is complete and logged in the ledger!');
|
->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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
$dynamic->participants()->detach();
|
||||||
|
$dynamic->delete();
|
||||||
|
$owner->delete();
|
||||||
|
$participant->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@ use Facebook\WebDriver\Remote\DesiredCapabilities;
|
|||||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||||
use Laravel\Dusk\TestCase as BaseTestCase;
|
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
abstract class DuskTestCase extends BaseTestCase
|
abstract class DuskTestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,13 +28,13 @@ abstract class DuskTestCase extends BaseTestCase
|
|||||||
*/
|
*/
|
||||||
protected function driver(): RemoteWebDriver
|
protected function driver(): RemoteWebDriver
|
||||||
{
|
{
|
||||||
$options = (new ChromeOptions)->addArguments(collect([
|
$options = (new ChromeOptions)->addArguments((new Collection([
|
||||||
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
|
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
|
||||||
'--disable-gpu',
|
'--disable-gpu',
|
||||||
'--headless=new',
|
'--headless=new',
|
||||||
'--no-sandbox',
|
'--no-sandbox',
|
||||||
'--disable-dev-shm-usage',
|
'--disable-dev-shm-usage',
|
||||||
])->unless(static::runningInSail(), function (collect $arguments) {
|
]))->unless(static::runningInSail(), function (Collection $arguments) {
|
||||||
return $arguments->push('--disable-smooth-scrolling');
|
return $arguments->push('--disable-smooth-scrolling');
|
||||||
})->all());
|
})->all());
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ test('authenticated users can visit the dashboard', function () {
|
|||||||
|
|
||||||
$response = $this->get(route('dashboard'));
|
$response = $this->get(route('dashboard'));
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
$response->assertInertia(fn ($page) => $page->component('Dashboard')->has('unreadDynamics'));
|
$response->assertInertia(fn ($page) => $page->component('Dashboard')->has('unreadEntities'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('visiting dynamic updates the read cursor', function () {
|
test('visiting dynamic updates the read cursor', function () {
|
||||||
@ -100,12 +100,12 @@ test('dashboard groups and filters unread entities correctly based on cursor', f
|
|||||||
// Verify unread grouping structure
|
// Verify unread grouping structure
|
||||||
$response->assertInertia(fn ($page) => $page
|
$response->assertInertia(fn ($page) => $page
|
||||||
->component('Dashboard')
|
->component('Dashboard')
|
||||||
->where('unreadDynamics.0.name', 'Testing Dynamic')
|
->where('unreadEntities.0.name', 'Testing Dynamic')
|
||||||
->where('unreadDynamics.0.unread_count', 1)
|
->where('unreadEntities.0.unread_count', 1)
|
||||||
->has('unreadDynamics.0.context_activities', 1) // Should have old message as context
|
->has('unreadEntities.0.context_activities', 1) // Should have old message as context
|
||||||
->where('unreadDynamics.0.context_activities.0.content', 'Old message context')
|
->where('unreadEntities.0.context_activities.0.content', 'Old message context')
|
||||||
->has('unreadDynamics.0.new_activities', 1) // Should have unread message
|
->has('unreadEntities.0.new_activities', 1) // Should have unread message
|
||||||
->where('unreadDynamics.0.new_activities.0.content', 'New unread message alert')
|
->where('unreadEntities.0.new_activities.0.content', 'New unread message alert')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Now visit the Dynamic, which clears the unread count
|
// Now visit the Dynamic, which clears the unread count
|
||||||
@ -116,7 +116,7 @@ test('dashboard groups and filters unread entities correctly based on cursor', f
|
|||||||
$response2->assertOk();
|
$response2->assertOk();
|
||||||
$response2->assertInertia(fn ($page) => $page
|
$response2->assertInertia(fn ($page) => $page
|
||||||
->component('Dashboard')
|
->component('Dashboard')
|
||||||
->has('unreadDynamics', 0)
|
->has('unreadEntities', 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
Carbon::setTestNow(); // Reset test time
|
Carbon::setTestNow(); // Reset test time
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
pest()->extend(Tests\DuskTestCase::class)
|
||||||
|
// ->use(Illuminate\Foundation\Testing\DatabaseMigrations::class)
|
||||||
|
->in('Browser');
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user