Skip to content

Commit e8d0ce0

Browse files
committed
revert
1 parent a505992 commit e8d0ce0

File tree

2 files changed

+67
-7
lines changed

2 files changed

+67
-7
lines changed

app/Filament/Resources/PluginResource/Pages/EditPlugin.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,6 @@ protected function getHeaderActions(): array
221221
->send();
222222
}),
223223

224-
Actions\Action::make('test')
225-
->label('Test')
226-
->color('primary')
227-
->action(function (): void {
228-
logger('TEST');
229-
}),
230-
231224
Actions\Action::make('resync')
232225
->label('Re-sync from GitHub')
233226
->icon('heroicon-o-arrow-path')
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Tests\Feature\Filament;
4+
5+
use App\Filament\Resources\PluginResource\Pages\EditPlugin;
6+
use App\Jobs\SyncPlugin;
7+
use App\Models\Plugin;
8+
use App\Models\User;
9+
use Illuminate\Foundation\Testing\RefreshDatabase;
10+
use Illuminate\Support\Facades\Bus;
11+
use Livewire\Livewire;
12+
use Tests\TestCase;
13+
14+
class ResyncPluginActionTest extends TestCase
15+
{
16+
use RefreshDatabase;
17+
18+
private User $admin;
19+
20+
protected function setUp(): void
21+
{
22+
parent::setUp();
23+
24+
$this->admin = User::factory()->create(['email' => 'admin@test.com']);
25+
config(['filament.users' => ['admin@test.com']]);
26+
}
27+
28+
public function test_resync_action_dispatches_job(): void
29+
{
30+
Bus::fake([SyncPlugin::class]);
31+
32+
$plugin = Plugin::factory()->free()->approved()->create([
33+
'repository_url' => 'https://github.com/acme/test-plugin',
34+
]);
35+
36+
Livewire::actingAs($this->admin)
37+
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
38+
->callAction('resync')
39+
->assertNotified();
40+
41+
Bus::assertDispatched(SyncPlugin::class, function ($job) use ($plugin) {
42+
return $job->plugin->is($plugin);
43+
});
44+
}
45+
46+
public function test_resync_action_visible_when_repository_url_exists(): void
47+
{
48+
$plugin = Plugin::factory()->free()->approved()->create([
49+
'repository_url' => 'https://github.com/acme/test-plugin',
50+
]);
51+
52+
Livewire::actingAs($this->admin)
53+
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
54+
->assertActionVisible('resync');
55+
}
56+
57+
public function test_resync_action_hidden_when_no_repository_url(): void
58+
{
59+
$plugin = Plugin::factory()->free()->approved()->create([
60+
'repository_url' => null,
61+
]);
62+
63+
Livewire::actingAs($this->admin)
64+
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
65+
->assertActionHidden('resync');
66+
}
67+
}

0 commit comments

Comments
 (0)