77 lines
2.5 KiB
JavaScript
77 lines
2.5 KiB
JavaScript
import path from 'path';
|
|
import SeleniumHelper from '../helpers/selenium-helper';
|
|
|
|
const {
|
|
clickText,
|
|
clickXpath,
|
|
getDriver,
|
|
getLogs,
|
|
loadUri
|
|
} = new SeleniumHelper();
|
|
|
|
const uri = path.resolve(__dirname, '../../build/index.html');
|
|
|
|
let driver;
|
|
|
|
describe('Loading scratch gui', () => {
|
|
beforeAll(() => {
|
|
driver = getDriver();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await driver.quit();
|
|
});
|
|
|
|
test('The "Not Now" button sends you to scratch', async () => {
|
|
await loadUri(uri);
|
|
await clickText('Not Now');
|
|
const currentUrl = await driver.getCurrentUrl();
|
|
await expect(currentUrl).toEqual('https://scratch.mit.edu/');
|
|
});
|
|
|
|
describe('Loading projects by ID', () => {
|
|
test('Load a project by ID directly through url', async () => {
|
|
await driver.quit(); // Reset driver to test hitting # url directly
|
|
driver = getDriver();
|
|
|
|
const projectId = '96708228';
|
|
await loadUri(`${uri}#${projectId}`);
|
|
await clickXpath('//button[@title="tryit"]');
|
|
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([]);
|
|
});
|
|
|
|
test('Load a project by ID (fullscreen)', async () => {
|
|
await driver.quit(); // Reset driver to test hitting # url directly
|
|
driver = getDriver();
|
|
|
|
const prevSize = driver.manage()
|
|
.window()
|
|
.getSize();
|
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
driver.manage()
|
|
.window()
|
|
.setSize(1920, 1080);
|
|
const projectId = '96708228';
|
|
await loadUri(`${uri}#${projectId}`);
|
|
await clickXpath('//button[@title="tryit"]');
|
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
await clickXpath('//img[@title="Full Screen Control"]');
|
|
await clickXpath('//img[@title="Go"]');
|
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
await clickXpath('//img[@title="Stop"]');
|
|
prevSize.then(value => {
|
|
driver.manage()
|
|
.window()
|
|
.setSize(value.width, value.height);
|
|
});
|
|
const logs = await getLogs();
|
|
await expect(logs).toEqual([]);
|
|
});
|
|
});
|
|
});
|