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(unify): launchpad header breadcrumbs and reusable tooltip component #20648

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
844edb8
display testing type in breadcrumb
Mar 16, 2022
8391e10
add component tests
Mar 16, 2022
91c71f5
add e2e tests
Mar 17, 2022
0a86fa7
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Mar 17, 2022
0244bff
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Mar 18, 2022
c7dbb56
improve navigation
Mar 18, 2022
085bab7
prevent navigation while loading
Mar 18, 2022
2379000
update test
Mar 18, 2022
6730945
refactor for cleaner code
Mar 18, 2022
32a912b
fix ts mistake
Mar 18, 2022
3c2f033
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Mar 21, 2022
dbae6d8
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Mar 21, 2022
1b9c1c7
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Mar 23, 2022
e214231
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Mar 25, 2022
20abd8c
Truncate branch
Mar 31, 2022
151ffa1
Tooltip
Apr 1, 2022
e99c8aa
Create tooltip component
Apr 1, 2022
cab9327
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 6, 2022
8ca09c7
Animation
Apr 6, 2022
cb30602
Replace SidebarNavigationRow tooltip
Apr 7, 2022
b27c3c8
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 7, 2022
ba242c7
Animation for placement right
Apr 8, 2022
3562b74
Animation for other placements
Apr 8, 2022
8f3b155
Delete now-unused SidebarTooltip
Apr 8, 2022
0329420
Replace SelectorPlaygroundTooltip
Apr 8, 2022
03ef886
Replace UnsupportedBrowserTooltip
Apr 8, 2022
5296f9c
Windify
Apr 8, 2022
bc43a34
Appease check-ts
Apr 11, 2022
bda72b6
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 11, 2022
b910768
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 11, 2022
dd01555
Add tests
Apr 11, 2022
845b877
appease TS
Apr 11, 2022
73e2cef
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 11, 2022
36d1800
push pixels
Apr 11, 2022
f19bf5d
remove unused divs
Apr 12, 2022
ac80921
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 12, 2022
4705255
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 14, 2022
8e948e5
Cause tooltip to be less persistent
Apr 14, 2022
1e477c3
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 14, 2022
ac8b72a
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 18, 2022
c1d30a3
Fix merge issues
Apr 18, 2022
b63834d
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 18, 2022
18cf600
Merge branch '10.0-release' into mapsandapps/feat/launchpad-header-br…
Apr 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,32 @@ describe('<HeaderBarContent />', { viewportWidth: 1000, viewportHeight: 750 }, (
cy.contains(`${defaultMessages.topNav.updateCypress.title} 8.7.0`).should('not.exist')
})

it('displays the active project name', () => {
it('displays the active project name and testing type', () => {
cy.mountFragment(HeaderBar_HeaderBarContentFragmentDoc, {
render: (gqlVal) => <div class="border-current border-1 h-700px resize overflow-auto"><HeaderBarContent gql={gqlVal} /></div>,
})

cy.contains('test-project').should('be.visible')
cy.contains('e2e testing', { matchCase: false }).should('be.visible')
})

it('displays the branch name', () => {
cy.mountFragment(HeaderBar_HeaderBarContentFragmentDoc, {
onResult: (result) => {
if (!result.currentProject) {
return
}

result.currentProject.branch = 'develop'
},
render: (gqlVal) => (
<div class="border-current border-1 h-700px resize overflow-auto">
<HeaderBarContent gql={gqlVal} />
</div>
),
})

cy.contains('develop').should('be.visible')
})

it('the login modal reaches "opening browser" status', () => {
Expand Down
51 changes: 47 additions & 4 deletions packages/frontend-shared/src/gql-components/HeaderBarContent.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="bg-white border-b border-b-gray-100 h-64px py-15px px-6">
<div
data-cy="header-bar-content"
class="bg-white border-b border-b-gray-100 h-64px py-15px px-6"
>
<div class="flex h-full gap-12px items-center justify-between">
<div
v-if="pageName"
Expand All @@ -9,7 +12,7 @@
</div>
<div
v-else
class="flex items-center children:font-medium children:leading-24px"
class="flex font-medium text-gray-700 items-center children:leading-24px"
>
<img
class="h-32px mr-18px w-32px"
Expand All @@ -28,7 +31,28 @@
v-if="props.gql?.currentProject"
class="h-16px mr-2px min-w-16px icon-dark-gray-200"
/>
<span class="text-body-gray-700">{{ props.gql?.currentProject?.title }}</span>
<span
Copy link
Contributor

Choose a reason for hiding this comment

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

For accessibility reasons, we should make this either a link or a button so it can receive keyboard focus and be announced the right way. Before it becomes interactive, the disabled link pattern here seems like it would work:

<a role="link" aria-disabled="true">project-name</a>

I think we should follow this pattern for the Projects link as well, we are already close to it there - though that doesn't need to get updated in this PR.

The "link with a fake href because it actually uses a click handler to trigger a mutation that updates state that will move the UI to a new 'page'" doesn't seem ideal at first, but it may be the clearest pattern to understand from a user perspective, in terms of how these breadcrumbs behave.

Copy link
Contributor Author

@mapsandapps mapsandapps Mar 18, 2022

Choose a reason for hiding this comment

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

I didn't think you should ever have an a without an href, so this was news to me!

In my update, I went ahead and used <nav> and <ol> for this, which i had been intending to do if i made a reusable breadcrumb component. LMK what you think about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I think that's good. I had only found the disabled link pattern recently, I think we needed it somewhere else in launchpad as well.

class="font-medium mr-2px"
:class="props.gql?.currentProject?.currentTestingType ? 'text-indigo-500 hocus-link-default cursor-pointer' :
'text-gray-700'"
@click.prevent="clearTestingType"
>
{{ props.gql?.currentProject?.title }}
</span>
<span
v-if="props.gql?.currentProject?.branch"
class="font-normal text-gray-500"
>
({{ props.gql.currentProject.branch }})
</span>
<i-cy-chevron-right_x16
v-if="props.gql?.currentProject?.currentTestingType"
class="h-16px mr-2px min-w-16px icon-dark-gray-200"
/>
<span
v-if="props.gql?.currentProject?.currentTestingType"
class="lowercase"
>{{ t(`testingType.${props.gql?.currentProject?.currentTestingType}.name`) }}</span>
</div>
<div class="flex gap-6">
<TopNav
Expand Down Expand Up @@ -86,7 +110,7 @@
</TopNav>
<div v-if="!props.gql?.cloudViewer">
<button
class="flex text-gray-600 group items-center focus:outline-transparent"
class="flex text-gray-600 items-center group focus:outline-transparent"
@click="openLogin"
>
<i-cy-profile_x16
Expand All @@ -110,6 +134,7 @@ import { ref, computed } from 'vue'
import type { HeaderBar_HeaderBarContentFragment } from '../generated/graphql'
import {
GlobalPageHeader_ClearCurrentProjectDocument,
GlobalPageHeader_ClearCurrentTestingTypeDocument,
HeaderBarContent_AuthChangeDocument,
} from '../generated/graphql'
import TopNav from './topnav/TopNav.vue'
Expand Down Expand Up @@ -141,13 +166,26 @@ mutation GlobalPageHeader_clearCurrentProject {
}
`

gql`
mutation GlobalPageHeader_ClearCurrentTestingType {
clearCurrentTestingType {
currentProject {
id
currentTestingType
}
}
}
`

gql`
fragment HeaderBar_HeaderBarContent on Query {
currentProject {
id
title
config
savedState
currentTestingType
branch
}
projectRootFromCI
...TopNav
Expand All @@ -164,6 +202,7 @@ const cloudProjectId = computed(() => {

const isLoginOpen = ref(false)
const clearCurrentProjectMutation = useMutation(GlobalPageHeader_ClearCurrentProjectDocument)
const clearCurrentTestingTypeMutation = useMutation(GlobalPageHeader_ClearCurrentTestingTypeDocument)
const email = computed(() => props.gql.cloudViewer?.email || undefined)

const openLogin = () => {
Expand All @@ -176,6 +215,10 @@ const clearCurrentProject = () => {
}
}

const clearTestingType = () => {
clearCurrentTestingTypeMutation.executeMutation({})
mapsandapps marked this conversation as resolved.
Show resolved Hide resolved
}

const props = defineProps<{
gql: HeaderBar_HeaderBarContentFragment
showBrowsers?: boolean
Expand Down
22 changes: 22 additions & 0 deletions packages/launchpad/cypress/e2e/open-mode.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Launchpad: Open Mode', () => {
cy.scaffoldProject('todos')
cy.openProject('todos', ['--e2e'])
cy.visitLaunchpad()
cy.get('[data-cy=header-bar-content]').contains('e2e testing', { matchCase: false })
// e2e testing is configured for the todo project, so we don't expect an error.
cy.get('h1').should('contain', 'Choose a Browser')
})
Expand All @@ -30,6 +31,7 @@ describe('Launchpad: Open Mode', () => {
cy.scaffoldProject('launchpad')
cy.openProject('launchpad', ['--component'])
cy.visitLaunchpad()
cy.get('[data-cy=header-bar-content]').contains('component testing', { matchCase: false })
// Component testing is not configured for the todo project
cy.get('h1').should('contain', 'Project Setup')
})
Expand Down Expand Up @@ -132,4 +134,24 @@ describe('Launchpad: Open Mode', () => {
})
})
})

it('can navigate to project from e2e menu', () => {
cy.scaffoldProject('todos')
cy.openProject('todos', ['--e2e'])
cy.visitLaunchpad()
cy.get('[data-cy=header-bar-content]').contains('e2e testing', { matchCase: false })
cy.get('[data-cy=header-bar-content]').contains('todos').click()

cy.get('h1').should('contain', 'Welcome to Cypress!')
})

it('can navigate to project from ct menu', () => {
cy.scaffoldProject('launchpad')
cy.openProject('launchpad', ['--component'])
cy.visitLaunchpad()
cy.get('[data-cy=header-bar-content]').contains('component testing', { matchCase: false })
cy.get('[data-cy=header-bar-content]').contains('launchpad').click()

cy.get('h1').should('contain', 'Welcome to Cypress!')
})
})