arthurtavaresdev/pest-plugin-nova

This package is abandoned and no longer maintained. No replacement package was suggested.

Pest Plugin for Laravel Nova

dev-master / 1.x-dev 2022-02-21 17:54 UTC

This package is auto-updated.

Last update: 2022-12-21 19:34:01 UTC


README

Author PHP Version Laravel Version Laravel Nova

Install

Via Composer

composer require --dev arthurtavaresdev/pest-plugin-nova

Usage

Once the plugin is installed you are ready to go! Combine the elegant syntax of Pest and Nova Assertions:

Assertions

For more details about assertions you can check the original package.

beforeEach(function () {
    Order::factory()->count(10)->create();
    $this->be(User::factory()->create());
});

test('index orders')
    ->novaIndex('orders')
    ->assertOk()
    // assert resources
    ->assertResources(fn($resources) => $resources->count() === 10)
    // assert cards
    ->assertCardCount(3)
    ->assertCardsInclude(OrderAmountPerDay::class)
    ->assertCardsInclude(OrderPerMerchant::class)
    ->assertCardsInclude(OrderPerStatus::class)
    // assert actions
    ->assertActionCount(1)
    ->assertActionsInclude(CancelOrderAction::class)
    // assert filters
    ->assertFilterCount(2)
    ->assertFiltersInclude(OrderStatusFilter::class)
    ->assertFiltersInclude(MerchantFilter::class)
    // assert fields
    ->assertFieldsInclude(['id', 'status', 'amount', 'created_at'])
    ->assertFieldsExclude(['external_id', 'currency'])
    // assert policies
    ->assertCanView()
    ->assertCanCreate()
    ->assertCanUpdate()
    ->assertCanDelete()
    ->assertCannotForceDelete()
    ->assertCannotRestore();
    ...

Expectations

[WIP]

    test('can index orders', function () {
       expect($this->novaIndex('orders')
           ->toBeCardsCount(3)
           ->toBeCardInclude(OrderAmountPerDay::class)
   });

    test('can update order', function () {
       expect($this->novaEdit('orders', Order::factory()->create()->id))
           ->toBeField('merchant')
           ->toBeField('shopper')
           ->toBeField('amount')
           ->toBeField('created_at')
           ->toBeField('tags');
   });
});

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email arthurabreu00@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.