Question about testing my OrderForm

I have an Order Form which I would like to test. So I have an OrderResource and the url to the form is: admin/orders/create I believe that this corresponds to: 'create' => Pages\CreateOrder::route('/create'),

So I wrote a test for this like so:
livewire(CreateOrder::class)
    ->fillForm([
        'brand_id' => $brand->id,
    ])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);

But when I run this I get:

Attempt to read property "form" on null.

at vendor/filament/forms/src/Testing/TestsForms.php:125
121▕ public function assertFormExists(): Closure
122{
123▕ return function (string $name = 'form'): static {
124/** @var ComponentContainer $form */
➜ 125$form = $this->instance()->{$name};
126
127$livewireClass = $this->instance()::class;
128
129Assert::assertInstanceOf(


MyCreateOrder class doesn't have a form property. I'm wondering where the $form property is set that renders the form when go to the aforementioned url

How can I solve this?

Thanks
Solution
you didn't login()
it('Can only select suppliers related to the brand', function () {
    login();

    $brand = Brand::factory()->create();
    $suppliers = Supplier::factory()
        ->count(2)
        ->hasAttached($brand)
        ->create();
    $this->get(OrderResource::getUrl('create'));
    livewire(CreateOrder::class)
        ->fillForm([
            'brand_id' => $brand->id,
        ])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
});
Was this page helpful?