Skip to content
Snippets Groups Projects
Commit 36da5cf2 authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3346066: Have support for CKEditor 5 in the automated functional...

Issue #3346066: Have support for CKEditor 5 in the automated functional testing after the switch to CKEditor 5 and remove not needed libraries
parent db2daaba
No related branches found
No related tags found
No related merge requests found
......@@ -504,7 +504,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
/*
* ===========================================================================
* Rich text editor Functions CKEditor.
* Rich text editor Functions CKEditor 5.
* ===========================================================================
*/
......@@ -522,14 +522,6 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
$el = $this->getSession()->getPage()->findField($locator);
$fieldId = $el->getAttribute('id');
if ($fieldId == NULL) {
// If the WYSIWYG is in an ifream with no id.
$iFreamID = $this->getAttributeByOtherAttributeValue('id', 'title', "Rich Text Editor, " . $el->getAttribute('id'), 'iframe');
if (!empty($iFreamID)) {
$fieldId = $iFreamID;
}
}
if (empty($fieldId)) {
throw new \Exception('Could not find an id for the rich text editor field : ' . $locator);
}
......@@ -583,14 +575,6 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
$el = $this->getSession()->getPage()->findField($locator);
$fieldId = $el->getAttribute('id');
if ($fieldId == NULL) {
// If the WYSIWYG is in an ifream with no id.
$iFreamID = $this->getAttributeByOtherAttributeValue('id', 'title', "Rich Text Editor, " . $el->getAttribute('id'), 'iframe');
if (!empty($iFreamID)) {
$fieldId = $iFreamID;
}
}
if (empty($fieldId)) {
throw new \Exception('Could not find an id for the rich text editor field : ' . $locator);
}
......@@ -613,14 +597,6 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
$el = $this->getSession()->getPage()->findField($locator);
$fieldId = $el->getAttribute('id');
if ($fieldId == NULL) {
// If the WYSIWYG is in an ifream with no id.
$iFreamID = $this->getAttributeByOtherAttributeValue('id', 'title', "Rich Text Editor, " . $el->getAttribute('id'), 'iframe');
if (!empty($iFreamID)) {
$fieldId = $iFreamID;
}
}
if (empty($fieldId)) {
throw new \Exception('Could not find an id for the rich text editor field : ' . $locator);
}
......@@ -666,9 +642,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
throw new \Exception('Could not find an id for the rich text editor field : ' . $selectedField);
}
$this->getSession()->getDriver()->evaluateScript("Drupal.CKEditor5Instances.get(document.getElementById(\"$fieldId\").dataset[\"ckeditor5Id\"]).execCommand('selectAll', false, null);");
$this->getSession()->getDriver()->evaluateScript("Drupal.CKEditor5Instances.get(document.getElementById(\"$fieldId\").dataset[\"ckeditor5Id\"]).forceNextSelectionCheck();");
$this->getSession()->getDriver()->evaluateScript("Drupal.CKEditor5Instances.get(document.getElementById(\"$fieldId\").dataset[\"ckeditor5Id\"]).selectionChange();");
$this->getSession()->getDriver()->evaluateScript("Drupal.CKEditor5Instances.get(document.getElementById(\"$fieldId\").dataset[\"ckeditor5Id\"]).execute( 'selectAll' );");
}
......@@ -1471,10 +1445,6 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
$this->getSession()->executeScript("return Drupal.CKEditor5Instances.get(document.getElementById(\"$fieldId\").dataset[\"ckeditor5Id\"]).getData();");
// Switch to the iframe.
$iFreamID = $this->getAttributeByOtherAttributeValue('id', 'title', $fieldId, 'iframe');
$this->getSession()->switchToIFrame($iFreamID);
// Find an image with the title.
$element = $this->getSession()->getPage()->findAll('xpath', "//img[contains(@title, '{$titleText}')]");
......@@ -1482,8 +1452,6 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
throw new \Exception('The page dose not have an image with the [ ' . $titleText . ' ] title text under [ ' . $locator . ' ].');
}
// Switch back too the page from the iframe.
$this->getSession()->switchToIFrame(NULL);
}
/**
......@@ -1770,104 +1738,6 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
$element->click();
}
/**
* Check if we do have the text in the selected panel region.
*
* Using the code name of the panel region. or the html id.
* Varbase Context #varbase.
*
* Example #1: Then I should see "Add new pane" in the "Center" panel region
* Example #2: Then I should see "custom pane title" in the "Right side" panel region
* Example #3: And I should see "Add new pane" in the "panels-ipe-regionid-center" panel region.
*
* @Then /^I should see "(?P<text>[^"]*)" in the "(?P<panleRegion>[^"]*)" panel region$/
*/
public function iShouldSeeInThePanelRegion($text, $panleRegion) {
if (strpos($panleRegion, "panels-ipe-regionid-")) {
$panleRegionId = $panleRegion;
}
else {
$panleRegionId = "panels-ipe-regionid-" . str_replace(' ', '-', strtolower($panleRegion));
}
$elementPanelRegion = $this->getSession()->getPage()->find('xpath', "//*[contains(@id, '{$panleRegionId}')]");
if (empty($elementPanelRegion)) {
throw new \Exception('The panle region [ ' . $panleRegion . ' ] is not in the page.');
}
$element = $this->getSession()->getPage()->find('xpath', "//*[contains(@id, '{$panleRegionId}')]//*[text()='{$text}']");
if (empty($element)) {
throw new \Exception('The panle region "' . $panleRegion . '" dose not have "' . $text . '" in it.');
}
}
/**
* Check if we do not have the text in the selected panel region.
*
* Using the code name of the panel region. or the html id.
* Varbase Context #varbase.
*
* Example #1: Then I should not see "Add new pane" in the "Center" panel region
* Example #2: Then I should not see "custom pane title" in the "Right side" panel region
* Example #3: And I should not see "Add new pane" in the "panels-ipe-regionid-center" panel region.
*
* @Then /^I should not see "(?P<text>[^"]*)" in the "(?P<panleRegion>[^"]*)" panel region$/
*/
public function iShouldNotSeeInThePanelRegion($text, $panleRegion) {
if (strpos($panleRegion, "panels-ipe-regionid-")) {
$panleRegionId = $panleRegion;
}
else {
$panleRegionId = "panels-ipe-regionid-" . str_replace(' ', '-', strtolower($panleRegion));
}
$elementPanelRegion = $this->getSession()->getPage()->find('xpath', "//*[contains(@id, '{$panleRegionId}')]");
if (empty($elementPanelRegion)) {
throw new \Exception('The panle region [ ' . $panleRegion . ' ] is not in the page.');
}
$element = $this->getSession()->getPage()->find('xpath', "//*[contains(@id, '{$panleRegionId}')]//*[text()='{$text}']");
if (!empty($element)) {
throw new \Exception('The panle region "' . $panleRegion . '" dose have "' . $text . '" in it.');
}
}
/**
* Click on the text in the selected panel region.
*
* Using the code name of the panel region. or the html id.
* Varbase Context #varbase.
*
* Example #1: When I click "Add new pane" in the "center" panel region
* Example #2: When I click "Region style" in the "left" panel region
* Example #3: And I click "Add new pane" in the "panels-ipe-regionid-center" panel region.
*
* @When /^I click "(?P<text>[^"]*)" in the "(?P<panleRegion>[^"]*)" panel region$/
*/
public function iClickInThePanelRegion($text, $panleRegion) {
if (strpos($panleRegion, "panels-ipe-regionid-")) {
$panleRegionId = $panleRegion;
}
else {
$panleRegionId = "panels-ipe-regionid-" . str_replace(' ', '-', strtolower($panleRegion));
}
$elementpanelRegion = $this->getSession()->getPage()->find('xpath', "//*[contains(@id, '{$panleRegionId}')]");
if (empty($elementpanelRegion)) {
throw new \Exception('The panle region [ ' . $panleRegion . ' ] is not in the page.');
}
$element = $this->getSession()->getPage()->find('xpath', "//*[contains(@id, '{$panleRegionId}')]//*[text()='{$text}']");
if (empty($element)) {
throw new \Exception('The panle region "' . $panleRegion . '" dose not have "' . $text . '".');
}
$element->click();
}
/**
* Alert Functions.
*
......
......@@ -14,16 +14,16 @@ So that can use different type of rich text editors.
When I select "full_html" from "body[0][format]"
And I wait for AJAX to finish
Then I should see the "#cke_edit-body-0-value" element in the "field body"
Then I should see the ".ck.ck-editor__main" element in the "field body"
When I select "basic_html" from "body[0][format]"
And I wait for AJAX to finish
Then I should see the "#cke_edit-body-0-value" element in the "field body"
Then I should see the ".ck.ck-editor__main" element in the "field body"
When I select "code_html" from "body[0][format]"
And I wait for AJAX to finish
Then I should see the "#edit-body-0-value" element in the "field body"
And I should not see the "#cke_edit-body-0-value" element in the "field body"
And I should not see the ".ck.ck-editor__main" element in the "field body"
@javascript @local @development @staging @production
Scenario: Check if Super Admin user can change the text format for the body of Basic page
......@@ -35,13 +35,13 @@ So that can use different type of rich text editors.
When I select "full_html" from "body[0][format]"
And I wait for AJAX to finish
Then I should see the "#cke_edit-body-0-value" element in the "field body"
Then I should see the ".ck.ck-editor__main" element in the "field body"
When I select "basic_html" from "body[0][format]"
And I wait for AJAX to finish
Then I should see the "#cke_edit-body-0-value" element in the "field body"
Then I should see the ".ck.ck-editor__main" element in the "field body"
When I select "code_html" from "body[0][format]"
And I wait for AJAX to finish
Then I should see the "#edit-body-0-value" element in the "field body"
And I should not see the "#cke_edit-body-0-value" element in the "field body"
And I should not see the ".ck.ck-editor__main" element in the "field body"
......@@ -52,8 +52,6 @@ So that the "Landing page (Paragraphs)" will have text and images in right and l
Then I should see "The maximum number of media items have been selected."
When I click "Text"
And I fill in the rich text editor field "Text" with "In eros ipsum, mattis vitae vulputate eu, blandit non risus. Maecenas ultricies volutpat massa id hendrerit. Phasellus magna quam, lacinia sed justo pulvinar, tristique finibus felis. Quisque in sagittis tellus. Curabitur in est at quam maximus elementum. Pellentesque interdum tincidunt nisl, ac efficitur elit aliquam id. Integer egestas neque ut risus tincidunt semper."
And I select all text in "Text" rich text editor field
And I click on "justifycenter" command button in the rich text editor field "Text"
And I wait
And I select "published" from "edit-moderation-state-0-state"
And I press the "Save" button
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment