Skip to content

Commit

Permalink
[TASK] run acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achimfritz committed Dec 21, 2024
1 parent 93d05cd commit 743be7e
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 57 deletions.
128 changes: 93 additions & 35 deletions Tests/Acceptance/Backend/ContentDefenderCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use B13\Container\Tests\Acceptance\Support\BackendTester;
use B13\Container\Tests\Acceptance\Support\PageTree;
use B13\Container\Tests\Acceptance\Support\PageTreeV13;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -30,32 +31,44 @@ public function _before(BackendTester $I)
/**
* @group content_defender
*/
public function canCreateChildIn2ColsContainerWithNoContentDefenderRestrictionsDefined(BackendTester $I, PageTree $pageTree): void
public function canCreateChildIn2ColsContainerWithNoContentDefenderRestrictionsDefined(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13): void
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithDifferentContainers']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithDifferentContainers']);
} else {
$pageTreeV13->openPath(['home', 'pageWithDifferentContainers']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(300, 200);
$I->waitForElement('#element-tt_content-300 [data-colpos="' . $dataColPos . '"]');
$newContentElementLabel = $I->getNewContentElementLabel();

$I->click($newContentElementLabel, '#element-tt_content-300 [data-colpos="' . $dataColPos . '"]');
$I->switchToIFrame();
$I->waitForElement('.modal-dialog');
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')");
}
$I->waitForText('Header Only');
$I->see('Header Only');
$I->see('Table');
$I->see('Regular Text Element');
}

/**
* @group content_defender
*/
public function doNotSeeNotAllowedContentElementsInNewContentElementWizard(BackendTester $I, PageTree $pageTree): void
public function doNotSeeNotAllowedContentElementsInNewContentElementWizard(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13): void
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithContainer-3']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithContainer-3']);
} else {
$pageTreeV13->openPath(['home', 'pageWithContainer-3']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(800, 200);
Expand All @@ -64,18 +77,25 @@ public function doNotSeeNotAllowedContentElementsInNewContentElementWizard(Backe
$I->click($newContentElementLabel, '#element-tt_content-800 [data-colpos="' . $dataColPos . '"]');
$I->switchToIFrame();
$I->waitForElement('.modal-dialog');
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')");
}
$I->waitForText('Header Only');
$I->dontSee('Table');
$I->dontSee('Regular Text Element');
}

/**
* @group content_defender
*/
public function doNotSeeNotAllowedContentElementsInNewContentElementWizardTriggeredByContextMenu(BackendTester $I, PageTree $pageTree): void
public function doNotSeeNotAllowedContentElementsInNewContentElementWizardTriggeredByContextMenu(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13): void
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithContainer-3']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithContainer-3']);
} else {
$pageTreeV13->openPath(['home', 'pageWithContainer-3']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
Expand All @@ -100,18 +120,25 @@ public function doNotSeeNotAllowedContentElementsInNewContentElementWizardTrigge
}
$I->switchToIFrame();
$I->waitForElement('.modal-dialog');
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')");
}
$I->waitForText('Header Only');
$I->dontSee('Table');
$I->dontSee('Regular Text Element');
}

/**
* @group content_defender
*/
public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenCreateNewElement(BackendTester $I, PageTree $pageTree)
public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenCreateNewElement(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13)
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithContainer-4']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithContainer-4']);
} else {
$pageTreeV13->openPath(['home', 'pageWithContainer-4']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(801, 200);
Expand All @@ -120,44 +147,59 @@ public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenCreateNewEl
$I->click($newContentElementLabel, '#element-tt_content-801 [data-colpos="' . $dataColPos . '"]');
$I->switchToIFrame();
$I->waitForElement('.modal-dialog');
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')");
}
$I->waitForText('Header Only');
$typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
if ($typo3Version->getMajorVersion() < 12) {
$I->click('Header Only');
} else {
$I->executeJS("document.querySelector('typo3-backend-new-content-element-wizard').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()");
if ($typo3Version->getMajorVersion() < 13) {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()");
} else {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()");
}
}
$I->switchToContentFrame();
$I->wait(0.5);
$I->see('textmedia', 'select');
$I->dontSee('Table', 'select');
$I->dontSee('Regular Text Element', 'select');
}

/**
* @group content_defender
*/
public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenEditAnElement(BackendTester $I, PageTree $pageTree)
public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenEditAnElement(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13)
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentTCASelectCtype']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentTCASelectCtype']);
} else {
$pageTreeV13->openPath(['home', 'contentTCASelectCtype']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$I->waitForElement('#element-tt_content-502 a[title="Edit"]');
$I->click('#element-tt_content-502 a[title="Edit"]');
$I->waitForElement('#EditDocumentController');
$I->see('textmedia', 'select');
$I->dontSee('Table', 'select');
$I->dontSee('Regular Text Element', 'select');
}

/**
* @group content_defender
*/
public function canSeeNewContentButtonIfMaxitemsIsNotReached(BackendTester $I, PageTree $pageTree)
public function canSeeNewContentButtonIfMaxitemsIsNotReached(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13)
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentDefenderMaxitems']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentDefenderMaxitems']);
} else {
$pageTreeV13->openPath(['home', 'contentDefenderMaxitems']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(402, 202);
Expand All @@ -168,11 +210,15 @@ public function canSeeNewContentButtonIfMaxitemsIsNotReached(BackendTester $I, P
/**
* @group content_defender
*/
public function canNotSeeNewContentButtonIfMaxitemsIsReached(BackendTester $I, PageTree $pageTree)
public function canNotSeeNewContentButtonIfMaxitemsIsReached(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13)
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentDefenderMaxitems']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentDefenderMaxitems']);
} else {
$pageTreeV13->openPath(['home', 'contentDefenderMaxitems']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(401, 202);
Expand All @@ -184,11 +230,15 @@ public function canNotSeeNewContentButtonIfMaxitemsIsReached(BackendTester $I, P
/**
* @group content_defender
*/
public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer(BackendTester $I, PageTree $pageTree)
public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13)
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentDefenderMaxitems']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'contentDefenderMaxitems']);
} else {
$pageTreeV13->openPath(['home', 'contentDefenderMaxitems']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(402, 202);
Expand All @@ -202,7 +252,11 @@ public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer(
if ($typo3Version->getMajorVersion() < 12) {
$I->click('Header Only');
} else {
$I->executeJS("document.querySelector('typo3-backend-new-content-element-wizard').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()");
if ($typo3Version->getMajorVersion() < 13) {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()");
} else {
$I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()");
}
}
$I->switchToContentFrame();
$I->waitForText('Create new Page Content on page');
Expand All @@ -213,11 +267,15 @@ public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer(
/**
* @group content_defender
*/
public function seeEditDocumentWhenAddingChildrenToColposWhereOnlyHeaderIsAllowed(BackendTester $I, PageTree $pageTree)
public function seeEditDocumentWhenAddingChildrenToColposWhereOnlyHeaderIsAllowed(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13)
{
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithDifferentContainers']);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$I->waitForElement('#typo3-pagetree-tree .nodes .node');
$pageTree->openPath(['home', 'pageWithDifferentContainers']);
} else {
$pageTreeV13->openPath(['home', 'pageWithDifferentContainers']);
}
$I->wait(0.5);
$I->switchToContentFrame();
$dataColPos = $I->getDataColPos(300, 201);
Expand All @@ -228,7 +286,7 @@ public function seeEditDocumentWhenAddingChildrenToColposWhereOnlyHeaderIsAllowe
$I->switchToContentFrame();
$I->wait(0.5);
$I->see('header', 'select');
$I->dontSee('Table', 'select');
$I->dontSee('Regular Text Element', 'select');
}

}
Loading

0 comments on commit 743be7e

Please sign in to comment.