Skip to content

Commit

Permalink
fix(plugins/plugin-client-common): blocks with Processing commands ca…
Browse files Browse the repository at this point in the history
…nnot be removed

Also improves the cursor discoverability in an unfocused pty block

Fixes #6954
  • Loading branch information
myan9 authored and starpit committed Feb 4, 2021
1 parent 50ca156 commit f750982
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugins/plugin-bash-like/web/scss/xterm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ body[kui-theme-style] .kui--tab-content {
}
.xterm-container .xterm-rows:not(.xterm-focus) .xterm-cursor.xterm-cursor-block {
background-color: var(--color-base03);
outline-color: transparent;
outline-color: var(--color-base04);
}

/* rules for terminated xterm */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Tab, i18n, isOfflineClient } from '@kui-shell/core'
import { InputOptions } from './Input'
import { SupportedIcon } from '../../../spi/Icons'
import TwoFaceIcon from '../../../spi/Icons/TwoFaceIcon'
import BlockModel, { hasUUID, isOutputOnly } from './BlockModel'
import BlockModel, { hasUUID, isOutputOnly, isRerunable } from './BlockModel'

const strings = i18n('plugin-client-common')

Expand Down Expand Up @@ -53,6 +53,7 @@ export default class Actions extends React.PureComponent<Props> {
if (
!isOfflineClient() &&
hasUUID(this.props.model) &&
isRerunable(this.props.model) &&
!isOutputOnly(this.props.model) &&
this.props.tab &&
this.props.command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export default class Input extends InputProvider {

/** DropDown menu for completed blocks */
private actions(command: string) {
if (isFinished(this.props.model) && !!this.props.tab && !!this.props.model) {
if ((isFinished(this.props.model) || isProcessing(this.props.model)) && !!this.props.tab && !!this.props.model) {
return <Actions command={command} idx={this.props.idx} {...this.props} />
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,54 @@

import { Common, CLI, ReplExpect, Selectors } from '@kui-shell/test'

async function removeAndValidate(ctx: Common.ISuite, N: number) {
await ctx.app.client.$(Selectors.PROMPT_N(N)).then(_ => _.moveTo())
await ctx.app.client.$(Selectors.BLOCK_REMOVE_BUTTON(N)).then(_ => {
_.waitForDisplayed()
_.moveTo()
_.click()
})

await ctx.app.client.waitUntil(async () => {
const text = await ctx.app.client.$(Selectors.OUTPUT_LAST).then(_ => _.getText())
return text === 'hi'
})
}

function doEchoThenRemove(this: Common.ISuite, idx: number) {
it(`should echo ${idx} then remove that block`, async () => {
try {
const res = await CLI.command(`echo ${idx}`, this.app)
await ReplExpect.okWithPtyOutput(idx.toString())(res)

const N = res.count
await this.app.client.$(Selectors.PROMPT_N(N)).then(_ => _.moveTo())
await this.app.client.$(Selectors.BLOCK_REMOVE_BUTTON(N)).then(_ => _.waitForDisplayed())
await this.app.client.$(Selectors.BLOCK_REMOVE_BUTTON(N)).then(_ => _.click())
await this.app.client.$(Selectors.OUTPUT_N(N)).then(_ => _.waitForExist({ timeout: 5000, reverse: true }))
await removeAndValidate(this, res.count)
} catch (err) {
await Common.oops(this, true)(err)
}
})
}

describe(`remove command output ${process.env.MOCHA_RUN_TARGET || ''}`, function(this: Common.ISuite) {
describe(`remove command block ${process.env.MOCHA_RUN_TARGET || ''}`, function(this: Common.ISuite) {
before(Common.before(this))
after(Common.after(this))

const echo = doEchoThenRemove.bind(this)

// here come the tests
it('should echo hi', () =>
CLI.command('echo hi', this.app)
.then(ReplExpect.okWithPtyOutput('hi'))
.catch(Common.oops(this)))

echo(1)
echo(2)

it(`should remove the block during sleep 30`, async () => {
try {
const res = await CLI.command('sleep 30', this.app)
await removeAndValidate(this, res.count)
} catch (err) {
await Common.oops(this, true)(err)
}
})
})

0 comments on commit f750982

Please sign in to comment.