work in progress: predefinedmutations
linter / quality (push) Failing after 1m5s
tests / ci (8.3) (push) Failing after 49s
tests / ci (8.4) (push) Failing after 1m5s
tests / ci (8.5) (push) Failing after 1m5s

This commit is contained in:
Daan Meijer
2026-06-26 10:22:55 +02:00
parent 806d17842f
commit 89a48fae16
7 changed files with 120 additions and 6 deletions
+36
View File
@@ -172,3 +172,39 @@ 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);
});