import cs from 'classnames'
import _ from 'lodash'
import { observer } from 'mobx-react'
import React, { Component } from 'react'
import Agents from '../agents/agents'
import Collapsible from '../collapsible/collapsible'
import Hooks from '../hooks/hooks'
import Routes from '../routes/routes'
import TestError from '../errors/test-error'
import TestModel from '../test/test-model'
import AttemptModel from './attempt-model'
import Sessions from '../sessions/sessions'
const NoCommands = () => (
-
No commands were issued in this test.
)
const AttemptHeader = ({ index }: {index: number}) => (
Attempt {index + 1}
)
const StudioError = () => (
Studio cannot add commands to a failing test.
)
function renderAttemptContent (model: AttemptModel) {
// performance optimization - don't render contents if not open
return (
)
}
interface AttemptProps {
model: AttemptModel
scrollIntoView: Function
}
@observer
class Attempt extends Component {
componentDidUpdate () {
this.props.scrollIntoView()
}
render () {
const { model } = this.props
// HACK: causes component update when command log is added
model.commands.length
return (
}
headerClass='attempt-name'
isOpen={model.isOpen}
>
{renderAttemptContent(model)}
)
}
}
const Attempts = observer(({ test, scrollIntoView }: {test: TestModel, scrollIntoView: Function}) => {
return (
{_.map(test.attempts, (attempt) => {
return (
)
})}
)
})
export { Attempt, AttemptHeader, NoCommands }
export default Attempts