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

feat(html): link from attachment step to attachment #33267

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Oct 24, 2024

Similar to #33265. Adds a link from the attachment step to the attachment view.

This comment has been minimized.

@Skn0tt
Copy link
Member Author

Skn0tt commented Oct 24, 2024

demo:

Screen.Recording.2024-10-24.at.14.40.25.mov

This comment has been minimized.

Copy link
Contributor

@dgozman dgozman left a comment

Choose a reason for hiding this comment

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

A screenshot of some sorts would be nice to see.

<span style={{ float: 'right' }}>{msToString(step.duration)}</span>
{attachmentName && <a style={{ float: 'right' }} title='link to attachment' href={'#' + componentID(params => params.set('attachment', attachmentName))} onClick={(evt) => { evt.stopPropagation(); }}>{icons.attachment()}</a>}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this rely on the browser to automatically scroll to the anchor? How does that work together with the router? I am confused.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's how it works. Didn't even know we had a router until now - i'll see if I can switch this to our Link component.

I figured using the anchor to target an element is the most browser-standards way of making this work. But I can also change it to use scrollIntoView if you'd prefer that.

Copy link
Member Author

Choose a reason for hiding this comment

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

#33295 is a refactoring that allows us to use one scrollIntoView implementation for all attachments. It makes this implementation a lot easier.

packages/html-reporter/src/testResultView.tsx Outdated Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 19, 2024

I've updated this PR to use the Anchor primitive we added in #33537.

@Skn0tt Skn0tt requested a review from dgozman November 19, 2024 16:20

This comment has been minimized.

@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 19, 2024

sorry, i'll need to look more into this to make links to trace etc work

@Skn0tt Skn0tt marked this pull request as draft November 19, 2024 17:21
@Skn0tt Skn0tt marked this pull request as ready for review November 20, 2024 09:15
@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 20, 2024

Here's a demo of it working:

Screen.Recording.2024-11-20.at.10.15.00.mov

This comment has been minimized.

This comment has been minimized.

}, [result]);

const screenshotAnchor = React.useMemo(() => screenshots.map(a => `attachment-${a.name}`), [screenshots]);
Copy link
Contributor

Choose a reason for hiding this comment

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

  • screenshotAnchors?
  • why not return this from the previous useMemo()?

Same for otherAttachmentsAnchor.

Copy link
Member Author

Choose a reason for hiding this comment

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

That'd also work, i'll make that change.

<span style={{ float: 'right' }}>{msToString(step.duration)}</span>
{attachmentName && <a style={{ float: 'right' }} title='link to attachment' href={`#?testId=${test.testId}&anchor=attachment-${encodeURIComponent(attachmentName)}&run=${test.results.indexOf(result)}`} onClick={evt => { evt.stopPropagation(); }}>{icons.attachment()}</a>}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • I wonder why do we use <Link> in some places, and plain <a> in others?
  • Can we simplify link generation to avoid passing test and result around somehow? Perhaps take existing ones from the current url? Or put them into a context? Something for a followup.

Copy link
Member Author

Choose a reason for hiding this comment

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

  • no idea 🤷 I guess I can also rewrite this to <Link>, but I don't think there'll be a big difference since it's not a text link but a button
  • agree, that'd be nice. i'll look at it in a followup.

Copy link
Member Author

@Skn0tt Skn0tt Nov 20, 2024

Choose a reason for hiding this comment

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

i've tried rewriting, but that doesn't work as well because <Link> doesn't allow passing in the float: 'right' style. Let's stick with <a>.

This comment has been minimized.

Copy link
Contributor

Test results for "tests 1"

3 flaky ⚠️ [chromium] › components/splitView.spec.tsx:35:5 › should render sidebar first @web-components-web
⚠️ [webkit-page] › page/page-leaks.spec.ts:107:5 › fill should not leak @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

37181 passed, 650 skipped
✔️✔️✔️

Merge workflow run.

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

Successfully merging this pull request may close these issues.

2 participants