Skip to content

Commit

Permalink
Merge branch 'develop' into v4.0-release
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Dec 10, 2019
2 parents 62fde51 + 05ad20f commit a0eddc2
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 37 deletions.
32 changes: 24 additions & 8 deletions packages/desktop-gui/cypress/fixtures/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@
"name": "chrome",
"displayName": "Chrome",
"family": "chrome",
"version": "50.0.2661.86",
"version": "78.0.3904.108",
"path": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"majorVersion": "50"
"majorVersion": "78"
},
{
"name": "chromium",
"displayName": "Chromium",
"family": "chrome",
"version": "49.0.2609.0",
"path": "/Users/bmann/Downloads/chrome-mac/Chromium.app/Contents/MacOS/Chromium",
"majorVersion": "49"
"version": "74.0.3729.0",
"path": "/Applications/Chromium.app/Contents/MacOS/Chromium",
"majorVersion": "74"
},
{
"name": "canary",
"displayName": "Canary",
"family": "chrome",
"version": "48.0",
"path": "/Users/bmann/Downloads/chrome-mac/Canary.app/Contents/MacOS/Canary",
"majorVersion": "48"
"version": "80.0.3977.4",
"path": "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
"majorVersion": "80"
},
{
"name": "electron",
"displayName": "Electron",
"family": "electron",
"version": "73.0.3683.121",
"path": "",
"majorVersion": "73"
},
{
"name": "firefox",
"displayName": "Firefox",
"family": "firefox",
"version": "69.0.1",
"path": "/Applications/Firefox/Contents/MacOS/Firefox",
"majorVersion": "69"
}
],
"clientRoute": "/__/",
Expand Down
70 changes: 52 additions & 18 deletions packages/desktop-gui/cypress/integration/project_nav_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,39 @@ describe('Project Nav', function () {
})

context('normal browser list behavior', function () {
it('lists browsers', () => {
it('lists browsers', function () {
cy.get('.browsers-list').parent()
.find('.dropdown-menu').first()
.find('li').should('have.length', 2)
.should(function ($li) {
expect($li.first()).to.contain('Chromium')
expect($li.last()).to.contain('Canary')
// one is showing in the selection, so won't be in the list
.find('li').should('have.length', this.config.browsers.length - 1)
.each(function ($li, i) {
const dropdownBrowsers = Cypress._.filter(this.config.browsers, (b) => {
// Chrome is shown in selection, so skip it
return b.displayName !== 'Chrome'
})

expect($li).to.contain(dropdownBrowsers[i].displayName)
})
})

it('displays browsers icons', function () {
cy.get('.browsers-list').parent()
.find('.dropdown-menu').first()
// one is showing in the selection, so won't be in the list
.find('.browser-icon')
.each(function ($i, i) {
const dropdownBrowsers = Cypress._.filter(this.config.browsers, (b) => {
// Chrome is shown in selection, so skip it
return b.displayName !== 'Chrome'
})

let family = dropdownBrowsers[i].family

family = family === 'electron' ? 'chrome' : family

// first one is shown in selection, so skip first
cy.wrap($i).should('have.class',
`fa-${family}`)
})
})

Expand Down Expand Up @@ -145,13 +171,16 @@ describe('Project Nav', function () {
cy.get('.browsers-list>a').first().contains('Chromium')
})

it('swaps the chosen browser into the dropdown', () => {
it('swaps the chosen browser into the dropdown', function () {
cy.get('.browsers-list').find('.dropdown-menu')
.find('li').should('have.length', 2)
.should(function ($li) {
expect($li.first()).to.contain('Chrome')

expect($li.last()).to.contain('Canary')
.find('li').should('have.length', this.config.browsers.length - 1)
.each(function ($li, i) {
const dropdownBrowsers = Cypress._.filter(this.config.browsers, (b) => {
// Chrome is shown in selection, so skip it
return b.displayName !== 'Chromium'
})

expect($li).to.contain(dropdownBrowsers[i].displayName)
})
})

Expand Down Expand Up @@ -343,28 +372,33 @@ describe('Project Nav', function () {
describe('custom browser available', function () {
beforeEach(function () {
this.config.browsers.push({
name: 'chromium',
family: 'chrome',
name: 'foo browser',
family: 'foo',
custom: true,
displayName: 'Custom Chromium',
displayName: 'Custom Foo',
version: '72.0.3626.96',
majorVersion: '72',
path: '/usr/bin/chromium-x',
info: 'Loaded from /usr/bin/chromium-x',
path: '/usr/bin/foo-x',
info: 'Loaded from /usr/bin/foo-x',
})

this.openProject.resolve(this.config)
})

it('displays generic icon', () => {
cy.get('.browsers-list>a').first()
.should('contain', 'Custom Foo')
})

it('pre-selects the custom browser', () => {
cy.get('.browsers-list>a').first()
.should('contain', 'Custom Chromium')
.should('contain', 'Custom Foo')
})

it('pre-selects the custom browser if chosenBrowser saved locally', function () {
localStorage.setItem('chosenBrowser', 'electron')
cy.get('.browsers-list>a').first()
.should('contain', 'Custom Chromium')
.should('contain', 'Custom Foo')

cy.wrap(localStorage.getItem('chosenBrowser')).should('equal', 'electron')
})
Expand Down
32 changes: 25 additions & 7 deletions packages/desktop-gui/src/app/nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@
.browsers.nav {
i {
font-size: 13px;

&.fa-firefox {
font-size: 14px;
}
}
}
}


.navbar-right {
margin-right: 0;

.nav {
.user-avatar {
position: relative;
top: -1px;
Expand Down Expand Up @@ -167,10 +169,26 @@
display: inline-block;
}

.chrome > i { color: #1aa15f; }
.canary > i { color: #e4b721; }
.chromium > i { color: #829ac3; }
.electron > i { color: #777; }
.browser-icon {
color: #4573d9;
}

.chrome > .browser-icon {
color: #1da261;
}
.canary > .browser-icon {
color: #f29b14;
}
.chromium > .browser-icon {
color: #4573d9;
}
.electron > .browser-icon {
color: #2b2e3a;
}
.firefox > .browser-icon {
color: #ff720d;
}


.dropdown-menu {
left: auto;
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop-gui/src/lib/browser-model.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { computed, observable } from 'mobx'
import { browserIcon } from '../lib/utils'

export default class Browser {
@observable displayName
Expand All @@ -25,6 +26,6 @@ export default class Browser {
}

@computed get icon () {
return 'chrome'
return browserIcon(this.family)
}
}
4 changes: 2 additions & 2 deletions packages/desktop-gui/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const osIconLookup = {

const browserIconLookup = {
chrome: 'chrome',
Electron: 'chrome',
electron: 'chrome',
firefox: 'firefox',
safari: 'safari',
}
Expand All @@ -28,7 +28,7 @@ export const osIcon = (osName) => {
export const browserIcon = (browserName) => {
if (!browserName) return ''

return browserIconLookup[browserName] || 'globe'
return browserIconLookup[_.lowerCase(browserName)] || 'globe'
}

export const browserNameFormatted = (browserName) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/project-nav/browsers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class Browsers extends Component {

return (
<span className={browser.name}>
<i className={icon}></i>{' '}
<i className={`browser-icon ${icon}`}></i>{' '}
{prefixText}{' '}
{browser.displayName}{' '}
{browser.majorVersion}
Expand Down

0 comments on commit a0eddc2

Please sign in to comment.