Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The code introduced in #2287805: Caption filter does not work with Quarter Size image format - or with floated captions. does not have any tests written for it.
Comment | File | Size | Author |
---|---|---|---|
#4 | wysiwyg_image_captions-2466823-4.patch | 3.47 KB | segovia94 |
Comments
Comment #1
segovia94 CreditAttribution: segovia94 commentedComment #2
carsonblack CreditAttribution: carsonblack commentedThis patch creates a new test that checks the caption when the Quarter Size image style is applied to an image added via WYSIWYG as well as adds a new method, iSwitchToTheWysiwygDialogFrame to the WysiwygSubContext class that add a new step definition that will make it possible to switch to the dialog iframe.
Comment #3
carsonblack CreditAttribution: carsonblack commentedComment #4
segovia94 CreditAttribution: segovia94 commentedI rerolled this with an addition to float the image to the right and check that the output class is attached to the .caption class.
One thing to think about here is that the test doesn't visually check any of the possible outcomes brought up in the related issue this is testing. It only checks that the image has a caption. It doesn't check to make sure that the image is not overflowing the caption container or other problems the related issue fixed. I'm not totally sure how this could be done without some screenshot comparisons or using javascript to calculate positions on the page.
Comment #5
dsnopekThanks @segovia94 and @carsonblack!
Comment #6
dsnopekOne small bit of review:
I'd prefer we used "WYSIWYG" (in all caps) in the step text to be consistent with the other WYSIWYG steps.
Trying on Travis-CI quick:
https://travis-ci.org/panopoly/panopoly/builds/63692054
Comment #7
dsnopekPassed on Travis! So, what we have so far works. :-)
I think the best approach would be Javascript that checks the width of the caption compared to the width of the image. That should be enough verify that everything is working as it should!
It'd be really great to get something like that included in this test, so leaving at "Needs work".
Comment #8
ergophobe CreditAttribution: ergophobe commentedThat's probably true. I have Selenium IDE tests that grab screenshots, but the verification is strictly manual and I can't imagine how it could be automated simply, so your idea is probably a reasonable compromise. I've used a similar method with Selenium IDE to test on a Views Slideshow that had special resizing requirement and it seemed to effectively trip if something breaks (i.e. a class changes so the selector breaks).
The issue that jumps out is that if a shared selector changes, I could see the caption and the image both being returned as zero. So it should probably test that they are not only equal, but numeric and non-zero.
The original patch this test is being written for already had code to grab the widths of the image, but was found not to be robust enough. The updated patch includes a more robust method for grabbing the image width.
#2486713: Caption filter doesn't select the correct image size when an image's size is manually adjusted.
That patch code also sets the caption width and could easily be adapted to grab it for comparison.
Unfortunately, I still don't know how to integrate this into a test, but I'm happy to help as I can.
[EDIT]
Another note - I believe this too will need to use the imagesLoaded method as in the original patch. Here's my note on that from the original issue:
Since the tests are run on Panopoly and should already fail if Manual Crop is unavailable, this should be fine and I assume the same imagesLoaded() method can be used here.
Comment #9
dsnopekActually, since we're using a known image for the tests and running under a known theme, we can (and should!) specify a hard-coded width in pixels in the test. I'm imagining a step like:
... or something like that.
Yeah, that would make sense. We could make a step like:
... which uses imagesLoaded to make sure everything is loaded before checking the width.
Comment #10
ergophobe CreditAttribution: ergophobe commented>>we're using a known image
Check.
One other issue just to put it on the radar is the manual resize issue as in #2486713: Caption filter doesn't select the correct image size when an image's size is manually adjusted.)
Ideally the test would follow the logic of that most recent patch where you would take the value of the width attribute if available and check the caption width against that. Again, it could be a hard-coded width in the test just like the test for the default image.
Anyway, I don't want to make it more complex than it is, but did want to just flag the manual resize issue.