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

misc: Move browser dropdown within AUT URL bar #31216

Merged
merged 30 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7db059b
misc: Begin code for moving viewport dimensions and removing dropdown
jennifer-shehane Feb 17, 2025
7952e8f
Merge branch 'develop' into viewport-dimensions-ux-update
jennifer-shehane Feb 18, 2025
904efd0
Update styles for viewport size + scale and handle component testing …
jennifer-shehane Feb 18, 2025
eef419d
Merge branch 'develop' into viewport-dimensions-ux-update
jennifer-shehane Feb 18, 2025
b51e9f8
add changelog
jennifer-shehane Feb 18, 2025
0d06668
fix changelog link
jennifer-shehane Feb 18, 2025
d4e529b
Merge branch 'develop' into viewport-dimensions-ux-update
jennifer-shehane Feb 18, 2025
365e1e3
fix issue link again!
jennifer-shehane Feb 18, 2025
386ae59
misc: begin reworking the browser dropdown
jennifer-shehane Feb 18, 2025
9fa1a05
Merge branch 'develop' into browser-dropdown-ux-update
jennifer-shehane Feb 21, 2025
c01adca
Merge branch 'develop' into browser-dropdown-ux-update
jennifer-shehane Feb 25, 2025
044e2dc
Merge branch 'develop' into browser-dropdown-ux-update
jennifer-shehane Mar 4, 2025
a8f6c87
Update UIs for dropdowns to work right in both modes
jennifer-shehane Mar 4, 2025
1d7dbbc
changelog entry
jennifer-shehane Mar 4, 2025
c0eb16d
remove assertions about browser dropdown being visible in tiny widths
jennifer-shehane Mar 4, 2025
7e57eb9
update changelog entry
jennifer-shehane Mar 4, 2025
37fc77b
Add zindex of 5 for the aut-panel so it doesn't ever cover the report…
jennifer-shehane Mar 5, 2025
e63d1a0
Merge branch 'develop' into browser-dropdown-ux-update
jennifer-shehane Mar 5, 2025
a102ab8
Just pass zindex to style - apparently tailwind css option doesn't wa…
jennifer-shehane Mar 5, 2025
c0629e2
Update aut height to new height
jennifer-shehane Mar 5, 2025
56abccd
Merge branch 'develop' into browser-dropdown-ux-update
jennifer-shehane Mar 7, 2025
8bd4480
Move zindex to input instead of main aut-url container to prevent scr…
jennifer-shehane Mar 7, 2025
fb7f2c7
Add a comment, maybe it will help someone one day
jennifer-shehane Mar 7, 2025
cb94aa1
set z-index back to 51 to be above studio URL panel, but runner to 60…
jennifer-shehane Mar 7, 2025
167149f
zindex
jennifer-shehane Mar 7, 2025
057fcaf
more z index changes!!1
jennifer-shehane Mar 7, 2025
22e5e0e
revert the resizable panel changes - make zindex of input dynamic!
jennifer-shehane Mar 10, 2025
44dace8
Merge branch 'develop' into browser-dropdown-ux-update
jennifer-shehane Mar 10, 2025
86103c5
Fix browser dropdown in AutomationMissing UI
jennifer-shehane Mar 10, 2025
6a49184
Merge branch 'browser-dropdown-ux-update' of https://github.com/cypre…
jennifer-shehane Mar 10, 2025
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
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _Released 3/11/2025 (PENDING)_

**Misc:**

- The browser dropdown now has a more minimal design - showing only the icon of the browser selected to the left of the URL. The currently selected browser also now shows at the top of the browser dropdown. Browsers with longer names will now have their names correctly left aligned in the browser dropdown. Addresses [#21755](https://github.com/cypress-io/cypress/issues/21755) and [#30998](https://github.com/cypress-io/cypress/issues/30998). Addressed in [#31216](https://github.com/cypress-io/cypress/pull/31216).
- Additional CLI options will be displayed in the terminal for some Cloud error messages. Addressed in [#31211](https://github.com/cypress-io/cypress/pull/31211).

**Dependency Updates:**
Expand Down
2 changes: 1 addition & 1 deletion packages/app/cypress/e2e/cypress-in-cypress-e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('Cypress In Cypress E2E', { viewportWidth: 1500, defaultCommandTimeout:
})

it('shows a compilation error with a malformed spec', { viewportHeight: 596, viewportWidth: 1000 }, () => {
const expectedAutHeight = 456 // based on explicitly setting viewport in this test to 596
const expectedAutHeight = 500 // based on explicitly setting viewport in this test to 596
Copy link
Member Author

Choose a reason for hiding this comment

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

This has legitimately changed, previously the browser dropdown at this width was lessening the AUT height.
Screenshot 2025-03-05 at 12 10 26 PM

Screenshot 2025-03-05 at 12 10 37 PM


cy.visitApp()
cy.specsPageIsVisible()
Expand Down
4 changes: 1 addition & 3 deletions packages/app/cypress/e2e/cypress-in-cypress.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('Cypress in Cypress', { viewportWidth: 1500, defaultCommandTimeout: 100
cy.get('@selectBrowser').should('be.visible') // with no specs list open, we should see this by scrolling

dragHandleToClientX('panel2', 200).then(() => {
cy.contains('Chrome 1').should('be.visible')
cy.contains('Chrome 1').should('not.be.visible')
})

cy.contains('[aria-controls=reporter-inline-specs-list]', 'Specs')
Expand All @@ -212,8 +212,6 @@ describe('Cypress in Cypress', { viewportWidth: 1500, defaultCommandTimeout: 100
cy.get('@selectBrowser').should('not.be.visible') // with specs list open, scrolling is not enough to see this

dragHandleToClientX('panel1', 130)
cy.get('@selectBrowser')
.should('be.visible') // now that we have reduced the specs list, we should be able to see this

cy.contains(testingTypeExpectedScales[`${ testingType }NarrowViewport`])
})
Expand Down
5 changes: 2 additions & 3 deletions packages/app/src/runner/ResizablePanels.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- Be careful with changing styles of the panels, it can impact our screenshot tests -->
Copy link
Member Author

Choose a reason for hiding this comment

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

lesson learned.......

<template>
<div
id="resizable-panels-root"
Expand Down Expand Up @@ -46,9 +47,7 @@
data-cy="aut-panel"
class="grow h-full bg-gray-100 relative"
:class="{'pointer-events-none':panel2IsDragging}"
:style="{
width: `${panel3width}px`
}"
:style="{ width: `${panel3width}px` }"
>
<slot
name="panel3"
Expand Down
12 changes: 8 additions & 4 deletions packages/app/src/runner/SpecRunnerDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<template>
<Popover
:key="`${props.disabled}`"
class="bg-white rounded border-[1px] border-gray-100 h-[32px] relative"
class="rounded-[50px] h-[30px] mx-[6px] py-[2px] relative"
#="{ open, close }"
>
<PopoverButton
class="border-transparent rounded grow h-full border-[1px] px-[12px] group"
class="bg-white border rounded-[50px] self-center h-full grow px-[5px] group"
:class="{
'hocus-default': !props.disabled,
'opacity-50 cursor-auto': props.disabled,
'rounded-[5px] border-[1px] border-indigo-100': !props.minimal,
'border-transparent': props.minimal,
}"
:disabled="props.disabled"
>
Expand All @@ -26,6 +28,7 @@
:close="close"
/>
<i-cy-chevron-down
v-if="!props.minimal"
class="transform transition-all w-[10px] duration-300"
:class="{
'group-hocus:icon-dark-indigo-500': !props.disabled,
Expand Down Expand Up @@ -61,14 +64,15 @@ import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
const props = withDefaults(defineProps<{
variant?: 'panel'
align?: 'left' | 'right'

minimal?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a comment or two describing the new minimal option here?

Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can see one allows for a visual dropdown with a chevron vs the browser icon being the dropdown?

// The disabled prop is used as the Popover key so that changes to the prop
// cause the Popover component to mount again. This re-mounting ensures that
// the PopoverPanel is closed if an enabled dropdown later becomes disabled.
disabled?: boolean
}>(), {
minimal: true,
variant: undefined,
align: 'right',
align: 'left',
disabled: false,
})

Expand Down
14 changes: 13 additions & 1 deletion packages/app/src/runner/SpecRunnerHeaderOpenMode.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('SpecRunnerHeaderOpenMode', { viewportHeight: 500 }, () => {
})

cy.findByTestId('aut-url-input').should('be.visible').should('have.value', autUrl)
cy.findByTestId('select-browser').should('be.visible').contains('Electron 73')
cy.findByTestId('select-browser').should('be.visible').contains('title', 'Electron 73')
cy.findByTestId('viewport-size').should('be.visible').contains('500x500')
})

Expand Down Expand Up @@ -218,6 +218,18 @@ describe('SpecRunnerHeaderOpenMode', { viewportHeight: 500 }, () => {
cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyGeneralGlobeX16.data)
})

it('shows selected browser as first browser in dropdown', () => {
cy.mountFragment(SpecRunnerHeaderFragmentDoc, {
render: (gqlVal) => {
return renderWithGql(gqlVal)
},
})

cy.get('[data-cy="select-browser"] > button').should('be.enabled').click()
cy.get('[data-browser-id="1"]').should('contain', 'Electron').and('contain', 'Version 73')
cy.get('[data-browser-id="1"]').find('[data-cy="top-nav-browser-list-selected-item"]')
})

it('shows current viewport info', () => {
cy.mountFragment(SpecRunnerHeaderFragmentDoc, {
render: (gqlVal) => {
Expand Down
58 changes: 31 additions & 27 deletions packages/app/src/runner/SpecRunnerHeaderOpenMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<div class="flex flex-wrap grow p-[16px] gap-[12px] justify-end">
<div
data-cy="aut-url"
class="border rounded flex grow border-gray-100 h-[32px] overflow-hidden align-middle"
class="border rounded flex grow border-gray-100 h-[32px] align-middle"
:class="{
'bg-gray-50': autStore.isLoadingUrl
}"
>
<Button
data-cy="playground-activator"
:disabled="isDisabled"
class="rounded-none border-gray-100 border-r-[1px] mr-[12px]"
class="rounded-none border-gray-100 border-r-[1px]"
variant="text"
:aria-label="t('runner.selectorPlayground.toggle')"
@click="togglePlayground"
Expand All @@ -24,14 +24,36 @@
:class="[selectorPlaygroundStore.show ? 'icon-dark-indigo-500' : 'icon-dark-gray-500']"
/>
</Button>
<SpecRunnerDropdown
v-if="selectedBrowser?.displayName"
data-cy="select-browser"
:disabled="autStore.isRunning"
>
<template #heading>
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
class="min-w-[16px] w-[16px]"
:alt="selectedBrowser.majorVersion ? `${selectedBrowser.displayName} ${selectedBrowser.majorVersion}` : selectedBrowser.displayName"
/>
</template>
<template #default>
<div class="max-h-[50vh] overflow-auto">
<VerticalBrowserListItems
:gql="props.gql"
:spec-path="activeSpecPath"
/>
</div>
</template>
</SpecRunnerDropdown>
<input
ref="autUrlInputRef"
data-cy="aut-url-input"
:disabled="urlDisabled"
:value="inputValue"
:placeholder="inputPlaceholder"
aria-label="url of the application under test"
class="aut-url-input flex grow mr-[12px] leading-normal max-w-full text-indigo-500 z-51 self-center hocus-link-default truncate"
class="aut-url-input flex grow mr-[12px] leading-normal max-w-full text-indigo-500 self-center hocus-link-default truncate"
:style="{ zIndex: inputZIndex }"
@input="setStudioUrl"
@click="openExternally"
@keyup.enter="visitUrl"
Expand Down Expand Up @@ -65,30 +87,6 @@
</span>
</Tag>
</div>

<SpecRunnerDropdown
v-if="selectedBrowser?.displayName"
data-cy="select-browser"
:disabled="autStore.isRunning"
>
<template #heading>
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
class="min-w-[16px] w-[16px]"
:alt="selectedBrowser.displayName"
/>
{{ selectedBrowser.displayName }} {{ selectedBrowser.majorVersion }}
</template>

<template #default>
<div class="max-h-[50vh] overflow-auto">
<VerticalBrowserListItems
:gql="props.gql"
:spec-path="activeSpecPath"
/>
</div>
</template>
</SpecRunnerDropdown>
</div>

<SelectorPlayground
Expand Down Expand Up @@ -184,6 +182,12 @@ watchEffect(() => {

const autIframe = props.getAutIframe()

const inputZIndex = computed(() => {
// input needs to be above the Studio prompt overlay
// but other times it needs to be below other resizable panels
return studioStore.needsUrl ? 51 : 5
Copy link
Contributor

Choose a reason for hiding this comment

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

is the studio prompt overlay have a z-index of 50 or something near that? Is there a better way to determine the z-index value here over static values?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah, the overlay has a 50 zindex. It is a good point, this code was so brittle with the zindex changes. I suffered a lot.

})

const displayScale = computed(() => {
return autStore.scale < 1 ? `${Math.round(autStore.scale * 100) }%` : 0
})
Expand Down
47 changes: 17 additions & 30 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 { cyGeneralGlobeX16, cyBrowserChromeX16 } from '@cypress-design/icon-registry'
import { cyGeneralGlobeX16 } from '@cypress-design/icon-registry'

const browser = {
displayName: 'Chrome',
Expand All @@ -19,18 +19,19 @@ describe('SpecRunnerHeaderRunMode', { viewportHeight: 500 }, () => {

cy.mount(<SpecRunnerHeaderRunMode/>)

cy.get('[data-cy="aut-url"]').should('be.visible')
cy.get('[data-cy="select-browser"]').should('be.visible')
.click()

cy.contains('Firefox').should('not.exist')
cy.get('[data-cy="select-browser"]')
.find('title').should('have.text', 'Chrome 1')

cy.get('[data-cy="playground-activator"]').should('not.exist')
// confirm expected content is rendered
cy.contains('1000x660').should('be.visible')
cy.contains('40%').should('be.visible')
cy.contains('Chrome 1').should('be.visible')
cy.contains('http://localhost:4000').should('be.visible')

// confirm no interactions are implemented
cy.contains('Chrome 1').click()
cy.contains('Firefox').should('not.exist')

cy.contains('http://localhost:4000').should('be.visible')
cy.percySnapshot()
})
})
Expand All @@ -46,32 +47,19 @@ describe('SpecRunnerHeaderRunMode', { viewportHeight: 500 }, () => {

cy.mount(<SpecRunnerHeaderRunMode />)

cy.get('[data-cy="select-browser"]').should('be.visible')
.click()

cy.contains('Firefox').should('not.exist')
cy.get('[data-cy="select-browser"]')
.find('title').should('have.text', 'Chrome 1')

cy.contains('URL navigation disabled in component testing').should('be.visible')

cy.get('[data-cy="playground-activator"]').should('not.exist')
// confirm expected content is rendered
cy.contains('500x500').should('be.visible')
cy.contains('40%').should('be.visible')
cy.contains('Chrome 1').should('be.visible')

// confirm no interactions are implemented
cy.contains('Chrome 1').click()
cy.contains('Firefox').should('not.exist')
})
})

it('disables browser dropdown button when specs are running', () => {
cy.window().then((win) => {
win.__CYPRESS_BROWSER__ = browser
win.__CYPRESS_TESTING_TYPE__ = 'e2e'
const autStore = useAutStore()

autStore.updateUrl('http://localhost:4000')
autStore.setIsRunning(true)

cy.mount(<SpecRunnerHeaderRunMode />)

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 @@ -87,7 +75,6 @@ describe('SpecRunnerHeaderRunMode', { viewportHeight: 500 }, () => {
cy.mount(<SpecRunnerHeaderRunMode />)

cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyGeneralGlobeX16.data)
cy.get('[data-cy="select-browser"] > button').should('be.disabled')
})
})
})
26 changes: 11 additions & 15 deletions packages/app/src/runner/SpecRunnerHeaderRunMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
'bg-gray-50': autStore.isLoadingUrl
}"
>
<div class="mx-[12px] flex grow text-gray-600 items-center truncate">
<SpecRunnerDropdown data-cy="select-browser">
<template #heading>
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
v-if="selectedBrowser.displayName"
class="min-w-[16px] w-[16px]"
:alt="selectedBrowser.majorVersion ? `${selectedBrowser.displayName} ${selectedBrowser.majorVersion}` : selectedBrowser.displayName"
/>
</template>
</SpecRunnerDropdown>
<div class="mr-[12px] flex grow text-gray-600 items-center truncate">
{{ testingType === 'e2e' ? autStore.url : 'URL navigation disabled in component testing' }}
</div>
<Tag
Expand All @@ -38,20 +48,6 @@
</span>
</Tag>
</div>
<SpecRunnerDropdown
data-cy="select-browser"
:disabled="autStore.isRunning"
>
<template #heading>
<component
:is="allBrowsersIcons[selectedBrowser.displayName?.toLowerCase()] || allBrowsersIcons.generic"
v-if="selectedBrowser.displayName"
class="min-w-[16px] w-[16px]"
alt=""
/> {{ selectedBrowser.displayName }}
{{ selectedBrowser.majorVersion }}
</template>
</SpecRunnerDropdown>
</div>
</div>
</template>
Expand Down
14 changes: 14 additions & 0 deletions packages/app/src/runner/automation/AutomationMissing.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,18 @@ describe('AutomationMissing', () => {
cy.get('[data-cy="select-browser"] > button svg').eq(0).children().verifyBrowserIconSvg(cyGeneralGlobeX16.data)
cy.percySnapshot()
})

it('browser dropdown displays on click', () => {
cy.mountFragment(AutomationMissingFragmentDoc, {
render (gql) {
return (<AutomationMissing gql={gql} />)
},
})

cy.get('[data-cy="select-browser"]').click()
cy.contains('li', 'Chrome').should('be.visible')
cy.contains('li', 'Version 80').should('be.visible')
cy.get('[data-browser-id=1]').contains('Electron').should('be.visible')
cy.percySnapshot()
})
})
1 change: 1 addition & 0 deletions packages/app/src/runner/automation/AutomationMissing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
align="left"
class="max-w-max"
data-cy="select-browser"
:minimal="false"
>
<template #heading>
<component
Expand Down
Loading
Loading