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

fix: Spec List: Added tooltips to git icons created/modified #21536

Merged
merged 17 commits into from
May 27, 2022

Conversation

MuazOthman
Copy link
Contributor

@MuazOthman MuazOthman commented May 17, 2022

User facing changelog

  • On Spec list page, show tooltips for git status icons when created/modified for clarity
  • On Spec list page, address the case when no git information is available to show no icons and file update time from file system

Additional details

How has the user experience changed?

image
image

PR Tasks

  • [na] Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 17, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented May 17, 2022



Test summary

37537 0 454 0Flakiness 0


Run details

Project cypress
Status Passed
Commit d6df106
Started May 26, 2022 8:26 PM
Ended May 26, 2022 8:47 PM
Duration 20:19 💡
OS Linux Debian - 10.11
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@marktnoonan
Copy link
Contributor

The description says "na" for "Have tests been added/updated?", but this seems like some new behavior that should be covered in a test. Are there existing tests that already cover these tooltips?

@ZachJW34
Copy link
Contributor

I'm seeing some weird behavior where the tooltip won't show up after the icon changes. Not sure if it is this PR that introduces this or not

Screen.Recording.2022-05-17.at.3.12.39.PM.mov

>
<component
:is="classes.icon"
:class="classes.iconClasses"
/>
<template
v-if="classes.showTooltip"
#popper
>
<div>
<p class="max-w-sm text-sm truncate overflow-hidden">
Copy link
Member

Choose a reason for hiding this comment

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

Can we conditionally render this if there is a tooltip message to show?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There will always be a tooltip to show. Prior to this PR, we had cases when we conditionally render tooltips, but now a tooltip should show in all cases but contents can vary.

Copy link
Member

Choose a reason for hiding this comment

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

Since the default was null I assumed there was cases when there wasn't content.

Is there always a tooltip even when the SCM is not available and/or git is not used in the project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's no SCM data available, this whole component won't be rendered

v-if="row.data.isLeaf && row.data.data?.gitInfo"

>
<component
:is="classes.icon"
:class="classes.iconClasses"
/>
<template
v-if="classes.showTooltip"
Copy link
Member

Choose a reason for hiding this comment

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

Can we conditionally render this if there is tooltip text to show?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There will always be a tooltip to show. Prior to this PR, we had cases when we conditionally render tooltips, but now a tooltip should show in all cases but contents can vary.

const gitTooltipSubtext = computed(() => {
const tooltipMainText = computed(() => {
switch (props.gql?.statusType) {
case 'unmodified': return props.gql?.subject
Copy link
Member

Choose a reason for hiding this comment

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

what does this props.gql?.subject show?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the commit subject. I think #21139 can further show previous work updated in this PR.

@MuazOthman
Copy link
Contributor Author

@marktnoonan thanks for the feedback. I'll review the tests.
@ZachJW34 thanks for catching that issue. I'll look into it.

@ZachJW34
Copy link
Contributor

@MuazOthman if this is an existing issue, I'm cool with getting this merged and following up with an issue for it.

@@ -760,6 +760,7 @@ type GitInfo {
enum GitInfoStatusType {
created
modified
no_git_info
Copy link
Member

Choose a reason for hiding this comment

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

Not seeing the related gql- enum change, was this edited in the SDL file directly?

Also, we generally use camelCase everywhere for variable naming, unless it's CONSTANT_CASE, so noGitInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I corrected to follow convention.
The main update is in packages/types/src/git.ts

export const gitStatusType = ['modified', 'created', 'unmodified', 'noGitInfo'] as const

@MuazOthman
Copy link
Contributor Author

@ZachJW34 this issue related to tooltips refusing to show up seems odd, would you have time to help look into it tomorrow maybe?
Meanwhile, I guess we can get this PR merged if since it was an existing issue and the updates in this PR need to go into 10.0.

Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

@MuazOthman could we please have a bit more description on this PR, it seems to do more than just add tooltips for the icons. Can we give context to the other changes made? It's hard to review without this context. A good example is the new tooltip on the header:

Screen Shot 2022-05-24 at 12 45 13 PM

This is not mentioned in the PR or the ticket as far as I can tell, and it looks different to other existing tooltips. What's my reference point to approve this change? I'm sure there is a figma link but don't know where to find it.

There are some other refactors as well. These may be improvements but it's not clear how they relate to what's described in the PR.

The main change request I have is that this PR appears to introduce something that breaks keyboard navigation through the specs list. After tabbing onto an icon that tiggers a tooltip, it gains focus and the next tab stop is the browser address bar:

tab-stops-not-working.mov

I confirmed this doesn't happen on 10.0-release - the icons still show tooltips on focus but I can immediately tab down through the next rows as expected.

On the other hand the column header does not receive keyboard focus and so doesn't reveal its tooltip to keyboard users. Ideally the header and the icons in the rows would behave the same way when focused.

I made a suggestion in the e2e spec for where to add coverage related to the tooltip content changing based on the git status - I think without this coverage we would not catch a regression if these tooltips were were removed/changed.

.should('have.class', 'icon-light-gray-500')
}
cy.get('[data-cy-row="dom-container.spec.js"] [data-cy="git-info-row"] svg')
.should('have.class', 'icon-light-gray-500')
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we can use cy.trigger('mouseenter') to expand the tooltips and then assert their contents?

{{ t('specPage.lastUpdated.tooltip.gitInfo') }}
</ExternalLink>
</i18n-t>
<!-- <i18n-t
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this?

cy.contains('Tooltip 0')
})

it('playground - interactive', { viewportHeight: 400 }, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since interactive is intended to have a different appearance than regular tooltips, could we add a percy snapshot to this and the other test, and update the test descriptions?

Comment on lines 5 to 9
:popper-triggers="['hover']"
:hide-triggers="['hover']"
:auto-hide="!isInteractive"
:theme="theme"
:placement="placement ?? 'auto'"
Copy link
Contributor

@marktnoonan marktnoonan May 25, 2022

Choose a reason for hiding this comment

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

I did a little more testing and found what I think are some other side effects related to these changes that surface when using the keyboard, leading to unexpected states:

Screen Shot 2022-05-24 at 6 39 19 PM

After comparing tooltips in general with 10.0-release, it seems something in here is also affecting the tooltips in the Selector Playground - both their positioning and focus behavior, moving focus out to the address bar immediately when a button that has a tooltip is focused. Let me know if you can reproduce, here's what I did:

https://www.loom.com/share/598305649aa741499ca1f909b80e31db - 10.0-release
https://www.loom.com/share/469f94e459554d729c5fe13b63489f2a - this branch

This seem like pretty extreme effects for such a small set of changes, so maybe something else is up with my local env. Though the changed positioning in the Selector Playground is also captured in percy here.

@MuazOthman
Copy link
Contributor Author

@ZachJW34 the issue you found is now fixed thanks to @tbiethman. Can you please verify the fix, @ZachJW34?

@MuazOthman
Copy link
Contributor Author

@marktnoonan file removed.

@@ -43,7 +43,9 @@
t('specPage.componentSpecsHeader') : t('specPage.e2eSpecsHeader') }}
</div>
<div class="flex items-center justify-between">
<div>{{ t('specPage.lastUpdatedHeader') }}</div>
<div :is-git-available="isGitAvailable">
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we can remove this attribute from the div and the isGitAvailable computed value, then this file won't be touched by the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed that, but the localized string path was updated so this will touch the file.

data-cy="git-info-row"
>
<Tooltip
v-if="classes.icon"
:key="props.gql?.statusType ?? undefined"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the key property used for 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.

It seems that the Tooltip component from floating-vue binds events to its contents when it is mounted, which we're losing when the contents change, causing the tooltip not to show up.
Adding the key attribute and causing it to change value when the target changes forces Vue to re-render the DOM, which allows for the events to be bound correctly. This may not be an ideal solution, but given the use case here it doesn't create much overhead as these changes are triggered by file status changes, which are not expected to be frequent within 60 seconds, which is the frequency used to update the file status icon.
This article explains some more details about key in Vue. In summary:

The key attribute tells Vue how your data relates to the HTML elements it's rendering to the screen. When your data changes, Vue uses these keys to know which HTML elements to remove or update, and if it needs to create any new ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah a key seems like the right move 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.

@ZachJW34 this was the fix for the issue you found

Comment on lines 83 to 84
icon: null,
iconClasses: 'icon-light-gray-500',
Copy link
Contributor

Choose a reason for hiding this comment

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

When the icon is null, do we still need to set iconClasses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, removed iconClasses for this case.

Comment on lines 92 to 106
return ''
return null
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we changed the return type from string to string or null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this was me missing on how JS evaluates falsy strings 😆 . I'm reverting it.

} catch {
this.#git = simpleGit()
// suppress exception if git cannot be found
Copy link
Contributor

Choose a reason for hiding this comment

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

I hit another spot in the code where an exception was suppressed and it took me foreverrrrrsssss to track it down. Is there any way we can surface an error, i.e. the error still shows in the console, but it does not impact the UI?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a friendly neighborhood debug would work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

debug added

@@ -1,5 +1,5 @@
import execa from 'execa'
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add something in the PR description that explains these changes in GitDataSource? It looks like this supports the "no git info" condition, but what's the expected change in the UI before and after? I found the info in the comments of the ticket that is linked in the PR, but that won't help future folks or outside contributors understand the changes, especially since we squash and merge PRs so the commit message that goes with these changes won't be directly visible. If we can move that comment from the ticket into the PR description I think it would help.

Can we have a test that simulates the no git info state and expected contents of the column based on file system info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new test to cover this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just saw this test fail for Windows, investigating.

Comment on lines +117 to +119
const toAwait = [
this.#loadAndWatchCurrentBranch(),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

I like!


let toSet: GitInfo | null = null

const stat = fs.statSync(file)
const ctime = dayjs(stat.ctime)
const birthtime = dayjs(stat.birthtime)
Copy link
Contributor

Choose a reason for hiding this comment

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

🐣

"lastUpdatedHeader": "Last updated",
"lastUpdated": {
"header": "Last updated",
"tooltip": {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this tooltip text in the i18n just yet, might as well remove it until the PR with the header updates comes along? Not a blocking request though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed 👍

Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

I see a couple of tasks left:

  • Update this test mentioned here: https://github.com/cypress-io/cypress/pull/21536/files#r880715651. At the moment, if I completely remove the tooltip from SpecListGitInfo.vue, the specs_list_actual_git_repo.cy.ts test still passes, which seems wrong to me, it should be yelling about the tooltips being missing. Ideally the main tooltip with the git commit info would also be covered here, but I know that's not part of this PR, so it's your call whether to add it or not.

  • Update PR description to explain what's expected in the "no git info" state to provide context for the GitDataSource changes.

And just a side note, is the right box ticked here? Not familiar with our ZenHub tagging process but wondering if you meant to check the top box instead.

Screen Shot 2022-05-26 at 8 22 20 AM

@ZachJW34
Copy link
Contributor

@MuazOthman verified that the tooltip is acting how it should! I'm curious, what was the fix?

Comment on lines +37 to +39
await git.reset(['--hard'])

return null
Copy link
Contributor

Choose a reason for hiding this comment

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

How come you're returning null? Is TS requiring you to have a return value?

Copy link
Contributor Author

@MuazOthman MuazOthman May 26, 2022

Choose a reason for hiding this comment

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

I guess I stole the pattern from the function above it. Upon more digging, it seems it is required to return something per the comment on the code shown below

cypress/cli/types/cypress.d.ts

Lines 5472 to 5477 in d6df106

/**
* Individual task callback. Receives a single argument and _should_ return
* anything but `undefined` or a promise that resolves anything but `undefined`
* TODO: find a way to express "anything but undefined" in TypeScript
*/
type Task = (value: any) => any

Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

All looks great 👍

@rachelruderman rachelruderman self-requested a review May 27, 2022 16:05
@MuazOthman MuazOthman merged commit 0a6391f into develop May 27, 2022
@MuazOthman MuazOthman deleted the muaz/CLOUD-576-latest-update-design-updates branch May 27, 2022 16:15
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 1, 2022

Released in 10.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants