diff --git a/tests/features/contentpage.feature b/tests/features/contentpage.feature
index 71ba067..bbdf206 100644
--- a/tests/features/contentpage.feature
+++ b/tests/features/contentpage.feature
@@ -20,12 +20,12 @@ Feature: Add content page
When I press "edit-submit"
Then the "h1" element should contain "Testing title"
- @api @javascript @panopoly_pages
+ @api @javascript @panopoly_pages @local_files
Scenario: Add a Featured Image with incorrect dimensions
When I attach the file "test-sm.png" to "files[field_featured_image_und_0]"
Then I should see "The specified file test-sm.png could not be uploaded. The image is too small; the minimum dimensions are 300x200 pixels."
- @api @javascript @panopoly_pages
+ @api @javascript @panopoly_pages @local_files
Scenario: Add a Featured image
# Revisting the page will not be necessary when https://drupal.org/node/2281709 is resolved
When I visit "/node/add/panopoly-page"
diff --git a/tests/features/file_widget.feature b/tests/features/file_widget.feature
index 0e97dfc..c0fda83 100644
--- a/tests/features/file_widget.feature
+++ b/tests/features/file_widget.feature
@@ -12,7 +12,7 @@ Feature: Add a file to a page
And I click "Add file" in the "CTools modal" region
Then I should see "Configure new Add file"
- @api @javascript @panopoly_widgets
+ @api @javascript @panopoly_widgets @local_files
Scenario: Add a file
Then I should see "Allowed file types: txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp."
When I fill in the following:
diff --git a/tests/features/image_widget.feature b/tests/features/image_widget.feature
index 18c451f..b4dbe92 100644
--- a/tests/features/image_widget.feature
+++ b/tests/features/image_widget.feature
@@ -3,7 +3,7 @@ Feature: Add image widget
As a site administrator
I need to be able to use the image widget
- @api @javascript @panopoly_widgets
+ @api @javascript @panopoly_widgets @local_files
Scenario: Add a image
Given I am logged in as a user with the "administrator" role
And Panopoly magic live previews are disabled
diff --git a/tests/features/livepreview.feature b/tests/features/livepreview.feature
index be9be57..de587a5 100644
--- a/tests/features/livepreview.feature
+++ b/tests/features/livepreview.feature
@@ -140,3 +140,123 @@ Feature: Live preview
When I fill in "Description" with "Testing description"
And I wait for live preview to finish
Then I should see "Image field is required"
+
+ @api @javascript @panopoly_magic @panopoly_widgets
+ Scenario: Page should match live preview after saving the widget but before saving the page
+ Given I am logged in as a user with the "administrator" role
+ And Panopoly magic live previews are manual
+ And I am viewing a landing page
+ When I customize this page with the Panels IPE
+ And I click "Add new pane"
+ And I click "Add text" in the "CTools modal" region
+ Then I should see "Configure new Add text"
+ When I fill in "Title" with "Widget title 1"
+ And I type "Widget content 1" in the "edit-field-basic-text-text-und-0-value" WYSIWYG editor
+ And I press "Update Preview"
+ Then I should see "Widget title 1" in the "Live preview" region
+ And I should see "Widget content 1" in the "Live preview" region
+ When I press "Save" in the "CTools modal" region
+ Then I should see "Widget title 1" in the "h2" element in the "Boxton Content" region
+ And I should see "Widget content 1"
+ # Now try saving the page, and doing the same test, but with an existing widget.
+ When I press "Save"
+ And I wait for the Panels IPE to deactivate
+ And I customize this page with the Panels IPE
+ And I click "Edit" in the "Boxton Content" region
+ When I fill in the "edit-field-basic-text-text-und-0-value" WYSIWYG editor with "Widget content 2"
+ And I fill in "Title" with "Widget title 2"
+ And I press "Update Preview"
+ Then I should see "Widget title 2" in the "Live preview" region
+ And I should see "Widget content 2" in the "Live preview" region
+ When I press "Save" in the "CTools modal" region
+ Then I should not see "Widget title 1"
+ And I should not see "Widget content 1"
+ And I should see "Widget title 2" in the "h2" element in the "Boxton Content" region
+ And I should see "Widget content 2"
+
+ @api @javascript @panopoly_magic @panopoly_widgets
+ Scenario: Live preview should work equally well with a reusable widget
+ Given I am logged in as a user with the "administrator" role
+ And Panopoly magic live previews are manual
+ And I am viewing a landing page
+ When I customize this page with the Panels IPE
+ And I click "Add new pane"
+ And I click "Add text" in the "CTools modal" region
+ Then I should see "Configure new Add text"
+ When I check the box "Make this reusable"
+ And I fill in "admin_title" with "Test text widget"
+ And I fill in "Title" with "Widget title 1"
+ And I type "Widget content 1" in the "edit-field-basic-text-text-und-0-value" WYSIWYG editor
+ And I press "Update Preview"
+ Then I should see "Widget title 1" in the "Live preview" region
+ And I should see "Widget content 1" in the "Live preview" region
+ When I press "Save" in the "CTools modal" region
+ Then I should see "Widget title 1" in the "h2" element in the "Boxton Content" region
+ And I should see "Widget content 1"
+ # Now try saving the page, and doing the same test, but with an existing widget.
+ When I press "Save"
+ And I wait for the Panels IPE to deactivate
+ And I customize this page with the Panels IPE
+ And I click "Edit" in the "Boxton Content" region
+ When I fill in the "edit-field-basic-text-text-und-0-value" WYSIWYG editor with "Widget content 2"
+ And I fill in "Title" with "Widget title 2"
+ And I press "Update Preview"
+ Then I should see "Widget title 2" in the "Live preview" region
+ And I should see "Widget content 2" in the "Live preview" region
+ When I press "Save" in the "CTools modal" region
+ Then I should not see "Widget title 1"
+ And I should not see "Widget content 1"
+ And I should see "Widget title 2" in the "h2" element in the "Boxton Content" region
+ And I should see "Widget content 2"
+
+ @api @javascript @panopoly_magic @panopoly_widgets
+ Scenario: Making the title a link should work for both new and existing widgets
+ Given I am logged in as a user with the "administrator" role
+ And Panopoly magic live previews are manual
+ And I am viewing a landing page
+ When I customize this page with the Panels IPE
+ And I click "Add new pane"
+ And I click "Add text" in the "CTools modal" region
+ Then I should see "Configure new Add text"
+ When I check the box "Make title a link"
+ And I fill in "path" with "http://google.com"
+ And I fill in "Title" with "Widget title 1"
+ And I type "Widget content 1" in the "edit-field-basic-text-text-und-0-value" WYSIWYG editor
+ And I press "Update Preview"
+ Then I should see "Widget title 1" in the "Live preview" region
+ And I should see "Widget content 1" in the "Live preview" region
+ And I should see the link "Widget title 1" in the "Live preview" region
+ # Now try saving the page, and doing the same test, but with an existing widget.
+ When I press "Save" in the "CTools modal" region
+ And I press "Save"
+ And I wait for the Panels IPE to deactivate
+ When I customize this page with the Panels IPE
+ And I click "Edit" in the "Boxton Content" region
+ And I uncheck the box "Make title a link"
+ And I press "Update Preview"
+ Then I should see "Widget title 1" in the "Live preview" region
+ And I should not see the link "Widget title 1" in the "Live preview" region
+ # Prevent modal popup from breaking subsequent tests.
+ When I press "Save" in the "CTools modal" region
+ And I press "Save"
+ And I wait for the Panels IPE to deactivate
+
+ @api @javascript @panopoly_magic @panopoly_widgets @local_files
+ Scenario: Previewing an image widget should show a valid image
+ Given I am logged in as a user with the "administrator" role
+ And Panopoly magic live previews are manual
+ And I am viewing a landing page
+ When I customize this page with the Panels IPE
+ And I click "Add new pane"
+ And I click "Add image" in the "CTools modal" region
+ Then I should see "Configure new Add image"
+ When I fill in the following:
+ | Title | Testing image widget title |
+ | Editor | plain_text |
+ | Caption | Testing caption |
+ And I attach the file "test-sm.png" to "files[field_basic_image_image_und_0]"
+ And I press "Upload"
+ And I press "Update Preview"
+ Then I should see "Testing image widget title" in the "Live preview" region
+ And I should see "Testing caption" in the "Live preview" region
+ And I should see an image in the "Live preview" region
diff --git a/tests/steps/panopoly_test.behat.inc b/tests/steps/panopoly_test.behat.inc
index a9babd9..5bda8ee 100644
--- a/tests/steps/panopoly_test.behat.inc
+++ b/tests/steps/panopoly_test.behat.inc
@@ -240,6 +240,52 @@ class TestSubContext extends BehatContext implements DrupalSubContextInterface {
}
/**
+ * @Then /^I should see an image in the "([^"]*)" region$/
+ *
+ * Attempts to determine if the image is broken or not.
+ */
+ public function assertValidImageRegion($region) {
+ $regionObj = $this->getMainContext()->getRegion($region);
+ $elements = $regionObj->findAll('css', 'img');
+ if (empty($elements)) {
+ throw new \Exception(sprintf('No image was not found in the "%s" region on the page %s', $region, $this->getSession()->getCurrentUrl()));
+ }
+
+ if ($src = $elements[0]->getAttribute('src')) {
+ $params = array('http' => array('method' => 'HEAD'));
+ $context = stream_context_create($params);
+ $fp = @fopen($src, 'rb', FALSE, $context);
+ if (!$fp) {
+ throw new \Exception(sprintf('Unable to download in the "%s" region on the page %s', $src, $region, $this->getSession()->getCurrentUrl()));
+ }
+
+ $meta = stream_get_meta_data($fp);
+ fclose($fp);
+ if ($meta === FALSE) {
+ throw new \Exception(sprintf('Error reading from in the "%s" region on the page %s', $src, $region, $this->getSession()->getCurrentUrl()));
+ }
+
+ $wrapper_data = $meta['wrapper_data'];
+ $found = FALSE;
+ if (is_array($wrapper_data)) {
+ foreach ($wrapper_data as $header) {
+ if (substr(strtolower($header), 0, 19) == 'content-type: image') {
+ $found = TRUE;
+ }
+ }
+ }
+
+ if (!$found) {
+ throw new \Exception(sprintf('Not a valid image in the "%s" region on the page %s', $src, $region, $this->getSession()->getCurrentUrl()));
+ }
+ }
+ else {
+ throw new \Exception(sprintf('No image had no src="..." attribute in the "%s" region on the page %s', $region, $this->getSession()->getCurrentUrl()));
+ }
+ }
+
+
+ /**
* @Then /^I should see the image alt "(?P(?:[^"]|\\")*)" in the "(?P[^"]*)"(?:| region)$/
*/
public function assertAltRegion($alt, $region) {