From f131812d17e5a08c372b34464bee6b0c8064f25e Mon Sep 17 00:00:00 2001 From: Adam Weston Date: Sat, 27 Jan 2024 14:16:23 -0600 Subject: [PATCH] Fix: latest release breaking changes --- .github/workflows/build-assets.yml | 8 + .../{fix-php-code-styling.yml => lint.yml} | 7 +- .github/workflows/tests.yml | 54 +++++++ composer.json | 6 +- phpunit.xml.dist | 33 ++-- .../views/components/table-repeater.blade.php | 21 +-- src/Components/TableRepeater.php | 7 +- tests/ExampleTest.php | 5 - tests/TestCase.php | 40 ----- tests/database/factories/PageFactory.php | 18 +++ .../migrations/create_pages_table.php | 19 +++ tests/resources/views/fixtures/form.blade.php | 3 + tests/src/AdminPanelProvider.php | 48 ++++++ tests/src/ArchTest.php | 5 + tests/src/FieldTest.php | 103 +++++++++++++ tests/src/Fixtures/Livewire.php | 84 +++++++++++ tests/src/FormsTest.php | 142 ++++++++++++++++++ tests/src/Models/Page.php | 23 +++ tests/src/Resources/PageResource.php | 66 ++++++++ .../PageResource/Pages/CreatePage.php | 11 ++ .../Resources/PageResource/Pages/EditPage.php | 19 +++ .../PageResource/Pages/ListPages.php | 19 +++ tests/src/TestCase.php | 53 +++++++ 23 files changed, 710 insertions(+), 84 deletions(-) rename .github/workflows/{fix-php-code-styling.yml => lint.yml} (82%) create mode 100644 .github/workflows/tests.yml delete mode 100644 tests/ExampleTest.php delete mode 100644 tests/TestCase.php create mode 100644 tests/database/factories/PageFactory.php create mode 100644 tests/database/migrations/create_pages_table.php create mode 100644 tests/resources/views/fixtures/form.blade.php create mode 100644 tests/src/AdminPanelProvider.php create mode 100644 tests/src/ArchTest.php create mode 100644 tests/src/FieldTest.php create mode 100644 tests/src/Fixtures/Livewire.php create mode 100644 tests/src/FormsTest.php create mode 100644 tests/src/Models/Page.php create mode 100644 tests/src/Resources/PageResource.php create mode 100644 tests/src/Resources/PageResource/Pages/CreatePage.php create mode 100644 tests/src/Resources/PageResource/Pages/EditPage.php create mode 100644 tests/src/Resources/PageResource/Pages/ListPages.php create mode 100644 tests/src/TestCase.php diff --git a/.github/workflows/build-assets.yml b/.github/workflows/build-assets.yml index f0ec2c8..2df5113 100644 --- a/.github/workflows/build-assets.yml +++ b/.github/workflows/build-assets.yml @@ -2,8 +2,14 @@ name: "Build Assets" on: pull_request: + branches: + - 2.x types: - closed + paths: + - 'resources/views/**.php' + - 'resources/js/**.js' + - 'resources/css/**.css' jobs: if_merged: @@ -12,6 +18,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: Setup Node uses: actions/setup-node@v4 diff --git a/.github/workflows/fix-php-code-styling.yml b/.github/workflows/lint.yml similarity index 82% rename from .github/workflows/fix-php-code-styling.yml rename to .github/workflows/lint.yml index a428b70..aec9c9c 100644 --- a/.github/workflows/fix-php-code-styling.yml +++ b/.github/workflows/lint.yml @@ -2,17 +2,22 @@ name: "Fix PHP code styling" on: pull_request: + branches: + - 2.x types: - closed + paths: + - '**.php' jobs: if_merged: if: github.event.pull_request.merged == true runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: Fix PHP code style issues uses: aglipanci/laravel-pint-action@2.3.1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..a63a689 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,54 @@ +name: "Tests" + +on: + pull_request: + types: + - opened + branches: + - 2.x + paths: + - '**.php' + - '.github/workflows/run-tests.yml' + - 'phpunit.xml.dist' + - 'composer.json' + - 'composer.lock' + +jobs: + run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [8.2, 8.1] + laravel: [10.*] + dependency-version: [prefer-stable] + include: + - laravel: 10.* + testbench: 8.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: "Checkout code" + uses: actions/checkout@v4 + + - name: "Cache dependencies" + uses: actions/cache@v3 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, pdo, pdo_sqlite + coverage: none + + - name: "Install dependencies" + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "filament/filament" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: "Execute tests" + run: ./vendor/bin/pest diff --git a/composer.json b/composer.json index a71a52c..409ef74 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^8.1", - "filament/filament": "^3.0", + "filament/filament": "^3.1", "spatie/laravel-package-tools": "^1.13.5" }, "require-dev": { @@ -25,6 +25,7 @@ "nunomaduro/collision": "^7.0", "orchestra/testbench": "^8.0", "pestphp/pest": "^2.0", + "pestphp/pest-plugin-faker": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "pestphp/pest-plugin-livewire": "^2.0", "phpunit/phpunit": "^10.0", @@ -37,7 +38,8 @@ }, "autoload-dev": { "psr-4": { - "Awcodes\\FilamentTableRepeater\\Tests\\": "tests" + "Awcodes\\FilamentTableRepeater\\Tests\\": "tests/src", + "Awcodes\\FilamentTableRepeater\\Tests\\Database\\Factories\\": "tests/database/factories" } }, "scripts": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fcf08db..4d05e38 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,26 @@ - - tests + + ./tests/ - - - ./src - - - - - - - + + + + + diff --git a/resources/views/components/table-repeater.blade.php b/resources/views/components/table-repeater.blade.php index c059417..e73a086 100644 --- a/resources/views/components/table-repeater.blade.php +++ b/resources/views/components/table-repeater.blade.php @@ -1,5 +1,6 @@ @php use Filament\Forms\Components\Actions\Action; + $containers = $getChildComponentContainers(); $addAction = $getAction($getAddActionName()); @@ -20,7 +21,7 @@ $emptyLabel = $getEmptyLabel(); - $hasActions = $reorderAction->isVisible() || $cloneAction->isVisible() || $deleteAction->isVisible() || $moveUpAction->isVisible() || $moveDownAction->isVisible() || count($visibleExtraItemActions); + $visibleExtraItemActions = []; foreach ($containers as $uuid => $row) { $visibleExtraItemActions = array_filter( @@ -28,6 +29,13 @@ fn (Action $action): bool => $action(['item' => $uuid])->isVisible(), ); } + + $hasActions = $reorderAction->isVisible() + || $cloneAction->isVisible() + || $deleteAction->isVisible() + || $moveUpAction->isVisible() + || $moveDownAction->isVisible() + || filled($visibleExtraItemActions); @endphp @@ -45,7 +53,7 @@ ]) }} > @if (count($containers) || $emptyLabel !== false) -