File size: 1,390 Bytes
6bcb42f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import path from 'path';
import SeleniumHelper from '../helpers/selenium-helper';

const {
    clickText,
    clickXpath,
    findByXpath,
    getDriver,
    Key,
    loadUri
} = new SeleniumHelper();

const uri = path.resolve(__dirname, '../../build/index.html');

let driver;

describe('Project state', () => {
    beforeAll(() => {
        driver = getDriver();
    });

    afterAll(async () => {
        await driver.quit();
    });

    test('File->New resets project title', async () => {
        const defaultProjectTitle = 'Scratch Project';
        await loadUri(uri);
        const inputEl = await findByXpath(`//input[@value="${defaultProjectTitle}"]`);
        for (let i = 0; i < defaultProjectTitle.length; i++) {
            inputEl.sendKeys(Key.BACK_SPACE);
        }
        inputEl.sendKeys('Changed title of project');
        await clickText('Costumes'); // just to blur the input
        // verify that project title has changed
        await clickXpath('//input[@value="Changed title of project"]');
        await clickXpath(
            '//div[contains(@class, "menu-bar_menu-bar-item") and ' +
            'contains(@class, "menu-bar_hoverable")][span[text()="File"]]'
        );
        await clickXpath('//li[span[text()="New"]]');
        // project title should be default again
        await clickXpath(`//input[@value="${defaultProjectTitle}"]`);
    });
});