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

Feature: allow to provide titles for link list in html formatter #2433

Open
vitalets opened this issue Sep 30, 2024 · 4 comments
Open

Feature: allow to provide titles for link list in html formatter #2433

vitalets opened this issue Sep 30, 2024 · 4 comments
Labels
βœ… accepted The core team has agreed that it is a good idea to fix this ⚑ enhancement Request for new functionality

Comments

@vitalets
Copy link

πŸ€” What's the problem you're trying to solve?

Currently HTML formatter can show link list as raw URIs. With long URIs it can lead to cluttered ui:
image

✨ What's your proposed solution?

Allow this.link() to accept list of objects { title: string, url: string }:

this.link(
    { title: 'Cucumber-js', url: 'https://github.com/cucumber/cucumber-js?param=value' },
    { title: 'Cucumber-jvm', url: 'https://github.com/cucumber/cucumber-jvm?param=value' },
);

Then output in reporter would be as follows:

⛏ Have you considered any alternatives or workarounds?

No response

πŸ“š Any additional context?

No response

@davidjgoss
Copy link
Contributor

I'm definitely supportive of having titles on links for the reasons you say, and that interface looks good to me.

The question is more how we map it to the Attachment message. I think the title can reasonably map to the fileName field. The MIME type is trickier - currently we use text/uri-list and for multiple links we newline-delimit them in the same attachment. We'd need to change this for multiple links with titles.

I think the best option is probably to emit one text/uri-list attachment for each link with a title, and make sure the HTML formatter does a good job of rendering consecutive link attachments without wasting vertical space.

What do you think?

@davidjgoss davidjgoss added βœ… accepted The core team has agreed that it is a good idea to fix this ⚑ enhancement Request for new functionality labels Dec 10, 2024
@vitalets
Copy link
Author

I think the best option is probably to emit one text/uri-list attachment for each link with a title, and make sure the HTML formatter does a good job of rendering consecutive link attachments without wasting vertical space.

Yes, I agree - a separate attachment message for each link.

In that case, if I still call it with pure urls, how many attachments will be added?

this.link(
  'https://github.com/cucumber/cucumber-js?param=value',
  'https://github.com/cucumber/cucumber-jvm?param=value',
);

I think, for the consistency and less maintenance efforts, it's better to behave in the same way - output several attachments even for pure urls.

One internal concern here is that text/uri-list will always contain a single link, not a list (as it's name assumes). There can be text/uri mime-type for adding a single link, that can gradually replace text/uri-list.

@davidjgoss
Copy link
Contributor

I tend to agree re making it one URL per attachment.

There can be text/uri mime-type for adding a single link, that can gradually replace text/uri-list.

The reason for text/uri-list originally was that it's a standard. I think if we deviate then we should make clear that it's non-standard e.g. text/x.cucumber.uri+plain which mirrors what we did for text/x.cucumber.log+plain.

@vitalets
Copy link
Author

The reason for text/uri-list originally was that it's a standard.

I didn't know that. Then I'd better vote for sticking to standard. List of a single element is still a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
βœ… accepted The core team has agreed that it is a good idea to fix this ⚑ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants