Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertRelation returns 404 but Laravel Nova finds it correctly #30

Open
nbyloff opened this issue Aug 20, 2022 · 0 comments
Open

assertRelation returns 404 but Laravel Nova finds it correctly #30

nbyloff opened this issue Aug 20, 2022 · 0 comments

Comments

@nbyloff
Copy link

nbyloff commented Aug 20, 2022

I have a simple Team resource with fields like this:

BelongsToMany::make('Users')->searchable()
        ->fields(new TeamUserFields),
HasMany::make('Whitelist Ips'),

The Nova UI works just fine and I can save new IP address to the team as expected. However when I run the test below it works fine on the users relation but the whitelist ips throws the error below.

$response = $this->novaDetail('teams', $team->id);
$response->assertOk()
    ->assertRelation('users', function($users) {
      return $users->count() == 1;
    })
    ->assertRelation('whitelistIps', function($ips) {
      return $ips->count() == 0;
    });
  • Tests\Feature\Nova\UserResourceTest > team resource covered
   ErrorException

  Undefined array key "resources"

  at vendor/laravel/framework/src/Illuminate/View/View.php:323

When I look at the data property in the View class from the error above, it appears to show a 404 and is generating the nova-api incorrectly,

It's creating this with an incorrect resource URL slug:

/nova-api/whitelistIps?viaResource=teams&viaResourceId=1&viaRelationship=whitelistIps&relationshipType=hasMany

When it should be:

/nova-api/whitelist-ips?viaResource=teams&viaResourceId=1&viaRelationship=whitelistIps&relationshipType=hasMany

I have tried different variations of the relationship name, but that always returns "Field not found" error from this package. I am not sure how to get the resource name to generate correctly when using these tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant