mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-02-04 15:53:17 +00:00
🛠️ Add checks to prevent unauthenticated users from voting and hide voting buttons accordingly
✅ Add tests to ensure proper handling of unauthenticated users during voting interactions
This commit is contained in:
@@ -304,3 +304,31 @@ it('can handle not approve vote', function () {
|
||||
expect($vote)->not->toBeNull()
|
||||
->and($vote->value)->toBeFalse();
|
||||
});
|
||||
|
||||
it('does not throw error when unauthenticated user calls handleApprove', function () {
|
||||
$project = ProjectProposal::factory()->create();
|
||||
|
||||
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||
->call('handleApprove')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect(\App\Models\Vote::where('project_proposal_id', $project->id)->exists())->toBeFalse();
|
||||
});
|
||||
|
||||
it('does not throw error when unauthenticated user calls handleNotApprove', function () {
|
||||
$project = ProjectProposal::factory()->create();
|
||||
|
||||
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||
->call('handleNotApprove')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect(\App\Models\Vote::where('project_proposal_id', $project->id)->exists())->toBeFalse();
|
||||
});
|
||||
|
||||
it('hides voting buttons from unauthenticated users', function () {
|
||||
$project = ProjectProposal::factory()->create();
|
||||
|
||||
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||
->assertDontSee('Zustimmen')
|
||||
->assertDontSee('Ablehnen');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user