Spaces:
Running
Running
File size: 3,541 Bytes
f2bee8a |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
/* globals Promise */
import path from 'path';
import SeleniumHelper from '../helpers/selenium-helper';
const {
clickButton,
clickText,
clickXpath,
findByXpath,
getDriver,
getLogs,
loadUri
} = new SeleniumHelper();
let driver;
describe('player example', () => {
const uri = path.resolve(__dirname, '../../build/player.html');
beforeAll(() => {
driver = getDriver();
});
afterAll(async () => {
await driver.quit();
});
test.skip('Player: load a project by ID', async () => {
const projectId = '96708228';
await loadUri(`${uri}#${projectId}`);
await clickXpath('//img[@title="Go"]');
await new Promise(resolve => setTimeout(resolve, 2000));
await clickXpath('//img[@title="Stop"]');
const logs = await getLogs();
await expect(logs).toEqual([]);
const projectRequests = await driver.manage().logs()
.get('performance')
.then(pLogs => pLogs.map(log => JSON.parse(log.message).message)
.filter(m => m.method === 'Network.requestWillBeSent')
.map(m => m.params.request.url)
.filter(url => url === 'https://projects.scratch.mit.edu/96708228')
);
await expect(projectRequests).toEqual(['https://projects.scratch.mit.edu/96708228']);
});
});
describe('blocks example', () => {
const uri = path.resolve(__dirname, '../../build/blocks-only.html');
beforeAll(() => {
driver = getDriver();
});
afterAll(async () => {
await driver.quit();
});
test.skip('Blocks: load a project by ID', async () => {
const projectId = '96708228';
await loadUri(`${uri}#${projectId}`);
await new Promise(resolve => setTimeout(resolve, 2000));
await clickXpath('//img[@title="Go"]');
await new Promise(resolve => setTimeout(resolve, 2000));
await clickXpath('//img[@title="Stop"]');
const logs = await getLogs();
await expect(logs).toEqual([]);
const projectRequests = await driver.manage().logs()
.get('performance')
.then(pLogs => pLogs.map(log => JSON.parse(log.message).message)
.filter(m => m.method === 'Network.requestWillBeSent')
.map(m => m.params.request.url)
.filter(url => url === 'https://projects.scratch.mit.edu/96708228')
);
await expect(projectRequests).toEqual(['https://projects.scratch.mit.edu/96708228']);
});
// skipping per https://github.com/LLK/scratch-gui/issues/4902 until we have better approach
test.skip('Change categories', async () => {
await loadUri(`${uri}`);
await clickText('Looks');
await clickText('Sound');
await clickText('Events');
await clickText('Control');
await clickText('Sensing');
await clickText('Operators');
await clickText('Variables');
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation
await clickText('Make a Variable');
let el = await findByXpath("//input[@name='New variable name:']");
await el.sendKeys('score');
await clickButton('OK');
await clickText('Make a Variable');
el = await findByXpath("//input[@name='New variable name:']");
await el.sendKeys('second variable');
await clickButton('OK');
const logs = await getLogs();
await expect(logs).toEqual([]);
});
});
|