File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ class SeleniumHelper {
28
28
'loadUri' ,
29
29
'rightClickText'
30
30
] ) ;
31
+
32
+ this . Key = webdriver . Key ; // map Key constants, for sending special keys
31
33
}
32
34
33
35
elementIsVisible ( element , timeoutMessage = 'elementIsVisible timed out' ) {
Original file line number Diff line number Diff line change
1
+ import path from 'path' ;
2
+ import SeleniumHelper from '../helpers/selenium-helper' ;
3
+
4
+ const {
5
+ clickText,
6
+ clickXpath,
7
+ findByXpath,
8
+ getDriver,
9
+ Key,
10
+ loadUri
11
+ } = new SeleniumHelper ( ) ;
12
+
13
+ const uri = path . resolve ( __dirname , '../../build/index.html' ) ;
14
+
15
+ let driver ;
16
+
17
+ describe ( 'Project state' , ( ) => {
18
+ beforeAll ( ( ) => {
19
+ driver = getDriver ( ) ;
20
+ } ) ;
21
+
22
+ afterAll ( async ( ) => {
23
+ await driver . quit ( ) ;
24
+ } ) ;
25
+
26
+ test ( 'File->New resets project title' , async ( ) => {
27
+ const defaultProjectTitle = 'Scratch Project' ;
28
+ await loadUri ( uri ) ;
29
+ const inputEl = await findByXpath ( `//input[@value="${ defaultProjectTitle } "]` ) ;
30
+ for ( let i = 0 ; i < defaultProjectTitle . length ; i ++ ) {
31
+ inputEl . sendKeys ( Key . BACK_SPACE ) ;
32
+ }
33
+ inputEl . sendKeys ( 'Changed title of project' ) ;
34
+ await clickText ( 'Costumes' ) ; // just to blur the input
35
+ // verify that project title has changed
36
+ await clickXpath ( '//input[@value="Changed title of project"]' ) ;
37
+ await clickXpath (
38
+ '//div[contains(@class, "menu-bar_menu-bar-item") and ' +
39
+ 'contains(@class, "menu-bar_hoverable")][span[text()="File"]]'
40
+ ) ;
41
+ await clickXpath ( '//li[span[text()="New"]]' ) ;
42
+ // project title should be default again
43
+ await clickXpath ( `//input[@value="${ defaultProjectTitle } "]` ) ;
44
+ } ) ;
45
+ } ) ;
You can’t perform that action at this time.
0 commit comments