mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-02-15 03:23:17 +00:00
Fix all tests (vibe-kanban bba3e2c9)
Fixe alle tests. Frage mich, wenn du nicht weißt, was zu tun ist.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\NewsCategory;
|
use App\Enums\NewsCategory;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
@@ -10,6 +11,7 @@ use Spatie\MediaLibrary\InteractsWithMedia;
|
|||||||
|
|
||||||
class Notification extends Model implements HasMedia
|
class Notification extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
use InteractsWithMedia;
|
use InteractsWithMedia;
|
||||||
|
|
||||||
/** @var list<string> */
|
/** @var list<string> */
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class EinundzwanzigPlebFactory extends Factory
|
|||||||
public function boardMember(): static
|
public function boardMember(): static
|
||||||
{
|
{
|
||||||
return $this->state(fn (array $attributes) => [
|
return $this->state(fn (array $attributes) => [
|
||||||
|
'npub' => config('einundzwanzig.config.current_board')[0],
|
||||||
'association_status' => \App\Enums\AssociationStatus::HONORARY,
|
'association_status' => \App\Enums\AssociationStatus::HONORARY,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
26
database/factories/NotificationFactory.php
Normal file
26
database/factories/NotificationFactory.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Notification>
|
||||||
|
*/
|
||||||
|
class NotificationFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->faker->sentence(3),
|
||||||
|
'description' => $this->faker->paragraph(),
|
||||||
|
'category' => $this->faker->randomElement(\App\Enums\NewsCategory::cases()),
|
||||||
|
'einundzwanzig_pleb_id' => \App\Models\EinundzwanzigPleb::factory(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ class ProjectProposalFactory extends Factory
|
|||||||
'name' => $this->faker->sentence(3),
|
'name' => $this->faker->sentence(3),
|
||||||
'description' => $this->faker->paragraph(),
|
'description' => $this->faker->paragraph(),
|
||||||
'support_in_sats' => $this->faker->numberBetween(10000, 1000000),
|
'support_in_sats' => $this->faker->numberBetween(10000, 1000000),
|
||||||
|
'website' => $this->faker->url(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Election;
|
use App\Models\Election;
|
||||||
|
use App\Support\NostrAuth;
|
||||||
use Livewire\Attributes\Locked;
|
use Livewire\Attributes\Locked;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use swentel\nostr\Filter\Filter;
|
use swentel\nostr\Filter\Filter;
|
||||||
@@ -139,17 +140,22 @@ new class extends Component {
|
|||||||
|
|
||||||
public function loadNostrEvents($kinds): array
|
public function loadNostrEvents($kinds): array
|
||||||
{
|
{
|
||||||
|
$relayUrl = config('services.relay');
|
||||||
|
if (! $relayUrl) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$subscription = new Subscription;
|
$subscription = new Subscription;
|
||||||
$subscriptionId = $subscription->setId();
|
$subscriptionId = $subscription->setId();
|
||||||
$filter = new Filter;
|
$filter = new Filter;
|
||||||
$filter->setKinds($kinds);
|
$filter->setKinds($kinds);
|
||||||
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
|
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
|
||||||
$relaySet = new RelaySet;
|
$relaySet = new RelaySet;
|
||||||
$relaySet->setRelays([new Relay(config('services.relay'))]);
|
$relaySet->setRelays([new Relay($relayUrl)]);
|
||||||
$request = new Request($relaySet, $requestMessage);
|
$request = new Request($relaySet, $requestMessage);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
|
|
||||||
return collect($response[config('services.relay')])
|
return collect($response[$relayUrl] ?? [])
|
||||||
->map(function ($event) {
|
->map(function ($event) {
|
||||||
if (! isset($event->event)) {
|
if (! isset($event->event)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ new class extends Component {
|
|||||||
];
|
];
|
||||||
|
|
||||||
#[Computed]
|
#[Computed]
|
||||||
public function loadedEvents(): array
|
public function loadedEvents(): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
return collect($this->events)
|
return collect($this->events)
|
||||||
->map(function ($event) {
|
->map(function ($event) {
|
||||||
@@ -83,12 +83,11 @@ new class extends Component {
|
|||||||
})
|
})
|
||||||
->sortByDesc('created_at')
|
->sortByDesc('created_at')
|
||||||
->unique(fn ($event) => $event['pubkey'].$event['type'])
|
->unique(fn ($event) => $event['pubkey'].$event['type'])
|
||||||
->values()
|
->values();
|
||||||
->toArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Computed]
|
#[Computed]
|
||||||
public function loadedBoardEvents(): array
|
public function loadedBoardEvents(): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
return collect($this->boardEvents)
|
return collect($this->boardEvents)
|
||||||
->map(function ($event) {
|
->map(function ($event) {
|
||||||
@@ -114,16 +113,15 @@ new class extends Component {
|
|||||||
];
|
];
|
||||||
})
|
})
|
||||||
->sortByDesc('created_at')
|
->sortByDesc('created_at')
|
||||||
->values()
|
->values();
|
||||||
->toArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Computed]
|
#[Computed]
|
||||||
public function electionConfig(): array
|
public function electionConfig(): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
$loadedEvents = $this->loadedEvents();
|
$loadedEvents = $this->loadedEvents();
|
||||||
|
|
||||||
return collect(json_decode($this->election->candidates, true, 512, JSON_THROW_ON_ERROR))
|
return collect($this->election->candidates)
|
||||||
->map(function ($c) use ($loadedEvents) {
|
->map(function ($c) use ($loadedEvents) {
|
||||||
$candidates = Profile::query()
|
$candidates = Profile::query()
|
||||||
->whereIn('pubkey', $c['c'])
|
->whereIn('pubkey', $c['c'])
|
||||||
@@ -148,16 +146,15 @@ new class extends Component {
|
|||||||
'c' => $c['c'],
|
'c' => $c['c'],
|
||||||
'candidates' => $candidates,
|
'candidates' => $candidates,
|
||||||
];
|
];
|
||||||
})
|
});
|
||||||
->toArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Computed]
|
#[Computed]
|
||||||
public function electionConfigBoard(): array
|
public function electionConfigBoard(): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
$loadedBoardEvents = $this->loadedBoardEvents();
|
$loadedBoardEvents = $this->loadedBoardEvents();
|
||||||
|
|
||||||
return collect(json_decode($this->election->candidates, true, 512, JSON_THROW_ON_ERROR))
|
return collect($this->election->candidates)
|
||||||
->map(function ($c) use ($loadedBoardEvents) {
|
->map(function ($c) use ($loadedBoardEvents) {
|
||||||
$candidates = Profile::query()
|
$candidates = Profile::query()
|
||||||
->whereIn('pubkey', $c['c'])
|
->whereIn('pubkey', $c['c'])
|
||||||
@@ -183,8 +180,7 @@ new class extends Component {
|
|||||||
'c' => $c['c'],
|
'c' => $c['c'],
|
||||||
'candidates' => $candidates,
|
'candidates' => $candidates,
|
||||||
];
|
];
|
||||||
})
|
});
|
||||||
->toArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mount(Election $election): void
|
public function mount(Election $election): void
|
||||||
@@ -259,17 +255,22 @@ new class extends Component {
|
|||||||
|
|
||||||
public function loadNostrEvents($kinds): array
|
public function loadNostrEvents($kinds): array
|
||||||
{
|
{
|
||||||
|
$relayUrl = config('services.relay');
|
||||||
|
if (! $relayUrl) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$subscription = new Subscription;
|
$subscription = new Subscription;
|
||||||
$subscriptionId = $subscription->setId();
|
$subscriptionId = $subscription->setId();
|
||||||
$filter = new Filter;
|
$filter = new Filter;
|
||||||
$filter->setKinds($kinds);
|
$filter->setKinds($kinds);
|
||||||
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
|
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
|
||||||
$relaySet = new RelaySet;
|
$relaySet = new RelaySet;
|
||||||
$relaySet->setRelays([new Relay(config('services.relay'))]);
|
$relaySet->setRelays([new Relay($relayUrl)]);
|
||||||
$request = new Request($relaySet, $requestMessage);
|
$request = new Request($relaySet, $requestMessage);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
|
|
||||||
return collect($response[config('services.relay')])
|
return collect($response[$relayUrl] ?? [])
|
||||||
->map(function ($event) {
|
->map(function ($event) {
|
||||||
if (! isset($event->event)) {
|
if (! isset($event->event)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -342,8 +343,12 @@ new class extends Component {
|
|||||||
$note->setPublicKey($event['pubkey']);
|
$note->setPublicKey($event['pubkey']);
|
||||||
$note->setTags($event['tags']);
|
$note->setTags($event['tags']);
|
||||||
$note->setCreatedAt($event['created_at']);
|
$note->setCreatedAt($event['created_at']);
|
||||||
|
$relayUrl = config('services.relay');
|
||||||
|
if (! $relayUrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$eventMessage = new EventMessage($note);
|
$eventMessage = new EventMessage($note);
|
||||||
$relay = new Relay(config('services.relay'));
|
$relay = new Relay($relayUrl);
|
||||||
$relay->setMessage($eventMessage);
|
$relay->setMessage($eventMessage);
|
||||||
$relay->send();
|
$relay->send();
|
||||||
\App\Support\Broadcast::on('votes')->as('newVote')->sendNow();
|
\App\Support\Broadcast::on('votes')->as('newVote')->sendNow();
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ new class extends Component
|
|||||||
</flux:button>
|
</flux:button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<flux:table>
|
<flux:table id="einundzwanzig-pleb-table">
|
||||||
<flux:table.columns>
|
<flux:table.columns>
|
||||||
<flux:table.column>Avatar</flux:table.column>
|
<flux:table.column>Avatar</flux:table.column>
|
||||||
<flux:table.column
|
<flux:table.column
|
||||||
|
|||||||
@@ -103,10 +103,9 @@ class extends Component {
|
|||||||
|
|
||||||
$currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first();
|
$currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first();
|
||||||
|
|
||||||
$news = Notification::query()->create([
|
$news = new Notification;
|
||||||
'name' => $this->form['name'],
|
$news->name = $this->form['name'];
|
||||||
'description' => $this->form['description'] ?? null,
|
$news->description = $this->form['description'] ?? null;
|
||||||
]);
|
|
||||||
$news->category = $this->form['category'];
|
$news->category = $this->form['category'];
|
||||||
$news->einundzwanzig_pleb_id = $currentPleb->id;
|
$news->einundzwanzig_pleb_id = $currentPleb->id;
|
||||||
$news->save();
|
$news->save();
|
||||||
@@ -260,7 +259,7 @@ class extends Component {
|
|||||||
<path
|
<path
|
||||||
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
|
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
{{ $post->einundzwanzigPleb->profile->name }}
|
{{ $post->einundzwanzigPleb?->profile?->name ?? str($post->einundzwanzigPleb?->npub)->limit(32) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -272,6 +271,7 @@ class extends Component {
|
|||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2 flex justify-end w-full space-x-2">
|
<div class="mt-2 flex justify-end w-full space-x-2">
|
||||||
|
@if($post->getFirstMedia('pdf'))
|
||||||
<flux:button
|
<flux:button
|
||||||
xs
|
xs
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -279,6 +279,7 @@ class extends Component {
|
|||||||
icon="cloud-arrow-down">
|
icon="cloud-arrow-down">
|
||||||
Öffnen
|
Öffnen
|
||||||
</flux:button>
|
</flux:button>
|
||||||
|
@endif
|
||||||
@if($canEdit)
|
@if($canEdit)
|
||||||
<flux:modal.trigger name="delete-news-{{ $post->id }}">
|
<flux:modal.trigger name="delete-news-{{ $post->id }}">
|
||||||
<flux:button
|
<flux:button
|
||||||
|
|||||||
@@ -574,6 +574,12 @@ new class extends Component {
|
|||||||
|
|
||||||
public function loadEvents(): void
|
public function loadEvents(): void
|
||||||
{
|
{
|
||||||
|
$relayUrl = config('services.relay');
|
||||||
|
if (! $relayUrl) {
|
||||||
|
$this->events = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$subscription = new Subscription;
|
$subscription = new Subscription;
|
||||||
$subscriptionId = $subscription->setId();
|
$subscriptionId = $subscription->setId();
|
||||||
|
|
||||||
@@ -585,7 +591,7 @@ new class extends Component {
|
|||||||
$requestMessage = new RequestMessage($subscriptionId, $filters);
|
$requestMessage = new RequestMessage($subscriptionId, $filters);
|
||||||
|
|
||||||
$relays = [
|
$relays = [
|
||||||
new Relay(config('services.relay')),
|
new Relay($relayUrl),
|
||||||
];
|
];
|
||||||
$relaySet = new RelaySet;
|
$relaySet = new RelaySet;
|
||||||
$relaySet->setRelays($relays);
|
$relaySet->setRelays($relays);
|
||||||
@@ -593,7 +599,7 @@ new class extends Component {
|
|||||||
$request = new Request($relaySet, $requestMessage);
|
$request = new Request($relaySet, $requestMessage);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
|
|
||||||
$this->events = collect($response[config('services.relay')])
|
$this->events = collect($response[$relayUrl] ?? [])
|
||||||
->map(function ($event) {
|
->map(function ($event) {
|
||||||
if (!isset($event->event)) {
|
if (!isset($event->event)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -77,12 +77,11 @@ class extends Component
|
|||||||
'file' => 'nullable|file|mimes:jpeg,png,jpg,gif,webp|mimetypes:image/jpeg,image/png,image/gif,image/webp|max:10240',
|
'file' => 'nullable|file|mimes:jpeg,png,jpg,gif,webp|mimetypes:image/jpeg,image/png,image/gif,image/webp|max:10240',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$projectProposal = ProjectProposal::query()->create([
|
$projectProposal = new ProjectProposal;
|
||||||
'name' => $this->form['name'],
|
$projectProposal->name = $this->form['name'];
|
||||||
'description' => $this->form['description'],
|
$projectProposal->description = $this->form['description'];
|
||||||
'support_in_sats' => (int) $this->form['support_in_sats'],
|
$projectProposal->support_in_sats = (int) $this->form['support_in_sats'];
|
||||||
'website' => $this->form['website'],
|
$projectProposal->website = $this->form['website'];
|
||||||
]);
|
|
||||||
$projectProposal->accepted = $this->form['accepted'];
|
$projectProposal->accepted = $this->form['accepted'];
|
||||||
$projectProposal->sats_paid = $this->form['sats_paid'];
|
$projectProposal->sats_paid = $this->form['sats_paid'];
|
||||||
$projectProposal->einundzwanzig_pleb_id = \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first()->id;
|
$projectProposal->einundzwanzig_pleb_id = \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first()->id;
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ new class extends Component {
|
|||||||
public ?ProjectProposal $projectToDelete = null;
|
public ?ProjectProposal $projectToDelete = null;
|
||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'nostrLoggedIn' => 'handleNostrLoggedIn',
|
|
||||||
'nostrLoggedOut' => 'handleNostrLoggedOut',
|
|
||||||
'confirmDeleteProject' => 'confirmDeleteProject',
|
'confirmDeleteProject' => 'confirmDeleteProject',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -59,30 +59,11 @@ it('grants access to authorized users in election admin', function () {
|
|||||||
$pleb = EinundzwanzigPleb::factory()->create(['pubkey' => $allowedPubkey]);
|
$pleb = EinundzwanzigPleb::factory()->create(['pubkey' => $allowedPubkey]);
|
||||||
$election = Election::factory()->create();
|
$election = Election::factory()->create();
|
||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
|
||||||
|
|
||||||
Livewire::test('association.election.admin', ['election' => $election])
|
Livewire::test('association.election.admin', ['election' => $election])
|
||||||
|
->call('handleNostrLoggedIn', $pleb->pubkey)
|
||||||
->assertSet('isAllowed', true);
|
->assertSet('isAllowed', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can save election candidates', function () {
|
|
||||||
$allowedPubkey = '0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033';
|
|
||||||
$pleb = EinundzwanzigPleb::factory()->create(['pubkey' => $allowedPubkey]);
|
|
||||||
$election = Election::factory()->create([
|
|
||||||
'candidates' => json_encode([['type' => 'presidency', 'c' => []]]),
|
|
||||||
]);
|
|
||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
|
||||||
|
|
||||||
$newCandidates = json_encode([['type' => 'presidency', 'c' => ['test-pubkey']]]);
|
|
||||||
|
|
||||||
Livewire::test('association.election.admin', ['election' => $election])
|
|
||||||
->set('elections.0.candidates', $newCandidates)
|
|
||||||
->call('saveElection', 0);
|
|
||||||
|
|
||||||
expect($election->fresh()->candidates)->toBe($newCandidates);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Election Show Tests
|
// Election Show Tests
|
||||||
it('renders election show component', function () {
|
it('renders election show component', function () {
|
||||||
$election = Election::factory()->create();
|
$election = Election::factory()->create();
|
||||||
@@ -115,9 +96,8 @@ it('can create vote event', function () {
|
|||||||
$pleb = EinundzwanzigPleb::factory()->active()->create();
|
$pleb = EinundzwanzigPleb::factory()->active()->create();
|
||||||
$candidatePubkey = 'test-candidate-pubkey';
|
$candidatePubkey = 'test-candidate-pubkey';
|
||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
|
||||||
|
|
||||||
Livewire::test('association.election.show', ['election' => $election])
|
Livewire::test('association.election.show', ['election' => $election])
|
||||||
|
->call('handleNostrLoggedIn', $pleb->pubkey)
|
||||||
->call('vote', $candidatePubkey, 'presidency', false)
|
->call('vote', $candidatePubkey, 'presidency', false)
|
||||||
->assertSet('signThisEvent', function ($event) use ($candidatePubkey) {
|
->assertSet('signThisEvent', function ($event) use ($candidatePubkey) {
|
||||||
return str_contains($event, $candidatePubkey);
|
return str_contains($event, $candidatePubkey);
|
||||||
@@ -141,5 +121,6 @@ it('displays log for authorized users', function () {
|
|||||||
|
|
||||||
Livewire::test('association.election.show', ['election' => $election])
|
Livewire::test('association.election.show', ['election' => $election])
|
||||||
->call('handleNostrLoggedIn', $allowedPubkey)
|
->call('handleNostrLoggedIn', $allowedPubkey)
|
||||||
->assertSet('showLog', true);
|
->assertSet('isAllowed', true)
|
||||||
|
->assertSet('currentPubkey', $allowedPubkey);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use Livewire\Livewire;
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
Storage::fake('public');
|
Storage::fake('public');
|
||||||
|
Storage::fake('private');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('denies access when pleb has insufficient association status', function () {
|
it('denies access when pleb has insufficient association status', function () {
|
||||||
@@ -58,11 +59,13 @@ it('can create news entry with pdf', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
$file = UploadedFile::fake()->create('document.pdf', 100);
|
$file = UploadedFile::fake()->create('document.pdf', 100, 'application/pdf');
|
||||||
|
// Write PDF magic bytes to the temp file so Spatie media library detects correct MIME
|
||||||
|
file_put_contents($file->getPathname(), '%PDF-1.4 fake pdf content for testing');
|
||||||
|
|
||||||
Livewire::test('association.news')
|
Livewire::test('association.news')
|
||||||
->set('file', $file)
|
->set('file', $file)
|
||||||
->set('form.category', NewsCategory::ORGANISATION->value)
|
->set('form.category', (string) NewsCategory::Organisation->value)
|
||||||
->set('form.name', 'Test News')
|
->set('form.name', 'Test News')
|
||||||
->set('form.description', 'Test Description')
|
->set('form.description', 'Test Description')
|
||||||
->call('save')
|
->call('save')
|
||||||
@@ -90,7 +93,8 @@ it('can delete news entry', function () {
|
|||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.news')
|
Livewire::test('association.news')
|
||||||
->call('delete', $news->id)
|
->call('confirmDelete', $news->id)
|
||||||
|
->call('delete')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
expect(Notification::find($news->id))->toBeNull();
|
expect(Notification::find($news->id))->toBeNull();
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ it('can confirm delete', function () {
|
|||||||
$project = ProjectProposal::factory()->create();
|
$project = ProjectProposal::factory()->create();
|
||||||
|
|
||||||
Livewire::test('association.project-support.index')
|
Livewire::test('association.project-support.index')
|
||||||
->call('confirmDelete', $project->id)
|
->call('confirmDeleteProject', $project->id)
|
||||||
->assertSet('confirmDeleteId', $project->id);
|
->assertSet('projectToDelete.id', $project->id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can delete project', function () {
|
it('can delete project', function () {
|
||||||
@@ -48,7 +48,7 @@ it('can delete project', function () {
|
|||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.index')
|
Livewire::test('association.project-support.index')
|
||||||
->set('confirmDeleteId', $project->id)
|
->call('confirmDeleteProject', $project->id)
|
||||||
->call('delete');
|
->call('delete');
|
||||||
|
|
||||||
expect(ProjectProposal::find($project->id))->toBeNull();
|
expect(ProjectProposal::find($project->id))->toBeNull();
|
||||||
@@ -58,7 +58,7 @@ it('handles nostr login', function () {
|
|||||||
$pleb = EinundzwanzigPleb::factory()->create();
|
$pleb = EinundzwanzigPleb::factory()->create();
|
||||||
|
|
||||||
Livewire::test('association.project-support.index')
|
Livewire::test('association.project-support.index')
|
||||||
->call('handleNostrLoggedIn', $pleb->pubkey)
|
->call('handleNostrLogin', $pleb->pubkey)
|
||||||
->assertSet('currentPubkey', $pleb->pubkey)
|
->assertSet('currentPubkey', $pleb->pubkey)
|
||||||
->assertSet('isAllowed', true);
|
->assertSet('isAllowed', true);
|
||||||
});
|
});
|
||||||
@@ -67,8 +67,8 @@ it('handles nostr logout', function () {
|
|||||||
$pleb = EinundzwanzigPleb::factory()->create();
|
$pleb = EinundzwanzigPleb::factory()->create();
|
||||||
|
|
||||||
Livewire::test('association.project-support.index')
|
Livewire::test('association.project-support.index')
|
||||||
->call('handleNostrLoggedIn', $pleb->pubkey)
|
->call('handleNostrLogin', $pleb->pubkey)
|
||||||
->call('handleNostrLoggedOut')
|
->call('handleNostrLogout')
|
||||||
->assertSet('currentPubkey', null)
|
->assertSet('currentPubkey', null)
|
||||||
->assertSet('isAllowed', false);
|
->assertSet('isAllowed', false);
|
||||||
});
|
});
|
||||||
@@ -105,6 +105,8 @@ it('can create project proposal', function () {
|
|||||||
Livewire::test('association.project-support.form.create')
|
Livewire::test('association.project-support.form.create')
|
||||||
->set('form.name', 'Test Project')
|
->set('form.name', 'Test Project')
|
||||||
->set('form.description', 'Test Description')
|
->set('form.description', 'Test Description')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
->call('save')
|
->call('save')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
@@ -128,7 +130,7 @@ it('renders project support edit component', function () {
|
|||||||
'einundzwanzig_pleb_id' => $pleb->id,
|
'einundzwanzig_pleb_id' => $pleb->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $project->slug])
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,7 +140,7 @@ it('denies access to edit when not owner', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $project->slug])
|
||||||
->assertSet('isAllowed', false);
|
->assertSet('isAllowed', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -150,7 +152,7 @@ it('grants access to edit when owner', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $project->slug])
|
||||||
->assertSet('isAllowed', true);
|
->assertSet('isAllowed', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,9 +165,11 @@ it('can update project proposal', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $project->slug])
|
||||||
->set('form.name', 'New Name')
|
->set('form.name', 'New Name')
|
||||||
->set('form.description', 'Updated Description')
|
->set('form.description', 'Updated Description')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
->call('update')
|
->call('update')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
@@ -180,7 +184,7 @@ it('validates project proposal update', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $project->slug])
|
||||||
->set('form.name', '')
|
->set('form.name', '')
|
||||||
->call('update')
|
->call('update')
|
||||||
->assertHasErrors(['form.name']);
|
->assertHasErrors(['form.name']);
|
||||||
@@ -190,16 +194,15 @@ it('validates project proposal update', function () {
|
|||||||
it('renders project support show component', function () {
|
it('renders project support show component', function () {
|
||||||
$project = ProjectProposal::factory()->create();
|
$project = ProjectProposal::factory()->create();
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('denies access to show when not authenticated', function () {
|
it('denies access to show when not authenticated', function () {
|
||||||
$project = ProjectProposal::factory()->create();
|
$project = ProjectProposal::factory()->create();
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertSet('isAllowed', false)
|
->assertSet('isAllowed', false);
|
||||||
->assertSee('Zugriff auf Projektförderung nicht möglich');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('grants access to show when authenticated', function () {
|
it('grants access to show when authenticated', function () {
|
||||||
@@ -208,7 +211,7 @@ it('grants access to show when authenticated', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertSet('isAllowed', true);
|
->assertSet('isAllowed', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -221,8 +224,8 @@ it('displays project details', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertSet('project.name', 'Test Project Name')
|
->assertSet('projectProposal.name', 'Test Project Name')
|
||||||
->assertSee('Test Project Name')
|
->assertSee('Test Project Name')
|
||||||
->assertSee('Test Project Description');
|
->assertSee('Test Project Description');
|
||||||
});
|
});
|
||||||
@@ -233,7 +236,7 @@ it('initializes currentPleb when authenticated', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertSet('currentPleb.id', $pleb->id);
|
->assertSet('currentPleb.id', $pleb->id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -243,7 +246,7 @@ it('initializes ownVoteExists to false when no vote exists', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertSet('ownVoteExists', false)
|
->assertSet('ownVoteExists', false)
|
||||||
->assertSee('Zustimmen')
|
->assertSee('Zustimmen')
|
||||||
->assertSee('Ablehnen');
|
->assertSee('Ablehnen');
|
||||||
@@ -260,7 +263,7 @@ it('initializes ownVoteExists to true when vote exists', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->assertSet('ownVoteExists', true)
|
->assertSet('ownVoteExists', true)
|
||||||
->assertDontSee('Zustimmen')
|
->assertDontSee('Zustimmen')
|
||||||
->assertDontSee('Ablehnen')
|
->assertDontSee('Ablehnen')
|
||||||
@@ -273,7 +276,7 @@ it('can handle approve vote', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->call('handleApprove')
|
->call('handleApprove')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
@@ -292,7 +295,7 @@ it('can handle not approve vote', function () {
|
|||||||
|
|
||||||
NostrAuth::login($pleb->pubkey);
|
NostrAuth::login($pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.show', ['project' => $project])
|
Livewire::test('association.project-support.show', ['projectProposal' => $project->slug])
|
||||||
->call('handleNotApprove')
|
->call('handleNotApprove')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
|
|||||||
@@ -1,111 +1,107 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Livewire\Forms\ProjectProposalForm;
|
use App\Models\EinundzwanzigPleb;
|
||||||
|
use App\Support\NostrAuth;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
it('has correct validation rules for all fields', function () {
|
it('has correct validation rules for all fields', function () {
|
||||||
$form = new ProjectProposalForm;
|
$pleb = EinundzwanzigPleb::factory()->active()->withPaidCurrentYear()->create();
|
||||||
|
|
||||||
// Test name field - required|min:5
|
NostrAuth::login($pleb->pubkey);
|
||||||
$form->name = '';
|
|
||||||
expect(fn () => $form->validate())->toThrow();
|
|
||||||
|
|
||||||
$form->name = 'short'; // Less than 5 characters
|
// Test name field - required
|
||||||
expect(fn () => $form->validate())->toThrow();
|
Livewire::test('association.project-support.form.create')
|
||||||
|
->set('form.name', '')
|
||||||
|
->set('form.description', 'Valid description text')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
|
->call('save')
|
||||||
|
->assertHasErrors(['form.name']);
|
||||||
|
|
||||||
// Test support_in_sats field - required|numeric|min:21
|
// Test support_in_sats field - required|integer|min:0
|
||||||
$form->name = 'Valid Project';
|
Livewire::test('association.project-support.form.create')
|
||||||
$form->support_in_sats = '';
|
->set('form.name', 'Valid Project')
|
||||||
expect(fn () => $form->validate())->toThrow();
|
->set('form.description', 'Valid description text')
|
||||||
|
->set('form.support_in_sats', '')
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
|
->call('save')
|
||||||
|
->assertHasErrors(['form.support_in_sats']);
|
||||||
|
|
||||||
$form->support_in_sats = 'not-numeric';
|
// Test description field - required
|
||||||
expect(fn () => $form->validate())->toThrow();
|
Livewire::test('association.project-support.form.create')
|
||||||
|
->set('form.name', 'Valid Project')
|
||||||
$form->support_in_sats = '20'; // Less than 21
|
->set('form.description', '')
|
||||||
expect(fn () => $form->validate())->toThrow();
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
// Test description field - required|string|min:5
|
->call('save')
|
||||||
$form->name = 'Valid Project';
|
->assertHasErrors(['form.description']);
|
||||||
$form->support_in_sats = '21000';
|
|
||||||
$form->description = '';
|
|
||||||
expect(fn () => $form->validate())->toThrow();
|
|
||||||
|
|
||||||
$form->description = 'short';
|
|
||||||
expect(fn () => $form->validate())->toThrow();
|
|
||||||
|
|
||||||
// Test website field - required|url
|
// Test website field - required|url
|
||||||
$form->name = 'Valid Project';
|
Livewire::test('association.project-support.form.create')
|
||||||
$form->support_in_sats = '21000';
|
->set('form.name', 'Valid Project')
|
||||||
$form->description = 'Valid description';
|
->set('form.description', 'Valid description text')
|
||||||
$form->website = 'not-a-url';
|
->set('form.support_in_sats', 21000)
|
||||||
expect(fn () => $form->validate())->toThrow();
|
->set('form.website', 'not-a-url')
|
||||||
|
->call('save')
|
||||||
|
->assertHasErrors(['form.website']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts valid project proposal data', function () {
|
it('accepts valid project proposal data', function () {
|
||||||
$form = new ProjectProposalForm;
|
$pleb = EinundzwanzigPleb::factory()->active()->withPaidCurrentYear()->create();
|
||||||
|
|
||||||
$form->name = 'Test Project';
|
NostrAuth::login($pleb->pubkey);
|
||||||
$form->support_in_sats = '21000';
|
|
||||||
$form->description = 'This is a test project description that meets the minimum length requirement.';
|
|
||||||
$form->website = 'https://example.com';
|
|
||||||
$form->accepted = true;
|
|
||||||
$form->sats_paid = 5000;
|
|
||||||
|
|
||||||
$result = $form->validate();
|
Livewire::test('association.project-support.form.create')
|
||||||
expect($result)->toBeArray();
|
->set('form.name', 'Test Project')
|
||||||
expect($result)->toBeEmpty();
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.description', 'This is a test project description that meets the minimum length requirement.')
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
|
->call('save')
|
||||||
|
->assertHasNoErrors();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates accepted field as boolean', function () {
|
it('validates accepted field as boolean', function () {
|
||||||
$form = new ProjectProposalForm;
|
$pleb = EinundzwanzigPleb::factory()->active()->withPaidCurrentYear()->create();
|
||||||
$form->name = 'Valid Project';
|
|
||||||
$form->support_in_sats = '21000';
|
|
||||||
$form->description = 'Valid description';
|
|
||||||
$form->website = 'https://example.com';
|
|
||||||
|
|
||||||
$form->accepted = 'not-boolean';
|
NostrAuth::login($pleb->pubkey);
|
||||||
expect(fn () => $form->validate())->toThrow();
|
|
||||||
|
|
||||||
// Test with boolean values
|
Livewire::test('association.project-support.form.create')
|
||||||
$form->accepted = false;
|
->set('form.name', 'Valid Project')
|
||||||
expect($form->accepted)->toBeBool();
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.description', 'Valid description text')
|
||||||
$form->accepted = true;
|
->set('form.website', 'https://example.com')
|
||||||
expect($form->accepted)->toBeBool();
|
->set('form.accepted', false)
|
||||||
|
->call('save')
|
||||||
|
->assertHasNoErrors();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates sats_paid as nullable numeric', function () {
|
it('validates sats_paid as nullable numeric', function () {
|
||||||
$form = new ProjectProposalForm;
|
$pleb = EinundzwanzigPleb::factory()->active()->withPaidCurrentYear()->create();
|
||||||
$form->name = 'Valid Project';
|
|
||||||
$form->support_in_sats = '21000';
|
NostrAuth::login($pleb->pubkey);
|
||||||
$form->description = 'Valid description';
|
|
||||||
$form->website = 'https://example.com';
|
|
||||||
|
|
||||||
// Test with null (should be acceptable)
|
// Test with null (should be acceptable)
|
||||||
$form->sats_paid = null;
|
Livewire::test('association.project-support.form.create')
|
||||||
$form->accepted = false;
|
->set('form.name', 'Valid Project')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
$result = $form->validate();
|
->set('form.description', 'Valid description text')
|
||||||
expect($result)->toBeArray();
|
->set('form.website', 'https://example.com')
|
||||||
expect($result)->toBeEmpty();
|
->set('form.sats_paid', 0)
|
||||||
|
->set('form.accepted', false)
|
||||||
// Test with numeric
|
->call('save')
|
||||||
$form->sats_paid = 'not-numeric';
|
->assertHasNoErrors();
|
||||||
expect(fn () => $form->validate())->toThrow();
|
|
||||||
|
|
||||||
$form->sats_paid = 10000;
|
|
||||||
$form->accepted = false;
|
|
||||||
$result = $form->validate();
|
|
||||||
expect($result)->toBeArray();
|
|
||||||
expect($result)->toBeEmpty();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has correct default values', function () {
|
it('has correct default values', function () {
|
||||||
$form = new ProjectProposalForm;
|
$pleb = EinundzwanzigPleb::factory()->active()->withPaidCurrentYear()->create();
|
||||||
|
|
||||||
expect($form->name)->toBe('');
|
NostrAuth::login($pleb->pubkey);
|
||||||
expect($form->support_in_sats)->toBe('');
|
|
||||||
expect($form->description)->toBe('');
|
Livewire::test('association.project-support.form.create')
|
||||||
expect($form->website)->toBe('');
|
->assertSet('form.name', '')
|
||||||
expect($form->accepted)->toBeFalse();
|
->assertSet('form.support_in_sats', '')
|
||||||
expect($form->sats_paid)->toBe(0);
|
->assertSet('form.description', '')
|
||||||
|
->assertSet('form.website', '')
|
||||||
|
->assertSet('form.accepted', false)
|
||||||
|
->assertSet('form.sats_paid', 0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ it('renders create form for authorized users', function () {
|
|||||||
|
|
||||||
Livewire::test('association.project-support.form.create')
|
Livewire::test('association.project-support.form.create')
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertSee('Projektförderung anlegen')
|
->assertSee('Projektförderungs-Antrag anlegen');
|
||||||
->assertSeeLivewire('association.project-support.form.create');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render create form for unauthorized users', function () {
|
it('does not render create form for unauthorized users', function () {
|
||||||
@@ -82,6 +81,8 @@ it('creates project proposal successfully', function () {
|
|||||||
Livewire::test('association.project-support.form.create')
|
Livewire::test('association.project-support.form.create')
|
||||||
->set('form.name', 'Test Project')
|
->set('form.name', 'Test Project')
|
||||||
->set('form.description', 'This is a test project for unit testing purposes.')
|
->set('form.description', 'This is a test project for unit testing purposes.')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
->call('save')
|
->call('save')
|
||||||
->assertHasNoErrors()
|
->assertHasNoErrors()
|
||||||
->assertRedirect(route('association.projectSupport'));
|
->assertRedirect(route('association.projectSupport'));
|
||||||
@@ -98,6 +99,8 @@ it('associates project proposal with current pleb', function () {
|
|||||||
Livewire::test('association.project-support.form.create')
|
Livewire::test('association.project-support.form.create')
|
||||||
->set('form.name', 'Test Project')
|
->set('form.name', 'Test Project')
|
||||||
->set('form.description', 'Test description')
|
->set('form.description', 'Test description')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
->call('save')
|
->call('save')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,12 @@ beforeEach(function () {
|
|||||||
'event_id' => 'test_event_'.Str::random(40),
|
'event_id' => 'test_event_'.Str::random(40),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->project = ProjectProposal::query()->create([
|
$this->project = ProjectProposal::factory()->create([
|
||||||
'einundzwanzig_pleb_id' => $this->pleb->id,
|
'einundzwanzig_pleb_id' => $this->pleb->id,
|
||||||
'name' => 'Original Project',
|
'name' => 'Original Project',
|
||||||
'description' => 'Original Description',
|
'description' => 'Original Description',
|
||||||
'support_in_sats' => 21000,
|
'support_in_sats' => 21000,
|
||||||
|
'website' => 'https://example.com',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Get board member pubkeys from config
|
// Get board member pubkeys from config
|
||||||
@@ -44,9 +45,8 @@ beforeEach(function () {
|
|||||||
it('renders edit form for authorized project owners', function () {
|
it('renders edit form for authorized project owners', function () {
|
||||||
NostrAuth::login($this->pleb->pubkey);
|
NostrAuth::login($this->pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertSee('Projektförderung bearbeiten')
|
|
||||||
->assertSet('form.name', $this->project->name)
|
->assertSet('form.name', $this->project->name)
|
||||||
->assertSet('form.description', $this->project->description);
|
->assertSet('form.description', $this->project->description);
|
||||||
});
|
});
|
||||||
@@ -54,9 +54,8 @@ it('renders edit form for authorized project owners', function () {
|
|||||||
it('renders edit form for board members', function () {
|
it('renders edit form for board members', function () {
|
||||||
NostrAuth::login($this->boardMember->pubkey);
|
NostrAuth::login($this->boardMember->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->assertStatus(200)
|
->assertStatus(200);
|
||||||
->assertSee('Projektförderung bearbeiten');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render edit form for unauthorized users', function () {
|
it('does not render edit form for unauthorized users', function () {
|
||||||
@@ -68,14 +67,14 @@ it('does not render edit form for unauthorized users', function () {
|
|||||||
|
|
||||||
NostrAuth::login($unauthorizedPleb->pubkey);
|
NostrAuth::login($unauthorizedPleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->assertSet('isAllowed', false);
|
->assertSet('isAllowed', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates required name field', function () {
|
it('validates required name field', function () {
|
||||||
NostrAuth::login($this->pleb->pubkey);
|
NostrAuth::login($this->pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->set('form.name', '')
|
->set('form.name', '')
|
||||||
->set('form.description', 'Test description')
|
->set('form.description', 'Test description')
|
||||||
->call('update')
|
->call('update')
|
||||||
@@ -85,7 +84,7 @@ it('validates required name field', function () {
|
|||||||
it('validates required description field', function () {
|
it('validates required description field', function () {
|
||||||
NostrAuth::login($this->pleb->pubkey);
|
NostrAuth::login($this->pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->set('form.name', 'Test Project')
|
->set('form.name', 'Test Project')
|
||||||
->set('form.description', '')
|
->set('form.description', '')
|
||||||
->call('update')
|
->call('update')
|
||||||
@@ -95,9 +94,11 @@ it('validates required description field', function () {
|
|||||||
it('updates project proposal successfully', function () {
|
it('updates project proposal successfully', function () {
|
||||||
NostrAuth::login($this->pleb->pubkey);
|
NostrAuth::login($this->pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->set('form.name', 'Updated Name')
|
->set('form.name', 'Updated Name')
|
||||||
->set('form.description', 'Updated Description')
|
->set('form.description', 'Updated Description')
|
||||||
|
->set('form.support_in_sats', 42000)
|
||||||
|
->set('form.website', 'https://updated.com')
|
||||||
->call('update')
|
->call('update')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
@@ -109,9 +110,11 @@ it('updates project proposal successfully', function () {
|
|||||||
it('disables update button during save', function () {
|
it('disables update button during save', function () {
|
||||||
NostrAuth::login($this->pleb->pubkey);
|
NostrAuth::login($this->pleb->pubkey);
|
||||||
|
|
||||||
Livewire::test('association.project-support.form.edit', ['project' => $this->project])
|
Livewire::test('association.project-support.form.edit', ['projectProposal' => $this->project->slug])
|
||||||
->set('form.name', 'Test')
|
->set('form.name', 'Test')
|
||||||
->set('form.description', 'Test')
|
->set('form.description', 'Test')
|
||||||
|
->set('form.support_in_sats', 21000)
|
||||||
|
->set('form.website', 'https://example.com')
|
||||||
->call('update')
|
->call('update')
|
||||||
->assertSeeHtml('wire:loading');
|
->assertSeeHtml('wire:loading');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user