Skip to content

Commit 8276e6b

Browse files
committed
test: add tests for copy and view presentation actions
1 parent ef040af commit 8276e6b

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

app/Filament/Resources/PresentationResource/Pages/EditPresentation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ protected function getHeaderActions(): array
2222
->label('Save changes')
2323
->action('save'),
2424
Actions\ActionGroup::make([
25-
Actions\Action::make('View')
25+
Actions\Action::make('view')
26+
->label('View')
2627
->color('gray')
2728
->url(fn (Presentation $record): string => route('presentations.show', [
2829
'user' => $record->user->username,
2930
'slug' => $record->slug,
3031
]))
3132
->icon('heroicon-o-arrow-top-right-on-square')
3233
->openUrlInNewTab(),
33-
CopyAction::make('Copy Share URL')
34+
CopyAction::make('copyShareUrl')
3435
->label('Copy Share URL')
3536
->disabled(fn (Presentation $record) => ! $record->is_published)
3637
->color('gray')

tests/Filament/PresentationResourceTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,42 @@
432432

433433
Queue::assertNotPushed(GenerateThumbnail::class);
434434
});
435+
436+
it('can view the presentation', function () {
437+
$record = Model::factory()->create([
438+
'user_id' => $this->nonAdmin->id,
439+
]);
440+
441+
livewire(EditResource::class, [
442+
'record' => $record->getRouteKey(),
443+
])
444+
->assertActionHasUrl('view', route('presentations.show', [
445+
'user' => $record->user->username,
446+
'slug' => $record->slug,
447+
]))
448+
->assertActionShouldOpenUrlInNewTab('view');
449+
});
450+
451+
it('can copy the share url of a published presentation', function () {
452+
$record = Model::factory()->create([
453+
'user_id' => $this->nonAdmin->id,
454+
]);
455+
456+
livewire(EditResource::class, [
457+
'record' => $record->getRouteKey(),
458+
])
459+
->assertActionEnabled('copyShareUrl');
460+
});
461+
462+
it('can not copy the share url of a draft presentation', function () {
463+
$record = Model::factory()->create([
464+
'user_id' => $this->nonAdmin->id,
465+
'is_published' => false,
466+
]);
467+
468+
livewire(EditResource::class, [
469+
'record' => $record->getRouteKey(),
470+
])
471+
->assertActionDisabled('copyShareUrl');
472+
});
435473
});

0 commit comments

Comments
 (0)