over naar uuids, policies, predefined mutations aan kunnen passen
This commit is contained in:
@@ -19,7 +19,7 @@ test('authenticated users can visit the dashboard', function () {
|
||||
|
||||
$response = $this->get(route('dashboard'));
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page->component('Dashboard')->has('unreadEntities'));
|
||||
$response->assertInertia(fn ($page) => $page->component('Dashboard')->has('unreadDynamics'));
|
||||
});
|
||||
|
||||
test('visiting dynamic updates the read cursor', function () {
|
||||
@@ -34,7 +34,7 @@ test('visiting dynamic updates the read cursor', function () {
|
||||
expect($initialCursor->toIso8601String())->toBe('1970-01-01T00:00:00+00:00');
|
||||
|
||||
// Visit Dynamic Show
|
||||
$this->get(route('dynamics.show', $dynamic->id))->assertOk();
|
||||
$this->get(route('dynamics.show', $dynamic->uuid))->assertOk();
|
||||
|
||||
// Re-check cursor is updated to near now
|
||||
$updatedCursor = $service->getCursorReadAt($user, $dynamic);
|
||||
@@ -56,7 +56,7 @@ test('visiting ledger updates the read cursor', function () {
|
||||
expect($initialCursor->toIso8601String())->toBe('1970-01-01T00:00:00+00:00');
|
||||
|
||||
// Visit Ledger Show
|
||||
$this->get(route('dynamics.ledgers.show', [$dynamic->id, $ledger->id]))->assertOk();
|
||||
$this->get(route('dynamics.ledgers.show', [$dynamic->uuid, $ledger->uuid]))->assertOk();
|
||||
|
||||
// Re-check cursor is updated to near now
|
||||
$updatedCursor = $service->getCursorReadAt($user, $ledger);
|
||||
@@ -101,23 +101,23 @@ test('dashboard groups and filters unread entities correctly based on cursor', f
|
||||
// Verify unread grouping structure
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('Dashboard')
|
||||
->where('unreadEntities.0.name', 'Testing Dynamic')
|
||||
->where('unreadEntities.0.unread_count', 1)
|
||||
->has('unreadEntities.0.context_activities', 1) // Should have old message as context
|
||||
->where('unreadEntities.0.context_activities.0.content', 'Old message context')
|
||||
->has('unreadEntities.0.new_activities', 1) // Should have unread message
|
||||
->where('unreadEntities.0.new_activities.0.content', 'New unread message alert')
|
||||
->where('unreadDynamics.0.name', 'Testing Dynamic')
|
||||
->where('unreadDynamics.0.unread_count', 1)
|
||||
->has('unreadDynamics.0.context_activities', 1) // Should have old message as context
|
||||
->where('unreadDynamics.0.context_activities.0.content', 'Old message context')
|
||||
->has('unreadDynamics.0.new_activities', 1) // Should have unread message
|
||||
->where('unreadDynamics.0.new_activities.0.content', 'New unread message alert')
|
||||
);
|
||||
|
||||
// Now visit the Dynamic, which clears the unread count
|
||||
$this->get(route('dynamics.show', $dynamic->id))->assertOk();
|
||||
$this->get(route('dynamics.show', $dynamic->uuid))->assertOk();
|
||||
|
||||
// Dashboard should now show 0 unread groups (caught up)
|
||||
$response2 = $this->get(route('dashboard'));
|
||||
$response2->assertOk();
|
||||
$response2->assertInertia(fn ($page) => $page
|
||||
->component('Dashboard')
|
||||
->has('unreadEntities', 0)
|
||||
->has('unreadDynamics', 0)
|
||||
);
|
||||
|
||||
Carbon::setTestNow(); // Reset test time
|
||||
|
||||
@@ -19,7 +19,7 @@ test('only owners can invite other users to a dynamic', function () {
|
||||
|
||||
// 1. Participant tries to send an invite (forbidden)
|
||||
$response = $this->actingAs($participant)
|
||||
->post(route('dynamics.invitations.store', $dynamic), [
|
||||
->post(route('dynamics.invitations.store', $dynamic->uuid), [
|
||||
'email' => 'invitee@example.com',
|
||||
'role' => 'participant',
|
||||
]);
|
||||
@@ -29,7 +29,7 @@ test('only owners can invite other users to a dynamic', function () {
|
||||
|
||||
// 2. Owner sends a valid invite (allowed)
|
||||
$response = $this->actingAs($owner)
|
||||
->post(route('dynamics.invitations.store', $dynamic), [
|
||||
->post(route('dynamics.invitations.store', $dynamic->uuid), [
|
||||
'email' => 'invitee@example.com',
|
||||
'role' => 'participant',
|
||||
]);
|
||||
@@ -83,7 +83,7 @@ test('only the user with the specified email address can accept the link', funct
|
||||
|
||||
// 3. Intended user accepts the signed invitation link (success)
|
||||
$response = $this->actingAs($invitee)->get($signedUrl);
|
||||
$response->assertRedirect(route('dynamics.show', $dynamic));
|
||||
$response->assertRedirect(route('dynamics.show', $dynamic->uuid));
|
||||
|
||||
// Verify invitee is joined as a participant with the specified role
|
||||
$isJoined = $dynamic->participants()
|
||||
|
||||
@@ -12,17 +12,17 @@ test('dynamic owners can view ledger creation form and create ledgers', function
|
||||
$this->actingAs($owner);
|
||||
|
||||
// Can view form
|
||||
$this->get(route('dynamics.ledgers.create', $dynamic->id))->assertOk();
|
||||
$this->get(route('dynamics.ledgers.create', $dynamic->uuid))->assertOk();
|
||||
|
||||
// Can store ledger
|
||||
$response = $this->post(route('dynamics.ledgers.store', $dynamic->id), [
|
||||
$response = $this->post(route('dynamics.ledgers.store', $dynamic->uuid), [
|
||||
'name' => 'Chores Ledger',
|
||||
'rules' => 'Do the tasks.',
|
||||
'alignment' => 'positive',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasNoErrors();
|
||||
$response->assertRedirect(route('dynamics.show', $dynamic->id));
|
||||
$response->assertRedirect(route('dynamics.show', $dynamic->uuid));
|
||||
|
||||
$this->assertDatabaseHas('ledgers', [
|
||||
'dynamic_id' => $dynamic->id,
|
||||
@@ -41,10 +41,10 @@ test('non-owners cannot view ledger creation form or store ledgers', function ()
|
||||
$this->actingAs($participant);
|
||||
|
||||
// Cannot view form
|
||||
$this->get(route('dynamics.ledgers.create', $dynamic->id))->assertStatus(403);
|
||||
$this->get(route('dynamics.ledgers.create', $dynamic->uuid))->assertStatus(403);
|
||||
|
||||
// Cannot store ledger
|
||||
$response = $this->post(route('dynamics.ledgers.store', $dynamic->id), [
|
||||
$response = $this->post(route('dynamics.ledgers.store', $dynamic->uuid), [
|
||||
'name' => 'Illegal Ledger',
|
||||
'rules' => 'This should fail.',
|
||||
'alignment' => 'positive',
|
||||
|
||||
@@ -15,7 +15,7 @@ test('authenticated participant can view another participant detail page in dyna
|
||||
|
||||
$this->actingAs($owner);
|
||||
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->id, $participant->id]));
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->uuid, $participant->uuid]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
@@ -40,7 +40,7 @@ test('non-participant cannot view participant detail page in dynamic', function
|
||||
|
||||
$this->actingAs($outsider);
|
||||
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->id, $participant->id]));
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->uuid, $participant->uuid]));
|
||||
|
||||
$response->assertStatus(403);
|
||||
});
|
||||
@@ -82,7 +82,7 @@ test('participant detail page displays their recent mutations in dynamic', funct
|
||||
|
||||
$this->actingAs($owner);
|
||||
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->id, $participant->id]));
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->uuid, $participant->uuid]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
|
||||
@@ -29,7 +29,7 @@ test('participant can update their display name', function () {
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->put(route('dynamics.participant.update', $dynamic->id), [
|
||||
$response = $this->put(route('dynamics.participant.update', $dynamic->uuid), [
|
||||
'display_name' => 'Ally',
|
||||
]);
|
||||
|
||||
@@ -53,7 +53,7 @@ test('display name update requires display_name parameter', function () {
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->put(route('dynamics.participant.update', $dynamic->id), [
|
||||
$response = $this->put(route('dynamics.participant.update', $dynamic->uuid), [
|
||||
'display_name' => '',
|
||||
]);
|
||||
|
||||
@@ -68,7 +68,7 @@ test('non participant cannot update display name', function () {
|
||||
|
||||
$this->actingAs($nonParticipant);
|
||||
|
||||
$response = $this->put(route('dynamics.participant.update', $dynamic->id), [
|
||||
$response = $this->put(route('dynamics.participant.update', $dynamic->uuid), [
|
||||
'display_name' => 'Bobby',
|
||||
]);
|
||||
|
||||
|
||||
@@ -5,14 +5,13 @@ use App\Models\Dynamic;
|
||||
use App\Models\Ledger;
|
||||
use App\Models\PredefinedMutation;
|
||||
|
||||
test('owner can view predefined mutations for ledger', function () {
|
||||
test('owner can view predefined mutations for dynamic', function () {
|
||||
$owner = User::factory()->create();
|
||||
$dynamic = Dynamic::factory()->create();
|
||||
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
|
||||
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
|
||||
|
||||
$predefined = PredefinedMutation::create([
|
||||
'ledger_id' => $ledger->id,
|
||||
'dynamic_id' => $dynamic->id,
|
||||
'name' => 'Weekly Room Cleaning',
|
||||
'description' => 'Cleaned up the master bedroom',
|
||||
'amount' => 20,
|
||||
@@ -20,73 +19,71 @@ test('owner can view predefined mutations for ledger', function () {
|
||||
|
||||
$this->actingAs($owner);
|
||||
|
||||
$response = $this->get(route('dynamics.ledgers.predefined-mutations.index', [$dynamic->id, $ledger->id]));
|
||||
$response = $this->get(route('dynamics.predefined-mutations.index', $dynamic->uuid));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('Ledgers/PredefinedMutations/Index')
|
||||
->where('ledger.id', $ledger->id)
|
||||
->component('Dynamics/PredefinedMutations/Index')
|
||||
->has('predefined_mutations', 1)
|
||||
->where('predefined_mutations.0.name', 'Weekly Room Cleaning')
|
||||
);
|
||||
});
|
||||
|
||||
test('non-owner cannot view predefined mutations for ledger', function () {
|
||||
test('non-owner cannot view predefined mutations for dynamic', 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]);
|
||||
|
||||
$this->actingAs($participant);
|
||||
|
||||
$response = $this->get(route('dynamics.ledgers.predefined-mutations.index', [$dynamic->id, $ledger->id]));
|
||||
$response = $this->get(route('dynamics.predefined-mutations.index', $dynamic->uuid));
|
||||
|
||||
$response->assertStatus(403);
|
||||
});
|
||||
|
||||
test('owner can create predefined mutations for ledger', function () {
|
||||
test('owner can create predefined mutations for dynamic', 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->post(route('dynamics.ledgers.predefined-mutations.store', [$dynamic->id, $ledger->id]), [
|
||||
$response = $this->post(route('dynamics.predefined-mutations.store', $dynamic->uuid), [
|
||||
'name' => 'Polished mirrors',
|
||||
'description' => 'Mirror polishing in dungeon',
|
||||
'amount' => 15,
|
||||
'type' => 'reward',
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertDatabaseHas('predefined_mutations', [
|
||||
'ledger_id' => $ledger->id,
|
||||
'dynamic_id' => $dynamic->id,
|
||||
'name' => 'Polished mirrors',
|
||||
'amount' => 15,
|
||||
]);
|
||||
});
|
||||
|
||||
test('non-owner cannot create predefined mutations for ledger', function () {
|
||||
test('non-owner cannot create predefined mutations for dynamic', 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]);
|
||||
|
||||
$this->actingAs($participant);
|
||||
|
||||
$response = $this->post(route('dynamics.ledgers.predefined-mutations.store', [$dynamic->id, $ledger->id]), [
|
||||
$response = $this->post(route('dynamics.predefined-mutations.store', $dynamic->uuid), [
|
||||
'name' => 'Polished mirrors',
|
||||
'description' => 'Mirror polishing in dungeon',
|
||||
'amount' => 15,
|
||||
'type' => 'reward',
|
||||
]);
|
||||
|
||||
$response->assertStatus(403);
|
||||
$this->assertDatabaseMissing('predefined_mutations', [
|
||||
'ledger_id' => $ledger->id,
|
||||
'dynamic_id' => $dynamic->id,
|
||||
'name' => 'Polished mirrors',
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user