dillingham / nova-assertions

Laravel Nova assertions for your tests
MIT License
79 stars 16 forks source link

assertCanView and asserCannotView #16

Closed asivaneswaran closed 3 years ago

asivaneswaran commented 3 years ago

Both these assertions don't work when I do this:

    public function testResponsibleCanViewOwnAssociationShow()
    {
        $this->be($this->responsible());
        $association = Association::factory()->create([
            'responsible_1_id' => $this->responsible()->member_id,
        ]);

        $response = $this->novaDetail('associations', $association->id);
        $response->assertCanView();
    }

I get this error:

Unable to find JSON fragment: 

[{"authorizedToView":true}]

And for this:

    public function testResponsibleCannotViewOtherAssociationShow()
    {
        $this->be($this->responsible());
        $association = Association::factory()->create([
            'responsible_1_id' => Member::factory(),
        ]);

        $response = $this->novaDetail('associations', $association->id);
        $response->assertCannotView();
    }

I get this error:

Unable to find JSON fragment: 

[{"authorizedToView":false}]

But the response I get is a AccessDeniedHttpException, so technically the test should pass.

I am on the latest version.