Skip to content

Commit

Permalink
Merge pull request #144 from krassowski/tests/notebook
Browse files Browse the repository at this point in the history
Fix R foreign extractor, add bash alias, add tests
  • Loading branch information
krassowski authored Jan 9, 2020
2 parents b33a316 + d42d0de commit 5151a0b
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 52 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
- all commands are now accessible from the command palette (
[#142](https://github.com/krassowski/jupyterlab-lsp/pull/142)
)
- bash LSP now also covers `%%bash` magic cell in addition to `%%sh` (
[#144](https://github.com/krassowski/jupyterlab-lsp/pull/144)
)
- bugfixes
- diagnostics in foreign documents are now correctly updated (
[133fd3d](https://github.com/krassowski/jupyterlab-lsp/pull/129/commits/133fd3d71401c7e5affc0a8637ee157de65bef62)
Expand All @@ -31,6 +34,9 @@
- the workaround for relative root path is now also applied on Mac (
[#139](https://github.com/krassowski/jupyterlab-lsp/pull/139)
)
- fixed LSP of R in Python (`%%R` magic cell from rpy2) (
[#144](https://github.com/krassowski/jupyterlab-lsp/pull/144)
)

## `lsp-ws-connection 0.3.0`

Expand Down
62 changes: 15 additions & 47 deletions atest/01_Editor.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ Resource Keywords.robot

*** Variables ***
${MENU EDITOR} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(., "Editor")]
${MENU OPEN WITH} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(text(), "Open With")]
${MENU JUMP} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(text(), "Jump to definition")]
${MENU RENAME} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(text(), "Rename")]
${CM CURSOR} css:.CodeMirror-cursor
${CM CURSORS} css:.CodeMirror-cursors:not([style='visibility: hidden'])
${DIALOG WINDOW} css:.jp-Dialog
${DIALOG INPUT} css:.jp-Input-Dialog input
${DIAGNOSTICS PANEL} css:#lsp-diagnostics-panel
${DIAGNOSTIC PANEL CLOSE} css:.p-DockPanel-tabBar .p-TabBar-tab[data-id="lsp-diagnostics-panel"] .p-TabBar-tabCloseIcon

*** Test Cases ***
Bash
Expand Down Expand Up @@ -74,7 +68,7 @@ Editor Shows Features for Language
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}editor${/}${Language.lower()}
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
Lab Command Close All Tabs
Open ${file} in Editor
Open ${file} in ${MENU EDITOR}
Capture Page Screenshot 00-opened.png
FOR ${f} IN @{features}
Run Keyword If "${f}" == "Diagnostics" Editor Should Show Diagnostics ${features["${f}"]}
Expand All @@ -84,37 +78,16 @@ Editor Shows Features for Language
Capture Page Screenshot 99-done.png
[Teardown] Clean Up After Working With File ${file}

Clean Up After Working With File
[Arguments] ${file}
Remove File ${OUTPUT DIR}${/}home${/}${file}
Reset Application State

Open ${file} in Editor
Ensure File Browser is Open
Click Element css:button[title="Refresh File List"]
Open Context Menu css:.jp-DirListing-item[title="${file}"]
Mouse Over ${MENU OPEN WITH}
Wait Until Page Contains Element ${MENU EDITOR}
Mouse Over ${MENU EDITOR}
Click Element ${MENU EDITOR}

Ensure File Browser is Open
${sel} = Set Variable css:.p-TabBar-tab[data-id="filebrowser"]:not(.p-mod-current)
${els} = Get WebElements ${sel}
Run Keyword If ${els.__len__()} Click Element ${sel}

Editor Should Show Diagnostics
[Arguments] ${diagnostic}
Set Tags feature:diagnostics
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=20s
Capture Page Screenshot 01-diagnostics.png
Lab Command Show Diagnostics Panel
Wait Until Page Contains Element ${DIAGNOSTICS PANEL} timeout=20s
Open Diagnostics Panel
Capture Page Screenshot 02-diagnostics.png
${count} = Get Element Count css:.lsp-diagnostics-listing tr
SHOULD BE TRUE ${count} >= 1
Mouse Over ${DIAGNOSTIC PANEL CLOSE}
Click Element ${DIAGNOSTIC PANEL CLOSE}
${count} = Count Diagnostics In Panel
Should Be True ${count} >= 1
Close Diagnostics Panel

Editor Should Jump To Definition
[Arguments] ${symbol}
Expand All @@ -139,20 +112,19 @@ Measure Cursor Position
${position} = Wait Until Keyword Succeeds 20 x 0.05s Get Vertical Position ${CM CURSOR}
[Return] ${position}

Wait For Dialog
Wait Until Page Contains Element ${DIALOG WINDOW} timeout=180s

Open Context Menu Over
[Arguments] ${sel}
Mouse Over ${sel}
Sleep 10s
Mouse Over ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Click Element ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}

Get Editor Content
${content} Execute JavaScript return document.querySelector('.CodeMirror').CodeMirror.getValue()
[Return] ${content}

Editor Content Changed
[Arguments] ${old_content}
${new_content} Execute JavaScript return document.querySelector('.CodeMirror').CodeMirror.getValue()
${new_content} Get Editor Content
Should Not Be Equal ${old_content} ${new_content}
[Return] ${new_content}

Expand All @@ -161,18 +133,14 @@ Editor Should Rename
Set Tags feature:rename
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol} xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()]
Open Context Menu Over ${sel}
${old_content} Execute JavaScript return document.querySelector('.CodeMirror').CodeMirror.getValue()
${old_content} Get Editor Content
Capture Page Screenshot 03-rename-0.png
Mouse Over ${MENU RENAME}
Capture Page Screenshot 03-rename-1.png
Click Element ${MENU RENAME}
Wait For Dialog
Click Element ${DIALOG INPUT}
Capture Page Screenshot 03-rename-3.png
Input Text ${DIALOG INPUT} new_name
Capture Page Screenshot 03-rename-4.png
Click Element css:button.jp-Dialog-button.jp-mod-accept
Capture Page Screenshot 03-rename-2.png
Input Into Dialog new_name
Sleep 2s
Capture Page Screenshot 03-rename-5.png
Capture Page Screenshot 03-rename-3.png
${new_content} Wait Until Keyword Succeeds 10 x 0.1 s Editor Content Changed ${old_content}
Should Be True "new_name" in """${new_content}"""
23 changes: 23 additions & 0 deletions atest/03_Notebook.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots notebook
Resource Keywords.robot

*** Test Cases ***
Python
[Setup] Reset Application State
Setup Notebook Python Python.ipynb
Capture Page Screenshot 01-python.png
${diagnostic} = Set Variable W291 trailing whitespace (pycodestyle)
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title="${diagnostic}"] timeout=20s
Capture Page Screenshot 02-python.png
Clean Up After Working With File Python.ipynb

Foregin Extractors
[Setup] Reset Application State
Setup Notebook Python Foreign extractors.ipynb
@{diagnostics} = Create List Failed to parse expression undefined name 'valid' (pyflakes) Trailing whitespace is superfluous. (lintr)
FOR ${diagnostic} IN @{diagnostics}
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title="${diagnostic}"] timeout=30s
Capture Page Screenshot 0x-${diagnostic}.png
END
Clean Up After Working With File Foreign Extractors.ipynb
50 changes: 50 additions & 0 deletions atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,53 @@ Open With JupyterLab Menu
FOR ${submenu} IN @{submenus}
Click JupyterLab Menu Item ${submenu}
END

Ensure File Browser is Open
${sel} = Set Variable css:.p-TabBar-tab[data-id="filebrowser"]:not(.p-mod-current)
${els} = Get WebElements ${sel}
Run Keyword If ${els.__len__()} Click Element ${sel}

Input Into Dialog
[Arguments] ${text}
Wait For Dialog
Click Element ${DIALOG INPUT}
Input Text ${DIALOG INPUT} ${text}
Click Element ${DIALOG ACCEPT}

Open ${file} in ${editor}
Ensure File Browser is Open
Click Element css:button[title="Refresh File List"]
Open Context Menu css:.jp-DirListing-item[title="${file}"]
Mouse Over ${MENU OPEN WITH}
Wait Until Page Contains Element ${editor}
Mouse Over ${editor}
Click Element ${editor}

Clean Up After Working With File
[Arguments] ${file}
Remove File ${OUTPUT DIR}${/}home${/}${file}
Reset Application State

Setup Notebook
[Arguments] ${Language} ${file}
Set Tags language:${Language.lower()}
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}notebook${/}${file.lower()}
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
Lab Command Close All Tabs
Open ${file} in ${MENU NOTEBOOK}
Capture Page Screenshot 00-opened.png

Open Diagnostics Panel
Lab Command Show Diagnostics Panel
Wait Until Page Contains Element ${DIAGNOSTICS PANEL} timeout=20s

Count Diagnostics In Panel
${count} = Get Element Count css:.lsp-diagnostics-listing tbody tr
[Return] ${count}

Close Diagnostics Panel
Mouse Over ${DIAGNOSTIC PANEL CLOSE}
Click Element ${DIAGNOSTIC PANEL CLOSE}

Wait For Dialog
Wait Until Page Contains Element ${DIALOG WINDOW} timeout=180s
14 changes: 12 additions & 2 deletions atest/Variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ ${SPLASH} id:jupyterlab-splash
${BASE} /@est/
# override with `python scripts/atest.py --variable HEADLESS:0`
${HEADLESS} 1
${CMD PALETTE INPUT} css:.p-CommandPalette-input
${CMD PALETTE ITEM ACTIVE} css:.p-CommandPalette-item.p-mod-active
${CMD PALETTE INPUT} css:#command-palette .p-CommandPalette-input
${CMD PALETTE ITEM ACTIVE} css:#command-palette .p-CommandPalette-item.p-mod-active
${JLAB XP TOP} //div[@id='jp-top-panel']
${JLAB XP MENU ITEM LABEL} //div[@class='p-Menu-itemLabel']
${JLAB XP MENU LABEL} //div[@class='p-MenuBar-itemLabel']
${JLAB CSS VERSION} css:.jp-About-version
${CSS DIALOG OK} css:.jp-Dialog .jp-mod-accept
${MENU OPEN WITH} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(text(), "Open With")]
# R is missing on purpose (may need to use .)
${MENU RENAME} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(., "ename")]
# N is missing on purpose
${MENU NOTEBOOK} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(., "otebook")]
${DIAGNOSTICS PANEL} id:lsp-diagnostics-panel
${DIAGNOSTIC PANEL CLOSE} css:.p-DockPanel-tabBar .p-TabBar-tab[data-id="lsp-diagnostics-panel"] .p-TabBar-tabCloseIcon
${DIALOG WINDOW} css:.jp-Dialog
${DIALOG INPUT} css:.jp-Input-Dialog input
${DIALOG ACCEPT} css:button.jp-Dialog-button.jp-mod-accept
92 changes: 92 additions & 0 deletions atest/examples/Foreign extractors.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Smoke"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"valid = 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Python"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%python\n",
"valid"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### R"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%R\n",
"test \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### bash"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"echo $"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
43 changes: 43 additions & 0 deletions atest/examples/Python.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"test = 1 "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 5151a0b

Please sign in to comment.