Skip to content

Commit

Permalink
misc: update browser icons (#30790)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschile authored Jan 7, 2025
1 parent 0ddb119 commit 558906f
Show file tree
Hide file tree
Showing 29 changed files with 263 additions and 327 deletions.
8 changes: 8 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 13.17.1

_Released 12/31/2024 (PENDING)_

**Misc:**

- Updated to use Cypress design system browser icons. Addressed in [#30790](https://github.com/cypress-io/cypress/pull/30790).

## 13.17.0

_Released 12/17/2024_
Expand Down
16 changes: 0 additions & 16 deletions packages/app/cypress/component/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
/// <reference path="../../../../frontend-shared/cypress/support/component.ts" />
import '../../../../frontend-shared/cypress/support/component.ts'
import { registerMountFn } from '@packages/frontend-shared/cypress/support/common'
// ***********************************************************
// This example support/index.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:

import { createRouter } from '../../../src/router/router'
import { createPinia } from '../../../src/store'
Expand Down
4 changes: 2 additions & 2 deletions packages/app/cypress/e2e/support/e2eSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ beforeEach(() => {
function e2eTestingTypeIsSelected () {
cy.findByTestId('specs-testing-type-header').within(() => {
cy.findByTestId('testing-type-switch').contains('button', 'E2E').should('have.attr', 'aria-selected', 'true')
cy.findByTestId('testing-type-switch').contains('button', 'Component').should('not.have.attr', 'aria-selected')
cy.findByTestId('testing-type-switch').contains('button', 'Component').should('have.attr', 'aria-selected', 'false')
})
}

Cypress.Commands.add('verifyE2ESelected', e2eTestingTypeIsSelected)

function ctTestingTypeIsSelected () {
cy.findByTestId('specs-testing-type-header').within(() => {
cy.findByTestId('testing-type-switch').contains('button', 'E2E').should('not.have.attr', 'aria-selected')
cy.findByTestId('testing-type-switch').contains('button', 'E2E').should('have.attr', 'aria-selected', 'false')
cy.findByTestId('testing-type-switch').contains('button', 'Component').should('have.attr', 'aria-selected', 'true')
})
}
Expand Down
12 changes: 7 additions & 5 deletions packages/app/cypress/e2e/top-nav.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
import { CYPRESS_REMOTE_MANIFEST_URL, NPM_CYPRESS_REGISTRY_URL } from '@packages/types'
import type Sinon from 'sinon'
import { dayjs } from '../../src/runs/utils/day'
import { cyBrowserMozillaFirefoxX16, cyBrowserChromeX16 } from '@cypress-design/icon-registry'

const pkg = require('@packages/root')

Expand Down Expand Up @@ -40,9 +41,9 @@ describe('App Top Nav Workflows', () => {
cy.visitApp()
cy.specsPageIsVisible()

cy.findByTestId('top-nav-active-browser-icon')
.should('have.attr', 'src')
.and('contain', 'firefox')
cy.findByTestId('top-nav-active-browser-icon').children()
.verifyBrowserIconSvg(cyBrowserMozillaFirefoxX16.data)
.get('title').should('contain', 'Firefox')

cy.findByTestId('top-nav-active-browser').should('contain', 'Firefox 6')
})
Expand All @@ -63,8 +64,9 @@ describe('App Top Nav Workflows', () => {
})

it('shows the current browser in the top nav browser list button', () => {
cy.findByTestId('top-nav-active-browser-icon')
.should('have.attr', 'src')
cy.findByTestId('top-nav-active-browser-icon').children()
.verifyBrowserIconSvg(cyBrowserChromeX16.data)
.get('title').should('contain', 'Chrome')

cy.findByTestId('top-nav-active-browser').should('contain', 'Chrome 1')
})
Expand Down
8 changes: 4 additions & 4 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
},
"dependencies": {},
"devDependencies": {
"@cypress-design/vue-button": "^0.11.6",
"@cypress-design/vue-icon": "^0.26.0",
"@cypress-design/vue-statusicon": "^0.5.7",
"@cypress-design/vue-tabs": "^0.5.1",
"@cypress-design/vue-button": "^1.1.0",
"@cypress-design/vue-icon": "^1.6.0",
"@cypress-design/vue-statusicon": "^1.0.0",
"@cypress-design/vue-tabs": "^1.2.2",
"@faker-js/faker": "8.4.1",
"@graphql-typed-document-node/core": "^3.1.0",
"@headlessui/vue": "1.4.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/debug/LayeredBrowserIcons.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import LayeredBrowserIcons from './LayeredBrowserIcons.vue'
import type { BrowserType } from './LayeredBrowserIcons.vue'

describe('<LayeredBrowserIcons/>', () => {
const browsers: BrowserType[] = ['CHROME', 'CHROME BETA', 'CANARY', 'CHROME CANARY', 'CHROME FOR TESTING', 'CUSTOM CHROME FOR TESTING', 'CHROMIUM', 'CUSTOM CHROMIUM', 'EDGE', 'EDGE BETA', 'EDGE CANARY', 'EDGE DEV', 'ELECTRON', 'FIREFOX', 'FIREFOX DEVELOPER EDITION', 'FIREFOX NIGHTLY', 'WEBKIT']
const browsers: string[] = ['CHROME', 'CHROME BETA', 'CANARY', 'CHROME CANARY', 'CHROME FOR TESTING', 'CUSTOM CHROME FOR TESTING', 'CHROMIUM', 'CUSTOM CHROMIUM', 'EDGE', 'EDGE BETA', 'EDGE CANARY', 'EDGE DEV', 'ELECTRON', 'FIREFOX', 'FIREFOX DEVELOPER EDITION', 'FIREFOX NIGHTLY', 'WEBKIT']

it('mounts correctly for single browser', () => {
browsers.forEach((ele) => {
Expand Down
39 changes: 3 additions & 36 deletions packages/app/src/debug/LayeredBrowserIcons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,10 @@

<script lang="ts" setup>
import { computed } from 'vue'
import {
IconBrowserChrome,
IconBrowserChromeBeta,
IconBrowserChromeCanary,
IconBrowserMozillaFirefox,
IconBrowserEdge,
IconBrowserWebkit,
IconBrowserElectronLight,
IconGeneralGlobe,
} from '@cypress-design/vue-icon'
// Note: These browser names should map to the list of logoPaths found at https://github.com/cypress-io/cypress-services/blob/develop/packages/common/src/logos/getLogoPath.ts
export type BrowserType = 'CHROME' | 'CHROME BETA' | 'CANARY' | 'CHROME CANARY' | 'CHROME FOR TESTING' | 'CUSTOM CHROME FOR TESTING' | 'CHROMIUM' | 'CUSTOM CHROMIUM' | 'EDGE' | 'EDGE BETA' | 'EDGE CANARY' | 'EDGE DEV' | 'ELECTRON' | 'FIREFOX' | 'FIREFOX DEVELOPER EDITION' | 'FIREFOX NIGHTLY' | 'WEBKIT'
import { allBrowsersIcons } from '@packages/frontend-shared/src/assets/browserLogos'
interface LayeredProps {
browsers: BrowserType[]
browsers: string[]
}
const props = defineProps<LayeredProps>()
Expand All @@ -44,7 +32,7 @@ const results = computed(() => {
if (props.browsers) {
return props.browsers.map((browserType) => {
return {
icon: BROWSER_MAP[browserType] || IconGeneralGlobe,
icon: allBrowsersIcons[browserType?.toLowerCase()] || allBrowsersIcons.generic,
name: `browser-icon-${browserType.toLowerCase().replaceAll(' ', '_')}`,
}
})
Expand All @@ -53,25 +41,4 @@ const results = computed(() => {
return []
})
// TODO: Add correct icons for firefox, edge, and chromium
const BROWSER_MAP: Record<BrowserType, any> = {
'CHROME': IconBrowserChrome,
'CHROME BETA': IconBrowserChromeBeta,
'CANARY': IconBrowserChromeCanary,
'CHROME CANARY': IconBrowserChromeCanary,
'CHROME FOR TESTING': IconBrowserChrome,
'CUSTOM CHROME FOR TESTING': IconBrowserChrome,
'CHROMIUM': IconGeneralGlobe,
'CUSTOM CHROMIUM': IconGeneralGlobe,
'EDGE': IconBrowserEdge,
'EDGE BETA': IconBrowserEdge,
'EDGE CANARY': IconBrowserEdge,
'EDGE DEV': IconBrowserEdge,
'ELECTRON': IconBrowserElectronLight,
'FIREFOX': IconBrowserMozillaFirefox,
'FIREFOX DEVELOPER EDITION': IconBrowserMozillaFirefox,
'FIREFOX NIGHTLY': IconBrowserMozillaFirefox,
'WEBKIT': IconBrowserWebkit,
}
</script>
5 changes: 2 additions & 3 deletions packages/app/src/runner/SpecRunnerHeaderOpenMode.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import SpecRunnerHeaderOpenMode from './SpecRunnerHeaderOpenMode.vue'
import { useAutStore } from '../store'
import { SpecRunnerHeaderFragment, SpecRunnerHeaderFragmentDoc } from '../generated/graphql-test'
import { createEventManager, createTestAutIframe } from '../../cypress/component/support/ctSupport'
import { allBrowsersIcons } from '@packages/frontend-shared/src/assets/browserLogos'
import { ExternalLink_OpenExternalDocument } from '@packages/frontend-shared/src/generated/graphql'
import { cyGeneralGlobeX16 } from '@cypress-design/icon-registry'

function renderWithGql (gqlVal: SpecRunnerHeaderFragment) {
const eventManager = createEventManager()
Expand Down Expand Up @@ -227,8 +227,7 @@ describe('SpecRunnerHeaderOpenMode', { viewportHeight: 500 }, () => {

cy.findByTestId('select-browser').contains('Fake Browser')

cy.get('[data-cy="select-browser"] > button img').should('have.attr', 'src', allBrowsersIcons.generic)

cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyGeneralGlobeX16.data)
cy.findByTestId('viewport').contains('500x500')
})

Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/runner/SpecRunnerHeaderOpenMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
:disabled="autStore.isRunning"
>
<template #heading>
<img
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
class="min-w-[16px] w-[16px]"
:src="allBrowsersIcons[selectedBrowser.displayName] || allBrowsersIcons.generic"
:alt="selectedBrowser.displayName"
>
/>
{{ selectedBrowser.displayName }} {{ selectedBrowser.majorVersion }}
</template>

Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/runner/SpecRunnerHeaderRunMode.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SpecRunnerHeaderRunMode from './SpecRunnerHeaderRunMode.vue'
import { useAutStore } from '../store'
import { allBrowsersIcons } from '@packages/frontend-shared/src/assets/browserLogos'
import { cyGeneralGlobeX16, cyBrowserChromeX16 } from '@cypress-design/icon-registry'

const browser = {
displayName: 'Chrome',
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('SpecRunnerHeaderRunMode', { viewportHeight: 500 }, () => {

cy.mount(<SpecRunnerHeaderRunMode />)

cy.get('[data-cy="select-browser"] > button img').should('have.attr', 'src', allBrowsersIcons.Chrome)
cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyBrowserChromeX16.data)
cy.get('[data-cy="select-browser"] > button').should('be.disabled')
})
})
Expand All @@ -86,7 +86,7 @@ describe('SpecRunnerHeaderRunMode', { viewportHeight: 500 }, () => {

cy.mount(<SpecRunnerHeaderRunMode />)

cy.get('[data-cy="select-browser"] > button img').should('have.attr', 'src', allBrowsersIcons.generic)
cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyGeneralGlobeX16.data)
cy.get('[data-cy="select-browser"] > button').should('be.disabled')
})
})
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/runner/SpecRunnerHeaderRunMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
:disabled="autStore.isRunning"
>
<template #heading>
<img
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
v-if="selectedBrowser.displayName"
class="min-w-[16px] w-[16px]"
alt=""
:src="allBrowsersIcons[selectedBrowser.displayName] || allBrowsersIcons.generic"
> {{ selectedBrowser.displayName }} {{ selectedBrowser.majorVersion }}
/> {{ selectedBrowser.displayName }} {{ selectedBrowser.majorVersion }}
</template>
</SpecRunnerDropdown>
<SpecRunnerDropdown
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/runner/automation/AutomationMissing.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { allBrowsersIcons } from '@packages/frontend-shared/src/assets/browserLogos'
import { AutomationMissingFragmentDoc, VerticalBrowserListItems_SetBrowserDocument } from '../../generated/graphql-test'
import AutomationMissing from './AutomationMissing.vue'
import { cyGeneralGlobeX16 } from '@cypress-design/icon-registry'

describe('AutomationMissing', () => {
it('should render', () => {
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('AutomationMissing', () => {
},
})

cy.get('[data-cy="select-browser"] > button img').should('have.attr', 'src', allBrowsersIcons.generic)
cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyGeneralGlobeX16.data)
cy.percySnapshot()
})
})
6 changes: 3 additions & 3 deletions packages/app/src/runner/automation/AutomationMissing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
data-cy="select-browser"
>
<template #heading>
<img
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
class="min-w-[16px] w-[16px]"
:src="allBrowsersIcons[selectedBrowser.displayName] || allBrowsersIcons.generic"
>
/>
{{ selectedBrowser.displayName }} {{ selectedBrowser.majorVersion }}
</template>

Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/runs/RunCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
:aria-label="t(props.debugEnabled ? 'runs.card.debugDescription' : 'runs.card.noDebugAvailable', { runNumber: run.runNumber })"
@click="onDebugClick"
>
<IconTechnologyDebugger
<IconObjectBug
aria-hidden="true"
class="h-[16px] w-[16px] mr-2 shrink-0"
/>
Expand Down Expand Up @@ -155,7 +155,7 @@ import Tooltip from '@packages/frontend-shared/src/components/Tooltip.vue'
import UserAvatar from '@cy/gql-components/topnav/UserAvatar.vue'
import { RunCardFragment, RunCard_ChangeDocument, RunCard_ShowDebugForCloudRunDocument } from '../generated/graphql'
import { useRunDateTimeInterval } from '../debug/useRunDateTimeInterval'
import { IconTechnologyDebugger, IconTimeClock, IconTechnologyBranchH } from '@cypress-design/vue-icon'
import { IconObjectBug, IconTimeClock, IconTechnologyBranchH } from '@cypress-design/vue-icon'
import { getUrlWithParams } from '@packages/frontend-shared/src/utils/getUrlWithParams'
const { t } = useI18n()
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/specs/switcher/TestingTypeSwitcher.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('<TestingTypeSwitcher />', () => {
/>)

cy.findByTestId('testing-type-switch').contains('button', 'E2E').should('have.attr', 'aria-selected', 'true')
cy.findByTestId('testing-type-switch').contains('button', 'Component').should('not.have.attr', 'aria-selected')
cy.findByTestId('testing-type-switch').contains('button', 'Component').should('have.attr', 'aria-selected', 'false')
})

it('selects current testing type when it is component', () => {
Expand All @@ -50,7 +50,7 @@ describe('<TestingTypeSwitcher />', () => {
onSelectTestingType={stub}
/>)

cy.findByTestId('testing-type-switch').contains('button', 'E2E').should('not.have.attr', 'aria-selected')
cy.findByTestId('testing-type-switch').contains('button', 'E2E').should('have.attr', 'aria-selected', 'false')
cy.findByTestId('testing-type-switch').contains('button', 'Component').should('have.attr', 'aria-selected', 'true')
})
})
41 changes: 41 additions & 0 deletions packages/frontend-shared/cypress/support/browserIconCommands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
declare global {
namespace Cypress {
interface Chainable {
verifyBrowserIconSvg(
expectedSvgData: string
): Chainable<JQuery<HTMLElement>>
}
}
}

function verifyBrowserIconSvg (
subject: JQuery<HTMLElement>,
expectedSvgData: string,
) {
cy.then(() => {
let actualSvgData = ''

subject.each((_, el) => {
actualSvgData += el.outerHTML
})

const actualNormalizedSvgData = actualSvgData
.replaceAll('></path>', '/>')
.replaceAll('></circle>', '/>')
.replace(/<title>.*<\/title>/, '')

const expectedNormalizedSvgData = expectedSvgData.replace(/<defs>.*<\/defs>/, '')

expect(actualNormalizedSvgData).to.equal(expectedNormalizedSvgData)

return subject
})
}

Cypress.Commands.add(
'verifyBrowserIconSvg',
{ prevSubject: true },
verifyBrowserIconSvg,
)

export {}
1 change: 1 addition & 0 deletions packages/frontend-shared/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { registerMountFn, addVueCommand } from './common'
import '../../src/styles/shared.scss'
import 'tailwindcss/tailwind.css'
import 'cypress-real-events/support'
import './browserIconCommands'
import { installCustomPercyCommand } from './customPercyCommand'
import { addNetworkCommands } from './onlineNetwork'
import { GQLStubRegistry } from './mock-graphql/stubgql-Registry'
Expand Down
1 change: 1 addition & 0 deletions packages/frontend-shared/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import i18n from '../../src/locales/en-US.json'
import { addNetworkCommands } from './onlineNetwork'
import { logInternal } from './utils'
import { tabUntil } from './tab-until'
import './browserIconCommands'

configure({ testIdAttribute: 'data-cy' })

Expand Down
3 changes: 1 addition & 2 deletions packages/frontend-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@antfu/utils": "^0.7.8",
"@cypress-design/css": "^0.13.3",
"@cypress-design/css": "^1.0.0",
"@faker-js/faker": "8.4.1",
"@graphql-typed-document-node/core": "^3.1.0",
"@headlessui/vue": "1.4.0",
Expand All @@ -45,7 +45,6 @@
"@vueuse/core": "7.2.2",
"autoprefixer": "^10.4.19",
"axe-core": "4.4.1",
"browser-logos": "github:alrra/browser-logos",
"combine-properties": "0.1.0",
"cross-env": "6.0.3",
"cypress-plugin-tab": "1.0.5",
Expand Down
Loading

4 comments on commit 558906f

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 558906f Jan 7, 2025

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/13.17.1/linux-x64/develop-558906f2f844ace15205471632da4f8d2c21d775/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 558906f Jan 7, 2025

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/13.17.1/linux-arm64/develop-558906f2f844ace15205471632da4f8d2c21d775/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 558906f Jan 7, 2025

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/13.17.1/darwin-arm64/develop-558906f2f844ace15205471632da4f8d2c21d775/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 558906f Jan 7, 2025

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/13.17.1/darwin-x64/develop-558906f2f844ace15205471632da4f8d2c21d775/cypress.tgz

Please sign in to comment.