This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add caption feild element in the page object | |
# acceptance/pages/content_items_edit_page.rb | |
element :photohud_caption_tinymce, :xpath, "//div[contains(@class, 'photo-mode-container')]//textarea[contains(@name, 'caption')]" | |
# acceptance/content_item/story_content_item_spec.rb | |
scenario "use related item photo hud to edit caption field" do | |
edit_page.load(content_item_id: @story1.id) | |
edit_page.relationships_tab.click | |
edit_page.edit_related_photo.click | |
# Can set an expectation on an element to be visible with have_x | |
# In this case its checking that the edit_page has the photo hud element | |
expect(edit_page).to have_photo_hud | |
# Using .wait_for_x is a good way to wait on an ajax request to complete | |
# In this case its waiting for the photo hud button to appear for the given # of seconds (5) | |
edit_page.wait_for_photohud_edit_original_button(5) | |
edit_page.photohud_edit_original_button.click | |
edit_page.execute_script(%Q(tinyMCE.get("#{edit_page.photohud_caption_tinymce(visible: false)[:id]}").setContent("Test"))) | |
# This is a tinymce thing to ensure that it writes to the textarea field for when the form submits | |
edit_page.execute_script(%Q(tinyMCE.triggerSave())) | |
edit_page.photohud_ok_button.click | |
edit_page.wait_for_photohud_submit_button(5) | |
edit_page.photohud_submit_button.click | |
# Make sure the hud has been remove from the page | |
expect(edit_page).to have_no_css('.hud_container') | |
edit_page.save.click | |
expect(@story1.related_content_items.first.caption).to eql("<p>Test</p>\r\n") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment