★ wanayoo — archive 1999 https://github.com/pytest-dev/pytest-html/pull/112Nouvelle recherche | Portail wanayoo
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

Add image galler/slider for screenshots etc #112

Open
wants to merge 1 commit into
base: master
from

Conversation

@BeyondEvil
Copy link
Contributor

BeyondEvil commented May 10, 2017

I would suggest merging this PR #111 first. Since this PR really hits the same code.

Hopefully this will get the discussion started @davehunt :)

Copy link
Collaborator

davehunt left a comment

This is a great start, thanks @BeyondEvil!

Whilst testing this, I found that if I had multiple failures in my report, only the last occurrence of an image worked - perhaps because all inputs belong to the same group?

It would be nice if the prev/next buttons were circular, in that clicking next on the last image would display the first image.

When next/prev are not required (if there's only one image) they should be hidden, and not add extra padding to the images.

Could we add the image name as an alt attribute for the image? A caption might be nice, but this will at least help when users need to link the images to the names.

html.a(html.img(src=src), href=href),
class_='image'))
self.images_html.append(html.a(html.img(
src=src), href=href, target='_blank'))

This comment has been minimized.

@davehunt

davehunt May 15, 2017 Collaborator

In the case that the src is a base64 encoded string, we're duplicating it for the href. This will cause considerable increase in the file size if there's more than a few screenshots. This is actually related to #110, where I suggest resolving this using JavaScript.

This comment has been minimized.

@BeyondEvil

BeyondEvil May 16, 2017 Author Contributor

Keep as is, and revisit in #110 ?

@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented May 17, 2017

I do not understand how the remote version of this branch can have the "name" PR. I really don't. Because I haven't pushed it. And if it has it, why then do I need to push it again for it to not complain when I'm trying to push real changes. It. Does. Not. Make. Sense.

To avoid this crap, do I push with -f ? Because I don't really care about the state of the remote version, I care about the updated changes I have locally.

@BeyondEvil BeyondEvil force-pushed the BeyondEvil:imagegallery branch from 00e9108 to d425265 May 23, 2017
@BeyondEvil BeyondEvil force-pushed the BeyondEvil:imagegallery branch from c4df2d3 to 1e26aa7 Jun 12, 2017
@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented Jun 12, 2017

Ping @davehunt

Copy link
Collaborator

davehunt left a comment

I just pulled down the changes and tested them locally. I'm still seeing issues where the first result with multiple images works as expected, but later results with multiple images affect the images displayed in the first result. I also noticed that the page jumps around when clicking the buttons, and the URL changes after a click. I think we should prevent this.

Also, style wise, I'd like to see the next/previous buttons at the bottom of the image, almost like a toolbar. I mocked up an example here:

wbst

What do you think?

@davehunt
Copy link
Collaborator

davehunt commented Jun 20, 2017

Also, I just wanted to note that I haven't reviewed the code as I think we should get the style and functionality working first.

@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented Jun 21, 2017

That's so weird as I specifically tested that scenario. I also mixed failures with 1 image, with failures with multiple images, and passes. And I couldn't see any issues. Maybe you can screenshot and/or be more specific to what issues you're seeing?

I will look at the jumping around issue (didn't notice that myself).

The URL changing is unfortunately something we have to live with unless we want to involve JS. At least to my knowledge (and the frontenders where I work).

I'll see how close to your mock I can get. :)

@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented Aug 23, 2017

Ping @davehunt I'm finally back to normalcy. Well, somewhat. Please have a look at my previous comments.

I'm going to spend some time on this now, but need to get my head back in the game. :)

@davehunt
Copy link
Collaborator

davehunt commented Oct 2, 2017

@BeyondEvil are there any particular comments you'd like me to review?

@PhilippSelenium
Copy link

PhilippSelenium commented Jan 7, 2019

Is there any update on this merge request? I would really like to have the ability to click the thumbnail instead of right click --> open image location.

@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented Jan 7, 2019

@PhilippSelenium Agreed, that should be an easy fix. I might do a separate PR just to fix that, unless you're willing to do it?

@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented Jan 22, 2019

Hi @RibeiroAna !

Would you mind talking a look at this PR? I have to admit it's a bit over my head. :(

The way a report looks today with multiple screenshots is no good. The stacktrace section is all squished together.

https://dporganizer-test-results.s3.amazonaws.com/e2e/2019-01-22_16-56-31_e2e_test_report_24396.html

@RibeiroAna
Copy link
Member

RibeiroAna commented Jan 23, 2019

I'm taking a look @BeyondEvil

html.a('>', class_='button next',
href='#{}'.format(self.images[next_image][0])))
image_html.append(
html.div(carousel_html, id='{}'.format(src)))

This comment has been minimized.

@RibeiroAna

RibeiroAna Jan 23, 2019 Member

Id must be unique for every image!! That is because the caroussel is not working when there are multiple test's cases.

Suggested change
html.div(carousel_html, id='{}'.format(src)))
html.div(carousel_html, id='{}'.format(src + self.test_id)))
@RibeiroAna
Copy link
Member

RibeiroAna commented Jan 23, 2019 •

@BeyondEvil I think I figured out the problem: when there are multiple test cases, the id for the multiple generated <div> were the same, so the Carousel couldn't work. My suggestion is adding the test_id to the id of the div, so it can be a single id per test (of course, you will need to change the "previous" and "next" links as well), I tested locally and this change seemed to work!

I reinforce Dave's request to style as he mocked because in the way you styled, depending on the image, the "next" and "previous" links are basically invisible, when I tested with some local images with gray background, I couldn't see them.

Last but not least, I think it would be nice to have a test case of this new functionality with the rerun plugin.

next_image = (image + 1) % num_of_images
carousel_html.append(
html.a('>', class_='button next',
href='#{}'.format(self.images[next_image][0])))

This comment has been minimized.

@RibeiroAna

RibeiroAna Jan 23, 2019 Member

Suggested change
href='#{}'.format(self.images[next_image][0])))
href='#{}'.format(self.images[next_image][0] + self.test_id)))
prev_image = (image - 1) % num_of_images
carousel_html.append(
html.a('<', class_='button prev',
href='#{}'.format(self.images[prev_image][0])))

This comment has been minimized.

@RibeiroAna

RibeiroAna Jan 23, 2019 Member

Suggested change
href='#{}'.format(self.images[prev_image][0])))
href='#{}'.format(self.images[prev_image][0] + self.test_id)))

test_index = hasattr(report, 'rerun') and report.rerun + 1 or 0

for extra_index, extra in enumerate(getattr(report, 'extra', [])):
self.append_extra_html(extra, extra_index, test_index)

num_of_images = len(self.images)
if num_of_images == 1: # Only one image, no need for carousel

This comment has been minimized.

@PhilippSelenium

PhilippSelenium Jan 23, 2019

Have you considered generalizing it using one for loop instead of the if elif else stuff.


elif num_of_images > 1: # More than one image, build carousel
image_html = []
for image in range(num_of_images):

This comment has been minimized.

@PhilippSelenium

PhilippSelenium Jan 23, 2019

for i in range(iterable):
    iterable[i]

Doesn't look very pythonic
Have a look here: https://stackoverflow.com/questions/1011938/python-previous-and-next-values-inside-a-loop

@BeyondEvil
Copy link
Contributor Author

BeyondEvil commented Jan 23, 2019

Thank you so much for your input @PhilippSelenium and @RibeiroAna !

Much appreciated! If your fingers are itching, I'm more than happy to relinquish this PR to your capable hands. If not, I should be able to work some on it next month.

@RibeiroAna
Copy link
Member

RibeiroAna commented Jan 23, 2019

@BeyondEvil I'm not interested on finishing it. If depends on me, you can go on.

@ssbarnea
Copy link
Collaborator

ssbarnea commented Aug 11, 2020

@BeyondEvil Can you fix conflicts or close it if no longer needed? Thanks.

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

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.