Added tests to ensure every list page loads correctly
This commit is contained in:
parent
b2c8ce7405
commit
9ae273fda0
@ -86,7 +86,7 @@ public static function table(Table $table): Table
|
|||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->is_admin;
|
return auth()->user()->is_admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRelations(): array
|
public static function getRelations(): array
|
||||||
|
@ -137,7 +137,7 @@ public static function table(Table $table): Table
|
|||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('internal_id')
|
TextColumn::make('internal_id')
|
||||||
->extraHeaderAttributes(fn ($livewire) => $livewire::class === InvoicesRelationManager::class ? ['class' => 'w-full'] : false)
|
->extraHeaderAttributes(fn ($livewire) => $livewire::class === InvoicesRelationManager::class ? ['class' => 'w-full'] : [false])
|
||||||
->label('ID')
|
->label('ID')
|
||||||
->fontFamily('mono')
|
->fontFamily('mono')
|
||||||
->color('primary')
|
->color('primary')
|
||||||
@ -265,7 +265,7 @@ public static function table(Table $table): Table
|
|||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->is_admin;
|
return auth()->user()->is_admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRelations(): array
|
public static function getRelations(): array
|
||||||
|
@ -86,7 +86,7 @@ public static function table(Table $table): Table
|
|||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->is_admin;
|
return auth()->user()->is_admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRelations(): array
|
public static function getRelations(): array
|
||||||
|
@ -113,7 +113,7 @@ public static function table(Table $table): Table
|
|||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->is_admin;
|
return auth()->user()->is_admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRelations(): array
|
public static function getRelations(): array
|
||||||
|
@ -87,7 +87,7 @@ public static function getRelations(): array
|
|||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->is_admin;
|
return auth()->user()->is_admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
|
@ -109,7 +109,7 @@ public static function table(Table $table): Table
|
|||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->is_admin;
|
return auth()->user()->is_admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRelations(): array
|
public static function getRelations(): array
|
||||||
|
19
tests/Unit/CustomerReportTest.php
Normal file
19
tests/Unit/CustomerReportTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\QuoteResource\Pages\ListQuotes;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListQuotes::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListQuotes::class)->assertForbidden();
|
||||||
|
});
|
14
tests/Unit/CustomerTest.php
Normal file
14
tests/Unit/CustomerTest.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\CustomerResource\Pages\ListCustomers;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListCustomers::class)->assertSuccessful();
|
||||||
|
});
|
19
tests/Unit/InvoiceReportTest.php
Normal file
19
tests/Unit/InvoiceReportTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\InvoiceReportResource\Pages\ListInvoiceReports;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListInvoiceReports::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListInvoiceReports::class)->assertForbidden();
|
||||||
|
});
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\Enums\InvoiceStatus;
|
use App\Enums\InvoiceStatus;
|
||||||
use App\Filament\Admin\Resources\InvoiceResource\Pages\CreateInvoice;
|
use App\Filament\Admin\Resources\InvoiceResource\Pages\CreateInvoice;
|
||||||
|
use App\Filament\Admin\Resources\InvoiceResource\Pages\ListInvoices;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
@ -10,8 +11,20 @@
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
uses(RefreshDatabase::class);
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListInvoices::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListInvoices::class)->assertForbidden();
|
||||||
|
});
|
||||||
|
|
||||||
it('can create an invoice', function () {
|
it('can create an invoice', function () {
|
||||||
$user = User::factory(['is_admin' => true])->create();
|
$user = User::factory(['is_admin' => true])->create();
|
||||||
$this->actingAs($user);
|
$this->actingAs($user);
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
use App\Enums\OrderAttributes;
|
use App\Enums\OrderAttributes;
|
||||||
use App\Enums\OrderStatus;
|
use App\Enums\OrderStatus;
|
||||||
use App\Enums\OrderType;
|
use App\Enums\OrderType;
|
||||||
use App\Filament\Admin\Resources\OrderResource\Pages\CreateOrder;
|
use App\Filament\Admin\Resources\OrderResource\Pages\CreateOrder;
|
||||||
|
use App\Filament\Admin\Resources\OrderResource\Pages\ListOrders;
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
@ -21,6 +20,10 @@
|
|||||||
|
|
||||||
uses(DatabaseMigrations::class);
|
uses(DatabaseMigrations::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
livewire(ListOrders::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
it('can create an order and all associated models and save it to the database', function () {
|
it('can create an order and all associated models and save it to the database', function () {
|
||||||
$type = fake()->randomElement(OrderType::cases());
|
$type = fake()->randomElement(OrderType::cases());
|
||||||
$status = fake()->randomElement(OrderStatus::cases());
|
$status = fake()->randomElement(OrderStatus::cases());
|
||||||
|
14
tests/Unit/PackingSlipTest.php
Normal file
14
tests/Unit/PackingSlipTest.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\PackingSlipResource\Pages\ListPackingSlips;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListPackingSlips::class)->assertSuccessful();
|
||||||
|
});
|
@ -3,6 +3,9 @@
|
|||||||
use App\Filament\Admin\Resources\PaymentResource\Pages\CreatePayment;
|
use App\Filament\Admin\Resources\PaymentResource\Pages\CreatePayment;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
it('can create a payment', function () {
|
it('can create a payment', function () {
|
||||||
$user = User::factory(['is_admin' => true])->create();
|
$user = User::factory(['is_admin' => true])->create();
|
||||||
|
19
tests/Unit/ProductServiceTest.php
Normal file
19
tests/Unit/ProductServiceTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\ServiceTypeResource\Pages\ListServiceTypes;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListServiceTypes::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListServiceTypes::class)->assertForbidden();
|
||||||
|
});
|
19
tests/Unit/QuoteTest.php
Normal file
19
tests/Unit/QuoteTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\QuoteResource\Pages\ListQuotes;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListQuotes::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListQuotes::class)->assertForbidden();
|
||||||
|
});
|
14
tests/Unit/ShippingEntryTest.php
Normal file
14
tests/Unit/ShippingEntryTest.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\ShippingEntryResource\Pages\ListShippingEntries;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListShippingEntries::class)->assertSuccessful();
|
||||||
|
});
|
19
tests/Unit/TaxRateTest.php
Normal file
19
tests/Unit/TaxRateTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\TaxRateResource\Pages\ListTaxRates;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListTaxRates::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListTaxRates::class)->assertForbidden();
|
||||||
|
});
|
19
tests/Unit/UserTest.php
Normal file
19
tests/Unit/UserTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Admin\Resources\UserResource\Pages\ListUsers;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('can render the list page', function () {
|
||||||
|
$this->actingAs(User::factory(['is_admin' => true])->create());
|
||||||
|
livewire(ListUsers::class)->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cannot render the list page if user isn\'t an admin', function () {
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
livewire(ListUsers::class)->assertForbidden();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user