TimeglitchD
TimeglitchD
FFilament
Created by TimeglitchD on 10/16/2023 in #❓┊help
assertTableActionDataSet() on a form with FileUpload field
I got this form:
public static function form(Form $form): Form
{
return $form
->schema([
static::getNameFormField(),
Forms\Components\FileUpload::make('file')
->label(___('signeditor.files', 1))
->required()
->disk('fonts')
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string => (string) str($file->getClientOriginalName())
->prepend(Str::random(40))->replace(' ', '_')
),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
static::getNameFormField(),
Forms\Components\FileUpload::make('file')
->label(___('signeditor.files', 1))
->required()
->disk('fonts')
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string => (string) str($file->getClientOriginalName())
->prepend(Str::random(40))->replace(' ', '_')
),
]);
}
and this test:
it('can save', function () {
Storage::disk('fonts')->put($this->name, file_get_contents('storage/app/tests/' . $this->name));
Storage::disk('thumbnails')->put($this->thumbnail, file_get_contents('storage/app/tests/' . $this->thumbnail));
$record = $this->modelClass::factory()->create(['file' => $this->name]);
expect(Storage::disk('fonts')->path($record->file))->toBeReadableFile();
expect(Storage::disk('thumbnails')->path($record->thumbnail))->toBeReadableFile();

livewire($this->indexClass)
->mountTableAction(EditAction::class, $record)
->assertTableActionDataSet([
'name' => $record->name,
'file' => $record->file
])->callTableAction(EditAction::class, $record, data: ['name'=>$name = fake()->word(), 'file'=>$this->newFile])
->assertHasNoTableActionErrors();
it('can save', function () {
Storage::disk('fonts')->put($this->name, file_get_contents('storage/app/tests/' . $this->name));
Storage::disk('thumbnails')->put($this->thumbnail, file_get_contents('storage/app/tests/' . $this->thumbnail));
$record = $this->modelClass::factory()->create(['file' => $this->name]);
expect(Storage::disk('fonts')->path($record->file))->toBeReadableFile();
expect(Storage::disk('thumbnails')->path($record->thumbnail))->toBeReadableFile();

livewire($this->indexClass)
->mountTableAction(EditAction::class, $record)
->assertTableActionDataSet([
'name' => $record->name,
'file' => $record->file
])->callTableAction(EditAction::class, $record, data: ['name'=>$name = fake()->word(), 'file'=>$this->newFile])
->assertHasNoTableActionErrors();
** FAILED Tests\Feature\Resources\FontResourceTest** > it can save
** [...] does not match expected type "object".**
** FAILED Tests\Feature\Resources\FontResourceTest** > it can save
** [...] does not match expected type "object".**
Now, obviously, the
$record->file
$record->file
part is a string, while the form field is whatever object type FileUpload takes. I've tried to put an UploadedFile fake in there, but to no avail. Does anyone know how I'd test the FileUpload field?
2 replies
FFilament
Created by TimeglitchD on 10/5/2023 in #❓┊help
live() deletes my cropper instance, custom field
No description
5 replies
FFilament
Created by TimeglitchD on 9/6/2023 in #❓┊help
Alpine plugins and Filament scripts problem
I have an application where I am using a few of the Filament packages. I am also using custom Alpine packages in this app. Here's the problem: Filament asks me to replace @livewireScripts with @/filamentScripts, but Livewire asks me to change @livewireScripts into @livewireScriptConfig to make the custom Alpine plugins work... Using both means running two instances 🥲 How do I fix this?
4 replies
FFilament
Created by TimeglitchD on 9/6/2023 in #❓┊help
Refresh custom column after update to model
No description
4 replies
FFilament
Created by TimeglitchD on 8/17/2023 in #❓┊help
filamentphp/plugin-skeleton workflow test jobs failing (after fixing some errors)
Hi! I'm new to plugin development. I used the template and after fixing some things (like removing the unused spatie services and changing the non-existent Icon class) the test workflow on Github is still mostly failing. The only succesful workflow job is P8.2 - L10.* - prefer-stable - ubuntu-latest. The error I seem to be getting after the command vendor/bin/pest --ci:
PHP Fatal error: Uncaught Error: Call to undefined method PHPUnit\Event\Facade::instance() in /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/nunomaduro/collision/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php:306
Stack trace:
#0 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/nunomaduro/collision/src/Adapters/Phpunit/Autoload.php(11): NunoMaduro\Collision\Adapters\Phpunit\Subscribers\EnsurePrinterIsRegisteredSubscriber::register()
#1 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/composer/autoload_real.php(41): require('...')
#2 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/composer/autoload_real.php(45): {closure}()
#3 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/autoload.php(25): ComposerAutoloaderInit5db1f2f2862bb4049ece0aa2034dfe35::getLoader()
#4 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/pestphp/pest/bin/pest(61): include_once('...')
#5 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/pestphp/pest/bin/pest(100): {closure}()
#6 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/bin/pest(119): include('...')
#7 {main}
thrown in /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/nunomaduro/collision/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php on line 306
Error: Process completed with exit code 255.
PHP Fatal error: Uncaught Error: Call to undefined method PHPUnit\Event\Facade::instance() in /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/nunomaduro/collision/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php:306
Stack trace:
#0 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/nunomaduro/collision/src/Adapters/Phpunit/Autoload.php(11): NunoMaduro\Collision\Adapters\Phpunit\Subscribers\EnsurePrinterIsRegisteredSubscriber::register()
#1 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/composer/autoload_real.php(41): require('...')
#2 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/composer/autoload_real.php(45): {closure}()
#3 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/autoload.php(25): ComposerAutoloaderInit5db1f2f2862bb4049ece0aa2034dfe35::getLoader()
#4 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/pestphp/pest/bin/pest(61): include_once('...')
#5 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/pestphp/pest/bin/pest(100): {closure}()
#6 /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/bin/pest(119): include('...')
#7 {main}
thrown in /home/runner/work/filament-nested-resources/filament-nested-resources/vendor/nunomaduro/collision/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php on line 306
Error: Process completed with exit code 255.
How do I fix this one and get all jobs working?
6 replies
FFilament
Created by TimeglitchD on 8/16/2023 in #❓┊help
Using Vite and HMR without extending theme
I want to use Vite for my Filament development. I extended the basic theme and included it as a viteTheme on my panel and it's working perfectly. I'd like to know if it's possible to use Vite and HMR in Vite without extending the theme, as it requires some extra NPM packages that otherwise would already be included in the Filament package itself. I mostly just want to be able to reload my browser page as soon as I save a php or blade file 🙈
5 replies