Skip to content

Commit

Permalink
extract out ui-components dropdown (#6452)
Browse files Browse the repository at this point in the history
* extract out ui-components dropdown

Co-authored-by: Chris Breiding <chrisbreiding@gmail.com>

* yarn.lock changes

* fix issues with desktop-gui dropdown

* use ui-components dropdown in runner no-automation

* fix desktop-gui user dropdown

* fix tests

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
  • Loading branch information
brian-mann and chrisbreiding committed Feb 14, 2020
1 parent 9326174 commit 1069310
Show file tree
Hide file tree
Showing 19 changed files with 204 additions and 169 deletions.
10 changes: 4 additions & 6 deletions packages/desktop-gui/cypress/integration/login_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ describe('Login', function () {
})

it('displays username in UI', function () {
cy.get('nav a').should(function ($a) {
expect($a).to.contain(this.user.name)
})
cy.get('.user-dropdown .dropdown-chosen').should('contain', this.user.name)
})

it('displays username in success dialog', () => {
Expand All @@ -117,22 +115,22 @@ describe('Login', function () {

context('log out', function () {
it('displays login button on logout', () => {
cy.get('nav a').contains('Jane').click()
cy.get('.user-dropdown .dropdown-chosen').contains('Jane').click()

cy.contains('Log Out').click()
cy.get('.nav').contains('Log In')
})

it('calls log:out', function () {
cy.get('nav a').contains('Jane').click()
cy.get('.user-dropdown .dropdown-chosen').contains('Jane').click()

cy.contains('Log Out').click().then(function () {
expect(this.ipc.logOut).to.be.called
})
})

it('has login button enabled when returning to login after logout', function () {
cy.get('nav a').contains('Jane').click()
cy.get('.user-dropdown .dropdown-chosen').contains('Jane').click()
cy.contains('Log Out').click()
cy.contains('Log In').click()

Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-gui/cypress/integration/nav_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Navigation', function () {
})

it('displays user name', () => {
cy.get('nav a').should(function ($a) {
cy.get('.user-dropdown .dropdown-chosen').should(function ($a) {
expect($a).to.contain(this.user.name)
})
})
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Navigation', function () {
})

it('displays email instead of name', () => {
cy.get('nav a').should(function ($a) {
cy.get('.user-dropdown .dropdown-chosen').should(function ($a) {
expect($a).to.contain(this.user.email)
})
})
Expand Down
5 changes: 2 additions & 3 deletions packages/desktop-gui/src/app/nav.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { observer } from 'mobx-react'
import React, { Component } from 'react'
import { Dropdown } from '@packages/ui-components'

import appStore from '../lib/app-store'
import authApi from '../auth/auth-api'
Expand All @@ -9,8 +10,6 @@ import ipc from '../lib/ipc'
import { gravatarUrl } from '../lib/utils'
import { Link, routes } from '../lib/routing'

import Dropdown from '../dropdown/dropdown'

@observer
export default class Nav extends Component {
render () {
Expand Down Expand Up @@ -87,7 +86,7 @@ export default class Nav extends Component {

return (
<Dropdown
className='dropdown-toggle'
className='user-dropdown'
chosen={{ id: 'user' }}
others={[{ id: 'logout' }]}
onSelect={this._select}
Expand Down
22 changes: 17 additions & 5 deletions packages/desktop-gui/src/app/nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
}

.nav {
> .open {
> a, > a:hover, > a:focus {
.dropdown-chosen {
&:hover, &:focus {
background-color: #111;
color: #fff;
}
Expand All @@ -140,6 +140,13 @@
font-size: 12px;
}

.dropdown-menu > li {
line-height: 30px;
font-size: 14px;
padding: 5px 15px;
}

.dropdown-chosen,
> li > div,
> li > a,
> li > span > a {
Expand All @@ -150,6 +157,7 @@
display: inline-block;
}

.dropdown-chosen,
> li > a,
> li > span > a {
&:hover,
Expand All @@ -163,23 +171,27 @@

.browsers-list {
margin: 5px;
border: 1px solid #c7c7c7;
border-radius: 4px;

li {
padding: 9px 15px;
white-space: nowrap;
}

&>a.dropdown-chosen {
.dropdown-chosen {
border-radius: 4px;
border: 1px solid #c7c7c7;
line-height: 28px !important;
background-color: #f6f6f6;

img {
position: relative;
top: -1px;
}

&.disabled,
&:active {
background-color: #dedede;
}
}

.fa-check-circle, .fa-sync-alt {
Expand Down
1 change: 1 addition & 0 deletions packages/desktop-gui/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
@import 'styles/vendor';
@import 'styles/components/*';
@import '!(styles)*/**/*';
@import '../../ui-components/src/dropdown';
4 changes: 1 addition & 3 deletions packages/desktop-gui/src/project-nav/browsers.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { Component } from 'react'
import { observer } from 'mobx-react'
import Tooltip from '@cypress/react-tooltip'
import { BrowserIcon } from '@packages/ui-components'
import { BrowserIcon, Dropdown } from '@packages/ui-components'

import Dropdown from '../dropdown/dropdown'
import MarkdownRenderer from '../lib/markdown-renderer'

import projectsApi from '../projects/projects-api'

@observer
Expand Down
54 changes: 0 additions & 54 deletions packages/runner/src/dropdown/dropdown.jsx

This file was deleted.

78 changes: 0 additions & 78 deletions packages/runner/src/dropdown/dropdown.scss

This file was deleted.

20 changes: 19 additions & 1 deletion packages/runner/src/errors/errors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,29 @@
top: -1px;

&.fa-globe {
top: 0;
top: 0;
}
}
}

&.automation-failure {
.browser-icon {
margin-right: 5px;
vertical-align: middle;
position: relative;
top: -1px;
}

.dropdown-toggle {
margin-left: 5px;
}

.dropdown-menu li {
padding: 8px 12px;
white-space: nowrap;
}
}

.automation-disconnected button {
font-size: 18px;
line-height: 1.3;
Expand Down
5 changes: 2 additions & 3 deletions packages/runner/src/errors/no-automation.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import _ from 'lodash'
import React from 'react'
import { BrowserIcon } from '@packages/ui-components'

import Dropdown from '../dropdown/dropdown'
import { BrowserIcon, Dropdown } from '@packages/ui-components'

const displayName = (name) => _.capitalize(name)

Expand Down Expand Up @@ -42,6 +40,7 @@ const browserPicker = (browsers, onLaunchBrowser) => {
others={otherBrowsers}
onSelect={onLaunchBrowser}
renderItem={browser}
keyProperty='key'
/>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions packages/runner/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
@import 'lib/shared';
@import '!(lib)*/**/!(selector-playground.scss)';

@import '../../ui-components/src/dropdown';
@import '../../reporter/src/main-runner';
Loading

3 comments on commit 1069310

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1069310 Feb 14, 2020

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.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.2/linux-x64/circle-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-254613/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.2/circle-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-254595/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1069310 Feb 14, 2020

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.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.2/darwin-x64/circle-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-254618/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.2/circle-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-254616/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1069310 Feb 14, 2020

Choose a reason for hiding this comment

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

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.2/win32-ia32/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.2/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.0.2/win32-ia32/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.2/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.2/win32-ia32/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.0.2/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.0.2/win32-ia32/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.0.2/appveyor-develop-1069310899176b6b2e626eb3c03ab9a1f5abb795-30805604/cypress.tgz

Please sign in to comment.