-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Spec List: Added tooltips to git icons created/modified #21536
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
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 |
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? |
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"> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
cypress/packages/app/src/specs/SpecsList.vue
Line 105 in 06a0283
v-if="row.data.isLeaf && row.data.data?.gitInfo" |
> | ||
<component | ||
:is="classes.icon" | ||
:class="classes.iconClasses" | ||
/> | ||
<template | ||
v-if="classes.showTooltip" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@marktnoonan thanks for the feedback. I'll review the tests. |
@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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
cypress/packages/types/src/git.ts
Line 1 in b8884b5
export const gitStatusType = ['modified', 'created', 'unmodified', 'noGitInfo'] as const |
@ZachJW34 this issue related to tooltips refusing to show up seems odd, would you have time to help look into it tomorrow maybe? |
…CLOUD-576-latest-update-design-updates
There was a problem hiding this 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:
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') |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 }, () => { |
There was a problem hiding this comment.
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?
:popper-triggers="['hover']" | ||
:hide-triggers="['hover']" | ||
:auto-hide="!isInteractive" | ||
:theme="theme" | ||
:placement="placement ?? 'auto'" |
There was a problem hiding this comment.
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:
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.
@ZachJW34 the issue you found is now fixed thanks to @tbiethman. Can you please verify the fix, @ZachJW34? |
@marktnoonan file removed. |
packages/app/src/specs/SpecsList.vue
Outdated
@@ -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"> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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
icon: null, | ||
iconClasses: 'icon-light-gray-500', |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
return '' | ||
return null |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
const toAwait = [ | ||
this.#loadAndWatchCurrentBranch(), | ||
] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 👍
…-576-latest-update-design-updates
There was a problem hiding this 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
, thespecs_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.
@MuazOthman verified that the tooltip is acting how it should! I'm curious, what was the fix? |
await git.reset(['--hard']) | ||
|
||
return null |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
…-576-latest-update-design-updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks great 👍
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
User facing changelog
Additional details
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?