@@ -4,59 +4,67 @@ Library SeleniumLibrary
44Library OperatingSystem
55Library Process
66Library String
7+ Library Collections
78Library ./logcheck.py
89Library ./ports.py
10+ Library ./config.py
911
1012*** Keywords ***
1113Setup Server and Browser
12- ${port } = Get Unused Port
13- Set Global Variable ${PORT } ${port }
14- Set Global Variable ${URL } http://localhost:${PORT }${BASE }
14+ Initialize Global Variables
15+ Create Notebok Server Config
16+ Initialize User Settings
17+ ${server } = Start Process jupyter-lab
18+ ... cwd=${NOTEBOOK DIR }
19+ ... stdout=${LAB LOG }
20+ ... stderr=STDOUT
21+ ... env:HOME=${HOME }
22+ Set Global Variable ${SERVER } ${server }
23+ Open JupyterLab
24+ Read Page Config
25+
26+ Initialize Global Variables
27+ ${root } = Normalize Path ${OUTPUT DIR }${/ } ..${/ } ..${/ } ..
28+ Set Global Variable ${ROOT } ${root }
1529 ${accel } = Evaluate "COMMAND" if "${OS } " == "Darwin" else "CTRL"
1630 Set Global Variable ${ACCEL } ${accel }
1731 ${token } = Generate Random String
1832 Set Global Variable ${TOKEN } ${token }
19- ${home } = Set Variable ${OUTPUT DIR }${/ } home
20- ${root } = Normalize Path ${OUTPUT DIR }${/ } ..${/ } ..${/ } ..
21- Create Directory ${home }
22- Create Notebok Server Config ${home }
23- Initialize User Settings
24- ${cmd } = Create Lab Launch Command ${root }
25- Set Screenshot Directory ${OUTPUT DIR }${/ } screenshots
26- Set Global Variable ${LAB LOG } ${OUTPUT DIR }${/ } lab.log
2733 Set Global Variable ${PREVIOUS LAB LOG LENGTH } 0
28- ${server } = Start Process ${cmd } shell=yes env:HOME=${home } cwd=${home } stdout=${LAB LOG }
29- ... stderr=STDOUT
30- Set Global Variable ${SERVER } ${server }
31- Open JupyterLab
34+ Set Screenshot Directory ${SCREENSHOTS DIR }
35+
36+ Create Notebok Server Config
37+ [Documentation] Copies in notebook server config file and updates accordingly
38+ ${conf } = Set Variable ${NOTEBOOK DIR }${/ }${NBSERVER CONF }
39+ ${extra_node_roots } = Create List ${ROOT }
40+ ${port } = Get Unused Port
41+ Set Global Variable ${PORT } ${port }
42+ Set Global Variable ${URL } http://localhost:${PORT }${BASE URL }
43+ Copy File ${FIXTURES }${/ }${NBSERVER CONF } ${conf }
44+ Update Jupyter Config ${conf } LabApp
45+ ... base_url=${BASE URL }
46+ ... port=${PORT }
47+ ... token=${TOKEN }
48+ ... user_settings_dir=${SETTINGS DIR }
49+ ... workspaces_dir=${WORKSPACES DIR }
50+ Update Jupyter Config ${conf } LanguageServerManager
51+ ... extra_node_roots=@{extra_node_roots }
52+
53+ Read Page Config
3254 ${script } = Get Element Attribute id:jupyter-config-data innerHTML
3355 ${config } = Evaluate __import__("json").loads("""${script } """)
3456 Set Global Variable ${PAGE CONFIG } ${config }
3557 Set Global Variable ${LAB VERSION } ${config["appVersion"] }
3658
37- Create Lab Launch Command
38- [Arguments] ${root }
39- [Documentation] Create a JupyterLab CLI shell string, escaping for traitlets
40- ${WORKSPACES DIR } = Set Variable ${OUTPUT DIR }${/ } workspaces
41- ${app args } = Set Variable --no-browser --debug --NotebookApp.base_url\='${BASE } ' --port\=${PORT } --NotebookApp.token\='${TOKEN } '
42- ${path args } = Set Variable --LabApp.user_settings_dir='${SETTINGS DIR.replace('\\', '\\\\') } ' --LabApp.workspaces_dir\='${WORKSPACES DIR.replace('\\', '\\\\') } '
43- ${ext args } = Set Variable --LanguageServerManager.extra_node_roots\="['${root.replace('\\', '\\\\') } ']"
44- ${cmd } = Set Variable jupyter-lab ${app args } ${path args } ${ext args }
45- [Return] ${cmd }
46-
47- Create Notebok Server Config
48- [Arguments] ${home }
49- [Documentation] Copies in notebook server config file to disables npm/build checks
50- Copy File ${FIXTURES }${/ }${NBSERVER CONF } ${home }${/ }${NBSERVER CONF }
51-
5259Setup Suite For Screenshots
5360 [Arguments] ${folder }
54- Set Screenshot Directory ${OUTPUT DIR }${ / } screenshots ${/ }${folder }
61+ Set Screenshot Directory ${SCREENSHOTS DIR }${/ }${folder }
5562 Set Tags lab:${LAB VERSION }
5663
5764Initialize User Settings
58- Set Suite Variable ${SETTINGS DIR } ${OUTPUT DIR }${/ } user-settings children=${True }
59- Create File ${SETTINGS DIR }${/ } @jupyterlab${/ } codemirror-extension${/ } commands.jupyterlab-settings {"styleActiveLine": true}
65+ Create File
66+ ... ${SETTINGS DIR }${/ } @jupyterlab${/ } codemirror-extension${/ } commands.jupyterlab-settings
67+ ... {"styleActiveLine": true}
6068
6169Reset Plugin Settings
6270 [Arguments] ${package } =jupyterlab-lsp ${plugin } =plugin
@@ -91,7 +99,7 @@ Open JupyterLab
9199 Create WebDriver Firefox
92100 ... executable_path=${geckodriver }
93101 ... firefox_binary=${firefox }
94- ... service_log_path=${OUTPUT DIR }${ / } geckodriver.log
102+ ... service_log_path=${GECKODRIVER LOG }
95103 ... service_args=${service args }
96104 Wait Until Keyword Succeeds 3x 5s Wait For Splash
97105
@@ -191,7 +199,7 @@ Ensure Sidebar Is Closed
191199Open Context Menu for File
192200 [Arguments] ${file }
193201 Ensure File Browser is Open
194- Click Element css:button[title="Refresh File List"]
202+ Click Element ${ JLAB CSS REFRESH FILES }
195203 ${selector } = Set Variable xpath://span[@class='jp-DirListing-itemText']\[text() = '${file } ']
196204 Wait Until Page Contains Element ${selector }
197205 Open Context Menu ${selector }
@@ -212,7 +220,19 @@ Input Into Dialog
212220 Input Text ${DIALOG INPUT } ${text }
213221 Click Element ${DIALOG ACCEPT }
214222
223+ Open Folder
224+ [Arguments] @{paths }
225+ Click Element ${JLAB CSS REFRESH FILES }
226+ FOR ${path } IN @{paths }
227+ ${sel } = Set Variable css:li.jp-DirListing-item\[title^='Name: ${path } ']
228+ Wait Until Page Contains Element ${sel }
229+ Double Click Element ${sel }
230+ END
231+
215232Open ${file} in ${editor}
233+ ${paths } = Set Variable ${file.split("/") }
234+ Run Keyword If ${paths.__len__() > 1 } Open Folder @{paths[:-1] }
235+ ${file } = Set Variable ${paths[-1] }
216236 Open Context Menu for File ${file }
217237 Mouse Over ${MENU OPEN WITH }
218238 Wait Until Page Contains Element ${editor }
@@ -221,15 +241,15 @@ Open ${file} in ${editor}
221241
222242Clean Up After Working With File
223243 [Arguments] ${file }
224- Remove File ${OUTPUT DIR }${ / } home ${/ }${file }
244+ Remove File ${NOTEBOOK DIR }${/ }${file }
225245 Reset Application State
226246 Lab Log Should Not Contain Known Error Messages
227247
228248Setup Notebook
229249 [Arguments] ${Language } ${file } ${isolated } =${True }
230250 Set Tags language:${Language.lower() }
231- Run Keyword If ${isolated } Set Screenshot Directory ${OUTPUT DIR }${ / } screenshots ${/ } notebook${/ }${TEST NAME.replace(' ', '_') }
232- Copy File examples${/ }${file } ${OUTPUT DIR }${ / } home ${/ }${file }
251+ Run Keyword If ${isolated } Set Screenshot Directory ${SCREENSHOTS DIR }${/ } notebook${/ }${TEST NAME.replace(' ', '_') }
252+ Copy File examples${/ }${file } ${NOTEBOOK DIR }${/ }${file }
233253 Run Keyword If ${isolated } Try to Close All Tabs
234254 Open ${file } in ${MENU NOTEBOOK }
235255 Capture Page Screenshot 00-notebook-opened.png
@@ -284,13 +304,13 @@ Open Context Menu Over
284304Prepare File for Editing
285305 [Arguments] ${Language } ${Screenshots } ${file }
286306 Set Tags language:${Language.lower() }
287- Set Screenshot Directory ${OUTPUT DIR }${ / } screenshots ${/ }${Screenshots }${/ }${Language.lower() }
307+ Set Screenshot Directory ${SCREENSHOTS DIR }${/ }${Screenshots }${/ }${Language.lower() }
288308 Try to Close All Tabs
289309 Open File ${file }
290310
291311Open File
292312 [Arguments] ${file }
293- Copy File examples${/ }${file } ${OUTPUT DIR }${ / } home ${/ }${file }
313+ Copy File examples${/ }${file } ${NOTEBOOK DIR }${/ }${file }
294314 Open ${file } in ${MENU EDITOR }
295315 Capture Page Screenshot 00-opened.png
296316
@@ -323,3 +343,31 @@ Clean Up After Working with File and Settings
323343 [Arguments] ${file }
324344 Clean Up After Working With File ${file }
325345 Reset Plugin Settings
346+
347+ Jump To Definition
348+ [Arguments] ${symbol }
349+ ${sel } = Set Variable If "${symbol } ".startswith(("xpath", "css")) ${symbol } xpath:(//span[@role="presentation"][contains(., "${symbol } ")])[last()]
350+ Open Context Menu Over ${sel }
351+ ${cursor } = Measure Cursor Position
352+ Capture Page Screenshot 02-jump-to-definition-0.png
353+ Mouse Over ${MENU JUMP }
354+ Capture Page Screenshot 02-jump-to-definition-1.png
355+ Click Element ${MENU JUMP }
356+ [Return] ${cursor }
357+
358+ Editor Should Jump To Definition
359+ [Arguments] ${symbol }
360+ Set Tags feature:jump-to-definition
361+ ${cursor } = Jump To Definition ${symbol }
362+ Wait Until Keyword Succeeds 10 x 1 s Cursor Should Jump ${cursor }
363+ Capture Page Screenshot 02-jump-to-definition-2.png
364+
365+ Cursor Should Jump
366+ [Arguments] ${original }
367+ ${current } = Measure Cursor Position
368+ Should Not Be Equal ${original } ${current }
369+
370+ Measure Cursor Position
371+ Wait Until Page Contains Element ${CM CURSORS }
372+ ${position } = Wait Until Keyword Succeeds 20 x 0.05s Get Vertical Position ${CM CURSOR }
373+ [Return] ${position }
0 commit comments