1
1
// Require modules used in the logic below
2
2
const jasmine = require ( 'jasmine' ) ;
3
3
const os = require ( 'os' ) ;
4
- const { Builder, By, Key, until} = require ( 'selenium-webdriver' ) ;
4
+ const { Builder, Options , By, Key, until} = require ( 'selenium-webdriver' ) ;
5
5
6
6
// You can use a remote Selenium Hub, but we are not doing that here
7
7
require ( 'chromedriver' ) ;
8
+
9
+ const chrome = require ( 'selenium-webdriver/chrome' ) ;
10
+ const options = new chrome . Options ( ) ;
11
+ options . addArguments ( '--remote-debugging-pipe' ) ;
12
+
8
13
const driver = new Builder ( )
9
- . forBrowser ( 'chrome' )
10
- . build ( ) ;
14
+ . forBrowser ( 'chrome' )
15
+ . setChromeOptions ( options )
16
+ . build ( ) ;
11
17
12
18
const baseUrl = "http://localhost:8080" ;
13
19
const password = "739f75e86e8d7843df146bac" ;
@@ -39,6 +45,10 @@ let login = async function() {
39
45
// once the Log in button has gone "stale."
40
46
await enterCredentialsAndLogin ( ) ;
41
47
console . log ( 'Logged in.' ) ;
48
+
49
+ console . log ( 'grant clipboard permissions if needed' ) ;
50
+ await driver . setPermission ( 'clipboard-read' , 'granted' ) ;
51
+ await driver . setPermission ( 'clipboard-write' , 'granted' ) ;
42
52
} ;
43
53
44
54
// Configure Jasmine's timeout value to account for longer tests.
@@ -264,6 +274,16 @@ async function findFileInput(driver) {
264
274
return await ibwrapper . findElement ( By . css ( ".input" ) ) ;
265
275
}
266
276
277
+ async function dismissTrustDialogue ( ) {
278
+ // Dismiss trust dialog if it comes up.
279
+ console . log ( 'check for the trust dialog' ) ;
280
+ let trustDialog = await driver . findElements ( By . css ( '.dialog-shadow' ) ) ;
281
+ if ( trustDialog . length !== 0 ) {
282
+ let trustButton = await driver . wait ( until . elementLocated ( byVisibleText ( "Yes, I trust the authors" ) ) ) ;
283
+ trustButton . click ( ) ;
284
+ }
285
+ }
286
+
267
287
// Define a category of tests using test framework, in this case Jasmine
268
288
describe ( "Basic element tests" , function ( ) {
269
289
// After each test, close the browser.
@@ -280,17 +300,11 @@ describe("Basic element tests", function() {
280
300
console . log ( 'wait for an element indicating that the workspace is up' ) ;
281
301
await driver . wait ( until . elementLocated ( By . css ( '.monaco-workbench' ) ) , 10 * 1000 ) ;
282
302
283
- // Things load more progressively in the current vs code.
303
+ // Things load more progressively in the current vs code.
284
304
const actions = driver . actions ( { async : true } ) ;
285
305
await actions . pause ( 3000 ) . perform ( ) ;
286
306
287
- // Dismiss trust dialog if it comes up.
288
- console . log ( 'check for the trust dialog' ) ;
289
- let trustDialog = await driver . findElements ( By . css ( '.dialog-shadow' ) ) ;
290
- if ( trustDialog . length !== 0 ) {
291
- let trustButton = await driver . wait ( until . elementLocated ( byVisibleText ( "Yes, I trust the authors" ) ) ) ;
292
- trustButton . click ( ) ;
293
- }
307
+ await dismissTrustDialogue ( ) ;
294
308
}
295
309
296
310
async function installVsix ( ) {
@@ -313,11 +327,26 @@ describe("Basic element tests", function() {
313
327
console . log ( 'install done' ) ;
314
328
}
315
329
330
+ // The launch json we have should have squiggles until the extension is installed.
331
+ async function checkSquiggleInLaunchJson ( ) {
332
+ await openFileTheLongWay ( driver , ".vscode/launch.json" ) ;
333
+
334
+ await dismissTrustDialogue ( ) ;
335
+
336
+ // Will abort if not found.
337
+ // There should be a squiggly here before the driver is installed.
338
+ let squiggly = await driver . wait ( until . elementLocated ( By . css ( ".squiggly-warning" ) ) ) ;
339
+
340
+ await dismissTrustDialogue ( ) ;
341
+ }
342
+
316
343
it ( "starts" , async function ( ) {
317
344
await login ( ) ;
318
345
319
346
await enterTheEditor ( ) ;
320
347
348
+ await checkSquiggleInLaunchJson ( ) ;
349
+
321
350
await installVsix ( ) ;
322
351
} ) ;
323
352
@@ -327,7 +356,7 @@ describe("Basic element tests", function() {
327
356
// This test should pass.
328
357
console . log ( 'Running test...' ) ;
329
358
330
- await openFile ( driver , 'collatz.cl' ) ;
359
+ await openFile ( driver , 'collatz.cl' ) ;
331
360
332
361
// If these elements can be found, we're highlighting.
333
362
console . log ( 'finding highlighting' ) ;
@@ -357,23 +386,23 @@ describe("Basic element tests", function() {
357
386
await sendReturn ( ) ;
358
387
359
388
console . log ( 'find the input box' ) ;
360
- let inputBox = await findFileInput ( driver ) ;
361
- await inputBox . click ( ) ;
389
+ let inputBox = await findFileInput ( driver ) ;
390
+ await inputBox . click ( ) ;
362
391
await inputBox . sendKeys ( "include/test-inc.clsp" ) ;
363
392
364
393
console . log ( 'accept input' ) ;
365
394
let okBox = await driver . wait ( until . elementLocated ( byVisibleText ( "OK" ) ) ) ;
366
395
okBox . click ( ) ;
367
396
368
- await wait ( 3.0 ) ;
397
+ await wait ( 3.0 ) ;
369
398
370
399
console . log ( 'Check the content of chialisp.json' ) ;
371
- await openFile ( driver , "chialisp.json" ) ;
400
+ await openFile ( driver , "chialisp.json" ) ;
372
401
373
402
console . log ( 'Check content' ) ;
374
403
let chialispText = await driver . wait ( until . elementLocated ( byVisibleText ( '"./project/include"' ) ) ) ;
375
404
376
- await openFile ( driver , "collatz.cl" ) ;
405
+ await openFile ( driver , "collatz.cl" ) ;
377
406
378
407
console . log ( 'comments should move' ) ;
379
408
let otherComment = await driver . wait ( until . elementLocated ( byVisibleText ( "defun-inline" ) ) ) ;
@@ -437,6 +466,20 @@ describe("Basic element tests", function() {
437
466
await closeBox . click ( ) ;
438
467
439
468
console . log ( "completion test done, should have no search box" ) ;
469
+
470
+ // Wait for the ui to settle.
471
+ await wait ( 2.0 ) ;
472
+
473
+ // Check that we apply our schema to the launch json
474
+ console . log ( 'Check launch json highlighting' ) ;
475
+ // This version of vs code opens from the most recent folder.
476
+ await openFileTheLongWay ( driver , "../.vscode/launch.json" ) ;
477
+
478
+ // Verify that installing the debugger made the lint warnings disappear in
479
+ // launch.json.
480
+ squigglies = await driver . findElements ( By . css ( '.squiggly-warning' ) ) ;
481
+ expect ( squigglies . length ) . toBe ( 0 ) ;
482
+
440
483
await wait ( 25.0 ) ;
441
484
442
485
//
@@ -447,7 +490,8 @@ describe("Basic element tests", function() {
447
490
// This test should pass.
448
491
console . log ( 'Running debug test 1...' ) ;
449
492
450
- await openFileTheLongWay ( driver , 'include/fact.clinc' ) ;
493
+ // Change folder.
494
+ await openFileTheLongWay ( driver , '../project/include/fact.clinc' ) ;
451
495
452
496
let debugButton = await driver . wait ( until . elementLocated ( By . css ( ".codicon-run-view-icon" ) ) ) ;
453
497
await debugButton . click ( ) ;
@@ -477,7 +521,7 @@ describe("Basic element tests", function() {
477
521
478
522
let expression = await driver . wait ( until . elementLocated ( By . css ( ".expression" ) ) ) ;
479
523
let text = await expression . getText ( ) ;
480
- while ( simplifyText ( text ) != "X: 4" ) {
524
+ while ( simplifyText ( text ) != "X= 4" ) {
481
525
await clickStepInto ( ) ;
482
526
console . log ( simplifyText ( text ) ) ;
483
527
expression = await driver . wait ( until . elementLocated ( By . css ( ".expression" ) ) ) ;
0 commit comments