Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Add action collectors to scoped component browser instances
Browse files Browse the repository at this point in the history
  • Loading branch information
nie7321 committed Jun 13, 2019
1 parent c12c31e commit 5451a7d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Dusk/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace BeyondCode\DuskDashboard\Dusk;

use Closure;
use BeyondCode\DuskDashboard\BrowserActionCollector;

class Browser extends \Laravel\Dusk\Browser
Expand Down Expand Up @@ -61,6 +62,28 @@ public function refresh()
return $browser;
}

/** {@inheritdoc} */
public function with($selector, Closure $callback)
{
$action_collector_callback = function ($browser) use ($callback) {
$browser->setActionCollector($this->getActionCollector());

return $callback($browser);
};

return parent::with($selector, $action_collector_callback);
}

/** {@inheritDoc} */
public function onComponent($component, $parentResolver)
{
if ($this->getActionCollector() === null) {
$this->setActionCollector(new BrowserActionCollector('dog'));
}

parent::onComponent($component, $parentResolver);
}

public function getCurrentPageSource()
{
$this->ensurejQueryIsAvailable();
Expand Down

0 comments on commit 5451a7d

Please sign in to comment.