@@ -4,59 +4,67 @@ Library SeleniumLibrary
4
4
Library OperatingSystem
5
5
Library Process
6
6
Library String
7
+ Library Collections
7
8
Library ./logcheck.py
8
9
Library ./ports.py
10
+ Library ./config.py
9
11
10
12
*** Keywords ***
11
13
Setup 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 }
15
29
${accel } = Evaluate "COMMAND" if "${OS } " == "Darwin" else "CTRL"
16
30
Set Global Variable ${ACCEL } ${accel }
17
31
${token } = Generate Random String
18
32
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
27
33
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
32
54
${script } = Get Element Attribute id:jupyter-config-data innerHTML
33
55
${config } = Evaluate __import__("json").loads("""${script } """)
34
56
Set Global Variable ${PAGE CONFIG } ${config }
35
57
Set Global Variable ${LAB VERSION } ${config["appVersion"] }
36
58
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
-
52
59
Setup Suite For Screenshots
53
60
[Arguments] ${folder }
54
- Set Screenshot Directory ${OUTPUT DIR }${ / } screenshots ${/ }${folder }
61
+ Set Screenshot Directory ${SCREENSHOTS DIR }${/ }${folder }
55
62
Set Tags lab:${LAB VERSION }
56
63
57
64
Initialize 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}
60
68
61
69
Reset Plugin Settings
62
70
[Arguments] ${package } =jupyterlab-lsp ${plugin } =plugin
@@ -91,7 +99,7 @@ Open JupyterLab
91
99
Create WebDriver Firefox
92
100
... executable_path=${geckodriver }
93
101
... firefox_binary=${firefox }
94
- ... service_log_path=${OUTPUT DIR }${ / } geckodriver.log
102
+ ... service_log_path=${GECKODRIVER LOG }
95
103
... service_args=${service args }
96
104
Wait Until Keyword Succeeds 3x 5s Wait For Splash
97
105
@@ -191,7 +199,7 @@ Ensure Sidebar Is Closed
191
199
Open Context Menu for File
192
200
[Arguments] ${file }
193
201
Ensure File Browser is Open
194
- Click Element css:button[title="Refresh File List"]
202
+ Click Element ${ JLAB CSS REFRESH FILES }
195
203
${selector } = Set Variable xpath://span[@class='jp-DirListing-itemText']\[text() = '${file } ']
196
204
Wait Until Page Contains Element ${selector }
197
205
Open Context Menu ${selector }
@@ -212,7 +220,19 @@ Input Into Dialog
212
220
Input Text ${DIALOG INPUT } ${text }
213
221
Click Element ${DIALOG ACCEPT }
214
222
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
+
215
232
Open ${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] }
216
236
Open Context Menu for File ${file }
217
237
Mouse Over ${MENU OPEN WITH }
218
238
Wait Until Page Contains Element ${editor }
@@ -221,15 +241,15 @@ Open ${file} in ${editor}
221
241
222
242
Clean Up After Working With File
223
243
[Arguments] ${file }
224
- Remove File ${OUTPUT DIR }${ / } home ${/ }${file }
244
+ Remove File ${NOTEBOOK DIR }${/ }${file }
225
245
Reset Application State
226
246
Lab Log Should Not Contain Known Error Messages
227
247
228
248
Setup Notebook
229
249
[Arguments] ${Language } ${file } ${isolated } =${True }
230
250
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 }
233
253
Run Keyword If ${isolated } Try to Close All Tabs
234
254
Open ${file } in ${MENU NOTEBOOK }
235
255
Capture Page Screenshot 00-notebook-opened.png
@@ -284,13 +304,13 @@ Open Context Menu Over
284
304
Prepare File for Editing
285
305
[Arguments] ${Language } ${Screenshots } ${file }
286
306
Set Tags language:${Language.lower() }
287
- Set Screenshot Directory ${OUTPUT DIR }${ / } screenshots ${/ }${Screenshots }${/ }${Language.lower() }
307
+ Set Screenshot Directory ${SCREENSHOTS DIR }${/ }${Screenshots }${/ }${Language.lower() }
288
308
Try to Close All Tabs
289
309
Open File ${file }
290
310
291
311
Open File
292
312
[Arguments] ${file }
293
- Copy File examples${/ }${file } ${OUTPUT DIR }${ / } home ${/ }${file }
313
+ Copy File examples${/ }${file } ${NOTEBOOK DIR }${/ }${file }
294
314
Open ${file } in ${MENU EDITOR }
295
315
Capture Page Screenshot 00-opened.png
296
316
@@ -323,3 +343,31 @@ Clean Up After Working with File and Settings
323
343
[Arguments] ${file }
324
344
Clean Up After Working With File ${file }
325
345
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