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

fix(studio): restore intro modal styles #17118

Merged
merged 7 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 22 additions & 16 deletions packages/runner-shared/src/studio/studio-modals.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { action, observable } from 'mobx'
import { observer } from 'mobx-react'
import React, { Component } from 'react'
import { Dialog } from '@reach/dialog'
Expand All @@ -7,6 +6,8 @@ import { eventManager } from '../event-manager'

import { studioRecorder } from './studio-recorder'

import './studio-modals.scss'

@observer
export class StudioInstructionsModal extends Component {
render () {
Expand All @@ -21,7 +22,8 @@ export class StudioInstructionsModal extends Component {
<h1 className='title'>
<i className='fas fa-magic icon' />
{' '}
Studio
Studio
{' '}
<span className='beta'>BETA</span>
</h1>
<div className='content center'>
Expand Down Expand Up @@ -52,7 +54,7 @@ Studio
{' '}
<a href='https://on.cypress.io/studio-beta' target='_blank' rel="noreferrer">feedback</a>
{' '}
will be highly influential to our team.
will be highly influential to our team.
</div>
</div>
<div className='controls'>
Expand All @@ -75,7 +77,7 @@ export class StudioInitModal extends Component {
render () {
return (
<Dialog
className='studio-modal'
className='studio-modal studio-init-modal'
aria-label='Start Studio'
isOpen={studioRecorder.initModalIsOpen}
onDismiss={this._close}
Expand All @@ -84,7 +86,8 @@ export class StudioInitModal extends Component {
<h1 className='title'>
<i className='fas fa-magic icon' />
{' '}
Studio
Studio
{' '}
<span className='beta'>BETA</span>
</h1>
<div className='gif'>
Expand Down Expand Up @@ -119,9 +122,13 @@ Studio

@observer
export class StudioSaveModal extends Component {
@observable name = ''
state = {
name: '',
}

render () {
const { name } = this.state

return (
<Dialog
className='studio-modal studio-save-modal'
Expand All @@ -133,16 +140,16 @@ export class StudioSaveModal extends Component {
<h1 className='title'>
<i className='fas fa-magic icon' />
{' '}
Save New Test
Save New Test
</h1>
<div className='content'>
<form onSubmit={this._save}>
<div className='text'>
<label className='text-strong' htmlFor='testName'>Test Name</label>
<input id='testName' type='text' value={this.name} required={true} onChange={this._onInputChange} />
<input id='testName' type='text' value={name} required={true} onChange={this._onInputChange} />
</div>
<div className='center'>
<button className='btn-main' type='submit' disabled={!this.name}>
<button className='btn-main' type='submit' disabled={!name}>
Save Test
</button>
</div>
Expand All @@ -159,25 +166,24 @@ Save New Test
)
}

@action
_onInputChange = (e) => {
this.name = e.target.value
this.setState({ name: e.target.value })
}

_save = (e) => {
e.preventDefault()

if (!this.name) return
const { name } = this.state

if (!name) return

studioRecorder.save(this.name)
studioRecorder.save(name)
}
}

const StudioModals = () => (
export const StudioModals = () => (
<>
<StudioInitModal />
<StudioSaveModal />
</>
)

export { StudioModals }
2 changes: 2 additions & 0 deletions packages/runner-shared/src/studio/studio-modals.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../variables';

.studio-modal {
max-width: 35em;

Expand Down
15 changes: 15 additions & 0 deletions packages/runner/cypress/integration/studio.ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ const { createCypress } = helpers
const { runIsolatedCypress } = createCypress({ config: { experimentalStudio: true } })

describe('studio ui', () => {
it('displays modal when launching studio for the first time', () => {
runIsolatedCypress('cypress/fixtures/studio/basic_spec.js', {
state: {
showedStudioModal: false,
},
})
.then(() => {
cy.get('.reporter').find('.test').first().find('.runnable-controls-studio').click()

cy.get('.studio-init-modal').should('be.visible')

cy.percySnapshot()
})
})

it('launches studio ui when extending test', () => {
runIsolatedCypress('cypress/fixtures/studio/basic_spec.js', {
state: {
Expand Down
3 changes: 3 additions & 0 deletions packages/runner/cypress/support/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ function createCypress (defaultOptions = {}) {
.withArgs('automation:request')
.yieldsAsync({ response: {} })

.withArgs('studio:init')
.yieldsAsync(_.defaultTo(opts.state.showedStudioModal, true))

const c = _.extend({}, Cypress.config(), {
isTextTerminal: false,
spec: {
Expand Down