Skip to content

Commit

Permalink
Start porting acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Aug 21, 2023
1 parent cb75215 commit 4ce1feb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion atest/03_Notebook.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Test Setup Try to Close All Tabs
Python
[Setup] Setup Notebook Python Python.ipynb
${diagnostic} = Set Variable W291 trailing whitespace (pycodestyle)
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title="${diagnostic}"] timeout=35s
# 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
Capture Page Screenshot 01-python.png
[Teardown] Clean Up After Working With File Python.ipynb

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 @@ -52,7 +52,7 @@ Status Changes Between Notebooks
Setup Notebook Python Python.ipynb
Wait Until Fully Initialized
Open New Notebook
Element Should Contain ${STATUSBAR} Waiting...
Element Should Contain ${STATUSBAR} Waiting
Wait Until Fully Initialized
Switch To Tab Python.ipynb
Wait Until Fully Initialized
Expand Down
24 changes: 15 additions & 9 deletions atest/Keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -321,29 +321,33 @@ Gently Reset Workspace

Enter Cell Editor
[Arguments] ${cell_nr} ${line}=1
Click Element css:.jp-Cell:nth-child(${cell_nr}) .CodeMirror-line:nth-child(${line})
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_nr}) .CodeMirror-focused
Click Element css:.jp-Cell:nth-child(${cell_nr}) .cm-line:nth-child(${line})
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_nr}) .cm-focused

Open Context Menu Over Cell Editor
[Arguments] ${cell_nr} ${line}=1
Enter Cell Editor ${cell_nr} line=${line}
Open Context Menu Over css:.jp-Cell:nth-child(${cell_nr}) .CodeMirror-line:nth-child(${line})
Open Context Menu Over css:.jp-Cell:nth-child(${cell_nr}) .cm-line:nth-child(${line})

Place Cursor In Cell Editor At
[Arguments] ${cell_nr} ${line} ${character}
Enter Cell Editor ${cell_nr} ${line}
Execute JavaScript
... return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.setCursor({line: ${line} - 1, ch: ${character}})
... view = document.querySelector('.jp-Cell:nth-child(${cell_nr}) .cm-content').cmView.view;
... pos = view.doc.line(${line}).from + ${character};
... return view.dispatch({selection: {anchor: pos, head: pos}});

Enter File Editor
Click Element css:.jp-FileEditor .CodeMirror
Wait Until Page Contains Element css:.jp-FileEditor .CodeMirror-focused
Click Element css:.jp-FileEditor .cm-editor
Wait Until Page Contains Element css:.jp-FileEditor .cm-focused

Place Cursor In File Editor At
[Arguments] ${line} ${character}
Enter File Editor
Execute JavaScript
... return document.querySelector('.jp-FileEditor .CodeMirror').CodeMirror.setCursor({line: ${line} - 1, ch: ${character}})
... view = document.querySelector('.jp-FileEditor .cm-content').cmView.view;
... pos = view.doc.line(${line}).from + ${character};
... return view.dispatch({selection: {anchor: pos, head: pos}});

Wait Until Fully Initialized
Wait Until Element Contains ${STATUSBAR} Fully initialized timeout=60s
Expand Down Expand Up @@ -398,11 +402,13 @@ Open in Advanced Settings

Set Editor Content
[Arguments] ${text} ${css}=${EMPTY}
Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.setValue(`${text}`)
Execute JavaScript
... doc = document.querySelector('${css} .cm-content').cmView.view.doc;
... return doc.replace(0, doc.length, `${text}`);

Get Editor Content
[Arguments] ${css}=${EMPTY}
${content} = Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.getValue()
${content} = Execute JavaScript return document.querySelector('${css} .cm-content').cmView.view.doc.toString()
RETURN ${content}

Configure JupyterLab Plugin
Expand Down
6 changes: 3 additions & 3 deletions atest/Variables.resource
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ${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:.CodeMirror-cursor
${CM CURSOR} css:.cm-cursor
${CM CURSORS}
... css:.jp-MainAreaWidget:not(.lm-mod-hidden) .CodeMirror-cursors:not([style='visibility: hidden'])
... css:.jp-MainAreaWidget:not(.lm-mod-hidden) .cm-cursorLayer:not([style='visibility: hidden'])
# settings
${LSP PLUGIN ID} @jupyter-lsp/jupyterlab-lsp:plugin
${COMPLETION PLUGIN ID} @jupyter-lsp/jupyterlab-lsp:completion
Expand All @@ -63,7 +63,7 @@ ${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-lsp-diagnostic
${CSS DIAGNOSTIC} css:.cm-lintRange
# log messages
@{KNOWN BAD ERRORS}
... pylsp_jsonrpc.endpoint - Failed to handle notification
Expand Down

0 comments on commit 4ce1feb

Please sign in to comment.