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

Commit c05100a

Browse files
committed
Add action collectors to scoped component browser instances
1 parent c12c31e commit c05100a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Dusk/Browser.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\DuskDashboard\Dusk;
44

5+
use Closure;
56
use BeyondCode\DuskDashboard\BrowserActionCollector;
67

78
class Browser extends \Laravel\Dusk\Browser
@@ -61,6 +62,28 @@ public function refresh()
6162
return $browser;
6263
}
6364

65+
/** {@inheritdoc} */
66+
public function with($selector, Closure $callback)
67+
{
68+
$action_collector_callback = function ($browser) use ($callback) {
69+
$browser->setActionCollector($this->getActionCollector());
70+
71+
return $callback($browser);
72+
};
73+
74+
return parent::with($selector, $action_collector_callback);
75+
}
76+
77+
/** {@inheritdoc} */
78+
public function onComponent($component, $parentResolver)
79+
{
80+
if ($this->getActionCollector() === null) {
81+
$this->setActionCollector(new BrowserActionCollector('dog'));
82+
}
83+
84+
parent::onComponent($component, $parentResolver);
85+
}
86+
6487
public function getCurrentPageSource()
6588
{
6689
$this->ensurejQueryIsAvailable();

0 commit comments

Comments
 (0)