Skip to content

MFTF Automation for: User locates licensed and uploaded image inside Media Gallery #639

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

Merged
merged 9 commits into from
Nov 20, 2019

Conversation

drpayyne
Copy link
Contributor

@drpayyne drpayyne commented Nov 4, 2019

Description

  • Added MFTF test for the below mentioned issue

Fixed Issues

Manual testing scenarios

  • Add magento/ADOBE_STOCK_LICENSED_IMAGE credential with the image ID of a licensed image
  • $ vendor/bin/mftf run:test AdminAdobeStockSavedLicensedImageLocateTest --remove

@diazwatson
Copy link
Contributor

Hi @drpayyne, thanks for your contribution.
While running your test I get the following error:

Time: 2.99 minutes, Memory: 12.00MB

There was 1 error:

---------
1) AdminAdobeStockSavedLicensedImageLocateTestCest: Admin adobe stock saved licensed image locate test
 Test  tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:AdminAdobeStockSavedLicensedImageLocateTest

  [Facebook\WebDriver\Exception\UnrecognizedExceptionException] element click intercepted: Element <button id="search_adobe_stock" title="Search Adobe Stock" type="button" class="action-default scalable action-secondary" onclick="jQuery(&quot;#adobe-stock-images-search-modal&quot;).trigger(&quot;openModal&quot;);" data-ui-id="wysiwyg-images-content-search-adobe-stock-button">...</button> is not clickable at point (532, 126). Other element would receive the click: <div class="action-buttons preview-buttons">...</div>
  (Session info: chrome=78.0.3904.87)
  (Driver info: chromedriver=78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800}),platform=Mac OS X 10.15.1 x86_64)


Scenario Steps:

 59. $I->click("[data-ui-id=wysiwyg-images-content-search-adobe-stock-button]") at tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:82
 58. // Entering Action Group [openAdobeStockPanel] AdminAdobeStockOpenPanelFromMediaGalleryActionGroup
 57. $I->saveScreenshot() at tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:113
 56. $I->grabAttributeFrom("//button[@class='action-secondary']//spa...","name") at tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:136
 55. // Exiting Action Group [expandLicensedImage] AdminAdobeStockExpandImagePreviewActionGroup
 54. $I->waitForLoadingMaskToDisappear() at tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:134

#1  /Users/rdiaz/Sites/adobestock/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:158
#2  /Users/rdiaz/Sites/adobestock/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:331
#3  /Users/rdiaz/Sites/adobestock/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:565
#4  /Users/rdiaz/Sites/adobestock/vendor/facebook/webdriver/lib/Remote/RemoteExecuteMethod.php:40
#5  /Users/rdiaz/Sites/adobestock/vendor/facebook/webdriver/lib/Remote/RemoteWebElement.php:81
#6  Codeception\Module\WebDriver->click
#7  /Users/rdiaz/Sites/adobestock/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_generated/AcceptanceTesterActions.php:1136
#8  /Users/rdiaz/Sites/adobestock/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:82
#9  Magento\AcceptanceTest\_default\Backend\AdminAdobeStockSavedLicensedImageLocateTestCest->_after

ERRORS!
Tests: 1, Assertions: 1, Errors: 1.

Have you seen this before?
Note: in order to run this test in isolation I had to comment out the following lines:

<group value="adobe_stock_integration_license"/>
<group value="adobe_stock_integration"/>

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 5, 2019

@diazwatson No I haven't got that error. Let me try in my local once again.

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 5, 2019

@diazwatson I think it's due to the Locate button image fix not being present here. (#637 (comment)) Testing with the fix in my local now.

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 5, 2019

Hi @diazwatson. I've fixed it now, thanks. Also note that I've changed environment variable name for more clarity due to multiple similar MFTF tests present for Adobe Stock image licensing.

@diazwatson
Copy link
Contributor

Great! thanks for your effort @drpayyne I am going to re test it now

@diazwatson
Copy link
Contributor

diazwatson commented Nov 7, 2019

Just ran the test and it complete successfully.

AdminAdobeStockSavedLicensedImageLocateTestCest: Admin adobe stock saved licensed image locate test
Signature: Magento\AcceptanceTest\_default\Backend\AdminAdobeStockSavedLicensedImageLocateTestCest:AdminAdobeStockSavedLicensedImageLocateTest
Test: tests/functional/Magento/FunctionalTest/_generated/default/AdminAdobeStockSavedLicensedImageLocateTestCest.php:AdminAdobeStockSavedLicensedImageLocateTest
Scenario --
[loginAsAdmin] LoginAsAdmin
  [navigateToAdmin] am on page "/admin/admin"
  [fillUsername] fill field "#username","admin"
  [fillPassword] fill field "#login","123123q"
  [clickLogin] click ".actions .action-primary"
  [clickLoginWaitForPageLoad] wait for page load 30
  [closeAdminNotification] close admin notification
[openMediaGalleryForPage] AdminOpenMediaGalleryForPageNoEditorActionGroup
  [amOnPagePagesGrid] am on page "/admin/cms/page"
  [waitForPageLoad] wait for page load 10
  [clickAddNewPage] click "#add"
  [clickAddNewPageWaitForPageLoad] wait for page load 30
  [clickExpandContent] click "div[data-index=content]"
  [waitForInsertImageButton] wait for element visible ".scalable.action-add-image.plugin",10
  [clickInsertImage] click ".scalable.action-add-image.plugin"
  [] wait for initial media gallery load, where the gallery chrome loads (and triggers loading modal)
  [waitForMediaGalleryInitialLoad] wait for page load 10
  [] javascript ERROR(SEVERE) - https://adobestock.test/static/version1572277603/adminhtml/Magento/backend/en_US/mage/adminhtml/browser.js 91:47 Uncaught T
  [] wait for second media gallery load, where the gallery images load (and triggers loading modal once more)
  [waitForMediaGallerySecondaryLoad] wait for page load 10
[openAdobeStockPanel] AdminAdobeStockOpenPanelFromMediaGalleryActionGroup
  [openAdobeStockPanel] click "[data-ui-id=wysiwyg-images-content-search-adobe-stock-button]"
  [waitForAdobeStockPanelOpen] wait for page load 10
[clickOnSignIn] AdminAdobeStockClickSignInActionGroup
  [clickOnSignInButton] click ".adobe-sign-in-button"
  [waitForLoad] wait for page load 10
[fillUserCredentials] AdminAdobeStockImsPopupSignInFillUserDataActionGroup
  [switchToWindow] switch to window
  [fillUserEmail] fill field "#adobeid_username","[email protected]"
  [clickPasswordField] click "#adobeid_password"
  [waitForUserEmailToLoad] wait for page load 10
  [fillUserPassword] fill field "#adobeid_password","47b4G3rQEuZ0"
[clickSignInImsPopup] AdminAdobeStockImsPopupClickSignInActionGroup
  [clickOnSignInButton] click "#sign_in"
  [switchToTab] switch to next tab
  [waitForLoad] wait for page load 10
[assertUserLoggedIn] AdminAdobeStockAssertUserLoggedActionGroup
  [seeUserIcon] see element ".adobe-profile-image-small"
[searchForLicensedImage] AdminSearchImagesOnModalActionGroup
  [fillQueryInput] fill field "input.data-grid-search-control","176476298"
  [applySearch] click "#words + button.action-submit"
  [waitForSearchForQuery] wait for loading mask to disappear
[expandLicensedImage] AdminAdobeStockExpandImagePreviewActionGroup
  [clickOnThumbnail] click "aside.adobe-stock-modal [data-role=grid-wrapper] img[data-role=thumbnail]"
  [waitForImagePreviewToExpand] wait for loading mask to disappear
[grabImageFileName] grab attribute from "//button[@class='action-secondary']//span[text()='Locate']","name"
[clickLocate] click "//button[@class='action-secondary']//span[text()='Locate']"
[waitForMediaGalleryOpen] wait for page load 10
[assertSavedImage] see element "//img[contains(@alt,'motorcycle-wheels-there-is-a-wom.jpeg')]"
[openMediaGalleryForPage] AdminOpenMediaGalleryForPageNoEditorActionGroup
  [amOnPagePagesGrid] am on page "/admin/cms/page"
  [waitForPageLoad] wait for page load 10
  [clickAddNewPage] click "#add"
  [clickAddNewPageWaitForPageLoad] wait for page load 30
  [clickExpandContent] click "div[data-index=content]"
  [waitForInsertImageButton] wait for element visible ".scalable.action-add-image.plugin",10
  [clickInsertImage] click ".scalable.action-add-image.plugin"
  [] wait for initial media gallery load, where the gallery chrome loads (and triggers loading modal)
  [waitForMediaGalleryInitialLoad] wait for page load 10
  [] javascript ERROR(SEVERE) - https://adobestock.test/static/version1572277603/adminhtml/Magento/backend/en_US/mage/adminhtml/browser.js 91:47 Uncaught T
  [] wait for second media gallery load, where the gallery images load (and triggers loading modal once more)
  [waitForMediaGallerySecondaryLoad] wait for page load 10
[openAdobeStockPanel] AdminAdobeStockOpenPanelFromMediaGalleryActionGroup
  [openAdobeStockPanel] click "[data-ui-id=wysiwyg-images-content-search-adobe-stock-button]"
  [waitForAdobeStockPanelOpen] wait for page load 10
[adobeLogout] AdminAdobeStockUserSignOutActionGroup
  [clickOnUserNameButton] click ".adobe-user-name"
  [clickOnUserSignOutButton] click ".adobe-sign-out-button"
  [waitForLoad] wait for page load 10
[assertAdobeUserLoggedOut] AdminAdobeStockAssertUserNotLoggedActionGroup
  [userIconIsNotVisible] don't see element ".adobe-profile-image-small"
  [signInLinkIsVisible] see element ".adobe-sign-in-button"
[resetAdminDataGridToDefaultView] resetAdminDataGridToDefaultView
  [openViewBookmarks] click "div.admin__data-grid-action-bookmarks button[data-bind='toggleCollapsible']"
  [openViewBookmarksWaitForPageLoad] wait for page load 30
  [selectDefaultGridView] click "//div[contains(@class, 'admin__data-grid-action-bookmarks')]/ul/li/div/a[text() = 'Default View']"
  [selectDefaultGridViewWaitForPageLoad] wait for page load 30
  [seeDefaultViewSelected] see "Default View","div.admin__data-grid-action-bookmarks button[data-bind='toggleCollapsible']"
  [seeDefaultViewSelectedWaitForPageLoad] wait for page load 30
[adminLogout] logout
  [amOnLogoutPage] am on page "/admin/admin/auth/logout/"
 PASSED

--------------------------------------------------------------------------------
200x DEPRECATION: Calling the "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead. /Users/rdiaz/Sites/adobestock/vendor/symfony/event-dispatcher/EventDispatcher.php:58


Time: 7.32 minutes, Memory: 8.00MB

OK (1 test, 5 assertions)

While during the test I noticed few repetitive and maybe unnecessary (for the purpose of this test) steps, I believe this is a side effect of the action groups.

Other than that, I think is all fine.

@filmaj @sivaschenko can you spot any way this can be improved?

diazwatson
diazwatson previously approved these changes Nov 7, 2019
@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2019

Damn @diazwatson , you also have long test run times, and you have the same "JS error severe" in your MFTF output as others. You should check in on #652 as that JS error may be the root of slow test runs on certain systems.

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 7, 2019

@diazwatson thank you, but which parts in the action group are unnecessary? Just for the sake of knowledge. Maybe I can improve it if possible.

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So as we've discussed in different issues / PRs, I think this test needs modification to expand the before and after clauses:

  • before the test assertions execute, we'll need to save a licensed image to the media gallery
  • after the test, we'll need to delete the saved + licensed image from the media gallery

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 8, 2019

Hey @filmaj, I have added the necessary modifications. Thanks!

@filmaj
Copy link
Contributor

filmaj commented Nov 8, 2019

Hmm.. for me, in the before, it fails at this point:

[searchForLicensedImage] AdminSearchImagesOnModalActionGroup
  [fillQueryInput] fill field "input.data-grid-search-control","286863296"
  [applySearch] click "#words + button.action-submit"
  [waitForSearchForQuery] wait for loading mask to disappear
[expandLicensedImage] AdminAdobeStockExpandImagePreviewActionGroup
  [clickOnThumbnail] click "aside.adobe-stock-modal [data-role=grid-wrapper] img[data-role=thumbnail]"
  [waitForImagePreviewToExpand] wait for loading mask to disappear
[clickSave] click "//button[@class='action-default primary']//span[text()='Save']"
[saveScreenshot] save screenshot

.. then explodes in the after since the before did not finish completing. I will try to dig into this a bit deeper.

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 9, 2019

@filmaj, a probable test fail at that particular button click might be that the image isn't licensed, so the button text was License and Save, or maybe the image was already saved, so only Locate button was present.

@filmaj
Copy link
Contributor

filmaj commented Nov 9, 2019

@drpayyne I was looking at the test as it was running, can confirm the button text was just 'Save'... I'm going to need to comment out the after clause and run in again to try to extract more failure details from the before clause, as the after clause's deleteImage action blows up and covers over any earlier failures.

Will report back when I have time to look into this.. not sure if I'll get to it this weekend, may have to wait until Monday.

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 9, 2019

@filmaj, no issues. I shall try on my local too asap.

@drpayyne
Copy link
Contributor Author

drpayyne commented Nov 11, 2019

Hi @filmaj, I ran the test and yes I can confirm the button text is Save but this is the actual error thrown: element click intercepted: Element <span>...</span> is not clickable at point (1147, 137). Other element would receive the click: <div class="preview-row-content">...</div>.
<div class="preview-row-content"> is the container for the image preview view. Not sure why this is being clicked, will debug further.

@filmaj
Copy link
Contributor

filmaj commented Nov 11, 2019

Can also confirm that local media gallery was empty in my runs here, that is, no images were saved before the test ran.

@filmaj filmaj changed the title Resolved issue #444 MFTF Automation for: User locates licensed and uploaded image inside Media Gallery Nov 13, 2019
Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The before bits now save the image locally, which is great, but extracting the saved file name using the Locate span's name attribute fails for me - see my comments below. So this still needs a little more work.

<argument name="query" value="{{AdobeStockConfigDataLicensedImage.value}}"/>
</actionGroup>
<actionGroup ref="AdminAdobeStockExpandImagePreviewActionGroup" stepKey="expandLicensedImage"/>
<grabAttributeFrom selector="{{AdobeStockImagePreviewSection.locateImage}}" userInput="name" stepKey="grabImageFileName"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line returns the empty string in my local test r un, as the span element containing the Locate text does not have a name attribute. This results in the rest of the test being unable to compare against the file name. Here's a snippet of this happening in my test run locally (note the empty string used with the alt attribute):

[searchForLicensedImage] AdminSearchImagesOnModalActionGroup
  [fillQueryInput] fill secret field "input.data-grid-search-control","84Gol3inT8K17CaG7uHIhg=="
  [applySearch] click "#words + button.action-submit"
  [waitForSearchForQuery] wait for loading mask to disappear
[expandLicensedImage] AdminAdobeStockExpandImagePreviewActionGroup
  [clickOnThumbnail] click "aside.adobe-stock-modal [data-role=grid-wrapper] img[data-role=thumbnail]"
  [waitForImagePreviewToExpand] wait for loading mask to disappear
[grabImageFileName] grab attribute from "//button[@class='action-secondary']//span[text()='Locate']","name"
[clickLocate] click "//button[@class='action-secondary']//span[text()='Locate']"
[waitForMediaGalleryOpen] wait for page load 10
[assertSavedImage] see element "//img[contains(@alt,'')]"
[deleteImageActionGroup] AdminMediaGalleryDeleteImage
  [seeImageToDelete] see element "//img[contains(@alt,'')]"
  [clickImageToDelete] click "//img[contains(@alt,'')]"
[saveScreenshot] save screenshot

Copy link
Contributor Author

@drpayyne drpayyne Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @filmaj, I just tested it locally and can confirm that this test just passed and the name attribute with the filename is present in the Locate button. 🤔 Could you check if actions.js file in this PR is loaded in your browser with the method getImageName()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you pointed out to me on Slack, I must not be in developer mode and client side assets a re being cached in my system. After doing that song and dance, I get a different error around finding the image in the media gallery once clicking the Locate button:

1) AdminAdobeStockSavedLicensedImageLocateTestCest: Admin adobe stock saved licensed image locate test
 Test  tests/functional/Magento/FunctionalTest/_generated/adobe_stock_integration_suite/AdminAdobeStockSavedLicensedImageLocateTestCest.php:AdminAdobeStockSavedLicensedImageLocateTest
 Step  See element "//img[contains(@alt,'hygge-concept-with-cat-book-and.jpeg')]"
 Fail  Failed asserting that an array is not empty.

I think it may be an issue with my environment. When clicking the Locate button, it takes a long time for the media gallery to load up on my local instance...

@ghost
Copy link

ghost commented Nov 20, 2019

Hi @drpayyne, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants