diff --git a/src/containers/preview-modal.jsx b/src/containers/preview-modal.jsx index db913e9ea709c170c1c94c609e9ce9c93e5f12ff..8d50dc83c279e5c4b1660b012b7f15cd83344c3b 100644 --- a/src/containers/preview-modal.jsx +++ b/src/containers/preview-modal.jsx @@ -28,7 +28,7 @@ class PreviewModal extends React.Component { this.props.onTryIt(); } handleCancel () { - window.history.back(); + window.location.replace('https://scratch.mit.edu'); } supportedBrowser () { if (platform.name === 'IE') { diff --git a/test/integration/project-loading.test.js b/test/integration/project-loading.test.js index 3bc4ecde03dde48b261da3fc1e9f816db8e1f6e2..9d5cb0384252aa9aacb96bd3a780173050dda366 100644 --- a/test/integration/project-loading.test.js +++ b/test/integration/project-loading.test.js @@ -2,6 +2,7 @@ import path from 'path'; import SeleniumHelper from '../helpers/selenium-helper'; const { + clickText, clickXpath, getDriver, getLogs, @@ -12,7 +13,7 @@ const uri = path.resolve(__dirname, '../../build/index.html'); let driver; -describe('Loading projects by ID', () => { +describe('Loading scratch gui', () => { beforeAll(() => { driver = getDriver(); }); @@ -21,40 +22,50 @@ describe('Loading projects by ID', () => { await driver.quit(); }); - test('Load a project by ID', async () => { - 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('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/'); }); - test('Load a project by ID (fullscreen)', async () => { - 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 => { + describe('Loading projects by ID', () => { + + test('Load a project by ID', async () => { + 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 () => { + const prevSize = driver.manage() + .window() + .getSize(); + await new Promise(resolve => setTimeout(resolve, 2000)); driver.manage() .window() - .setSize(value.width, value.height); + .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([]); }); - const logs = await getLogs(); - await expect(logs).toEqual([]); }); });