laravel / nova-dusk-suite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When testing filters on index components, test fail before reloading

victorpfm opened this issue · comments

I'm trying to test filters on index components. I'm using the Index page and IndexComponent from this repository in order to achieve this.

My test looks like this:

$see = create('App\Match', ['league' => Leagues::ATP]);
$dontSee = create('App\Match', ['league' => Leagues::WTA]);

$this->browse(function (Browser $browser) use ($see, $dontSee) {
    $browser->visit(new Index('matches')
        ->within(new IndexComponent('matches'), function (Browser $browser) use ($see, $dontSee) {
            $browser->applyFilters('league', $see->league);
            $browser->assertSeeResource($see->id);
            $browser->assertDontSeeResource($dontSee->id);
        });
});

The first error I got was:

Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body [dusk="jogos-index-component"] [dusk="filter-selector"]"}

Added an waitFor('@filter-selector') on the beginning of IndexComponent's applyFilters method.

Then I got another error:

Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body [dusk="jogos-index-component"] [dusk="1-row"]"}

It seems the assertion is being made even before the initial resources list is rendered, but I can't realize what I should wait for. Since Nova will now show loading indicators for the resource table when fetching new records on version 2.0.4, tried adding these to the end of applyFilters method without success:

$browser->waitUntilVue('loading', false)
$browser->waitUntilVue('$parent.loading', false)