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

Laravel Dusk Testing not working #109

Open
Morinohtar opened this issue Apr 28, 2022 · 0 comments
Open

Laravel Dusk Testing not working #109

Morinohtar opened this issue Apr 28, 2022 · 0 comments

Comments

@Morinohtar
Copy link

  • noCaptcha Version: 13.0.0
  • Laravel Version: 9.9
  • PHP Version: 8.1

Using Vue for the form submission.

Also left the same comment in a topic that was already closed #39

Cant seem to make the test work with Dusk, though the Feature Test works fine.
Dont think the mock is working in Dusk...

If i log the response from the rule, it spits this:

`{"Arcanedev\\NoCaptcha\\Utilities\\ResponseV2":{"success":false,"hostname":null,"challenge_ts":null,"apk_package_name":null,"error-codes":["invalid-input-response"]}}`

So, the rule response comes as false.

Code:

    protected function ignoreCaptcha(string $name = 'g-recaptcha-response'): void
    {
        NoCaptchaFacade::shouldReceive('display')
            ->andReturn('<input type="textarea"  value="anything, really" name="' . $name . '">');
            
        NoCaptchaFacade::shouldReceive('script')
            ->andReturn('<script src="captcha.js"></script>');
            
        NoCaptchaFacade::shouldReceive('verify')
            ->andReturn(NoCaptchaFacade::getFacadeRoot());
            
        NoCaptchaFacade::shouldReceive('isSuccess')
            ->andReturn(true);
    }

    /** @test */
    public function it_submits_contact_form()
    {
        $this->ignoreCaptcha();

        $this->browse(function (Browser $browser) {
            $browser->visitRoute('contact')
                ->type('name', $this->faker->name)
                ->type('email', $this->faker->safeEmail)
                ->type('message', $this->faker->paragraphs(3, true))
                ->fillHidden('g-recaptcha-response', '1')
                ->pressAndWaitFor('Submit', 3)
                ->assertSee('Message sent!');
        });
    }
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