add nova
This commit is contained in:
158
nova/src/Testing/Browser/Pages/Attach.php
Executable file
158
nova/src/Testing/Browser/Pages/Attach.php
Executable file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Nova\Testing\Browser\Components\SearchInputComponent;
|
||||
|
||||
class Attach extends Page
|
||||
{
|
||||
use InteractsWithRelations;
|
||||
|
||||
public $resourceName;
|
||||
|
||||
public $resourceId;
|
||||
|
||||
public $relation;
|
||||
|
||||
public $viaRelationship;
|
||||
|
||||
public $polymorphic = false;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param string $relation
|
||||
* @param string|null $viaRelationship
|
||||
* @param bool $polymorphic
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $resourceId, $relation, $viaRelationship = null, $polymorphic = false)
|
||||
{
|
||||
$this->relation = $relation;
|
||||
$this->resourceId = $resourceId;
|
||||
$this->resourceName = $resourceName;
|
||||
$this->viaRelationship = $viaRelationship;
|
||||
$this->polymorphic = $polymorphic;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/{$this->resourceId}/attach/{$this->relation}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new page instance for Belongs-to-Many.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param string $relation
|
||||
* @param string|null $viaRelationship
|
||||
* @return static
|
||||
*/
|
||||
public static function belongsToMany($resourceName, $resourceId, $relation, $viaRelationship = null)
|
||||
{
|
||||
return new static($resourceName, $resourceId, $relation, $viaRelationship);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new page instance for Morph-to-Many.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param string $relation
|
||||
* @param string|null $viaRelationship
|
||||
* @return static
|
||||
*/
|
||||
public static function morphToMany($resourceName, $resourceId, $relation, $viaRelationship = null)
|
||||
{
|
||||
return new static($resourceName, $resourceId, $relation, $viaRelationship, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
return $this->novaPageUrl.'?'.http_build_query([
|
||||
'viaRelationship' => $this->viaRelationship ?? $this->relation,
|
||||
'polymorphic' => $this->polymorphic === true ? 1 : 0,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the attachable resource with the given ID.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string|int $id
|
||||
* @return void
|
||||
*/
|
||||
public function selectAttachable(Browser $browser, $id)
|
||||
{
|
||||
$this->selectRelation($browser, 'attachable', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the attachable resource with the given ID.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string|int $id
|
||||
* @return void
|
||||
*/
|
||||
public function searchAttachable(Browser $browser, $id)
|
||||
{
|
||||
$browser->within(new SearchInputComponent($this->relation), function ($browser) use ($id) {
|
||||
$browser->searchFirstRelation($id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the attach button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function create(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@attach-button')
|
||||
->pause(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the update and continue editing button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function createAndAttachAnother(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@attach-and-attach-another-button')
|
||||
->pause(750);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the cancel button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function cancel(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@cancel-attach-button');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-form');
|
||||
}
|
||||
}
|
||||
88
nova/src/Testing/Browser/Pages/Create.php
Executable file
88
nova/src/Testing/Browser/Pages/Create.php
Executable file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class Create extends Page
|
||||
{
|
||||
use InteractsWithRelations;
|
||||
|
||||
public $resourceName;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $queryParams = [])
|
||||
{
|
||||
$this->resourceName = $resourceName;
|
||||
$this->queryParams = $queryParams;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/new");
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the create button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function create(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@create-button')
|
||||
->pause(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the create and add another button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function createAndAddAnother(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@create-and-add-another-button')
|
||||
->pause(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the cancel button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function cancel(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@cancel-create-button');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that there are no search results.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $resourceName
|
||||
* @return void
|
||||
*/
|
||||
public function assertNoRelationSearchResults(Browser $browser, $resourceName)
|
||||
{
|
||||
$browser->assertMissing('@'.$resourceName.'-search-input-result-0');
|
||||
}
|
||||
}
|
||||
46
nova/src/Testing/Browser/Pages/Dashboard.php
Normal file
46
nova/src/Testing/Browser/Pages/Dashboard.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class Dashboard extends Page
|
||||
{
|
||||
public $dashboardName;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $dashboardName
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($dashboardName = 'main')
|
||||
{
|
||||
$this->dashboardName = $dashboardName;
|
||||
|
||||
$this->setNovaPage("/dashboards/{$this->dashboardName}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@nova-dashboard' => "[dusk='dashboard-{$this->dashboardName}']",
|
||||
];
|
||||
}
|
||||
}
|
||||
242
nova/src/Testing/Browser/Pages/Detail.php
Executable file
242
nova/src/Testing/Browser/Pages/Detail.php
Executable file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Nova\Testing\Browser\Components\ActionDropdownComponent;
|
||||
use Laravel\Nova\Testing\Browser\Components\IndexComponent;
|
||||
use Laravel\Nova\Testing\Browser\Components\Modals\DeleteResourceModalComponent;
|
||||
use Laravel\Nova\Testing\Browser\Components\Modals\RestoreResourceModalComponent;
|
||||
|
||||
class Detail extends Page
|
||||
{
|
||||
public $resourceName;
|
||||
|
||||
public $resourceId;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $resourceId, $queryParams = [])
|
||||
{
|
||||
$this->resourceId = $resourceId;
|
||||
$this->resourceName = $resourceName;
|
||||
$this->queryParams = $queryParams;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/{$this->resourceId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the action with the given URI key.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $uriKey
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function runAction(Browser $browser, $uriKey)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->elsewhereWhenAvailable(new ActionDropdownComponent(), function ($browser) use ($uriKey) {
|
||||
$browser->runWithConfirmation($uriKey);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the action with the given URI key.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $uriKey
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function runInstantAction(Browser $browser, $uriKey)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->elsewhereWhenAvailable(new ActionDropdownComponent(), function ($browser) use ($uriKey) {
|
||||
$browser->runWithoutConfirmation($uriKey);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the action modal but cancel the action.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $uriKey
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function cancelAction(Browser $browser, $uriKey)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->elsewhereWhenAvailable(new ActionDropdownComponent(), function ($browser) use ($uriKey) {
|
||||
$browser->cancel($uriKey);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function edit(Browser $browser)
|
||||
{
|
||||
$browser->waitFor('@edit-resource-button')
|
||||
->click('@edit-resource-button');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the related resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $relatedResourceName
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function runCreateRelation(Browser $browser, $relatedResourceName)
|
||||
{
|
||||
$browser->within(new IndexComponent($relatedResourceName), function ($browser) {
|
||||
$browser->waitFor('@create-button')->click('@create-button');
|
||||
})->on(new Create($relatedResourceName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the related resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $relatedResourceName
|
||||
* @param string|null $viaRelationship
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function runAttachRelation(Browser $browser, $relatedResourceName, $viaRelationship = null)
|
||||
{
|
||||
$browser->within(new IndexComponent($relatedResourceName, $viaRelationship), function ($browser) {
|
||||
$browser->waitFor('@attach-button')->click('@attach-button');
|
||||
})->on(new Attach($this->resourceName, $this->resourceId, $relatedResourceName, $viaRelationship));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the delete selector.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function openControlSelector(Browser $browser)
|
||||
{
|
||||
$browser->whenAvailable("@{$this->resourceId}-control-selector", function ($browser) {
|
||||
$browser->click('');
|
||||
})->pause(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replicate the resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function replicate(Browser $browser)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->whenAvailable("@{$this->resourceId}-replicate-button", function ($browser) {
|
||||
$browser->click('');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function delete(Browser $browser)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->whenAvailable('@open-delete-modal-button', function ($browser) {
|
||||
$browser->click('');
|
||||
})
|
||||
->elsewhereWhenAvailable(new DeleteResourceModalComponent(), function ($browser) {
|
||||
$browser->confirm();
|
||||
})->pause(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function restore(Browser $browser)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->whenAvailable('@open-restore-modal-button', function ($browser) {
|
||||
$browser->click('');
|
||||
})
|
||||
->elsewhereWhenAvailable(new RestoreResourceModalComponent(), function ($browser) {
|
||||
$browser->confirm();
|
||||
})->pause(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force delete the resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function forceDelete(Browser $browser)
|
||||
{
|
||||
$browser->openControlSelector()
|
||||
->whenAvailable('@open-force-delete-modal-button', function ($browser) {
|
||||
$browser->click('');
|
||||
})
|
||||
->elsewhereWhenAvailable(new DeleteResourceModalComponent(), function ($browser) {
|
||||
$browser->confirm();
|
||||
})->pause(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-resource-detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@nova-resource-detail' => '[dusk="'.$this->resourceName.'-detail-component"]',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
nova/src/Testing/Browser/Pages/Forbidden.php
Normal file
31
nova/src/Testing/Browser/Pages/Forbidden.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class Forbidden extends Page
|
||||
{
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('/403');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->whenAvailable('@403-error-page', function ($browser) {
|
||||
$browser->assertSee('403');
|
||||
});
|
||||
}
|
||||
}
|
||||
214
nova/src/Testing/Browser/Pages/HasSearchable.php
Normal file
214
nova/src/Testing/Browser/Pages/HasSearchable.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Nova\Testing\Browser\Components\SearchInputComponent;
|
||||
|
||||
trait HasSearchable
|
||||
{
|
||||
/**
|
||||
* Search for the given value for a searchable field attribute.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @param int $pause
|
||||
* @return void
|
||||
*/
|
||||
public function searchInput(Browser $browser, $attribute, $search, int $pause = 500)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($search, $pause) {
|
||||
$browser->searchInput($search, $pause);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the searchable field.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param int $resultIndex
|
||||
* @return void
|
||||
*/
|
||||
public function resetSearchResult(Browser $browser, $attribute)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) {
|
||||
$browser->resetSearchResult();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the searchable field by result index.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param int $resultIndex
|
||||
* @return void
|
||||
*/
|
||||
public function selectSearchResult(Browser $browser, $attribute, $resultIndex)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($resultIndex) {
|
||||
$browser->selectSearchResult($resultIndex);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the currently highlighted searchable field.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function selectFirstSearchResult(Browser $browser, $attribute)
|
||||
{
|
||||
$this->selectSearchResult($browser, $attribute, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the currently highlighted searchable field.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function cancelSelectingSearchResult(Browser $browser, $attribute)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) {
|
||||
$browser->cancelSelectingSearchResult();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and select the searchable field by result index.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @param int $resultIndex
|
||||
* @return void
|
||||
*/
|
||||
public function searchAndSelectResult(Browser $browser, $attribute, $search, $resultIndex)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($search, $resultIndex) {
|
||||
$browser->searchAndSelectResult($search, $resultIndex);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and select the currently highlighted searchable field.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @return void
|
||||
*/
|
||||
public function searchAndSelectFirstResult(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$this->searchAndSelectResult($browser, $attribute, $search, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param callable(\Laravel\Nova\Browser, string):void $fieldCallback
|
||||
* @return void
|
||||
*/
|
||||
public function assertSearchResult(Browser $browser, $attribute, callable $fieldCallback)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($fieldCallback) {
|
||||
$browser->assertSearchResult($search, $fieldCallback);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results current value.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @return void
|
||||
*/
|
||||
public function assertSelectedSearchResult(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($search) {
|
||||
$browser->assertSelectedSearchResult($search);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results is locked to single result.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @return void
|
||||
*/
|
||||
public function assertSelectedFirstSearchResult(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($search) {
|
||||
$browser->assertSelectedFirstSearchResult($search);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results is empty.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function assertEmptySearchResult(Browser $browser, $attribute)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) {
|
||||
$browser->assertEmptySearchResult();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results has the search value.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string|array $search
|
||||
* @return void
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function assertSearchResultHas(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$this->assertSearchResultContains($browser, $attribute, $search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results has the search value.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string|array $search
|
||||
* @return void
|
||||
*/
|
||||
public function assertSearchResultContains(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($search) {
|
||||
$browser->assertSearchResultContains($search);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert on searchable results doesn't has the search value.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string|array $search
|
||||
* @return void
|
||||
*/
|
||||
public function assertSearchResultDoesNotContains(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$browser->whenAvailable(new SearchInputComponent($attribute), function ($browser) use ($search) {
|
||||
$browser->assertSearchResultDoesNotContains($search);
|
||||
});
|
||||
}
|
||||
}
|
||||
16
nova/src/Testing/Browser/Pages/HomePage.php
Executable file
16
nova/src/Testing/Browser/Pages/HomePage.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
class HomePage extends Page
|
||||
{
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('/');
|
||||
}
|
||||
}
|
||||
72
nova/src/Testing/Browser/Pages/Index.php
Executable file
72
nova/src/Testing/Browser/Pages/Index.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Nova\Testing\Browser\Components\FormComponent;
|
||||
use Laravel\Nova\Testing\Browser\Components\IndexComponent;
|
||||
|
||||
class Index extends Page
|
||||
{
|
||||
public $resourceName;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $queryParams = [])
|
||||
{
|
||||
$this->resourceName = $resourceName;
|
||||
$this->queryParams = $queryParams;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the related resource.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param \Closure|null $fieldCallback
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function runCreate(Browser $browser, $fieldCallback = null)
|
||||
{
|
||||
$browser->within(new IndexComponent($this->resourceName), function ($browser) {
|
||||
$browser->waitFor('@create-button')->click('@create-button');
|
||||
})->on(new Create($this->resourceName));
|
||||
|
||||
if (! is_null($fieldCallback)) {
|
||||
$browser->within(new FormComponent(), function ($browser) use ($fieldCallback) {
|
||||
call_user_func($fieldCallback, $browser);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-resource-index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@nova-resource-index' => '[dusk="'.$this->resourceName.'-index-component"]',
|
||||
];
|
||||
}
|
||||
}
|
||||
147
nova/src/Testing/Browser/Pages/InteractsWithRelations.php
Executable file
147
nova/src/Testing/Browser/Pages/InteractsWithRelations.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Nova\Testing\Browser\Components\Controls\RelationSelectControlComponent;
|
||||
use Laravel\Nova\Testing\Browser\Concerns\InteractsWithInlineCreateRelation;
|
||||
|
||||
trait InteractsWithRelations
|
||||
{
|
||||
use HasSearchable;
|
||||
use InteractsWithInlineCreateRelation;
|
||||
|
||||
/**
|
||||
* Select for the given value for a relationship attribute.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string|null $value
|
||||
* @return void
|
||||
*/
|
||||
public function selectRelation(Browser $browser, $attribute, $value = null)
|
||||
{
|
||||
$browser->whenAvailable(new RelationSelectControlComponent($attribute), function (Browser $browser) use ($value) {
|
||||
$browser->assertSelectHasOption('', $value)->select('', $value);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the given value for a searchable relationship attribute.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @return void
|
||||
*/
|
||||
public function searchRelation(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$this->searchInput($browser, $attribute, $search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the searchable relationship attribute.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function resetSearchRelation(Browser $browser, $attribute)
|
||||
{
|
||||
$this->resetSearchResult($browser, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the currently highlighted searchable relation.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function selectFirstRelation(Browser $browser, $attribute)
|
||||
{
|
||||
$this->selectFirstSearchResult($browser, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the currently highlighted searchable relation.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function firstSearchableResult(Browser $browser, $attribute)
|
||||
{
|
||||
$this->selectFirstSearchResult($browser, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the searchable relation result.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @return void
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function closeSearchableResult(Browser $browser, $attribute)
|
||||
{
|
||||
$this->cancelSelectingSearchResult($browser, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and select the currently highlighted searchable relation.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $attribute
|
||||
* @param string $search
|
||||
* @return void
|
||||
*/
|
||||
public function searchFirstRelation(Browser $browser, $attribute, $search)
|
||||
{
|
||||
$this->searchAndSelectFirstResult($browser, $attribute, $search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that trashed relations should be included in the search results.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $resourceName
|
||||
* @return void
|
||||
*/
|
||||
public function waitForTrashedRelation(Browser $browser, $resourceName)
|
||||
{
|
||||
$browser->waitFor("@{$resourceName}-with-trashed-checkbox", 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that trashed relations should be included in the search results.
|
||||
*/
|
||||
public function withTrashedRelation(Browser $browser, $resourceName)
|
||||
{
|
||||
$browser->waitForTrashedRelation($resourceName)->click('')->with(
|
||||
"@{$resourceName}-with-trashed-checkbox",
|
||||
function (Browser $browser) {
|
||||
$browser->waitFor('input[type="checkbox"]')
|
||||
->check('input[type="checkbox"]')
|
||||
->pause(250);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that trashed relations should not be included in the search results.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $resourceName
|
||||
* @return void
|
||||
*/
|
||||
public function withoutTrashedRelation(Browser $browser, $resourceName)
|
||||
{
|
||||
$browser->waitForTrashedRelation($resourceName)
|
||||
->uncheck('[dusk="'.$resourceName.'-with-trashed-checkbox"] input[type="checkbox"]')
|
||||
->pause(250);
|
||||
}
|
||||
}
|
||||
50
nova/src/Testing/Browser/Pages/Lens.php
Executable file
50
nova/src/Testing/Browser/Pages/Lens.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class Lens extends Index
|
||||
{
|
||||
public $lens;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $lens
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $lens, $queryParams = [])
|
||||
{
|
||||
$this->lens = $lens;
|
||||
$this->resourceName = $resourceName;
|
||||
$this->queryParams = $queryParams;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/lens/{$this->lens}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-resource-lens');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@nova-resource-lens' => '[dusk="'.$this->lens.'-lens-component"]',
|
||||
];
|
||||
}
|
||||
}
|
||||
40
nova/src/Testing/Browser/Pages/Login.php
Normal file
40
nova/src/Testing/Browser/Pages/Login.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class Login extends Page
|
||||
{
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('/login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert page not found.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assertOk(Browser $browser)
|
||||
{
|
||||
$browser->waitForLocation($this->novaPageUrl)->assertPathIs($this->novaPageUrl);
|
||||
}
|
||||
}
|
||||
31
nova/src/Testing/Browser/Pages/NotFound.php
Normal file
31
nova/src/Testing/Browser/Pages/NotFound.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class NotFound extends Page
|
||||
{
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('/404');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->whenAvailable('@404-error-page', function ($browser) {
|
||||
$browser->assertSee('404');
|
||||
});
|
||||
}
|
||||
}
|
||||
124
nova/src/Testing/Browser/Pages/Page.php
Normal file
124
nova/src/Testing/Browser/Pages/Page.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Dusk\Page as Dusk;
|
||||
use Laravel\Nova\Nova;
|
||||
use Laravel\Nova\Testing\Browser\Concerns\InteractsWithElements;
|
||||
|
||||
class Page extends Dusk
|
||||
{
|
||||
use InteractsWithElements;
|
||||
|
||||
public $novaPageUrl;
|
||||
|
||||
public $queryParams;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($path = '/')
|
||||
{
|
||||
$this->setNovaPage($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
if ($this->queryParams) {
|
||||
return $this->novaPageUrl.'?'.http_build_query($this->queryParams);
|
||||
}
|
||||
|
||||
return $this->novaPageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert page not found.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assertOk(Browser $browser)
|
||||
{
|
||||
$browser->waitForLocation($this->novaPageUrl)
|
||||
->assertPathIs($this->novaPageUrl)
|
||||
->waitFor('@nova-content');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert page not found.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assertNotFound(Browser $browser)
|
||||
{
|
||||
$browser->on(new NotFound());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert page not forbidden.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assertForbidden(Browser $browser)
|
||||
{
|
||||
$browser->on(new Forbidden());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert page doesn't contain breadcrumb.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assertWithoutBreadcrumb(Browser $browser)
|
||||
{
|
||||
$browser->assertMissing('@breadcrumbs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set luxon timezone for the frontend.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $timezone
|
||||
* @return void
|
||||
*/
|
||||
public function luxonTimezone(Browser $browser, string $timezone = 'system')
|
||||
{
|
||||
$browser->script('Nova.$testing.timezone("'.$timezone.'")');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global element shortcuts for the site.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function siteElements(): array
|
||||
{
|
||||
return [
|
||||
'@nova-content' => '[dusk="content"]',
|
||||
'@nova-form' => '[dusk="content"]',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Nova Page URL.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
protected function setNovaPage(string $path)
|
||||
{
|
||||
$this->novaPageUrl = Nova::path().'/'.trim($path, '/');
|
||||
}
|
||||
}
|
||||
25
nova/src/Testing/Browser/Pages/Replicate.php
Normal file
25
nova/src/Testing/Browser/Pages/Replicate.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
class Replicate extends Create
|
||||
{
|
||||
public $fromResourceId;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param int|string $fromResourceId
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $fromResourceId, $queryParams = [])
|
||||
{
|
||||
parent::__construct($resourceName, $queryParams);
|
||||
|
||||
$this->fromResourceId = $fromResourceId;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/{$this->fromResourceId}/replicate");
|
||||
}
|
||||
}
|
||||
111
nova/src/Testing/Browser/Pages/Update.php
Executable file
111
nova/src/Testing/Browser/Pages/Update.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Laravel\Nova\Testing\Browser\Components\Modals\CreateRelationModalComponent;
|
||||
|
||||
class Update extends Page
|
||||
{
|
||||
use InteractsWithRelations;
|
||||
|
||||
public $resourceName;
|
||||
|
||||
public $resourceId;
|
||||
|
||||
public $queryParams;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param int $resourceId
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $resourceId, $queryParams = [])
|
||||
{
|
||||
$this->resourceName = $resourceName;
|
||||
$this->resourceId = $resourceId;
|
||||
$this->queryParams = $queryParams;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/{$this->resourceId}/edit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the inline create relation.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @param string $uriKey
|
||||
* @param callable $fieldCallback
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function runInlineCreate(Browser $browser, $uriKey, callable $fieldCallback)
|
||||
{
|
||||
$browser->whenAvailable("@{$uriKey}-inline-create", function ($browser) use ($fieldCallback) {
|
||||
$browser->click('')
|
||||
->elsewhereWhenAvailable(new CreateRelationModalComponent(), function ($browser) use ($fieldCallback) {
|
||||
$fieldCallback($browser);
|
||||
|
||||
$browser->confirm()->pause(250);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the update button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function update(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->waitFor('@update-button')
|
||||
->click('@update-button')
|
||||
->pause(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the update and continue editing button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function updateAndContinueEditing(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->waitFor('@update-and-continue-editing-button')
|
||||
->click('@update-and-continue-editing-button')
|
||||
->pause(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the cancel button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function cancel(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@cancel-update-button');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-form');
|
||||
}
|
||||
}
|
||||
139
nova/src/Testing/Browser/Pages/UpdateAttached.php
Executable file
139
nova/src/Testing/Browser/Pages/UpdateAttached.php
Executable file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class UpdateAttached extends Page
|
||||
{
|
||||
public $resourceName;
|
||||
|
||||
public $resourceId;
|
||||
|
||||
public $relation;
|
||||
|
||||
public $relatedId;
|
||||
|
||||
public $viaRelationship;
|
||||
|
||||
public $viaPivotId;
|
||||
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param string $relation
|
||||
* @param string $relatedId
|
||||
* @param string|null $viaRelationship
|
||||
* @param string|null $viaPivotId
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceName, $resourceId, $relation, $relatedId, $viaRelationship = null, $viaPivotId = null)
|
||||
{
|
||||
$this->relation = $relation;
|
||||
$this->relatedId = $relatedId;
|
||||
$this->resourceId = $resourceId;
|
||||
$this->resourceName = $resourceName;
|
||||
$this->viaRelationship = $viaRelationship;
|
||||
$this->viaPivotId = $viaPivotId;
|
||||
|
||||
$this->setNovaPage("/resources/{$this->resourceName}/{$this->resourceId}/edit-attached/{$this->relation}/{$this->relatedId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new page instance for Belongs-to-Many.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param string $relation
|
||||
* @param string $relatedId
|
||||
* @param string|null $viaRelationship
|
||||
* @param string|null $viaPivotId
|
||||
* @return static
|
||||
*/
|
||||
public static function belongsToMany($resourceName, $resourceId, $relation, $relatedId, $viaRelationship = null, $viaPivotId = null)
|
||||
{
|
||||
return new static($resourceName, $resourceId, $relation, $relatedId, $viaRelationship, $viaPivotId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new page instance for Morph-to-Many.
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @param string $resourceId
|
||||
* @param string $relation
|
||||
* @param string $relatedId
|
||||
* @param string|null $viaRelationship
|
||||
* @param string|null $viaPivotId
|
||||
* @return static
|
||||
*/
|
||||
public static function morphToMany($resourceName, $resourceId, $relation, $relatedId, $viaRelationship = null, $viaPivotId = null)
|
||||
{
|
||||
return new static($resourceName, $resourceId, $relation, $relatedId, $viaRelationship, $viaPivotId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
return $this->novaPageUrl.'?'.http_build_query(array_filter([
|
||||
'viaRelationship' => $this->viaRelationship ?? $this->relation,
|
||||
'viaPivotId' => $this->viaPivotId,
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the update button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function update(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@update-button')
|
||||
->pause(750);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the update and continue editing button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function updateAndContinueEditing(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@update-and-continue-editing-button')
|
||||
->pause(750);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the cancel button.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function cancel(Browser $browser)
|
||||
{
|
||||
$browser->dismissToasted()
|
||||
->click('@cancel-update-attached-button');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*
|
||||
* @throws \Facebook\WebDriver\Exception\TimeOutException
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
$browser->assertOk()->waitFor('@nova-form');
|
||||
}
|
||||
}
|
||||
17
nova/src/Testing/Browser/Pages/UserIndex.php
Executable file
17
nova/src/Testing/Browser/Pages/UserIndex.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Testing\Browser\Pages;
|
||||
|
||||
class UserIndex extends Index
|
||||
{
|
||||
/**
|
||||
* Create a new page instance.
|
||||
*
|
||||
* @param array $queryParams
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($queryParams = [])
|
||||
{
|
||||
parent::__construct('users', $queryParams);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user