Testing ImportAction within a table headerActions

Scenario: I have a livewire component using filament table with the headerActions of ImportAction. I have a csv file that when uploaded, will update the database with the values within in.

A snippet of my table:
public function table(Table $table): Table
    {
        return $table
            ->query(Model::query()->orderByDesc('created_at'))
            ->columns($this->table_columns())
            ->headerActions([
                ImportAction::make()
                    ->name('import_choices')
                    ->importer(DatasetImporter::class),
            ]);
    }


My test
/** @test */
    public function test_example()
    {
        $this->csv  = file_get_contents(base_path('tests/data/mapping_data/filament_import.csv'));
        $this->file = UploadedFile::fake()->createWithContent('filament_import.csv', $this->csv);
        // given that my field does not have a field choice
        $this->assertNull($this->field->choice_id);
        $this->assertCount(0, Import::get());

        // when I import the file
        Livewire::test(RedcapBackfillMissingOptionsComponent::class)
            ->callTableAction('import_choices'); // what do I need to be passing through here?

        // then my field should have a field choice
        $this->assertCount(1, Import::get());
        $this->assertEquals($this->choice->id, $this->field->fresh()->choice_id);
    }


Problem: when I ->callTableAction('import_choices'), I know I can pass through the $record, $data, $arguments from drilling into it, but I'm not too sure what I need to pass in order to get my import, and see that the $this->field->choice_id is set.

When I run my test currently, I don't get any errors but my Import count is 0.

How do I test this import?
Was this page helpful?