Skip to content

Commit

Permalink
Merge pull request #1 from sandstorm/feature/add-more-steps-for-neos-…
Browse files Browse the repository at this point in the history
…be-and-general-requests

add steps for Neos backend document tree navigation / create sites with name
  • Loading branch information
skurfuerst authored Jun 18, 2021
2 parents 10aa301 + a262dca commit d4b4e7f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Tests/Behavior/Bootstrap/FusionRenderingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,34 @@ public function setupFusionRendering(string $sitePackageKey)
* @Given I have a site for Site Node :siteNodeName
*/
public function iHaveASite($siteNodeName)
{
$this->createAndPersistSite($siteNodeName);
}

/**
* @Given I have a site for Site Node :siteNodeName with name :siteName
*/
public function iHaveASiteWithName($siteNodeName, $siteName)
{
$this->createAndPersistSite($siteNodeName, function ($site) use ($siteName) {
$site->setName($siteName);
return $site;
});
}

/**
* @param string $siteNodeName
* @param $mapper
* @throws \Neos\Flow\Persistence\Exception\IllegalObjectTypeException
*/
protected function createAndPersistSite($siteNodeName, $mapper = null)
{
$site = new Site($siteNodeName);
$site->setState(Site::STATE_ONLINE);
$site->setSiteResourcesPackageKey($this->sitePackageKey);
if ($mapper !== null) {
$site = $mapper($site);
}
/** @var SiteRepository $siteRepository */
$siteRepository = $this->objectManager->get(SiteRepository::class);
$siteRepository->add($site);
Expand Down
37 changes: 34 additions & 3 deletions Tests/Behavior/Bootstrap/NeosBackendControlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Neos\Domain\Service\UserService;
use PHPUnit\Framework\Assert;
use function PHPUnit\Framework\assertEquals;

trait NeosBackendControlTrait
{
Expand All @@ -28,7 +29,7 @@ public function iLogIntoTheBackendUsingCredentials(string $username, string $pas
$this->playwrightConnector->execute($this->playwrightContext, sprintf('
vars.page = await context.newPage();
await vars.page.goto("BASEURL/neos/");
await vars.page.fill("[placeholder=\"Username\"]", "%s");
await vars.page.fill("[placeholder=\"Password\"]", "%s");
await vars.page.click("button:has-text(\"Login\")");
Expand Down Expand Up @@ -58,12 +59,28 @@ public function iClickTheDashboardOverviewTile($tileTitle)
', $tileTitle));
}

/**
* @When I click the document tree entry :documentTitle
*/
public function iClickTheDocumentTreeEntry($documentTitle)
{
$this->playwrightConnector->execute($this->playwrightContext, sprintf(
// language=JavaScript
'
await vars.page.click(`body div[class^=style__leftSideBar__top___] div[role=button]:has(span:has-text("%s"))`);
await vars.page.waitForSelector(`div#neos-Inspector`);
vars.neosContentFrame = await vars.page.frame(`neos-content-main`);
'// language=PHP
, $documentTitle));
}


/**
* @Then the URI path should be :uriPath
*/
public function theUriPathShouldBe($uriPath)
{
$actual = $this->playwrightConnector->execute($this->playwrightContext,'
$actual = $this->playwrightConnector->execute($this->playwrightContext, '
return vars.page.evaluate(() => window.location.pathname);
');
Assert::assertEquals(rtrim($uriPath, '/'), rtrim($actual, '/'));
Expand All @@ -86,7 +103,21 @@ public function iAccess($uriPath)
{
$this->playwrightConnector->execute($this->playwrightContext, sprintf('
vars.page = await context.newPage();
await vars.page.goto("BASEURL%s");
vars.response = await vars.page.goto("BASEURL%s");
', $uriPath));
}

/**
* @Then the response status code should be :status
*/
public function theResponseStatusCodeShouldBe($status)
{
$actualStatusCode = $this->playwrightConnector->execute($this->playwrightContext, sprintf(
// language=JavaScript
'
return vars.response.status();
'));// language=PHP
assertEquals($status, $actualStatusCode, 'HTTP response status code mismatch');
}

}

0 comments on commit d4b4e7f

Please sign in to comment.