Skip to content

Commit

Permalink
Merge branch 'develop' into tsify-lib-gui-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig authored Jun 25, 2020
2 parents 98dd95b + 759d87f commit c19befb
Show file tree
Hide file tree
Showing 42 changed files with 846 additions and 294 deletions.
13 changes: 13 additions & 0 deletions packages/desktop-gui/cypress/fixtures/specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,69 @@
"integration": [
{
"name": "app_spec.coffee",
"absolute": "/user/project/cypress/integration/app_spec.coffee",
"relative": "cypress/integration/app_spec.coffee"
},
{
"name": "accounts/account_new_spec.coffee",
"absolute": "/user/project/cypress/integration/accounts/account_new_spec.coffee",
"relative": "cypress/integration/accounts/account_new_spec.coffee"
},
{
"name": "accounts/accounts_list_spec.coffee",
"absolute": "/user/project/cypress/integration/accounts/accounts_list_spec.coffee",
"relative": "cypress/integration/accounts/accounts_list_spec.coffee"
},
{
"name": "admin_users/admin_users_list_spec.coffee",
"absolute": "/user/project/cypress/integration/admin_users/admin_users_list_spec.coffee",
"relative": "cypress/integration/admin_users/admin_users_list_spec.coffee"
},
{
"name": "admin_users/admin.user/foo_list_spec.coffee",
"absolute": "/user/project/cypress/integration/admin_users/admin.user/foo_list_spec.coffee",
"relative": "cypress/integration/admin_users/admin.user/foo_list_spec.coffee"
}
],
"unit": [
{
"name": "admin_users/admin/users/bar_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/bar_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/bar_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/one_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/one_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/one_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/two_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/two_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/two_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/three_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/three_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/three_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/four_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/four_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/four_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/five_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/five_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/five_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/six_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/six_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/six_list_spec.coffee"
},
{
"name": "admin_users/admin/users/all/admin/last_list_spec.coffee",
"absolute": "/user/project/cypress/unit/admin_users/admin/users/all/admin/last_list_spec.coffee",
"relative": "cypress/unit/admin_users/admin/users/all/admin/last_list_spec.coffee"
}
]
Expand Down
173 changes: 159 additions & 14 deletions packages/desktop-gui/cypress/integration/specs_list_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ describe('Specs List', function () {
cy.stub(this.ipc, 'getOptions').resolves({ projectRoot: '/foo/bar' })
cy.stub(this.ipc, 'getCurrentUser').resolves(this.user)
cy.stub(this.ipc, 'getSpecs').yields(null, this.specs)
cy.stub(this.ipc, 'getUserEditor').resolves({})
cy.stub(this.ipc, 'closeBrowser').resolves(null)
cy.stub(this.ipc, 'launchBrowser')
cy.stub(this.ipc, 'openFinder')
cy.stub(this.ipc, 'openFile')
cy.stub(this.ipc, 'externalOpen')
cy.stub(this.ipc, 'onboardingClosed')
cy.stub(this.ipc, 'onSpecChanged')
cy.stub(this.ipc, 'setUserEditor')

this.openProject = this.util.deferred()
cy.stub(this.ipc, 'openProject').returns(this.openProject.promise)
Expand Down Expand Up @@ -173,8 +176,8 @@ describe('Specs List', function () {
})

it('lists test specs', function () {
cy.get('.file a').last().should('contain', 'last_list_spec.coffee')
cy.get('.file a').last().should('not.contain', 'admin_users')
cy.get('.file .file-name-wrapper').last().should('contain', 'last_list_spec.coffee')
cy.get('.file .file-name-wrapper').last().should('not.contain', 'admin_users')
})
})
})
Expand Down Expand Up @@ -515,7 +518,7 @@ describe('Specs List', function () {
this.ipc.getSpecs.yields(null, this.specs)
this.openProject.resolve(this.config)

cy.contains('.file a', 'app_spec.coffee').as('firstSpec')
cy.contains('.file .file-name-wrapper', 'app_spec.coffee').as('firstSpec')
})

it('closes then launches browser on click of file', () => {
Expand All @@ -533,9 +536,11 @@ describe('Specs List', function () {
})

it('adds \'active\' class on click', () => {
cy.get('@firstSpec')
cy.get('@firstSpec').parent()
.should('not.have.class', 'active')
.click()

cy.get('@firstSpec').click()
.parent()
.should('have.class', 'active')
})

Expand All @@ -544,7 +549,7 @@ describe('Specs List', function () {
this.ipc.getSpecs.yield(null, this.specs)
})

cy.get('@firstSpec').should('have.class', 'active')
cy.get('@firstSpec').parent().should('have.class', 'active')
})
})

Expand All @@ -557,7 +562,7 @@ describe('Specs List', function () {

context('choose shallow spec', function () {
beforeEach(() => {
cy.get('.file a').contains('a', 'app_spec.coffee').as('firstSpec').click()
cy.get('.file .file-name-wrapper').contains('a', 'app_spec.coffee').as('firstSpec').click()
})

it('updates spec icon', function () {
Expand All @@ -566,21 +571,21 @@ describe('Specs List', function () {
})

it('sets spec as active', () => {
cy.get('@firstSpec').should('have.class', 'active')
cy.get('@firstSpec').parent().should('have.class', 'active')
})
})

context('choose deeper nested spec', function () {
beforeEach(() => {
cy.get('.file a').contains('a', 'last_list_spec.coffee').as('deepSpec').click()
cy.get('.file .file-name-wrapper').contains('a', 'last_list_spec.coffee').as('deepSpec').click()
})

it('updates spec icon', () => {
cy.get('@deepSpec').find('i').should('have.class', 'fa-dot-circle')
})

it('sets spec as active', () => {
cy.get('@deepSpec').should('have.class', 'active')
cy.get('@deepSpec').parent().should('have.class', 'active')
})
})
})
Expand All @@ -603,8 +608,8 @@ describe('Specs List', function () {
})

it('updates active spec', function () {
cy.get('@firstSpec').should('not.have.class', 'active')
cy.get('@secondSpec').should('have.class', 'active')
cy.get('@firstSpec').parent().should('not.have.class', 'active')
cy.get('@secondSpec').parent().should('have.class', 'active')
})
})
})
Expand All @@ -623,15 +628,155 @@ describe('Specs List', function () {
this.ipc.onSpecChanged.yield(null, 'integration/app_spec.coffee')
})

cy.get('@firstSpec').should('have.class', 'active')
cy.get('@firstSpec').parent().should('have.class', 'active')
.then(function () {
this.ipc.onSpecChanged.yield(null, 'integration/accounts/account_new_spec.coffee')
})

cy.get('@firstSpec').should('not.have.class', 'active')
cy.get('@firstSpec').parent().should('not.have.class', 'active')

cy.contains('a', 'account_new_spec.coffee')
.parent()
.should('have.class', 'active')
})
})

describe('open in IDE', function () {
beforeEach(function () {
this.ipc.getSpecs.yields(null, this.specs)

this.openProject.resolve(this.config)

cy.get('.file').contains('a', 'app_spec.coffee').parent().as('spec')
cy.get('@spec').contains('Open in IDE').as('button')
})

it('does not display button without hover', function () {
cy.contains('Open in IDE').should('not.be.visible')
})

it('displays when spec is hovered over', function () {
cy.get('@button').invoke('show').should('be.visible')
})

describe('opens files', function () {
beforeEach(function () {
this.availableEditors = [
{ id: 'computer', name: 'On Computer', isOther: false, openerId: 'computer' },
{ id: 'atom', name: 'Atom', isOther: false, openerId: 'atom' },
{ id: 'vim', name: 'Vim', isOther: false, openerId: 'vim' },
{ id: 'sublime', name: 'Sublime Text', isOther: false, openerId: 'sublime' },
{ id: 'vscode', name: 'Visual Studio Code', isOther: false, openerId: 'vscode' },
{ id: 'other', name: 'Other', isOther: true, openerId: '' },
]

cy.get('@button').invoke('show')
})

context('when user has not already set opener and opens file', function () {
beforeEach(function () {
this.ipc.getUserEditor.resolves({
availableEditors: this.availableEditors,
preferredOpener: this.availableEditors[4],
})
})

it('opens in preferred opener', function () {
cy.get('@button').click().then(() => {
expect(this.ipc.openFile).to.be.calledWith({
where: this.availableEditors[4],
file: '/user/project/cypress/integration/app_spec.coffee',
line: 0,
column: 0,
})
})
})
})

context('when user has not already set opener and opens file', function () {
beforeEach(function () {
this.ipc.getUserEditor.resolves({
availableEditors: this.availableEditors,
})

cy.get('@button').click()
})

it('opens modal with available editors', function () {
this.availableEditors.forEach(({ name }) => {
cy.contains(name)
})

cy.contains('Set preference and open file')
})

it('closes modal when cancel is clicked', function () {
cy.contains('Cancel').click()
cy.contains('Set preference and open file').should('not.be.visible')
})

describe('when editor is not selected', function () {
it('disables submit button', function () {
cy.contains('Set preference and open file')
.should('have.class', 'is-disabled')
.click()
.then(function () {
expect(this.ipc.setUserEditor).not.to.be.called
expect(this.ipc.openFile).not.to.be.called
})
})

it('shows validation message when hovering over submit button', function () {
cy.get('.editor-picker-modal .submit').trigger('mouseover')
cy.get('.cy-tooltip').should('have.text', 'Please select a preference')
})
})

describe('when Other is selected but path is not entered', function () {
beforeEach(function () {
cy.contains('Other').click()
})

it('disables submit button', function () {
cy.contains('Set preference and open file')
.should('have.class', 'is-disabled')
.click()
.then(function () {
expect(this.ipc.setUserEditor).not.to.be.called
expect(this.ipc.openFile).not.to.be.called
})
})

it('shows validation message when hovering over submit button', function () {
cy.get('.editor-picker-modal .submit').trigger('mouseover')
cy.get('.cy-tooltip').should('have.text', 'Please enter the path for the "Other" editor')
})
})

describe('when editor is set', function () {
beforeEach(function () {
cy.contains('Visual Studio Code').click()
cy.contains('Set preference and open file').click()
})

it('closes modal', function () {
cy.contains('Set preference and open file').should('not.be.visible')
})

it('sets user editor', function () {
expect(this.ipc.setUserEditor).to.be.calledWith(this.availableEditors[4])
})

it('opens file in selected editor', function () {
expect(this.ipc.openFile).to.be.calledWith({
where: this.availableEditors[4],
file: '/user/project/cypress/integration/app_spec.coffee',
line: 0,
column: 0,
})
})
})
})
})
})
})
1 change: 1 addition & 0 deletions packages/desktop-gui/src/lib/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ register('launch:browser', false)
register('log:out')
register('on:focus:tests', false)
register('on:menu:clicked', false)
register('open:file')
register('open:finder')
register('open:project', false)
register('on:config:changed', false)
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop-gui/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import 'styles/mixins';
@import 'styles/vendor';
@import 'styles/components/*';
@import '../../ui-components/src/file-opener/file-opener';
@import '!(styles)*/**/*';
@import '../../../node_modules/@reach/dialog/styles.css';
@import '../../ui-components/src/dropdown';
@import '../../ui-components/src/editor-picker';
Loading

0 comments on commit c19befb

Please sign in to comment.