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

Dynamically add stable or experimental labels to Interop Dashboard URLs #3287

Merged
merged 6 commits into from
May 3, 2023

Conversation

DanielRyanSmith
Copy link
Contributor

@DanielRyanSmith DanielRyanSmith commented Apr 27, 2023

Fixes #3286

This change adds the stable or experimental labels to test results links on the Interop dashboard based on the view that the user is viewing. Previously, the "experimental" label was used for all links, even when viewing stable data.

@DanielRyanSmith DanielRyanSmith marked this pull request as ready for review April 27, 2023 18:42
@DanielRyanSmith DanielRyanSmith changed the title Add 'stable' or 'experimental' labels to test urls Dynamically add stable or experimental labels to Interop Dashboard URLs Apr 27, 2023
}

if (stable) {
testsURL += '&label=stable';
Copy link
Collaborator

@KyleJu KyleJu Apr 28, 2023

Choose a reason for hiding this comment

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

I would assume that ? delimiter is always present in the testURL, e.g. /results/ vs /results/? /results/&label=stable would fail here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these are always wpt.fyi paths to test results pages with an interop label, so the query string should always already be present

Copy link
Member

Choose a reason for hiding this comment

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

Another way would be:

const url = new URL(testsURL);
url.searchParams.set('label', stable ? 'stable' : 'experimental');
return url.toString();

This works regardless of what the query string is initially.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After trying this, I think using the URL object might not work in our specific case because we allow for multiples of the same query string parameter (e.g. multiple "label" params). Using the set method might overwrite a &label=master search param.

Copy link
Collaborator

@jcscottiii jcscottiii May 1, 2023

Choose a reason for hiding this comment

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

I looked at the URLSearchParams API.
Yeah, you're right, I wish there was a setAll method.

Here's a fiddle with it working but it adds a lot of lines of code using the existing APIs for URLSearchParams. (Probably can be optimized)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the example @jcscottiii 🙂 I agree that it would be nice to have another method that allows for multiples of the same search param.
Would you suggest updating the implementation to match? Or do you think the current implementation is fine?

Copy link
Collaborator

@jcscottiii jcscottiii May 2, 2023

Choose a reason for hiding this comment

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

I would update the implementation to match. I like @foolip's suggestion because search parameter modification shouldn't be something we deal with manually if we can avoid it.
I did some searching to make sure we weren't the only ones looking for this same solution.

You should put a TODO note that it could be simplified and add these three links:

Any of those would help simplify the code a little bit.

@KyleJu
Copy link
Collaborator

KyleJu commented May 3, 2023

Thanks for addressing the comments!

@DanielRyanSmith DanielRyanSmith merged commit 2bbae12 into main May 3, 2023
@DanielRyanSmith DanielRyanSmith deleted the interop-test-urls-stable-experimental branch May 3, 2023 19:57
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.

Link to stable results from stable Interop 2023 results table
4 participants