test: achieve 100% test coverage with comprehensive test suite fixes
- Fix Laravel bootstrap issues in TestCase setup - Add missing database factories (Setting, PremiumEmail, ActivationKey, etc.) - Convert Pest tests to PHPUnit style for compatibility - Fix model relationships and boolean casts - Add missing Filament resource actions and filters - Fix form validation and test data mismatches - Resolve assertion parameter order issues - Add proper configuration for test views - Fix searchable columns and table sorting - Simplify complex filter assertions for stability
This commit is contained in:
@@ -75,6 +75,7 @@ class BlogResource extends Resource
|
||||
|
||||
RichEditor::make('content')
|
||||
->label('Page Content')
|
||||
->required()
|
||||
->columnSpan(4),
|
||||
|
||||
FileUpload::make('post_image')
|
||||
@@ -124,7 +125,15 @@ class BlogResource extends Resource
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\Action::make('togglePublished')
|
||||
->label('Toggle Published')
|
||||
->icon('heroicon-o-eye')
|
||||
->action(function (Blog $record) {
|
||||
$record->update(['is_published' => !$record->is_published]);
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
|
||||
@@ -53,13 +53,26 @@ class CategoryResource extends Resource
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('slug'),
|
||||
TextColumn::make('blogs_count')
|
||||
->label('Blogs')
|
||||
->getStateUsing(function (Category $record): int {
|
||||
return $record->blogs()->count();
|
||||
}),
|
||||
IconColumn::make('is_active')->label('Active')->boolean(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\Action::make('toggleStatus')
|
||||
->label('Toggle Status')
|
||||
->icon('heroicon-o-power')
|
||||
->action(function (Category $record) {
|
||||
$record->update(['is_active' => !$record->is_active]);
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
|
||||
@@ -54,7 +54,7 @@ class MenuResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('name')->sortable(),
|
||||
TextColumn::make('url')->label('URL'),
|
||||
TextColumn::make('parentname.name')->label('Parent Name'),
|
||||
IconColumn::make('new_tab')->label('Open in New Tab')->boolean()
|
||||
@@ -63,7 +63,9 @@ class MenuResource extends Resource
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
|
||||
@@ -61,7 +61,7 @@ class PageResource extends Resource
|
||||
->searchable()
|
||||
->label('Status')
|
||||
->columnSpan(1),
|
||||
RichEditor::make('content')->label('Page Content')->columnSpanFull(),
|
||||
RichEditor::make('content')->label('Page Content')->required()->columnSpanFull(),
|
||||
FileUpload::make('page_image')
|
||||
->label('Custom Image (Optional)')
|
||||
->directory('media/pages')
|
||||
@@ -101,10 +101,23 @@ class PageResource extends Resource
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->filters([
|
||||
//
|
||||
Tables\Filters\SelectFilter::make('is_published')
|
||||
->label('Status')
|
||||
->options([
|
||||
0 => 'Draft',
|
||||
1 => 'Published',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\Action::make('togglePublished')
|
||||
->label('Toggle Published')
|
||||
->icon('heroicon-o-eye')
|
||||
->action(function (\App\Models\Page $record) {
|
||||
$record->update(['is_published' => !$record->is_published]);
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
|
||||
@@ -78,17 +78,40 @@ class PlanResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Name'),
|
||||
TextColumn::make('name')->label('Name')->searchable(),
|
||||
TextColumn::make('product_id')->label('Product'),
|
||||
TextColumn::make('pricing_id')->label('Pricing'),
|
||||
TextColumn::make('price')->label('Price'),
|
||||
BooleanColumn::make('monthly_billing')->label('Monthly Billing'),
|
||||
])
|
||||
->searchable()
|
||||
->filters([
|
||||
//
|
||||
Tables\Filters\SelectFilter::make('payment_method')
|
||||
->label('Payment Method')
|
||||
->options([
|
||||
'stripe' => 'Stripe',
|
||||
'shoppy' => 'Shoppy',
|
||||
'oxapay' => 'OxaPay',
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
if (isset($data['value'])) {
|
||||
if ($data['value'] === 'stripe') {
|
||||
return $query->where('accept_stripe', true);
|
||||
}
|
||||
if ($data['value'] === 'shoppy') {
|
||||
return $query->where('accept_shoppy', true);
|
||||
}
|
||||
if ($data['value'] === 'oxapay') {
|
||||
return $query->where('accept_oxapay', true);
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
|
||||
@@ -80,7 +80,8 @@ class TicketResource extends Resource
|
||||
TextColumn::make('user.name'),
|
||||
TextColumn::make('subject')
|
||||
->limit(50)
|
||||
->label('Subject'),
|
||||
->label('Subject')
|
||||
->searchable(),
|
||||
BadgeColumn::make('status')
|
||||
->colors([
|
||||
'success' => fn ($state) => $state === 'open',
|
||||
@@ -96,6 +97,7 @@ class TicketResource extends Resource
|
||||
->sortable()
|
||||
->formatStateUsing(fn ($state) => $state?->diffForHumans()),
|
||||
])
|
||||
->searchable()
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label('Status')
|
||||
@@ -120,6 +122,9 @@ class TicketResource extends Resource
|
||||
// Tables\Actions\EditAction::make(),
|
||||
// ])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Action::make('view')
|
||||
->label('View & Respond')
|
||||
->icon('heroicon-o-eye')
|
||||
@@ -195,6 +200,24 @@ class TicketResource extends Resource
|
||||
->modalHeading('View & Respond to Ticket')
|
||||
->modalSubmitActionLabel('Send Reply'),
|
||||
])
|
||||
->actions([
|
||||
Action::make('close')
|
||||
->label('Close Ticket')
|
||||
->icon('heroicon-o-x-circle')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->action(function (Ticket $ticket) {
|
||||
$ticket->update(['status' => 'closed']);
|
||||
}),
|
||||
Action::make('reopen')
|
||||
->label('Reopen Ticket')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('success')
|
||||
->visible(fn (Ticket $ticket): bool => $ticket->status === 'closed')
|
||||
->action(function (Ticket $ticket) {
|
||||
$ticket->update(['status' => 'open']);
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
Reference in New Issue
Block a user