better system messages, display name relocation
This commit is contained in:
@@ -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("{$invitee->name} joined the Dynamic as a EDITOR");
|
||||
expect($chatMessages->last()->content)->toBe("<user:{$invitee->id}> joined the Dynamic as a EDITOR");
|
||||
});
|
||||
|
||||
@@ -32,11 +32,13 @@ test('owner can create a mutation which is automatically approved and does not s
|
||||
// Verify chat messages (should NOT say "approved" or "Approved")
|
||||
$mutationChatMessages = $mutation->chat->messages;
|
||||
expect($mutationChatMessages)->toHaveCount(1);
|
||||
expect($mutationChatMessages->first()->content)->toBe("System: Entry was created by {$owner->name}.");
|
||||
expect($mutationChatMessages->first()->user_id)->toBeNull();
|
||||
expect($mutationChatMessages->first()->content)->toBe("Entry was created by <user:{$owner->id}>.");
|
||||
|
||||
$dynamicChatMessages = $dynamic->chat->messages;
|
||||
expect($dynamicChatMessages)->toHaveCount(1);
|
||||
expect($dynamicChatMessages->first()->content)->toBe("System: {$owner->name} added entry \"Direct point reward\" for +15 points on \"{$ledger->name}\" ledger.");
|
||||
expect($dynamicChatMessages->first()->user_id)->toBeNull();
|
||||
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 () {
|
||||
@@ -68,11 +70,13 @@ test('non-owner participant creates a suggestion which defaults to pending and s
|
||||
// Verify chat messages
|
||||
$mutationChatMessages = $mutation->chat->messages;
|
||||
expect($mutationChatMessages)->toHaveCount(1);
|
||||
expect($mutationChatMessages->first()->content)->toBe("System: Suggestion was created by {$participant->name}.");
|
||||
expect($mutationChatMessages->first()->user_id)->toBeNull();
|
||||
expect($mutationChatMessages->first()->content)->toBe("Suggestion was created by <user:{$participant->id}>.");
|
||||
|
||||
$dynamicChatMessages = $dynamic->chat->messages;
|
||||
expect($dynamicChatMessages)->toHaveCount(1);
|
||||
expect($dynamicChatMessages->first()->content)->toBe("System: {$participant->name} suggested \"Suggested point reward\" for +10 points on \"{$ledger->name}\" ledger.");
|
||||
expect($dynamicChatMessages->first()->user_id)->toBeNull();
|
||||
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 () {
|
||||
@@ -110,8 +114,10 @@ test('owner can approve a pending suggestion and it is updated and logged', func
|
||||
$mutationChatMessages = $mutation->chat->messages;
|
||||
// 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()->content)->toBe("System: Suggestion was APPROVED by {$owner->name}.");
|
||||
expect($mutationChatMessages->last()->user_id)->toBeNull();
|
||||
expect($mutationChatMessages->last()->content)->toBe("Suggestion was APPROVED by <user:{$owner->id}>.");
|
||||
|
||||
$dynamicChatMessages = $dynamic->chat->messages;
|
||||
expect($dynamicChatMessages->last()->content)->toBe("System: {$owner->name} APPROVED the suggestion \"Polished dungeon floors\" for +20 points on \"{$ledger->name}\" ledger.");
|
||||
expect($dynamicChatMessages->last()->user_id)->toBeNull();
|
||||
expect($dynamicChatMessages->last()->content)->toBe("<user:{$owner->id}> APPROVED the suggestion \"Polished dungeon floors\" for +20 points on \"{$ledger->name}\" ledger.");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Dynamic;
|
||||
use App\Models\Ledger;
|
||||
use App\Models\Mutation;
|
||||
|
||||
test('authenticated participant can view another participant detail page in dynamic', function () {
|
||||
$owner = User::factory()->create();
|
||||
$participant = User::factory()->create();
|
||||
$dynamic = Dynamic::factory()->create();
|
||||
|
||||
$dynamic->participants()->attach($owner->id, ['role' => 'owner', 'display_name' => 'The Boss']);
|
||||
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
|
||||
|
||||
$this->actingAs($owner);
|
||||
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->id, $participant->id]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('Participants/Show')
|
||||
->has('dynamic')
|
||||
->where('participant.id', $participant->id)
|
||||
->where('participant.name', $participant->name)
|
||||
->where('participant.display_name', null)
|
||||
->where('participant.role', 'participant')
|
||||
->has('mutations')
|
||||
);
|
||||
});
|
||||
|
||||
test('non-participant cannot view participant detail page in dynamic', function () {
|
||||
$owner = User::factory()->create();
|
||||
$participant = User::factory()->create();
|
||||
$outsider = User::factory()->create();
|
||||
$dynamic = Dynamic::factory()->create();
|
||||
|
||||
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
|
||||
$dynamic->participants()->attach($participant->id, ['role' => 'participant']);
|
||||
|
||||
$this->actingAs($outsider);
|
||||
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->id, $participant->id]));
|
||||
|
||||
$response->assertStatus(403);
|
||||
});
|
||||
|
||||
test('participant detail page displays their recent mutations in dynamic', function () {
|
||||
$owner = User::factory()->create();
|
||||
$participant = User::factory()->create();
|
||||
$dynamic = Dynamic::factory()->create();
|
||||
$ledger = Ledger::factory()->create(['dynamic_id' => $dynamic->id]);
|
||||
|
||||
$dynamic->participants()->attach($owner->id, ['role' => 'owner']);
|
||||
$dynamic->participants()->attach($participant->id, ['role' => 'participant', 'display_name' => 'Bitch']);
|
||||
|
||||
// Create mutations in this dynamic
|
||||
$mutation1 = Mutation::factory()->create([
|
||||
'ledger_id' => $ledger->id,
|
||||
'user_id' => $participant->id,
|
||||
'amount' => 10,
|
||||
'description' => 'Chore 1',
|
||||
]);
|
||||
|
||||
$mutation2 = Mutation::factory()->create([
|
||||
'ledger_id' => $ledger->id,
|
||||
'user_id' => $participant->id,
|
||||
'amount' => -5,
|
||||
'description' => 'Infraction 1',
|
||||
]);
|
||||
|
||||
// Create a mutation in another dynamic (should NOT be displayed)
|
||||
$otherDynamic = Dynamic::factory()->create();
|
||||
$otherLedger = Ledger::factory()->create(['dynamic_id' => $otherDynamic->id]);
|
||||
$otherDynamic->participants()->attach($participant->id, ['role' => 'participant']);
|
||||
$mutation3 = Mutation::factory()->create([
|
||||
'ledger_id' => $otherLedger->id,
|
||||
'user_id' => $participant->id,
|
||||
'amount' => 100,
|
||||
'description' => 'Other dynamic chore',
|
||||
]);
|
||||
|
||||
$this->actingAs($owner);
|
||||
|
||||
$response = $this->get(route('dynamics.users.show', [$dynamic->id, $participant->id]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('Participants/Show')
|
||||
->where('participant.display_name', 'Bitch')
|
||||
->has('mutations', 2)
|
||||
->where('mutations.0.description', 'Infraction 1') // Ordered latest first
|
||||
->where('mutations.1.description', 'Chore 1')
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user