Skip to content

Commit

Permalink
Merge pull request #692 from jupyter-lsp/try-to-reduce-flake
Browse files Browse the repository at this point in the history
Reduce flakiness of acceptance tests
  • Loading branch information
krassowski authored Oct 17, 2021
2 parents 9362847 + 40e043c commit 7eb96d0
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/job.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ jobs:
- name: Set up Python and mamba
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
environment-file: requirements/github-actions.yml
miniforge-variant: Mambaforge
use-mamba: true
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
- fix tab completions not showing up in strings due to incomplete trigger kind invalidation ([#686])
- fix path completions reconciliation for `pyls`/`pylsp` with `IPython` ([#686])
- improve escaping rule for IPython magics overrides ([#688])
- fix documentation panel not showing up when typing fast ([#692])

[#671]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/671
[#675]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/675
[#686]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/686
[#688]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/688
[#689]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/689
[#692]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/692

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

Expand Down
5 changes: 4 additions & 1 deletion atest/01_Editor.robot
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Editor Shows Features for Server
Configure JupyterLab Plugin
... {"language_servers": {"${server}": {"priority": 10000}}}
Editor Shows Features for Language ${Language} ${file} &{features}
# reset to empty settings
Configure JupyterLab Plugin
... {}

Editor Shows Features for Language
[Arguments] ${Language} ${file} &{features}
Expand All @@ -97,7 +100,7 @@ Editor Shows Features for Language
Editor Should Show Diagnostics
[Arguments] ${diagnostic}
Set Tags feature:diagnostics
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=20s
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=25s
Capture Page Screenshot 01-diagnostics.png
Open Diagnostics Panel
Capture Page Screenshot 02-diagnostics.png
Expand Down
28 changes: 18 additions & 10 deletions atest/05_Features/Completion.robot
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,23 @@ Can Prioritize LSP Completions
Should Be True ${kernel_position} > ${lsp_position}

Invalidates On Cell Change
# this test seems to crash Jedi (highlights crash on
# `usages = document.jedi_script().get_references(**code_position)`
Enter Cell Editor 1 line=2
Press Keys None TAB
Enter Cell Editor 2
# just to increase chances of caching this on CI (which is slow)
Sleep 5s
# just to increase chances of catching this on CI (which is slow)
Sleep 4s
Completer Should Not Suggest test

Invalidates On Focus Loss
Enter Cell Editor 1 line=2
Press Keys None TAB
Enter Cell Editor 2
# just to increase chances of caching this on CI (which is slow)
Sleep 5s
Click JupyterLab Menu File
# just to increase chances of catching this on CI (which is slow)
Sleep 4s
Completer Should Not Suggest test
Enter Cell Editor 1 line=2

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

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

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

Expand Down Expand Up @@ -369,14 +376,14 @@ Activate Completer Suggestion
Select Completer Suggestion
[Arguments] ${text}
${suggestion} = Set Variable css:.jp-Completer-item[data-value="${text}"]
Wait Until Element Is Visible ${suggestion} timeout=10s
Wait Until Element Is Visible ${suggestion} timeout=15s
Scroll Element Into View ${suggestion}
Mouse Over ${suggestion}
Click Element ${suggestion} code

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

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

Trigger Completer
[Arguments] ${timeout}=35s
Wait For Ready State
Press Keys None TAB
Wait Until Page Contains Element ${COMPLETER_BOX} timeout=${timeout}

Expand Down
3 changes: 2 additions & 1 deletion atest/05_Features/Signature.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Triggers Signature Help After A Keystroke
Element Should Contain ${SIGNATURE_HIGHLIGHTED_ARG} x
# should remain visible after typing an argument
Press Keys None x=2,
Element Should Contain ${SIGNATURE_BOX} Important docstring of abc()
Wait For Ready State
Wait Until Keyword Succeeds 10x 0.5s Element Should Contain ${SIGNATURE_BOX} Important docstring of abc()
# and should switch highlight to y
Wait Until Keyword Succeeds 20x 0.5s Element Should Contain ${SIGNATURE_HIGHLIGHTED_ARG} y
Press Keys None LEFT
Expand Down
2 changes: 2 additions & 0 deletions atest/06_Style.robot
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Screenshot Editor Themes with Lab Theme
FOR ${editor theme} IN @{THEME NAMES}
Capture Theme Screenshot ${editor theme}
END
# Reset theme
Lab Command Use Theme: JupyterLab Light
[Teardown] Clean Up After Working With File ${file}

Capture Theme Screenshot
Expand Down
9 changes: 8 additions & 1 deletion atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Click JupyterLab Menu
[Arguments] ${label}
[Documentation] Click a top-level JupyterLab menu bar item with by ``label``,
... e.g. File, Help, etc.
${xpath} = Set Variable ${JLAB XP TOP}${JLAB XP MENU LABEL}\[text() = '${label}']
${xpath} = Set Variable xpath:${JLAB XP TOP}${JLAB XP MENU LABEL}\[text() = '${label}']
Wait Until Page Contains Element ${xpath}
Mouse Over ${xpath}
Click Element ${xpath}
Expand Down Expand Up @@ -245,6 +245,7 @@ Open Folder
FOR ${path} IN @{paths}
${sel} = Set Variable css:li.jp-DirListing-item\[title^='Name: ${path}']
Wait Until Page Contains Element ${sel}
Wait Until Element Is Visible ${sel} timeout=5s
Double Click Element ${sel}
END

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

Wait For Ready State
Wait For Condition return document.readyState=="complete"

Open Context Menu Over
[Arguments] ${sel}
Wait For Ready State
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
Wait For Ready State
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}

Context Menu Should Contain
Expand Down Expand Up @@ -390,6 +396,7 @@ Jump To Definition
Open Context Menu Over ${sel}
${cursor} = Measure Cursor Position
Capture Page Screenshot 02-jump-to-definition-0.png
Wait Until Element Is Visible ${MENU JUMP} timeout=5s
Mouse Over ${MENU JUMP}
Capture Page Screenshot 02-jump-to-definition-1.png
Click Element ${MENU JUMP}
Expand Down
4 changes: 2 additions & 2 deletions atest/Variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ${HEADLESS} 1
${CMD PALETTE INPUT} css:#command-palette .lm-CommandPalette-input
${CMD PALETTE ITEM ACTIVE} css:#command-palette .lm-CommandPalette-item.lm-mod-active
${JLAB XP TOP} //div[@id='jp-top-panel']
${JLAB XP MENU ITEM LABEL} //div[@class='lm-Menu-itemLabel']
${JLAB XP MENU LABEL} //div[@class='lm-MenuBar-itemLabel']
${JLAB XP MENU ITEM LABEL} //div[contains(@class, 'lm-Menu-itemLabel')]
${JLAB XP MENU LABEL} //div[contains(@class, 'lm-MenuBar-itemLabel')]
${JLAB XP DOCK TAB} xpath://div[contains(@class, 'lm-DockPanel-tabBar')]//li[contains(@class, 'lm-TabBar-tab')]
${JLAB CSS VERSION} css:.jp-About-version
${JLAB CSS REFRESH FILES} css:button[title="Refresh File List"]
Expand Down
19 changes: 16 additions & 3 deletions packages/jupyterlab-lsp/src/features/completion/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
protected current_completion_handler: CompletionHandler;
protected current_adapter: WidgetAdapter<IDocumentWidget> = null;
protected renderer: LSPCompletionRenderer;
private _latestActiveItem: LazyCompletionItem = null;

constructor(
private app: JupyterFrontEnd,
Expand Down Expand Up @@ -134,15 +135,22 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
item
.resolve()
.then(resolvedCompletionItem => {
if (item.self !== this._latestActiveItem.self) {
return;
}
this.set_doc_panel_placeholder(false);
if (resolvedCompletionItem === null) {
return;
}
this.refresh_doc_panel(item);
})
.catch(e => {
this.set_doc_panel_placeholder(false);
console.warn(e);
// disabling placeholder can remove currently displayed documentation,
// so only do that if this is really the active item!
if (item.self === this._latestActiveItem.self) {
this.set_doc_panel_placeholder(false);
}
this.console.warn(e);
});
}

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

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

// TODO upstream: add getActiveItem() to Completer
// TODO: use public activeIndex available since 3.1
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return completer._activeIndex;
Expand Down
2 changes: 2 additions & 0 deletions packages/jupyterlab-lsp/src/features/completion/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ export class LSPCompletionRenderer
}

createDocumentationNode(item: LazyCompletionItem): HTMLElement {
// note: not worth trying to `fetchDocumentation()` as this is not
// invoked if documentation is empty (as of jlab 3.2)
if (item.isDocumentationMarkdown) {
let documentation = item.documentation;
this.options.markdownRenderer
Expand Down

0 comments on commit 7eb96d0

Please sign in to comment.