Skip to content

Commit 6b48dc3

Browse files
committed
fix pest test
1 parent 6d0a480 commit 6b48dc3

5 files changed

Lines changed: 47 additions & 27 deletions

File tree

src/Models/User.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace SolutionForest\InspireCms\Models;
44

5+
use Filament\Panel;
56
use Illuminate\Support\Str;
67
use SolutionForest\InspireCms\InspireCmsConfig;
78
use SolutionForest\InspireCms\Models\Concerns\CmsUserTrait;
@@ -48,4 +49,9 @@ protected static function boot()
4849
}
4950
});
5051
}
52+
53+
public function canAccessPanel(Panel $panel): bool
54+
{
55+
return true;
56+
}
5157
}

tests/src/Feature/Livewire/ContentVersionHistoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ function getLivewireParams($content): array
2626
publishState: 'publish'
2727
);
2828
Livewire::test('inspirecms::content-version-history', getLivewireParams($content))
29-
->assertSee(__('inspirecms::resources/content-version.tables.search_placeholder'));
29+
// The translation contains an apostrophe which may be escaped in the HTML output.
30+
// Disable escaping in the assertion so the raw string is matched.
31+
->assertSee(__('inspirecms::resources/content-version.tables.search_placeholder'), $escape = false);
3032
});
3133

3234
test('rollback_content_version', function () {

tests/src/Feature/Resources/ExtraResourceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
use SolutionForest\InspireCms\Tests\Fixtures\Filament\Resources\PostResource\Pages\ListPosts;
44
use SolutionForest\InspireCms\Tests\TestCase;
5+
use function Pest\Livewire\livewire;
56

67
uses(TestCase::class);
78
pest()->group('feature', 'fi-resource');
89

910
beforeEach(function () {
1011
$this->createSuperAdminUser();
12+
$this->loginCmsPanelAsSuperAdmin();
1113
});
1214

1315
it('can have extra post resource', function () {

tests/src/Fixtures/Filament/Resources/PostResource.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
namespace SolutionForest\InspireCms\Tests\Fixtures\Filament\Resources;
44

5+
use BackedEnum;
56
use Filament\Resources\Resource;
7+
use Filament\Support\Icons\Heroicon;
8+
use Filament\Tables\Columns\TextColumn;
9+
use Filament\Tables\Table;
610
use SolutionForest\InspireCms\Filament\Clusters\Settings;
711
use SolutionForest\InspireCms\Filament\Concerns\ClusterSectionResourceTrait;
812
use SolutionForest\InspireCms\Filament\Contracts\ClusterSectionResource;
@@ -15,7 +19,7 @@ class PostResource extends Resource implements ClusterSectionResource
1519

1620
protected static ?string $model = Post::class;
1721

18-
protected static null | \BackedEnum | string $navigationIcon = 'heroicon-o-rectangle-stack';
22+
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
1923

2024
protected static ?string $cluster = Settings::class;
2125

@@ -25,4 +29,14 @@ public static function getPages(): array
2529
'index' => ListPosts::route('/'),
2630
];
2731
}
32+
33+
public static function table(Table $table): Table
34+
{
35+
return $table
36+
// ->query(Post::query())
37+
// ->recordKey('id')
38+
->columns([
39+
TextColumn::make('id')->label('ID')->sortable(),
40+
]);
41+
}
2842
}

tests/src/TestCase.php

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,38 +53,34 @@ protected function setUp(): void
5353
protected function getPackageProviders($app)
5454
{
5555
return [
56-
ActionsServiceProvider::class,
57-
BladeCaptureDirectiveServiceProvider::class,
58-
BladeHeroiconsServiceProvider::class,
59-
BladeIconsServiceProvider::class,
60-
BladeCssIconsServiceProvider::class,
61-
62-
FilamentServiceProvider::class,
63-
FormsServiceProvider::class,
64-
InfolistsServiceProvider::class,
65-
LivewireServiceProvider::class,
66-
NotificationsServiceProvider::class,
67-
SchemasServiceProvider::class,
68-
SupportServiceProvider::class,
69-
TablesServiceProvider::class,
70-
WidgetsServiceProvider::class,
56+
\BladeUI\Heroicons\BladeHeroiconsServiceProvider::class,
57+
\BladeUI\Icons\BladeIconsServiceProvider::class,
58+
59+
\Filament\Actions\ActionsServiceProvider::class,
60+
\Filament\FilamentServiceProvider::class,
61+
\Filament\Forms\FormsServiceProvider::class,
62+
\Filament\Infolists\InfolistsServiceProvider::class,
63+
\Filament\Notifications\NotificationsServiceProvider::class,
64+
\Filament\Schemas\SchemasServiceProvider::class,
65+
\Filament\Support\SupportServiceProvider::class,
66+
\Filament\Tables\TablesServiceProvider::class,
67+
\Filament\Widgets\WidgetsServiceProvider::class,
7168

72-
\Spatie\Permission\PermissionServiceProvider::class,
73-
74-
FilamentFieldGroupServiceProvider::class,
75-
76-
\Staudenmeir\LaravelAdjacencyList\IdeHelperServiceProvider::class,
69+
\Kalnoy\Nestedset\NestedSetServiceProvider::class,
70+
\Khatabwedaa\BladeCssIcons\BladeCssIconsServiceProvider::class,
7771
\Kirschbaum\PowerJoins\PowerJoinsServiceProvider::class,
7872

79-
\Kalnoy\Nestedset\NestedSetServiceProvider::class,
73+
\Livewire\LivewireServiceProvider::class,
8074

8175
\Pboivin\FilamentPeek\FilamentPeekServiceProvider::class,
76+
\RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider::class,
8277

83-
InspireCmsSupportServiceProvider::class,
84-
85-
InspireCmsServiceProvider::class,
86-
78+
\SolutionForest\FilamentFieldGroup\FilamentFieldGroupServiceProvider::class,
8779
\SolutionForest\InspireCms\CmsPanelProvider::class,
80+
\SolutionForest\InspireCms\InspireCmsServiceProvider::class,
81+
\SolutionForest\InspireCms\Support\InspireCmsSupportServiceProvider::class,
82+
83+
\Spatie\Permission\PermissionServiceProvider::class,
8884
];
8985
}
9086

0 commit comments

Comments
 (0)