Skip to content

Commit 6c536c7

Browse files
authored
Fix more flaky completion tests (#863)
1 parent 4da6697 commit 6c536c7

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

atest/05_Features/Completion.robot

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,15 @@ User Can Select Lowercase After Starting Uppercase
193193
Mid Token Completions Do Not Overwrite
194194
# `disp<tab>data` → `display_table<cursor>data`
195195
Place Cursor In Cell Editor At 9 line=1 character=4
196-
Capture Page Screenshot 01-cursor-placed.png
196+
Wait For Our Completer To Replace Native In Cell 9
197197
Trigger Completer
198198
Completer Should Suggest display_table
199199
Select Completer Suggestion display_table
200200
Capture Page Screenshot 02-completed.png
201201
Wait Until Keyword Succeeds 40x 0.5s Cell Editor Should Equal 9 display_tabledata
202202
# `disp<tab>lay` → `display_table<cursor>`
203203
Place Cursor In Cell Editor At 11 line=1 character=4
204+
Wait For Our Completer To Replace Native In Cell 11
204205
Trigger Completer
205206
Wait For Ready State
206207
Completer Should Suggest display_table
@@ -295,11 +296,7 @@ Completes Correctly With R Double And Triple Colon
295296
[Setup] Prepare File for Editing R completion completion.R
296297
Place Cursor In File Editor At 2 7
297298
Wait Until Fully Initialized
298-
# normally the completion adapter taking time to initialise is not a problem
299-
# but because the token-based completion fallback would break our test example
300-
# if it kicked off we try to avoid it by adding some delay
301-
# TODO remove sleep after migrating to JupyterLab 4.0 native adapters.
302-
Sleep 2s Workaround completion adapter taking some time to initialize
299+
Wait For Our Completer To Replace Native In File Editor
303300
Trigger Completer
304301
Completer Should Suggest .print.via.format
305302
Select Completer Suggestion .print.via.format
@@ -324,8 +321,7 @@ Shows Documentation With CompletionItem Resolve
324321
[Setup] Prepare File for Editing R completion completion.R
325322
Place Cursor In File Editor At 8 7
326323
Wait Until Fully Initialized
327-
# TODO remove sleep after migrating to JupyterLab 4.0 native adapters.
328-
Sleep 2s Workaround completion adapter taking some time to initialize
324+
Wait For Our Completer To Replace Native In File Editor
329325
Trigger Completer
330326
Completer Should Suggest print.data.frame
331327
# if data.frame is not active, activate it (it should be in top 10 on any platform)
@@ -352,6 +348,7 @@ Completes In R Magics
352348
# - R lanugage server is very sensitive to off-by-one errors (see https://github.com/REditorSupport/languageserver/issues/395)
353349
# '%%R\n librar<tab>'
354350
Enter Cell Editor 22 line=2
351+
Wait For Our Completer To Replace Native In Cell 22
355352
Trigger Completer
356353
Completer Should Suggest library
357354
# '%R lib<tab>'
@@ -361,6 +358,7 @@ Completes In R Magics
361358

362359
Completes Paths In Strings
363360
Enter Cell Editor 26
361+
Wait For Our Completer To Replace Native In Cell 26
364362
Press Keys None LEFT
365363
Trigger Completer
366364
Press Keys None ENTER
@@ -467,3 +465,15 @@ Should Complete While Kernel Is Busy
467465
Completer Should Suggest test
468466
# Confirm that the kernel indicator was busy all along
469467
Page Should Contain Element ${KERNEL_BUSY_INDICATOR}
468+
469+
Wait For Our Completer To Replace Native In File Editor
470+
# Normally the completion adapter taking time to initialise is not a problem
471+
# but because the token-based completion fallback would break some test example
472+
# if it kicked in (by instant-completing some token) so we try to avoid it
473+
# TODO remove after migrating to JupyterLab 4.0 native adapters.
474+
Wait Until Page Contains Element css:.jp-FileEditor .lsp-completer-enabled
475+
476+
Wait For Our Completer To Replace Native In Cell
477+
[Arguments] ${cell_nr}
478+
# TODO remove after migrating to JupyterLab 4.0 native adapters.
479+
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_nr}) .lsp-completer-enabled

atest/05_Features/Signature.robot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ Triggers Signature Help After A Keystroke
4141
Press Keys None )
4242
Wait Until Keyword Succeeds 20x 0.5s Page Should Not Contain Element ${SIGNATURE_BOX}
4343

44-
4544
Triggered Signature Is Visible In First Cell
4645
# test boundary conditions for out of view behaviour
4746
Enter Cell Editor 1
4847
Press Keys None (
4948
Wait Until Keyword Succeeds 20x 0.5s Page Should Contain Element ${SIGNATURE_BOX}
5049
Element Should Be Visible ${SIGNATURE_BOX}
5150

52-
5351
Should Close After Moving Cursor Prior To Start
5452
Enter Cell Editor 2 line=6
5553
Press Keys None (

atest/Variables.resource

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ${CMD PALETTE ITEM ACTIVE} css:#command-palette .lm-CommandPalette-item.lm-
2222
${JLAB XP TOP} //div[@id='jp-top-panel']
2323
${JLAB XP MENU ITEM LABEL} //div[contains(@class, 'lm-Menu-itemLabel')]
2424
${JLAB XP MENU LABEL} //div[contains(@class, 'lm-MenuBar-itemLabel')]
25-
${JLAB XP DOCK TAB} xpath://div[contains(@class, 'lm-DockPanel-tabBar')]//li[contains(@class, 'lm-TabBar-tab')]
25+
${JLAB XP DOCK TAB}
26+
... xpath://div[contains(@class, 'lm-DockPanel-tabBar')]//li[contains(@class, 'lm-TabBar-tab')]
2627
${JLAB CSS VERSION} css:.jp-About-version
2728
${JLAB CSS REFRESH F_OLD} css:button[title="Refresh File List"]
2829
${JLAB CSS REFRESH FILES} css:button[data-command="filebrowser:refresh"]
@@ -31,28 +32,34 @@ ${MENU OPEN WITH} xpath://div[contains(@class, 'lm-Menu-itemLabel'
3132
# R is missing on purpose (may need to use .)
3233
${MENU RENAME} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(., "ename")]
3334
# N is missing on purpose (N is in separate <span>)
34-
${MENU NOTEBOOK} xpath://li[@data-command='filebrowser:open']/div[contains(@class, 'lm-Menu-itemLabel')][contains(., "otebook")]
35+
${MENU NOTEBOOK}
36+
... xpath://li[@data-command='filebrowser:open']/div[contains(@class, 'lm-Menu-itemLabel')][contains(., "otebook")]
3537
${DIAGNOSTICS PANEL} id:lsp-diagnostics-panel
36-
${DIAGNOSTIC PANEL CLOSE} css:.lm-DockPanel-tabBar .lm-TabBar-tab[data-id="lsp-diagnostics-panel"] .lm-TabBar-tabCloseIcon
38+
${DIAGNOSTIC PANEL CLOSE}
39+
... css:.lm-DockPanel-tabBar .lm-TabBar-tab[data-id="lsp-diagnostics-panel"] .lm-TabBar-tabCloseIcon
3740
${DIALOG WINDOW} css:.jp-Dialog
3841
${DIALOG INPUT} css:.jp-Input-Dialog input
3942
${DIALOG ACCEPT} css:button.jp-Dialog-button.jp-mod-accept
4043
${STATUSBAR} css:div.lsp-statusbar-item
4144
${MENU EDITOR} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(., "Editor")]
42-
${MENU JUMP} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "Jump to definition")]
45+
${MENU JUMP}
46+
... xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "Jump to definition")]
4347
${MENU SETTINGS} xpath://div[contains(@class, 'lm-MenuBar-itemLabel')][contains(text(), "Settings")]
44-
${MENU EDITOR THEME} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "Text Editor Theme")]
48+
${MENU EDITOR THEME}
49+
... xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "Text Editor Theme")]
4550
${LAB MENU} css:.lm-Menu
4651
${CM CURSOR} css:.CodeMirror-cursor
47-
${CM CURSORS} css:.jp-MainAreaWidget:not(.lm-mod-hidden) .CodeMirror-cursors:not([style='visibility: hidden'])
52+
${CM CURSORS}
53+
... css:.jp-MainAreaWidget:not(.lm-mod-hidden) .CodeMirror-cursors:not([style='visibility: hidden'])
4854
# settings
4955
${LSP PLUGIN ID} @krassowski/jupyterlab-lsp:plugin
5056
${COMPLETION PLUGIN ID} @krassowski/jupyterlab-lsp:completion
5157
${HIGHLIGHTS PLUGIN ID} @krassowski/jupyterlab-lsp:highlights
5258
${JUMP PLUGIN ID} @krassowski/jupyterlab-lsp:jump_to
5359
${DIAGNOSTICS PLUGIN ID} @krassowski/jupyterlab-lsp:diagnostics
5460
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
55-
${JLAB XP CLOSE SETTINGS} ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')]
61+
${JLAB XP CLOSE SETTINGS}
62+
... ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')]
5663
# diagnostics
5764
${CSS DIAGNOSTIC} css:.cm-lsp-diagnostic
5865
# log messages

docs/Installation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
],
363363
"metadata": {
364364
"kernelspec": {
365-
"display_name": "Python 3",
365+
"display_name": "Python 3 (ipykernel)",
366366
"language": "python",
367367
"name": "python3"
368368
},

packages/jupyterlab-lsp/src/features/completion/completion.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { ICompletionData, LSPCompletionRenderer } from './renderer';
3232
const DOC_PANEL_SELECTOR = '.jp-Completer-docpanel';
3333
const DOC_PANEL_PLACEHOLDER_CLASS = 'lsp-completer-placeholder';
3434
const LSP_COMPLETER_CLASS = 'lsp-completer';
35+
const LSP_COMPLETER_ENABLED_CLASS = 'lsp-completer-enabled';
3536

3637
export class CompletionCM extends CodeMirrorIntegration {
3738
private _completionCharacters: string[];
@@ -443,5 +444,10 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
443444
?.session,
444445
console: this.console
445446
});
447+
if (this._disabled) {
448+
editor.host.classList.remove(LSP_COMPLETER_ENABLED_CLASS);
449+
} else {
450+
editor.host.classList.add(LSP_COMPLETER_ENABLED_CLASS);
451+
}
446452
}
447453
}

0 commit comments

Comments
 (0)