Skip to content

Commit 7eb96d0

Browse files
authored
Merge pull request jupyter-lsp#692 from jupyter-lsp/try-to-reduce-flake
Reduce flakiness of acceptance tests
2 parents 9362847 + 40e043c commit 7eb96d0

File tree

10 files changed

+57
-18
lines changed

10 files changed

+57
-18
lines changed

.github/workflows/job.test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ jobs:
259259
- name: Set up Python and mamba
260260
uses: conda-incubator/setup-miniconda@v2
261261
with:
262+
python-version: ${{ matrix.python }}
262263
environment-file: requirements/github-actions.yml
263264
miniforge-variant: Mambaforge
264265
use-mamba: true

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
- fix tab completions not showing up in strings due to incomplete trigger kind invalidation ([#686])
1818
- fix path completions reconciliation for `pyls`/`pylsp` with `IPython` ([#686])
1919
- improve escaping rule for IPython magics overrides ([#688])
20+
- fix documentation panel not showing up when typing fast ([#692])
2021

2122
[#671]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/671
2223
[#675]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/675
2324
[#686]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/686
2425
[#688]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/688
2526
[#689]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/689
27+
[#692]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/692
2628

2729
### `@krassowski/jupyterlab-lsp 3.8.1` (2021-08-02)
2830

atest/01_Editor.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Editor Shows Features for Server
7979
Configure JupyterLab Plugin
8080
... {"language_servers": {"${server}": {"priority": 10000}}}
8181
Editor Shows Features for Language ${Language} ${file} &{features}
82+
# reset to empty settings
83+
Configure JupyterLab Plugin
84+
... {}
8285

8386
Editor Shows Features for Language
8487
[Arguments] ${Language} ${file} &{features}
@@ -97,7 +100,7 @@ Editor Shows Features for Language
97100
Editor Should Show Diagnostics
98101
[Arguments] ${diagnostic}
99102
Set Tags feature:diagnostics
100-
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=20s
103+
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=25s
101104
Capture Page Screenshot 01-diagnostics.png
102105
Open Diagnostics Panel
103106
Capture Page Screenshot 02-diagnostics.png

atest/05_Features/Completion.robot

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,23 @@ Can Prioritize LSP Completions
4848
Should Be True ${kernel_position} > ${lsp_position}
4949

5050
Invalidates On Cell Change
51+
# this test seems to crash Jedi (highlights crash on
52+
# `usages = document.jedi_script().get_references(**code_position)`
5153
Enter Cell Editor 1 line=2
5254
Press Keys None TAB
5355
Enter Cell Editor 2
54-
# just to increase chances of caching this on CI (which is slow)
55-
Sleep 5s
56+
# just to increase chances of catching this on CI (which is slow)
57+
Sleep 4s
5658
Completer Should Not Suggest test
5759

5860
Invalidates On Focus Loss
5961
Enter Cell Editor 1 line=2
6062
Press Keys None TAB
61-
Enter Cell Editor 2
62-
# just to increase chances of caching this on CI (which is slow)
63-
Sleep 5s
63+
Click JupyterLab Menu File
64+
# just to increase chances of catching this on CI (which is slow)
65+
Sleep 4s
6466
Completer Should Not Suggest test
67+
Enter Cell Editor 1 line=2
6568

6669
Uses LSP Completions When Kernel Resoponse Times Out
6770
Configure JupyterLab Plugin {"kernelResponseTimeout": 1, "waitForBusyKernel": true} plugin id=${COMPLETION PLUGIN ID}
@@ -120,16 +123,18 @@ Completes In Strings Or Python Dictionaries
120123
Wait Until Keyword Succeeds 40x 0.5s File Editor Line Should Equal 15 test_dict['key_a']
121124
[Teardown] Clean Up After Working With File completion.py
122125

123-
Continious Hinting Works
126+
Continuous Hinting Works
127+
[Setup] Prepare File for Editing Python completion completion.py
124128
Configure JupyterLab Plugin {"continuousHinting": true} plugin id=${COMPLETION PLUGIN ID}
125-
Prepare File for Editing Python completion completion.py
126129
Place Cursor In File Editor At 9 2
127-
Capture Page Screenshot 01-editor-ready.png
130+
Wait For Ready State
128131
Press Keys None d
132+
Wait For Ready State
129133
Completer Should Suggest addition
130134
# gh430 - auto invoke after dot should work too
131135
Press Keys None .
132136
Completer Should Suggest __doc__
137+
[Teardown] Clean Up After Working With File completion.py
133138

134139
Autocompletes If Only One Option
135140
Enter Cell Editor 3 line=1
@@ -174,7 +179,9 @@ Mid Token Completions Do Not Overwrite
174179
# `disp<tab>lay` → `display_table<cursor>`
175180
Place Cursor In Cell Editor At 11 line=1 character=4
176181
Trigger Completer
182+
Wait For Ready State
177183
Completer Should Suggest display_table
184+
Wait For Ready State
178185
Select Completer Suggestion display_table
179186
Wait Until Keyword Succeeds 40x 0.5s Cell Editor Should Equal 11 display_table
180187

@@ -369,14 +376,14 @@ Activate Completer Suggestion
369376
Select Completer Suggestion
370377
[Arguments] ${text}
371378
${suggestion} = Set Variable css:.jp-Completer-item[data-value="${text}"]
372-
Wait Until Element Is Visible ${suggestion} timeout=10s
379+
Wait Until Element Is Visible ${suggestion} timeout=15s
380+
Scroll Element Into View ${suggestion}
373381
Mouse Over ${suggestion}
374382
Click Element ${suggestion} code
375383

376384
Completer Should Suggest
377385
[Arguments] ${text} ${timeout}=10s
378386
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"] timeout=${timeout}
379-
Capture Page Screenshot ${text.replace(' ', '_')}.png
380387

381388
Get Completion Item Vertical Position
382389
[Arguments] ${text}
@@ -393,6 +400,7 @@ Completer Should Not Suggest
393400

394401
Trigger Completer
395402
[Arguments] ${timeout}=35s
403+
Wait For Ready State
396404
Press Keys None TAB
397405
Wait Until Page Contains Element ${COMPLETER_BOX} timeout=${timeout}
398406

atest/05_Features/Signature.robot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Triggers Signature Help After A Keystroke
2020
Element Should Contain ${SIGNATURE_HIGHLIGHTED_ARG} x
2121
# should remain visible after typing an argument
2222
Press Keys None x=2,
23-
Element Should Contain ${SIGNATURE_BOX} Important docstring of abc()
23+
Wait For Ready State
24+
Wait Until Keyword Succeeds 10x 0.5s Element Should Contain ${SIGNATURE_BOX} Important docstring of abc()
2425
# and should switch highlight to y
2526
Wait Until Keyword Succeeds 20x 0.5s Element Should Contain ${SIGNATURE_HIGHLIGHTED_ARG} y
2627
Press Keys None LEFT

atest/06_Style.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Screenshot Editor Themes with Lab Theme
3535
FOR ${editor theme} IN @{THEME NAMES}
3636
Capture Theme Screenshot ${editor theme}
3737
END
38+
# Reset theme
39+
Lab Command Use Theme: JupyterLab Light
3840
[Teardown] Clean Up After Working With File ${file}
3941

4042
Capture Theme Screenshot

atest/Keywords.robot

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Click JupyterLab Menu
184184
[Arguments] ${label}
185185
[Documentation] Click a top-level JupyterLab menu bar item with by ``label``,
186186
... e.g. File, Help, etc.
187-
${xpath} = Set Variable ${JLAB XP TOP}${JLAB XP MENU LABEL}\[text() = '${label}']
187+
${xpath} = Set Variable xpath:${JLAB XP TOP}${JLAB XP MENU LABEL}\[text() = '${label}']
188188
Wait Until Page Contains Element ${xpath}
189189
Mouse Over ${xpath}
190190
Click Element ${xpath}
@@ -245,6 +245,7 @@ Open Folder
245245
FOR ${path} IN @{paths}
246246
${sel} = Set Variable css:li.jp-DirListing-item\[title^='Name: ${path}']
247247
Wait Until Page Contains Element ${sel}
248+
Wait Until Element Is Visible ${sel} timeout=5s
248249
Double Click Element ${sel}
249250
END
250251

@@ -322,9 +323,14 @@ Place Cursor In File Editor At
322323
Wait Until Fully Initialized
323324
Wait Until Element Contains ${STATUSBAR} Fully initialized timeout=60s
324325

326+
Wait For Ready State
327+
Wait For Condition return document.readyState=="complete"
328+
325329
Open Context Menu Over
326330
[Arguments] ${sel}
331+
Wait For Ready State
327332
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
333+
Wait For Ready State
328334
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}
329335

330336
Context Menu Should Contain
@@ -390,6 +396,7 @@ Jump To Definition
390396
Open Context Menu Over ${sel}
391397
${cursor} = Measure Cursor Position
392398
Capture Page Screenshot 02-jump-to-definition-0.png
399+
Wait Until Element Is Visible ${MENU JUMP} timeout=5s
393400
Mouse Over ${MENU JUMP}
394401
Capture Page Screenshot 02-jump-to-definition-1.png
395402
Click Element ${MENU JUMP}

atest/Variables.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ${HEADLESS} 1
1919
${CMD PALETTE INPUT} css:#command-palette .lm-CommandPalette-input
2020
${CMD PALETTE ITEM ACTIVE} css:#command-palette .lm-CommandPalette-item.lm-mod-active
2121
${JLAB XP TOP} //div[@id='jp-top-panel']
22-
${JLAB XP MENU ITEM LABEL} //div[@class='lm-Menu-itemLabel']
23-
${JLAB XP MENU LABEL} //div[@class='lm-MenuBar-itemLabel']
22+
${JLAB XP MENU ITEM LABEL} //div[contains(@class, 'lm-Menu-itemLabel')]
23+
${JLAB XP MENU LABEL} //div[contains(@class, 'lm-MenuBar-itemLabel')]
2424
${JLAB XP DOCK TAB} xpath://div[contains(@class, 'lm-DockPanel-tabBar')]//li[contains(@class, 'lm-TabBar-tab')]
2525
${JLAB CSS VERSION} css:.jp-About-version
2626
${JLAB CSS REFRESH FILES} css:button[title="Refresh File List"]

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
8686
protected current_completion_handler: CompletionHandler;
8787
protected current_adapter: WidgetAdapter<IDocumentWidget> = null;
8888
protected renderer: LSPCompletionRenderer;
89+
private _latestActiveItem: LazyCompletionItem = null;
8990

9091
constructor(
9192
private app: JupyterFrontEnd,
@@ -134,15 +135,22 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
134135
item
135136
.resolve()
136137
.then(resolvedCompletionItem => {
138+
if (item.self !== this._latestActiveItem.self) {
139+
return;
140+
}
137141
this.set_doc_panel_placeholder(false);
138142
if (resolvedCompletionItem === null) {
139143
return;
140144
}
141145
this.refresh_doc_panel(item);
142146
})
143147
.catch(e => {
144-
this.set_doc_panel_placeholder(false);
145-
console.warn(e);
148+
// disabling placeholder can remove currently displayed documentation,
149+
// so only do that if this is really the active item!
150+
if (item.self === this._latestActiveItem.self) {
151+
this.set_doc_panel_placeholder(false);
152+
}
153+
this.console.warn(e);
146154
});
147155
}
148156

@@ -151,6 +159,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
151159
active_completion: ICompletionData
152160
) {
153161
let { item } = active_completion;
162+
this._latestActiveItem = item;
154163
if (!item.supportsResolution()) {
155164
if (item.isDocumentationMarkdown) {
156165
// TODO: remove once https://github.com/jupyterlab/jupyterlab/pull/9663 is merged and released
@@ -164,6 +173,10 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
164173
this.fetchDocumentation(item);
165174
} else if (item.isResolved()) {
166175
this.refresh_doc_panel(item);
176+
} else {
177+
// resolution has already started, but the re-render update could have been invalidated
178+
// by user action, so let's ensure the documentation will get shown this time.
179+
this.fetchDocumentation(item);
167180
}
168181

169182
// also fetch completion for the previous and the next item to prevent jitter
@@ -318,7 +331,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
318331
private get current_index() {
319332
let completer = this.current_completion_handler.completer;
320333

321-
// TODO upstream: add getActiveItem() to Completer
334+
// TODO: use public activeIndex available since 3.1
322335
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
323336
// @ts-ignore
324337
return completer._activeIndex;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ export class LSPCompletionRenderer
142142
}
143143

144144
createDocumentationNode(item: LazyCompletionItem): HTMLElement {
145+
// note: not worth trying to `fetchDocumentation()` as this is not
146+
// invoked if documentation is empty (as of jlab 3.2)
145147
if (item.isDocumentationMarkdown) {
146148
let documentation = item.documentation;
147149
this.options.markdownRenderer

0 commit comments

Comments
 (0)