@@ -22,15 +22,38 @@ class Page {
22
22
}
23
23
24
24
get job ( ) {
25
- return new Job ( this . client . element ( ".job" ) ) ;
25
+ return new Job ( this . client , this . client . element ( ".job" ) ) ;
26
26
}
27
27
}
28
28
29
- class Job {
30
- constructor ( private job : WebdriverIO . Client < WebdriverIO . RawResult < WebdriverIO . Element > > & WebdriverIO . RawResult < WebdriverIO . Element > ) { }
29
+ abstract class Block {
30
+ constructor (
31
+ protected client : SpectronClient ,
32
+ protected selector : WebdriverIO . Client < WebdriverIO . RawResult < WebdriverIO . Element > > & WebdriverIO . RawResult < WebdriverIO . Element >
33
+ ) { }
34
+ }
31
35
36
+ class Job extends Block {
32
37
get output ( ) {
33
- return this . job . element ( ".output" ) ;
38
+ return this . selector . element ( ".output" ) ;
39
+ }
40
+
41
+ get menu ( ) {
42
+ return new JobMenu ( this . client , this . selector . element ( ".jobMenu" ) ) ;
43
+ }
44
+ }
45
+
46
+ class JobMenu extends Block {
47
+ get sigkillItem ( ) {
48
+ return this . client . element ( ".floatingMenuItem:first-of-type" ) ;
49
+ }
50
+
51
+ get sigtermItem ( ) {
52
+ return this . client . element ( ".floatingMenuItem:last-of-type" ) ;
53
+ }
54
+
55
+ open ( ) {
56
+ return this . selector . click ( ) ;
34
57
}
35
58
}
36
59
@@ -43,7 +66,7 @@ describe("application launch", function () {
43
66
beforeEach ( async ( ) => {
44
67
app = new Application ( { path : "node_modules/.bin/electron" , args : [ "." ] } ) ;
45
68
await app . start ( ) ;
46
- app . client . waitUntilWindowLoaded ( ) ;
69
+ await app . client . waitUntilWindowLoaded ( ) ;
47
70
page = new Page ( app . client ) ;
48
71
return page . waitTillLoaded ( ) ;
49
72
} ) ;
@@ -56,25 +79,21 @@ describe("application launch", function () {
56
79
57
80
it ( "can execute a command" , async ( ) => {
58
81
await page . executeCommand ( "echo expected-text" ) ;
59
- const text = await page . job . output . getText ( ) ;
82
+ const output = await page . job . output . getText ( ) ;
60
83
61
- expect ( text ) . to . contain ( "expected-text" ) ;
84
+ expect ( output ) . to . contain ( "expected-text" ) ;
62
85
} ) ;
63
86
64
- it ( "send signals via button" , async ( ) => {
87
+ it . only ( "send signals via button" , async ( ) => {
65
88
await page . executeCommand ( `node ${ join ( __dirname , "test_files" , "print_on_sigterm.js" ) } ` ) ;
66
89
67
- return app . client . waitForExist ( ".jobMenu" , timeout ) .
68
- click ( ".jobMenu" ) .
69
- waitForExist ( ".floatingMenuItem" ) .
70
- click ( ".floatingMenuItem:last-of-type" ) .
71
- click ( ".jobMenu" ) .
72
- waitForExist ( ".floatingMenuItem" ) .
73
- click ( ".floatingMenuItem:first-of-type" ) .
74
- waitForExist ( ".prompt" ) .
75
- getText ( ".job .output" ) .
76
- then ( output => {
77
- expect ( output ) . to . eql ( "Received SIGTERM" ) ;
78
- } ) ;
90
+ await page . job . menu . open ( ) ;
91
+ await page . job . menu . sigtermItem . click ( ) ;
92
+
93
+ await page . job . menu . open ( ) ;
94
+ await page . job . menu . sigkillItem . click ( ) ;
95
+
96
+ const output = await page . job . output . getText ( ) ;
97
+ expect ( output ) . to . eql ( "Received SIGTERM" ) ;
79
98
} ) ;
80
99
} ) ;
0 commit comments