Skip to content

Commit

Permalink
feat: add "dot" version of "new" badge (#25882)
Browse files Browse the repository at this point in the history
Co-authored-by: astone123 <adams@cypress.io>
  • Loading branch information
marktnoonan and astone123 committed Feb 24, 2023
1 parent 351413f commit 948bc02
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _Released 02/28/2023 (PENDING)_
- It is now possible to set `hostOnly` cookies with [`cy.setCookie()`](https://docs.cypress.io/api/commands/setcookie) for a given domain. Addresses [#16856](https://github.com/cypress-io/cypress/issues/16856) and [#17527](https://github.com/cypress-io/cypress/issues/17527).
- Added a Public API for third party component libraries to define a Framework Definition, embedding their library into the Cypress onboarding workflow. Learn more [here](https://docs.cypress.io/guides/component-testing/third-party-definitions). Implemented in [#25780](https://github.com/cypress-io/cypress/pull/25780) and closes [#25638](https://github.com/cypress-io/cypress/issues/25638).
- Added a Debug Page tutorial slideshow for projects that are not connected to Cypress Cloud. Addresses [#25768](https://github.com/cypress-io/cypress/issues/25768).
- Updated the "new" status badge for the Debug page navigation link to be less noticeable when the navigation is collapsed. Addresses [#25739](https://github.com/cypress-io/cypress/issues/25739).

**Bugfixes:**

Expand Down
28 changes: 28 additions & 0 deletions packages/app/cypress/e2e/sidebar_navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,34 @@ describe('Sidebar Navigation', { viewportWidth: 1280 }, () => {
cy.get('.router-link-active').findByText('Debug').should('be.visible')
})

it('Debug "new" notification appears as a dot when nav is collapsed', () => {
cy.findByLabelText('New Debug feature')
.should('be.visible')
.contains('New')

// in expanded state, expect no dot
cy.findByTestId('debug-badge-dot').should('not.exist')

// collapse the nav
cy.findByTestId('toggle-sidebar').click()

// in collapsed state, find the dot
// TODO (Percy): when Percy is enabled for e2e tests
// we can stop testing the class name directly here
cy.findByLabelText('New Debug feature', {
selector: '[data-cy=debug-badge-dot]',
})
.should('be.visible')
.and('have.class', 'bg-jade-500')
.invoke('text')
.should('eq', '')

// go to the Spec Runner route by clicking on a test
cy.contains('a', 'flower.png').click()

cy.findByTestId('debug-badge-dot').should('have.class', 'bg-gray-800')
})

it('Specs sidebar nav link is not active when a test is running', () => {
cy.location('hash').should('equal', '#/specs')
cy.contains('.router-link-exact-active', 'Specs')
Expand Down
16 changes: 12 additions & 4 deletions packages/app/src/navigation/SidebarNavigation.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,18 @@ describe('SidebarNavigation', () => {
mountComponent()
cy.tick(1000) //wait for debounce

cy.findByLabelText('New Debug feature').should('be.visible').contains('New')
cy.findByLabelText('New Debug feature', {
selector: '[data-cy=debug-badge-dot]',
}).should('be.visible')

cy.percySnapshot('Debug Badge:collapsed')

cy.findByLabelText(defaultMessages.sidebar.toggleLabel.collapsed, {
selector: 'button',
}).click()

cy.tick(1000) //wait for transition
cy.findByLabelText('New Debug feature').should('be.visible').contains('New')
cy.percySnapshot('Debug Badge:expanded badge')
})

Expand All @@ -149,7 +154,9 @@ describe('SidebarNavigation', () => {
for (const status of ['NOTESTS', 'RUNNING'] as CloudRunStatus[]) {
mountComponent({ cloudProject: { status, numFailedTests: 0 } })
cy.tick(1000) //wait for debounce
cy.findByLabelText('New Debug feature').should('be.visible').contains('New')
cy.findByLabelText('New Debug feature', {
selector: '[data-cy=debug-badge-dot]',
}).should('be.visible')
}
})

Expand Down Expand Up @@ -218,8 +225,9 @@ describe('SidebarNavigation', () => {
mountComponent({ online: false })

cy.tick(1000) //wait for debounce

cy.findByLabelText('New Debug feature').should('be.visible').contains('New')
cy.findByLabelText('New Debug feature', {
selector: '[data-cy=debug-badge-dot]',
}).should('be.visible')
})
})
})
33 changes: 32 additions & 1 deletion packages/app/src/navigation/SidebarNavigationRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@
{{ name }}
</span>
<span
v-if="badge"
v-if="badge && !showDot"
:aria-label="badge.label"
class="rounded-md font-medium text-white p-4px transition-opacity z-1"
:class="[badgeVariant, badgeColorStyles[badge.status], {'opacity-0': transitioning}]"
>
{{ badge.value }}
</span>
<div
v-else-if="badge && showDot"
:class="[{'opacity-0': transitioning}, dotClass]"
:aria-label="badge.label"
data-cy="debug-badge-dot"
/>
</div>
<template #popper>
{{ name }}
Expand All @@ -66,9 +72,14 @@
import { computed, FunctionalComponent, SVGAttributes, watch, ref } from 'vue'
import Tooltip from '@packages/frontend-shared/src/components/Tooltip.vue'
import { promiseTimeout } from '@vueuse/core'
import { useI18n } from '@cy/i18n'
import { useRoute } from 'vue-router'
export type Badge = { value: string, status: 'success' | 'failed' | 'error', label: string }
const { t } = useI18n()
const route = useRoute()
const props = withDefaults(defineProps <{
icon: FunctionalComponent<SVGAttributes>
name: string
Expand Down Expand Up @@ -107,6 +118,26 @@ const badgeColorStyles = {
'error': 'bg-warning-500',
}
const showDot = computed(() => {
return props.badge.value === t('sidebar.debug.new') && !props.isNavBarExpanded
})
const dotClass = computed(() => {
const dotColor = route.name === 'SpecRunner' ? 'bg-gray-800' : 'bg-jade-500'
return `${dotColor}
w-10px
h-10px
relative
-bottom-7px
-left-30px
flex-shrink-0
z-1
border-2px
border-gray-1000
rounded-full`
})
const transitioning = ref(false)
// Badge is either absolutely positioned or relative. Since the navbar expands with an animation,
Expand Down

5 comments on commit 948bc02

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 948bc02 Feb 24, 2023

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/linux-arm64/develop-948bc027003181b1cd40d96ce814259b6657ae4d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 948bc02 Feb 24, 2023

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/linux-x64/develop-948bc027003181b1cd40d96ce814259b6657ae4d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 948bc02 Feb 24, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/darwin-x64/develop-948bc027003181b1cd40d96ce814259b6657ae4d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 948bc02 Feb 24, 2023

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/win32-x64/develop-948bc027003181b1cd40d96ce814259b6657ae4d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 948bc02 Feb 24, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/darwin-arm64/develop-948bc027003181b1cd40d96ce814259b6657ae4d/cypress.tgz

Please sign in to comment.