Skip to content
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

#26847: Added 'enterKey' event handler to prompt widget #27029

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="ClickInsertEditImageTinyMCEButtonActionGroup">
<annotations>
<description>Clicks on the 'Insert/edit image' TinyMCE button.</description>
</annotations>

<click selector="{{TinyMCESection.InsertImageIcon}}" stepKey="clickInsertImageBtn" />
<waitForPageLoad stepKey="waitForPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CreateImageFolderByEnterKeyActionGroup" extends="CreateImageFolderActionGroup">
<annotations>
<description>Creates a folder (by enter key) in the Media Gallery based on the provided Folder.</description>
</annotations>

<pressKey selector="{{MediaGallerySection.FolderName}}" parameterArray="[\Facebook\WebDriver\WebDriverKeys::ENTER]" stepKey="acceptFolderName"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="DeleteFolderActionGroup">
<annotations>
<description>Deletes the provided folder by name from the Media Gallery.</description>
</annotations>
<arguments>
<argument name="ImageFolder" defaultValue="ImageFolder"/>
</arguments>

<click userInput="{{ImageFolder.name}}" stepKey="clickOnCreatedFolder"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoading"/>
<see selector="{{MediaGallerySection.DeleteFolder}}" userInput="Delete Folder" stepKey="seeDeleteFolderBtn"/>
<click selector="{{MediaGallerySection.DeleteFolder}}" stepKey="clickDeleteFolderBtn"/>
<waitForText userInput="OK" stepKey="waitForConfirm"/>
<click selector="{{MediaGallerySection.confirmDelete}}" stepKey="confirmDelete"/>
<waitForPageLoad stepKey="waitForPopUpHide"/>
<dontSeeElement selector="{{ImageFolder.name}}" stepKey="dontSeeFolderName"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="PressEscImageFolderActionGroup">
<annotations>
<description>Opens the 'create folder' modal, fills 'folder name' input with provided folder name,
presses escape key to cancel folder creation (close modal).</description>
</annotations>
<arguments>
<argument name="ImageFolder" defaultValue="ImageFolder"/>
</arguments>

<click selector="{{MediaGallerySection.CreateFolder}}" stepKey="createFolder"/>
<waitForElementVisible selector="{{MediaGallerySection.FolderName}}" stepKey="waitForPopUp"/>
<fillField selector="{{MediaGallerySection.FolderName}}" userInput="{{ImageFolder.name}}" stepKey="fillFolderName"/>
<pressKey selector="{{MediaGallerySection.FolderName}}" parameterArray="[\Facebook\WebDriver\WebDriverKeys::ESCAPE]" stepKey="cancelFolderName"/>
<waitForPageLoad stepKey="waitForPopUpHide"/>
<dontSeeElement selector="{{ImageFolder.name}}" stepKey="dontSeeFolderName"/>
</actionGroup>
</actionGroups>
1 change: 1 addition & 0 deletions app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<element name="insertBtn" type="button" selector="#insert"/>
<element name="InsertFile" type="text" selector="#insert_files"/>
<element name="CreateFolder" type="button" selector="#new_folder" />
<element name="DeleteFolder" type="button" selector="#delete_folder" />
<element name="DeleteSelectedBtn" type="text" selector="#delete_files"/>
<element name="CancelBtn" type="button" selector="#cancel" />
<element name="FolderName" type="button" selector="input[data-role='promptField']" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCheckCreateFolderEscapeAndEnterHandlesForWYSIWYGBlockTest">
<annotations>
<features value="Cms"/>
<stories value="WYSIWYG toolbar configuration with Magento Media Gallery"/>
<group value="Cms"/>
<title value="Admin should be able to cancel and close 'create folder' modal window using ESC key and
to add image to new folder (using enter key) for WYSIWYG content of Block"/>
<description value="Admin should be able to cancel and close 'create folder' modal window using ESC key and
to add image to new folder (using enter key) for WYSIWYG content of Block"/>
</annotations>

<before>
<createData entity="_defaultBlock" stepKey="createPreReqBlock" />
<actionGroup ref="LoginActionGroup" stepKey="login"/>
<actionGroup ref="EnabledWYSIWYGActionGroup" stepKey="enableWYSIWYG"/>
<actionGroup ref="SwitchToVersion4ActionGroup" stepKey="switchToTinyMCE4" />
</before>

<after>
<deleteData createDataKey="createPreReqBlock" stepKey="deletePreReqBlock" />
<actionGroup ref="DisabledWYSIWYGActionGroup" stepKey="disableWYSIWYG"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<actionGroup ref="NavigateToCreatedCMSBlockPageActionGroup" stepKey="navigateToCreatedCMSBlockPage">
<argument name="CMSBlockPage" value="$$createPreReqBlock$$"/>
</actionGroup>
<actionGroup ref="ClickInsertEditImageTinyMCEButtonActionGroup" stepKey="clickInsertImageIcon"/>
<actionGroup ref="ClickBrowseBtnOnUploadPopupActionGroup" stepKey="clickBrowserBtn"/>
<actionGroup ref="VerifyMediaGalleryStorageActionsActionGroup" stepKey="VerifyMediaGalleryStorageBtn"/>

<actionGroup ref="CreateImageFolderByEnterKeyActionGroup" stepKey="CreateImageFolderByEnterKeyPress">
<argument name="ImageFolder" value="ImageFolder"/>
</actionGroup>

<actionGroup ref="DeleteFolderActionGroup" stepKey="DeleteCreatedFolder">
<argument name="ImageFolder" value="ImageFolder"/>
</actionGroup>

<actionGroup ref="PressEscImageFolderActionGroup" stepKey="CancelImageFolderCreation">
<argument name="ImageFolder" value="ImageFolder"/>
</actionGroup>
</test>
</tests>
38 changes: 38 additions & 0 deletions app/code/Magento/Ui/view/base/web/js/modal/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,44 @@ define([
value: '',
validation: false,
validationRules: [],
keyEventHandlers: {

/**
* Enter key press handler,
* submit result and close modal window
* @param {Object} event - event
*/
enterKey: function (event) {
if (this.options.isOpen && this.modal.find(document.activeElement).length ||
this.options.isOpen && this.modal[0] === document.activeElement) {
this.closeModal(true);
event.preventDefault();
}
},

/**
* Tab key press handler,
* set focus to elements
*/
tabKey: function () {
if (document.activeElement === this.modal[0]) {
this._setFocus('start');
}
},

/**
* Escape key press handler,
* cancel and close modal window
* @param {Object} event - event
*/
escapeKey: function (event) {
if (this.options.isOpen && this.modal.find(document.activeElement).length ||
this.options.isOpen && this.modal[0] === document.activeElement) {
this.closeModal();
event.preventDefault();
}
}
},
actions: {

/**
Expand Down