Git Product home page Git Product logo

filament-tests's Introduction

CodeWithDennis ๐Ÿ‘‹

Hey there! I'm thrilled to have you visit my GitHub profile. I'm Dennis, and I'm passionate about coding, creativity, and collaboration. Here's a little bit about me:

  • ๐Ÿ”ญ Currently working on: I'm diving deep into the world of Filament Plugins.
  • ๐Ÿ‘ฏ Looking to collaborate on: Well, pretty much anything!
  • ๐Ÿ’ผ Laravel Enthusiast: I specialize in working with Laravel related projects.

Support Me

If you find my work valuable or just want to show your appreciation, you can buy me a coffee! โ˜•๏ธ

"Buy Me A Coffee"

filament-tests's People

Contributors

codewithdennis avatar dissto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

filament-tests's Issues

Auto register stubs

Eliminating the step to manually add the stubs to the getStubs() would be nice

This would require some sort of ordering (perhaps by group + abc)

Generating a test for `UserResource` results in unexpected behaviour

Running as stated in the readme: php artisan filament:make-test UserResource will generate a new file named UserTest.php with content of:

use App\Filament\Resources\UserResource\Pages\ListUserResources;

use function Pest\Livewire\livewire;

it('can render the userresource list page', function () {
    livewire(ListUserResources::class)->assertSuccessful();
});

I think the expected result should be:

UserResourceTest.php with content:

use App\Filament\Resources\UserResource\Pages\ListUsers;

use function Pest\Livewire\livewire;

it('can render the UserResource list page', function () {
    livewire(ListUsers::class)->assertSuccessful();
});

Potential additional command arguments/options

Originally posted by dissto March 13, 2024

  • --outputName Alter the output name for a given test. Instead of {ResourceName}Test.php maybe WhatEverTest.php (probably need to ensure the "Test.php" suffix
  • --withoutActions Opt out of action tests
  • --onlyActions
  • --exceptActions
  • --withoutFilters Opt out of filter tests
  • --onlyFilters
  • --exceptFilters
  • --withoutWidgets Opt out of widget tests
  • --onlyWidgets
  • --exceptWidgets
  • --onlySearchableColumns
  • --withoutSearchableColumns
  • --exceptSearchableColumns
  • --onlyVisibleColumns
  • --withoutVisibleColumns
  • --exceptVisibleColumns
  • --onlySortableColumns
  • --withoutSortableColumns
  • --exceptSortableColumns
  • --onlyTogglableColumns
  • --withoutTogglableColumns
  • --exceptTogglableColumns
  • --onlySearchableColumns
  • --withoutSearchableColumns
  • --exceptSearchableColumns
  • --onlyIndividualSearchableColumns
  • --withoutIndividualSearchableColumns
  • --exceptIndividualSearchableColumns
  • --useTestInsteadOfIt Allow the user (for the sake of preference) to generate all tests with test() instead of it()
  • --only generate tests for the specified resource/s
  • --except generate tests expect the specified (comma separated)
  • --onlyGroups generate tests for a specified group (eg. "rendering", "auth" etc)
  • --exceptGroups
  • --withoutGroups
  • --outputDirectory #8
  • --all generate a test for ALL resources #80

May or may not want config settings for each argument/option

Add internal testing

Setting up a local project that satisfies every single possible test.

This should be high priority to confirm quality for upcoming PR's and reduce the time to actually review.

There is so much variability already -> with soft deletes, pages, actions, header actions, bulk actions, filters etc...That testing features manually seems very improbable.

Potential additional tests (apart from resources)

Originally posted by dissto March 16, 2024
Sky's the limit. Leaving just a few nuggets here ๐Ÿ˜Šย 

  • Widgets
  • Actions
  • Forms
    • Hints
  • Pages
  • Models
  • Policies
  • Relation Managers
  • Events
  • Observers
  • Multi-Tenancy
  • Notifications
  • Settings (Spatie)
  • File-Upload
  • Import/Export
  • Filters
  • Global Search
  • Navigation (Items)
  • Pagination

** all relative to the resource

Bug: `UserResource` shows wrong count -> failing tests

If the resource uses the User::class model (UserResource), the count and therefor the assertions are mismatched because of the user we generate in the beforeEach

Need to add an additional stub for the UserResource

Bug: Columns with enums can't be searched

FAILED Tests\Feature\BlogResourceTest > it can search column with data set "('status')"
Livewire\Features\SupportTesting\Testable::Filament\Tables\Testing\{closure}(): Argument #1 ($search) must be of type ?string, App\Enums\Status given, called in /vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php on line 123

Add `hasX` check

For better readability we should add helper methods to get rid off ->isNotEmpty() calls.

Example:

public function getShouldGenerate(): bool
{
    return $this->getResourceTableFilters($this->getResourceTable($this->resource))->isNotEmpty();
}

to

public function getShouldGenerate(): bool
{
    return $this->hasTableFilters();
}

Additionally we could add hasAnyTableFilter(array $filters) ... and similar

Add sanity checks for tests

We should add sanity checks like

expect({{ MODEL_SINGULAR_NAME }}::count())->toBe(X);

at the beginning of the test and throughout (where applicable)

Note: beforeEach's user

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.