Kimi chinh sua
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Resources\Products\ProductResource;
|
||||
use App\Filament\Resources\Products\Pages;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\Testing\Livewire;
|
||||
use Filament\Pages\Actions\DeleteAction as ActionsDeleteAction;
|
||||
use function Pest\Livewire\livewire;
|
||||
|
||||
beforeEach(function () {
|
||||
// Tạo user và đăng nhập để qua được middleware auth của Filament
|
||||
$this->actingAs(User::factory()->create());
|
||||
});
|
||||
|
||||
@@ -22,25 +19,24 @@ it('can render list products page', function () {
|
||||
it('can render create product page and has required fields', function () {
|
||||
$this->get(ProductResource::getUrl('create'))->assertStatus(200);
|
||||
|
||||
livewire(ProductResource\Pages\CreateProduct::class)
|
||||
livewire(Pages\CreateProduct::class)
|
||||
->assertFormExists()
|
||||
->assertFormFieldExists('code')
|
||||
->assertFormFieldExists('area');
|
||||
->assertFormFieldExists('code');
|
||||
});
|
||||
|
||||
it('can create a new product via livewire form', function () {
|
||||
$project = Project::factory()->create();
|
||||
|
||||
livewire(ProductResource\Pages\CreateProduct::class)
|
||||
->fillForm([
|
||||
'project_id' => $project->id,
|
||||
'product_type' => 'LAND',
|
||||
'code' => 'TEST-001',
|
||||
'area' => 100,
|
||||
'price_per_unit' => 50000000,
|
||||
'total_price' => 5000000000,
|
||||
'status' => 'Đang mở bán',
|
||||
])
|
||||
livewire(Pages\CreateProduct::class)
|
||||
->set('data.project_id', $project->id)
|
||||
->set('data.product_type', 'LAND')
|
||||
->set('data.code', 'TEST-001')
|
||||
->set('data.area', 100)
|
||||
->set('data.price_per_unit', 50000000)
|
||||
->set('data.total_price', 5000000000)
|
||||
->set('data.qsdd_value', 0)
|
||||
->set('data.foundation_temp_value', 0)
|
||||
->set('data.status', 'Đang mở bán')
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
@@ -55,12 +51,10 @@ it('can render edit page and update product data', function () {
|
||||
|
||||
$this->get(ProductResource::getUrl('edit', ['record' => $product]))->assertStatus(200);
|
||||
|
||||
livewire(ProductResource\Pages\EditProduct::class, [
|
||||
livewire(Pages\EditProduct::class, [
|
||||
'record' => $product->getRouteKey(),
|
||||
])
|
||||
->fillForm([
|
||||
'code' => 'NEW-CODE',
|
||||
])
|
||||
->set('data.code', 'NEW-CODE')
|
||||
->call('save')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
@@ -70,7 +64,7 @@ it('can render edit page and update product data', function () {
|
||||
it('can delete a product from edit page', function () {
|
||||
$product = Product::factory()->create();
|
||||
|
||||
livewire(ProductResource\Pages\EditProduct::class, [
|
||||
livewire(Pages\EditProduct::class, [
|
||||
'record' => $product->getRouteKey(),
|
||||
])
|
||||
->callAction(DeleteAction::class);
|
||||
|
||||
Reference in New Issue
Block a user