Skip to content

Commit d623fc5

Browse files
committed
wip
1 parent 8c1b903 commit d623fc5

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

app/Filament/Resources/Posts/PostResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static function table(Table $table): Table
174174
->hidden(fn (Post $post): bool => ! $post->is_published),
175175

176176
Action::make('generate thumbnail')
177-
->action(fn (Post $post) => CreateOgImageJob::dispatch($post)),
177+
->action(fn (Post $post) => CreateOgImageJob::dispatchSync($post)),
178178
]),
179179
])
180180
->toolbarActions([

app/Models/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function scopeDefaultOrder(Builder $query): Builder
5858
{
5959
return $query
6060
->orderByDesc('is_featured')
61-
->orderByDesc('published_at');
61+
->orderByDesc('created_at');
6262
}
6363

6464
/**

tests/Feature/Filament/Resources/Posts/ListPostsTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,13 @@
267267
$post = Post::factory()->create();
268268

269269
livewire(ListPosts::class)
270-
->callTableAction('generate thumbnail', $post);
270+
->assertActionExists(TestAction::make('generate thumbnail')->table($post));
271271

272-
Queue::assertPushed(CreateOgImageJob::class, function ($job) use ($post) {
273-
return $job->post->id === $post->id;
274-
});
272+
livewire(ListPosts::class)
273+
->callAction(TestAction::make('generate thumbnail')->table($post));
274+
275+
Queue::assertPushedTimes(CreateOgImageJob::class, 1);
276+
Queue::assertPushed(CreateOgImageJob::class, fn ($job) => $job->post->id === $post->id);
275277
});
276278

277279
it('can bulk generate thumbnails', function () {
@@ -281,10 +283,13 @@
281283

282284
$posts = Post::factory()->count(3)->create();
283285

286+
livewire(ListPosts::class)
287+
->assertActionExists(TestAction::make('generate thumbnails')->table()->bulk());
288+
284289
livewire(ListPosts::class)
285290
->assertCanSeeTableRecords($posts)
286291
->selectTableRecords($posts)
287292
->callAction(TestAction::make('generate thumbnails')->table()->bulk());
288293

289-
Queue::assertPushed(CreateOgImageJob::class, 3);
294+
Queue::assertPushedTimes(CreateOgImageJob::class, 3);
290295
});

tests/Feature/Http/Controllers/ProjectControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
use App\Models\Project;
66

77
it('can load project index page', function (): void {
8-
Project::factory()->published()->create(['title' => 'Project A', 'is_featured' => false]);
9-
Project::factory()->published()->create(['title' => 'Project B', 'is_featured' => false]);
10-
Project::factory()->published()->create(['title' => 'Project C', 'is_featured' => false]);
8+
Project::factory()->published()->create(['title' => 'Project A', 'is_featured' => false, 'created_at' => '2024-01-01 00:00:00']);
9+
Project::factory()->published()->create(['title' => 'Project B', 'is_featured' => false, 'created_at' => '2024-01-02 00:00:00']);
10+
Project::factory()->published()->create(['title' => 'Project C', 'is_featured' => false, 'created_at' => '2024-01-03 00:00:00']);
1111

1212
$this->get('/projects')
1313
->assertOk()

0 commit comments

Comments
 (0)