-
Notifications
You must be signed in to change notification settings - Fork 17
IBX-9519: [Behat] Added Behat content tree coverage #1685
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
base: 4.6
Are you sure you want to change the base?
Changes from all commits
460b087
f04b7bc
0437403
e1fc2da
f367b02
1cbff53
b8e4e98
9b59924
c74bc6d
18147b5
c47650c
2130231
2836713
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"recipesEndpoint": "", | ||
"packages": [ | ||
{ | ||
"requirement": "dev-IBX-9519-behat-coverage-contenttree as 4.6.x-dev", | ||
"repositoryUrl": "https://github.com/ibexa/behat", | ||
"package": "ibexa/behat", | ||
"shouldBeAddedAsVCS": false | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@IbexaOSS @IbexaHeadless @IbexaCommerce @IbexaExperience @javascript | ||
Feature: Content tree basic operations | ||
|
||
Scenario: Content tree can be displayed | ||
Given I am logged as admin | ||
When I'm on Content view Page for "root" | ||
Then I verify Content tree visibility | ||
|
||
Scenario: It is possible to display items on Content tree | ||
Given I create "article" Content items | ||
| title | short_title | parentPath | language | | ||
| Article1 | art1 | root | eng-GB | | ||
| Article2 | art2 | root | eng-GB | | ||
| Article3 | art3 | root | eng-GB | | ||
And I am logged as admin | ||
When I'm on Content view Page for "root/art1" | ||
Then Content item "root/art1" exists in Content tree | ||
|
||
Scenario: New Content item can be created under chosen nested node | ||
Given I am logged as admin | ||
And I'm on Content view Page for "root/art1" | ||
When I start creating a new content "Article" | ||
And I set content fields | ||
| label | value | | ||
| Title | Arttest | | ||
| Short title | arttest | | ||
| Intro | TestArticleIntro| | ||
And I perform the "Publish" action | ||
And I'm on Content view Page for "root/art1/arttest" | ||
Then Content item "root/art1/arttest" exists in Content tree |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\AdminUi\Behat\BrowserContext; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Ibexa\AdminUi\Behat\Component\ContentTree; | ||
use Symfony\Component\Stopwatch\Stopwatch; | ||
|
||
final class ContentTreeContext implements Context | ||
{ | ||
private ContentTree $contentTree; | ||
|
||
public function __construct(ContentTree $contentTree) | ||
ContentTree $contentTree | ||
Check failure on line 20 in src/lib/Behat/BrowserContext/ContentTreeContext.php
|
||
) | ||
{ | ||
$this->contentTree = $contentTree; | ||
} | ||
|
||
/** | ||
* @Then I verify Content tree visibility | ||
*/ | ||
public function iAmOnContentTree(): void | ||
{ | ||
$this->contentTree->verifyIsLoaded(); | ||
} | ||
|
||
/** | ||
* @Then Content item :itemPath exists in Content tree | ||
*/ | ||
public function contentItemExistsInContentTree(string $itemPath): void | ||
Check failure on line 37 in src/lib/Behat/BrowserContext/ContentTreeContext.php
|
||
{ | ||
$this->contentTree->verifyIsLoaded(); | ||
$this->contentTree->verifyItemExists($itemPath); | ||
} | ||
/** | ||
* @Given I wait :number seconds | ||
*/ | ||
public function iWait(string $number): void | ||
Check failure on line 45 in src/lib/Behat/BrowserContext/ContentTreeContext.php
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unused, please delete it if so. |
||
{ | ||
$number = (int) $number; | ||
sleep($number); | ||
} | ||
} | ||
Check failure on line 50 in src/lib/Behat/BrowserContext/ContentTreeContext.php
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
Check warning on line 1 in src/lib/Behat/Component/ContentTree.php
|
||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\AdminUi\Behat\Component; | ||
|
||
use Ibexa\Behat\Browser\Component\Component; | ||
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; | ||
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; | ||
use PHPUnit\Framework\Assert; | ||
|
||
final class ContentTree extends Component | ||
{ | ||
public function verifyIsLoaded(): void | ||
{ | ||
$this->getHTMLPage()->find($this->getLocator('header'))->assert()->textEquals('Content tree'); | ||
} | ||
public function verifyItemExists(string $itemPath): void | ||
{ | ||
Assert::assertTrue($this->itemExists($itemPath)); | ||
} | ||
private function itemExists(string $itemPath): bool | ||
{ | ||
|
||
$pathParts = explode('/', $itemPath); | ||
$searchedElement = $this->getHTMLPage()->findAll($this->getLocator('contextInTree'))->getByCriterion(new ElementTextCriterion(end($pathParts))); | ||
return $searchedElement !== null; | ||
} | ||
|
||
protected function specifyLocators(): array | ||
{ | ||
return [ | ||
new VisibleCSSLocator('header', '.ibexa-content-tree-container .c-tb-header__name-content,.c-header .c-header__name'), | ||
new VisibleCSSLocator('treeItem', '.c-tb-list-item-single__label'), | ||
new VisibleCSSLocator('treeElement', '.ibexa-content-tree-container__root .c-tb-list-item-single__element'), | ||
new VisibleCSSLocator('search', '.c-tb-search .ibexa-input'), | ||
Comment on lines
+38
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unused, please delete it if so. |
||
new VisibleCSSLocator('contentItemInTree', '.c-tb-list-item-single__link'), | ||
]; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.