Skip to content

Commit

Permalink
Merge pull request #966 from krassowski/fix-integration-tests
Browse files Browse the repository at this point in the history
Fix tests and edge cases in jump to, diagnostics,  highlighting, and rename
  • Loading branch information
krassowski authored Aug 29, 2023
2 parents 74e0d07 + 38e7b80 commit 64efa34
Show file tree
Hide file tree
Showing 26 changed files with 553 additions and 239 deletions.
33 changes: 17 additions & 16 deletions atest/01_Editor.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,56 @@ Test Tags ui:editor aspect:ls:features

*** Test Cases ***
Bash
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'HelloWorld')])[last()]
Editor Shows Features for Language
... Bash
... example.sh
... Diagnostics=Double quote to prevent globbing and word splitting.
... Jump to Definition=fib
... Jump to Definition=${def}

CSS
${def} = Set Variable
... xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '--some-var')])[last()]
... xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., '--some-var')])[last()]
Editor Shows Features for Language CSS example.css Diagnostics=Do not use empty rulesets
... Jump to Definition=${def} Rename=${def}

Docker
${def} = Set Variable xpath://span[contains(@class, 'cm-string')][contains(text(), 'PLANET')]
${def} = Set Variable xpath://div[contains(@class, 'cm-line')]//text()[contains(., 'PLANET')]
Wait Until Keyword Succeeds 3x 100ms Editor Shows Features for Language Docker Dockerfile
... Diagnostics=Instructions should be written in uppercase letters Jump to Definition=${def}
... Rename=${def}

JS
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
Editor Shows Features for Language JS example.js Diagnostics=Expression expected
... Jump to Definition=${def} Rename=${def}

JSON
Editor Shows Features for Language JSON example.json Diagnostics=Duplicate object key

JSX
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'hello')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'hello')])[last()]
Editor Shows Features for Language JSX example.jsx Diagnostics=Expression expected
... Jump to Definition=${def} Rename=${def}
# Julia
# ${def} = Set Variable xpath:(//span[contains(@class, 'cm-builtin')][contains(text(), 'add_together')])[last()]
# ${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'add_together')])[last()]
# Editor Shows Features for Language Julia example.jl Jump to Definition=${def} Rename=${def}

LaTeX
[Tags] language:latex
${def} = Set Variable xpath:(//span[contains(@class, 'cm-atom')][contains(text(), 'foo')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//span[contains(text(), 'foo')])[last()]
Editor Shows Features for Language LaTeX example.tex Jump to Definition=${def} Rename=${def}

Less
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '@width')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., '@width')])[last()]
Editor Shows Features for Language Less example.less Diagnostics=Do not use empty rulesets
... Jump to Definition=${def}

Markdown
Editor Shows Features for Language Markdown example.md Diagnostics=`Color` is misspelt

Python (pylsp)
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
Editor Shows Features for Server
... pylsp
... Python
Expand All @@ -67,35 +68,35 @@ Python (pylsp)
... Rename=${def}

Python (pyright)
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
Editor Shows Features for Server pyright Python example.py Diagnostics=is not defined (Pyright)
... Jump to Definition=${def}

R
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
Editor Shows Features for Language R example.R Diagnostics=Put spaces around all infix operators
... Jump to Definition=${def}

Robot Framework
[Tags] gh:332
${def} = Set Variable
... xpath:(//span[contains(@class, 'cm-keyword')][contains(text(), 'Special Log')])[last()]
... xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'Special Log')])[last()]
Editor Shows Features for Language Robot Framework example.robot Diagnostics=Undefined keyword
... Jump to Definition=${def}

SCSS
${def} = Set Variable
... xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), 'primary-color')])[last()]
... xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'primary-color')])[last()]
Editor Shows Features for Language SCSS example.scss Diagnostics=Do not use empty rulesets
... Jump to Definition=${def}

TSX
${def} = Set Variable xpath:(//span[contains(@class, 'cm-tag')][contains(text(), 'HelloWorld')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'HelloWorld')])[last()]
Editor Shows Features for Language TSX example.tsx
... Diagnostics='hello' is declared but its value is never read. Jump to Definition=${def} Rename=${def}

TypeScript
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'inc')])[last()]
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'inc')])[last()]
Editor Shows Features for Language TypeScript example.ts Diagnostics=The left-hand side of an arithmetic
... Jump to Definition=${def} Rename=${def}

Expand Down Expand Up @@ -137,7 +138,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=25s
Wait Until Page Contains Diagnostic [title*="${diagnostic}"] timeout=25s
Capture Page Screenshot 01-diagnostics.png
Open Diagnostics Panel
Capture Page Screenshot 02-diagnostics.png
Expand Down
13 changes: 6 additions & 7 deletions atest/03_Notebook.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Test Setup Try to Close All Tabs
Python
[Setup] Setup Notebook Python Python.ipynb
${diagnostic} = Set Variable W291 trailing whitespace (pycodestyle)
# TODO: no title for diagnostics; we can get the title with JS via `element.cmView.mark.spec.diagnostic.message` but this is not selectable
Wait Until Page Contains Element css:.cm-lintRange[title="${diagnostic}"] timeout=35s
Wait Until Page Contains Diagnostic [title="${diagnostic}"] timeout=35s
Capture Page Screenshot 01-python.png
[Teardown] Clean Up After Working With File Python.ipynb

Expand Down Expand Up @@ -40,11 +39,11 @@ Moving Cells Around
[Setup] Setup Notebook Python Python.ipynb
${diagnostic} = Set Variable undefined name 'test' (pyflakes)
Enter Cell Editor 1
Lab Command Move Cells Down
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title="${diagnostic}"] timeout=35s
Lab Command Move Cell Down
Wait Until Page Contains Diagnostic [title="${diagnostic}"] timeout=35s
Enter Cell Editor 1
Lab Command Move Cells Down
Wait Until Page Does Not Contain Element css:.cm-lsp-diagnostic[title="${diagnostic}"] timeout=35s
Lab Command Move Cell Down
Wait Until Page Does Not Contain Diagnostic [title="${diagnostic}"] timeout=35s
[Teardown] Clean Up After Working With File Python.ipynb

Foreign Extractors
Expand All @@ -61,7 +60,7 @@ Foreign Extractors
... `frob` is misspelt # markdown
... Command terminated with space # latex
FOR ${diagnostic} IN @{diagnostics}
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*\="${diagnostic}"] timeout=35s
Wait Until Page Contains Diagnostic [title*\="${diagnostic}"] timeout=35s
END
Capture Page Screenshot 11-extracted.png
[Teardown] Clean Up After Working with File and Settings ${file}
Expand Down
6 changes: 3 additions & 3 deletions atest/04_Interface/DiagnosticsPanel.robot
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Diagnostics Panel Works After Rename
[Documentation] Test for #141 bug (diagnostics were not cleared after rename)
Rename Jupyter File Panel.ipynb PanelRenamed.ipynb
Close Diagnostics Panel
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${DIAGNOSTIC}"] timeout=20s
Wait Until Page Contains Diagnostic [title*="${DIAGNOSTIC}"] timeout=20s
Capture Page Screenshot 00-panel-rename.png
Open Diagnostics Panel
Capture Page Screenshot 01-panel-rename.png
Expand All @@ -39,7 +39,7 @@ Diagnostics Panel Works After Kernel Restart
Lab Command Restart Kernel…
Wait For Dialog
Accept Default Dialog Option
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${DIAGNOSTIC}"] timeout=20s
Wait Until Page Contains Diagnostic [title*="${DIAGNOSTIC}"] timeout=20s
Open Diagnostics Panel
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT}

Expand Down Expand Up @@ -135,7 +135,7 @@ Open Notebook And Panel
[Arguments] ${notebook}
Setup Notebook Python ${notebook}
Capture Page Screenshot 00-notebook-and-panel-openeing.png
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${DIAGNOSTIC}"] timeout=20s
Wait Until Page Contains Diagnostic [title*="${DIAGNOSTIC}"] timeout=20s
Open Diagnostics Panel
Capture Page Screenshot 00-notebook-and-panel-opened.png

Expand Down
2 changes: 1 addition & 1 deletion atest/04_Interface/Statusbar.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ${HELP_BUTTON} css:.lsp-popover .lsp-help-button
*** Test Cases ***
Statusbar Popup Opens
Setup Notebook Python Python.ipynb
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${DIAGNOSTIC}"] timeout=20s
Wait Until Page Contains Diagnostic [title*="${DIAGNOSTIC}"] timeout=20s
Element Should Contain ${STATUSBAR} Fully initialized
Click Element ${STATUSBAR}
Wait Until Page Contains Element ${POPOVER} timeout=10s
Expand Down
4 changes: 2 additions & 2 deletions atest/05_Features/Diagnostics.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Test Tags feature:diagnostics

*** Test Cases ***
Diagnostics with deprecated tag have strike-through decoration
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="is deprecated"] timeout=25s
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="Unreachable code"] timeout=5s
Wait Until Page Contains Diagnostic [title*="is deprecated"] timeout=25s
Wait Until Page Contains Diagnostic [title*="Unreachable code"] timeout=5s
Page Should Contain Element css:.cm-lsp-diagnostic-tag-Deprecated
Page Should Contain Element css:.cm-lsp-diagnostic-tag-Unnecessary
9 changes: 6 additions & 3 deletions atest/05_Features/Highlights.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Test Teardown Clean Up After Working With File Highlights.ipynb
Test Tags feature:highlights


*** Variables ***
${HIGHLIGHT_XPATH_SELECTOR} span[contains(@class, 'cm-lsp-highlight-Read') or contains(@class, 'cm-lsp-highlight-Write') or contains(@class, 'cm-lsp-highlight-Text')]

*** Test Cases ***
# cursor is symbolized by pipe (|), for example when
# it is at the end of line, after `1` in `test = 1`
Expand Down Expand Up @@ -64,18 +67,18 @@ Highlights are removed when no cell is focused

*** Keywords ***
Should Not Highlight Any Tokens
Page Should Not Contain css:.cm-lsp-highlight
Page Should Not Contain xpath://${HIGHLIGHT_XPATH_SELECTOR}

Should Highlight Token
[Arguments] ${token} ${timeout}=15s
${token_element} Set Variable
... xpath://span[contains(@class, 'cm-lsp-highlight')][contains(text(), '${token}')]
... xpath://${HIGHLIGHT_XPATH_SELECTOR}\[contains(text(), '${token}')]
Wait Until Page Contains Element ${token_element} timeout=${timeout}

Should Not Highlight Token
[Arguments] ${token} ${timeout}=15s
${token_element} Set Variable
... xpath://span[contains(@class, 'cm-lsp-highlight')][contains(text(), '${token}')]
... xpath://${HIGHLIGHT_XPATH_SELECTOR}\[contains(text(), '${token}')]
Wait Until Page Does Not Contain Element ${token_element} timeout=${timeout}

Setup Highlights Test
Expand Down
2 changes: 1 addition & 1 deletion atest/05_Features/Hover.robot
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Update hover after character deletion
Last Occurrence
[Arguments] ${symbol}
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol}
... xpath:(//div[@class="cm-line"][contains(., "${symbol}")])[last()]
... xpath:(//div[@class="cm-content"]//text()[contains(., "${symbol}")])[last()]
RETURN ${sel}

Trigger Automatically By Hover
Expand Down
16 changes: 8 additions & 8 deletions atest/05_Features/Jump.robot
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ Jumps To References With Modifier Click
[Setup] Prepare File for Editing Python editor jump_references.py
Configure JupyterLab Plugin {"modifierKey": "Accel"} plugin id=${JUMP PLUGIN ID}
Wait Until Fully Initialized
${token} = Select Token Occurrence func type=def
${token} = Select Token Occurrence func which=1
Click Element ${token}
${original} = Measure Cursor Position
Ctrl Click Element ${token}
Wait Until Page Contains Choose the jump target
${references_count} = Get Element Count css:.jp-Dialog select option
Should Be True ${references_count} == ${3}
Select From List By Index css:.jp-Dialog select 2
Should Be True ${references_count} == ${2}
Select From List By Index css:.jp-Dialog select 1
Click Element css:.jp-Dialog-button.jp-mod-accept
Wait Until Keyword Succeeds 10 x 1 s Cursor Should Jump ${original}
[Teardown] Clean Up After Working With File jump_references.py

Jumps To References From Context Menu
[Setup] Prepare File for Editing Python editor jump_references.py
Wait Until Fully Initialized
${token} = Select Token Occurrence func type=def
${token} = Select Token Occurrence func which=1
Click Element ${token}
${original} = Measure Cursor Position
Open Context Menu Over ${token}
Select Menu Entry Jump to references
Wait Until Page Contains Choose the jump target
${references_count} = Get Element Count css:.jp-Dialog select option
Should Be True ${references_count} == ${3}
Select From List By Index css:.jp-Dialog select 2
Should Be True ${references_count} == ${2}
Select From List By Index css:.jp-Dialog select 1
Click Element css:.jp-Dialog-button.jp-mod-accept
Wait Until Keyword Succeeds 10 x 1 s Cursor Should Jump ${original}
[Teardown] Clean Up After Working With File jump_references.py
Expand Down Expand Up @@ -92,9 +92,9 @@ Clean Up Folder With Spaces
Remove Directory ${NOTEBOOK DIR}${/}${FOLDER WITH SPACE} recursive=True

Select Token Occurrence
[Arguments] ${token} ${type}=variable ${which}=last
[Arguments] ${token} ${which}=last()
${sel} = Set Variable
... xpath:(//span[contains(@class, 'cm-${type}')][contains(text(), '${token}')])[${which}()]
... xpath:(//div[contains(@class, 'cm-line')]//*[contains(text(), '${token}')])[${which}]
RETURN ${sel}

Ctrl Click Element
Expand Down
22 changes: 11 additions & 11 deletions atest/05_Features/Syntax_highlighting.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ Test Tags feature:syntax_highlighting
*** Test Cases ***
Syntax Highlighting Mode Stays Normal In Normal Cells
${mode} = Get Mode Of A Cell 1
should be equal ${mode['name']} ipython
should be equal ${mode} python

Syntax Highlighting Mode Changes In Cells Dominated By Foreign Documents
${mode} = Get Mode Of A Cell 2
should be equal ${mode['name']} markdown
should be equal ${mode} markdown
${mode} = Get Mode Of A Cell 3
should be equal ${mode['name']} xml
should be equal ${mode} html
${mode} = Get Mode Of A Cell 4
should be equal ${mode['name']} javascript
should be equal ${mode} javascript

Highlighing Mode Works For Multiple Documents
${mode} = Get Mode Of A Cell 4
should be equal ${mode['name']} javascript
should be equal ${mode} javascript
${mode} = Get Mode Of A Cell 6
should be equal ${mode['name']} javascript
should be equal ${mode} javascript

Highlighting Mode Changes Back And Forth After Edits
${mode} = Get Mode Of A Cell 2
should be equal ${mode['name']} markdown
should be equal ${mode} markdown
Enter Cell Editor 2 line=1
Press Keys None BACKSPACE
Capture Page Screenshot backapse.png
wait until keyword succeeds 5x 2s Mode Of A Cell Should Equal 2 ipython
wait until keyword succeeds 5x 2s Mode Of A Cell Should Equal 2 python
Enter Cell Editor 2 line=1
Press Keys None n
wait until keyword succeeds 5x 2s Mode Of A Cell Should Equal 2 markdown
Expand All @@ -43,9 +43,9 @@ Highlighting Mode Changes Back And Forth After Edits
Get Mode Of A Cell
[Arguments] ${cell_number}
Click Element css:.jp-Cell:nth-child(${cell_number})
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_number}) .CodeMirror-focused
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_number}) .cm-focused
${mode} = Execute JavaScript
... return document.querySelector('.jp-Cell:nth-child(${cell_number}) .CodeMirror').CodeMirror.getMode()
... return document.querySelector('.jp-Cell:nth-child(${cell_number}) .cm-content').dataset.language
RETURN ${mode}

Setup Highlighting Test
Expand All @@ -54,4 +54,4 @@ Setup Highlighting Test
Mode Of A Cell Should Equal
[Arguments] ${cell_number} ${expected_mode}
${mode} = Get Mode Of A Cell ${cell_number}
should be equal ${mode['name']} ${expected_mode}
should be equal ${mode} ${expected_mode}
Loading

0 comments on commit 64efa34

Please sign in to comment.