diff --git a/atest/01_Editor.robot b/atest/01_Editor.robot index b2d1e3b65..8162206e5 100644 --- a/atest/01_Editor.robot +++ b/atest/01_Editor.robot @@ -9,26 +9,27 @@ 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} @@ -36,20 +37,20 @@ 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} @@ -57,7 +58,7 @@ 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 @@ -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} @@ -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 diff --git a/atest/03_Notebook.robot b/atest/03_Notebook.robot index a2e4e87eb..b6325056f 100644 --- a/atest/03_Notebook.robot +++ b/atest/03_Notebook.robot @@ -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 @@ -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 @@ -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} diff --git a/atest/04_Interface/DiagnosticsPanel.robot b/atest/04_Interface/DiagnosticsPanel.robot index b71078775..25fbb3975 100644 --- a/atest/04_Interface/DiagnosticsPanel.robot +++ b/atest/04_Interface/DiagnosticsPanel.robot @@ -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 @@ -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} @@ -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 diff --git a/atest/04_Interface/Statusbar.robot b/atest/04_Interface/Statusbar.robot index 403b6b3c8..0780f6dd4 100644 --- a/atest/04_Interface/Statusbar.robot +++ b/atest/04_Interface/Statusbar.robot @@ -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 diff --git a/atest/05_Features/Diagnostics.robot b/atest/05_Features/Diagnostics.robot index b61517b2d..2a3c139b7 100644 --- a/atest/05_Features/Diagnostics.robot +++ b/atest/05_Features/Diagnostics.robot @@ -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 diff --git a/atest/05_Features/Highlights.robot b/atest/05_Features/Highlights.robot index b5b9e4435..0ad434b21 100644 --- a/atest/05_Features/Highlights.robot +++ b/atest/05_Features/Highlights.robot @@ -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` @@ -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 diff --git a/atest/05_Features/Hover.robot b/atest/05_Features/Hover.robot index b1f4ef3fb..6430f3e9d 100644 --- a/atest/05_Features/Hover.robot +++ b/atest/05_Features/Hover.robot @@ -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 diff --git a/atest/05_Features/Jump.robot b/atest/05_Features/Jump.robot index 13cfc277f..69ddf2cfa 100644 --- a/atest/05_Features/Jump.robot +++ b/atest/05_Features/Jump.robot @@ -25,14 +25,14 @@ 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 @@ -40,15 +40,15 @@ Jumps To References With Modifier Click 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 @@ -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 diff --git a/atest/05_Features/Syntax_highlighting.robot b/atest/05_Features/Syntax_highlighting.robot index e1011cbe3..d866a47c5 100644 --- a/atest/05_Features/Syntax_highlighting.robot +++ b/atest/05_Features/Syntax_highlighting.robot @@ -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 @@ -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 @@ -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} diff --git a/atest/07_Configuration.robot b/atest/07_Configuration.robot index ac59ef44c..298c4f4a2 100644 --- a/atest/07_Configuration.robot +++ b/atest/07_Configuration.robot @@ -66,8 +66,8 @@ LaTeX *** Keywords *** Settings Should Change Editor Diagnostics [Arguments] ${language} ${file} ${server} ${settings} ${before} ${after} ${save command}=${EMPTY} ${needs reload}=${False} ${setting_key}=serverSettings - ${before diagnostic} = Set Variable ${CSS DIAGNOSTIC}\[title*="${before}"] - ${after diagnostic} = Set Variable ${CSS DIAGNOSTIC}\[title*="${after}"] + ${before diagnostic} = Set Variable [title*="${before}"] + ${after diagnostic} = Set Variable [title*="${after}"] ${tab} = Set Variable ${JLAB XP DOCK TAB}\[contains(., '${file}')] ${close icon} = Set Variable *[contains(@class, 'm-TabBar-tabCloseIcon')] ${save command} = Set Variable If "${save command}" ${save command} Save ${language} File @@ -79,7 +79,7 @@ Settings Should Change Editor Diagnostics Drag and Drop By Offset ${JLAB XP DOCK TAB}\[contains(., 'Diagnostics Panel')] 600 -200 Click Element ${JLAB XP DOCK TAB}\[contains(., 'Launcher')]/${close icon} IF "${before}" - Wait Until Page Contains Element ${before diagnostic} timeout=30s + Wait Until Page Contains Diagnostic ${before diagnostic} timeout=30s END Page Should Not Contain ${after diagnostic} Capture Page Screenshot 01-default-diagnostics-and-settings.png @@ -95,9 +95,9 @@ Settings Should Change Editor Diagnostics IF ${needs reload} Reload After Configuration ${language} ${file} # allow longer after reload - Wait Until Page Contains Element ${after diagnostic} timeout=60s + Wait Until Page Contains Diagnostic ${after diagnostic} timeout=60s ELSE - Wait Until Page Contains Element ${after diagnostic} timeout=30s + Wait Until Page Contains Diagnostic ${after diagnostic} timeout=30s END Capture Page Screenshot 04-configured-diagnostic-found.png [Teardown] Clean Up After Working with File and Settings ${file} diff --git a/atest/Keywords.resource b/atest/Keywords.resource index a11b4b217..a02563c19 100644 --- a/atest/Keywords.resource +++ b/atest/Keywords.resource @@ -9,6 +9,7 @@ Library ./logcheck.py Library ./ports.py Library ./config.py Library ./paths.py +Library ./diagnostics.py *** Keywords *** @@ -334,7 +335,7 @@ Place Cursor In Cell Editor At Enter Cell Editor ${cell_nr} ${line} Execute JavaScript ... var view = document.querySelector('.jp-Cell:nth-child(${cell_nr}) .cm-content').cmView.view; - ... var pos = view.doc.line(${line}).from + ${character}; + ... var pos = view.state.doc.line(${line}).from + ${character}; ... return view.dispatch({selection: {anchor: pos, head: pos}}); Enter File Editor @@ -346,7 +347,7 @@ Place Cursor In File Editor At Enter File Editor Execute JavaScript ... var view = document.querySelector('.jp-FileEditor .cm-content').cmView.view; - ... var pos = view.doc.line(${line}).from + ${character}; + ... var pos = view.state.doc.line(${line}).from + ${character}; ... return view.dispatch({selection: {anchor: pos, head: pos}}); Wait Until Fully Initialized @@ -404,13 +405,16 @@ Set Editor Content [Arguments] ${text} ${css}=${EMPTY} Wait Until Page Contains Element css:${css} .cm-content Execute JavaScript - ... var doc = document.querySelector('${css} .cm-content').cmView.view.doc; - ... return doc.replace(0, doc.length, `${text}`); + ... let view = document.querySelector('${css} .cm-content').cmView.view; + ... view.dispatch({ + ... changes: {from: 0, to: view.state.doc.length, insert: `${text}`} + ... }); Get Editor Content [Arguments] ${css}=${EMPTY} Wait Until Page Contains Element css:${css} .cm-content - ${content} = Execute JavaScript return document.querySelector('${css} .cm-content').cmView.view.doc.toString() + ${content} = Execute JavaScript + ... return document.querySelector('${css} .cm-content').cmView.view.state.doc.toString() RETURN ${content} Configure JupyterLab Plugin @@ -431,8 +435,9 @@ Jump To Definition [Arguments] ${symbol} ${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol} ... xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()] - Open Context Menu Over ${sel} + Click Element ${sel} ${cursor} = Measure Cursor Position + Open Context Menu Over ${sel} Capture Page Screenshot 02-jump-to-definition-0.png Wait Until Element Is Visible ${MENU JUMP} timeout=5s Mouse Over ${MENU JUMP} @@ -453,8 +458,11 @@ Cursor Should Jump Should Not Be Equal ${original} ${current} Measure Cursor Position - Wait Until Page Contains Element ${CM CURSORS} - ${position} = Wait Until Keyword Succeeds 20 x 0.05s Get Vertical Position ${CM CURSOR} + Wait Until Page Contains Element ${ACTIVE CURSOR} + ${position} = Wait Until Keyword Succeeds 20 x 0.05s Get Vertical Position ${ACTIVE CURSOR} + LOG ${position} + # position = 0 indicates that the element was not active. + Should Not Be Equal ${position} 0 RETURN ${position} Switch To Tab diff --git a/atest/Variables.resource b/atest/Variables.resource index a0bfd2e85..57619f06a 100644 --- a/atest/Variables.resource +++ b/atest/Variables.resource @@ -49,9 +49,8 @@ ${MENU SETTINGS} xpath://div[contains(@class, 'lm-MenuBar-itemLab ${MENU EDITOR THEME} ... xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "Text Editor Theme")] ${LAB MENU} css:.lm-Menu -${CM CURSOR} css:.cm-cursor -${CM CURSORS} -... css:.jp-MainAreaWidget:not(.lm-mod-hidden) .cm-cursorLayer:not([style='visibility: hidden']) +${ACTIVE CURSOR} +... css:.jp-MainAreaWidget:not(.lm-mod-hidden) .cm-cursorLayer:not([style='visibility: hidden']) .cm-cursor-primary # settings ${LSP PLUGIN ID} @jupyter-lsp/jupyterlab-lsp:plugin ${COMPLETION PLUGIN ID} @jupyter-lsp/jupyterlab-lsp:completion @@ -62,8 +61,6 @@ ${HOVER PLUGIN ID} @jupyter-lsp/jupyterlab-lsp:hover ${CSS USER SETTINGS} .jp-SettingsRawEditor-user ${JLAB XP CLOSE SETTINGS} ... ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')] -# diagnostics -${CSS DIAGNOSTIC} css:.cm-lintRange # log messages @{KNOWN BAD ERRORS} ... pylsp_jsonrpc.endpoint - Failed to handle notification diff --git a/atest/diagnostics.py b/atest/diagnostics.py new file mode 100644 index 000000000..4bd37cd24 --- /dev/null +++ b/atest/diagnostics.py @@ -0,0 +1,59 @@ +from functools import partial +from robot.libraries.BuiltIn import BuiltIn +from selenium.common.exceptions import NoSuchElementException, TimeoutException +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.common.by import By +from selenium.webdriver.remote.webdriver import WebDriver +from SeleniumLibrary import SeleniumLibrary + +from robot.utils import timestr_to_secs + +DIAGNOSTIC_CLASS = 'cm-lintRange' + +def page_contains_diagnostic(driver: WebDriver, selector, negate=False): + elements = driver.find_elements(By.CSS_SELECTOR, f'.{DIAGNOSTIC_CLASS}') + if not elements: + return True if negate else False + driver.execute_script(""" + arguments[0].map(el => { + let diagnostic = el.cmView.mark.spec.diagnostic; + el.title = diagnostic.message + " (" + diagnostic.source + ")"; + }); + """, elements) + try: + driver.find_element(By.CSS_SELECTOR, f'.{DIAGNOSTIC_CLASS}{selector}') + except NoSuchElementException: + return True if negate else False + return False if negate else True + + +def wait_until_page_contains_diagnostic(selector, timeout='3s'): + sl: SeleniumLibrary = BuiltIn().get_library_instance("SeleniumLibrary") + wait = WebDriverWait(sl.driver, timestr_to_secs(timeout)) + try: + return wait.until( + partial(page_contains_diagnostic, selector=selector) + ) + except TimeoutException: + elements = sl.driver.find_elements(By.CSS_SELECTOR, f'.{DIAGNOSTIC_CLASS}') + if elements: + titles = ( + '\n - ' + + '\n - '.join([el.get_attribute('title') for el in elements]) + ) + hint = f'Visible diagnostics are: {titles}' + else: + hint = 'No diagnostics were visible.' + raise TimeoutException( + f'Diagnostic with selector {selector} not found in {timeout}.' + f'\n{hint}' + ) + + +def wait_until_page_does_not_contain_diagnostic(selector, timeout='3s'): + sl: SeleniumLibrary = BuiltIn().get_library_instance("SeleniumLibrary") + wait = WebDriverWait(sl.driver, timestr_to_secs(timeout)) + return wait.until( + partial(page_contains_diagnostic, selector=selector, negate=True), + f'Diagnostic with selector {selector} still present after {timeout}' + ) diff --git a/packages/jupyterlab-lsp/src/components/serverSettings.tsx b/packages/jupyterlab-lsp/src/components/serverSettings.tsx index 82a78579c..15019a6c4 100644 --- a/packages/jupyterlab-lsp/src/components/serverSettings.tsx +++ b/packages/jupyterlab-lsp/src/components/serverSettings.tsx @@ -4,8 +4,9 @@ import { ISchemaValidator } from '@jupyterlab/settingregistry'; import { TranslationBundle } from '@jupyterlab/translation'; +import { FormComponent } from '@jupyterlab/ui-components'; import { ReadonlyPartialJSONObject } from '@lumino/coreutils'; -import Form, { IChangeEvent } from '@rjsf/core'; +import { IChangeEvent } from '@rjsf/core'; import { FieldProps, ObjectFieldTemplateProps, @@ -139,7 +140,7 @@ export class LanguageServerSettings extends React.Component<