From e55895a15b567bdc4c27e4bab869ee5b26576931 Mon Sep 17 00:00:00 2001 From: Mengting Yan Date: Wed, 3 Feb 2021 12:22:22 -0500 Subject: [PATCH] fix(plugins/plugin-client-common): when there're 3 splits, clicking table cells in the first split fail Fixes #6937 --- .../Views/Terminal/ScrollableTerminal.tsx | 2 +- .../src/test/core-support2/split-terminals.ts | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/plugins/plugin-client-common/src/components/Views/Terminal/ScrollableTerminal.tsx b/plugins/plugin-client-common/src/components/Views/Terminal/ScrollableTerminal.tsx index 06df3df5d28..604caae9b92 100644 --- a/plugins/plugin-client-common/src/components/Views/Terminal/ScrollableTerminal.tsx +++ b/plugins/plugin-client-common/src/components/Views/Terminal/ScrollableTerminal.tsx @@ -914,7 +914,7 @@ export default class ScrollableTerminal extends React.PureComponent(request.spec.options.ifnot).catch(() => true)) if (!respIf || !respIfNot) { const { cmdline } = request.spec.options - const mainSplit = this.findMainSplit(thisSplitIdx) + const mainSplit = this.findMainSplit(thisSplitIdx) || thisSplit request.spec.options.cmdline = undefined // null this out, since we got it! mainSplit.facade.REPL.pexec(cmdline) return diff --git a/plugins/plugin-core-support/src/test/core-support2/split-terminals.ts b/plugins/plugin-core-support/src/test/core-support2/split-terminals.ts index f73ec4c00b8..f0625c024f1 100644 --- a/plugins/plugin-core-support/src/test/core-support2/split-terminals.ts +++ b/plugins/plugin-core-support/src/test/core-support2/split-terminals.ts @@ -325,3 +325,65 @@ describe('split close and reopen', function(this: Common.ISuite) { } }) }) + +describe('click and show in splits', function(this: Common.ISuite) { + before(Common.before(this)) + after(Common.after(this)) + Util.closeAllExceptFirstTab.bind(this)() + + const splitTheTerminalViaButton = splitViaButton.bind(this) + const count = expectSplits.bind(this) + + let selector: string + + const doClickAndValidate = (splitIndex: number) => { + return this.app.client.waitUntil(async () => { + await this.app.client.$(selector).then(_ => _.click()) + + const text = await this.app.client.$(`${Selectors.OUTPUT_LAST_FOR_SPLIT(splitIndex)}`).then(_ => _.getText()) + + return text === 'hi' + }) + } + + const clickAndValidate = splitIndex => { + it(`should click in the first split and show in split: ${splitIndex}`, async () => { + try { + await doClickAndValidate(splitIndex) + } catch (err) { + await Common.oops(this, true)(err) + } + }) + } + + it('should click in the first split and show in the second split', async () => { + try { + await CLI.command('echo hi', this.app).then(ReplExpect.okWithPtyOutput('hi')) + + selector = `${await Util.doList(this, 'history 1', 'echo hi')} [data-value="echo hi"].clickable` + await doClickAndValidate(2) + } catch (err) { + await Common.oops(this, true)(err) + } + }) + + splitTheTerminalViaButton(3) + count(3) + clickAndValidate(3) + + splitTheTerminalViaButton(4) + count(4) + clickAndValidate(4) + + splitTheTerminalViaButton(5) + count(5) + clickAndValidate(5) + + splitTheTerminalViaButton(6) + count(6) + clickAndValidate(6) + + splitTheTerminalViaButton(7) + count(7) + clickAndValidate(7) +})