Skip to content

Commit

Permalink
Properly close login modal during project setup (#5647)
Browse files Browse the repository at this point in the history
* write failing test for login modal not closing during project setup

* add closeLogin, openLogin to authStore

* update test to click Continue before setup can proceed

* add event listeners to fix this strange modal flow
  • Loading branch information
jennifer-shehane authored Nov 8, 2019
1 parent 98063ae commit 1466f7c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,20 @@ describe('Set Up Project', function () {
cy.get('.modal').contains('Log In to Dashboard')
})

it('closes login modal', () => {
cy.get('.modal').contains('Log In to Dashboard')
cy.get('.close').click()
cy.get('.btn').contains('Set up project').click()
})

describe('when login succeeds', function () {
beforeEach(function () {
cy.stub(this.ipc, 'beginAuth').resolves(this.user)
cy.contains('button', 'Log In to Dashboard').click()
})

it('shows setup', () => {
cy.get('.login-content > .btn').click()
cy.contains('h4', 'Set up project')
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/app/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class Nav extends Component {
}

_showLogin () {
authStore.setShowingLogin(true)
authStore.openLogin()
}

_openDocs (e) {
Expand Down
15 changes: 13 additions & 2 deletions packages/desktop-gui/src/auth/auth-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,20 @@ class AuthStore {
this.message = message
}

@action setShowingLogin (isShowing) {
@action openLogin (onCloseCb) {
this.onCloseCb = onCloseCb

this.setMessage(null)
this.isShowingLogin = true
}

@action closeLogin () {
if (this.onCloseCb) {
this.onCloseCb(this.isAuthenticated)
}

this.setMessage(null)
this.isShowingLogin = isShowing
this.isShowingLogin = false
}

@action setUser (user) {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/auth/login-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import authStore from './auth-store'
import ipc from '../lib/ipc'

const close = () => {
authStore.setShowingLogin(false)
authStore.closeLogin()
}

// LoginContent is a separate component so that it pings the api
Expand Down
17 changes: 17 additions & 0 deletions packages/desktop-gui/src/runs/project-not-setup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import BootstrapModal from 'react-bootstrap-modal'
import ipc from '../lib/ipc'
import { configFileFormatted } from '../lib/config-file-formatted'
import SetupProject from './setup-project-modal'
import authStore from '../auth/auth-store'

@observer
export default class ProjectNotSetup extends Component {
Expand Down Expand Up @@ -92,6 +93,22 @@ export default class ProjectNotSetup extends Component {
_projectSetup () {
if (!this.state.setupProjectModalOpen) return null

if (!this.props.isAuthenticated) {
authStore.openLogin((isAuthenticated) => {
if (!isAuthenticated) {
// auth was canceled, cancel project setup too
this.setState({ setupProjectModalOpen: false })
}
})

return null
}

if (this.props.isShowingLogin) {
// login dialog still open, wait for it to close before proceeding
return null
}

return (
<SetupProject
project={this.props.project}
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop-gui/src/runs/runs-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class RunsList extends Component {
_projectNotSetup (isValid = true) {
return (
<ProjectNotSetup
isAuthenticated={authStore.isAuthenticated}
isShowingLogin={authStore.isShowingLogin}
project={this.props.project}
isValid={isValid}
onSetup={this._setProjectDetails}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/runs/setup-project-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SetupProject extends Component {

render () {
if (!authStore.isAuthenticated) {
authStore.setShowingLogin(true)
authStore.openLogin()

return null
}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/settings/record-key.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const openRecordKeyGuide = (e) => {
}

const showLogin = () => {
authStore.setShowingLogin(true)
authStore.openLogin()
}

@observer
Expand Down

4 comments on commit 1466f7c

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1466f7c Nov 8, 2019

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/3.6.1/linux-x64/circle-develop-1466f7cc988c45b43567a2f12a898b238502a21d-188597/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.6.1/circle-develop-1466f7cc988c45b43567a2f12a898b238502a21d-188594/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1466f7c Nov 8, 2019

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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.6.1/win32-ia32/appveyor-develop-1466f7cc988c45b43567a2f12a898b238502a21d-28726115/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.6.1/win32-ia32/appveyor-develop-1466f7cc988c45b43567a2f12a898b238502a21d-28726115/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1466f7c Nov 8, 2019

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 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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.6.1/win32-x64/appveyor-develop-1466f7cc988c45b43567a2f12a898b238502a21d-28726115/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.6.1/win32-x64/appveyor-develop-1466f7cc988c45b43567a2f12a898b238502a21d-28726115/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1466f7c Nov 8, 2019

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.

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/3.6.1/darwin-x64/circle-develop-1466f7cc988c45b43567a2f12a898b238502a21d-188698/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.6.1/circle-develop-1466f7cc988c45b43567a2f12a898b238502a21d-188645/cypress.tgz

Please sign in to comment.