diff --git a/test/fixtures/project1.sb3 b/test/fixtures/project1.sb3 new file mode 100644 index 0000000000000000000000000000000000000000..747ecd37a3a8d4a11b6abd6d6b388fe395a633d8 Binary files /dev/null and b/test/fixtures/project1.sb3 differ diff --git a/test/integration/menu-bar.test.js b/test/integration/menu-bar.test.js index 6529b7bc4550a1114f9022e76c062ffbaff4f5d2..223161b8fbdbb49b9697c07e810f2828ab34f5fc 100644 --- a/test/integration/menu-bar.test.js +++ b/test/integration/menu-bar.test.js @@ -4,9 +4,13 @@ import SeleniumHelper from '../helpers/selenium-helper'; const { clickText, clickXpath, + findByText, findByXpath, getDriver, - loadUri + loadUri, + rightClickText, + scope, + waitUntilGone } = new SeleniumHelper(); const uri = path.resolve(__dirname, '../../build/index.html'); @@ -74,4 +78,32 @@ describe('Menu bar settings', () => { await clickText('Costumes'); // just to blur the input await clickXpath('//input[@value="Scratch Project - Personalized"]'); }); + + test('User is not warned before uploading project file over a fresh project', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + await clickText('File'); + const input = await findByXpath('//input[@accept=".sb,.sb2,.sb3"]'); + await input.sendKeys(path.resolve(__dirname, '../fixtures/project1.sb3')); + await waitUntilGone(findByText('Loading')); + // No replace alert since no changes were made + await findByText('project1-sprite'); + }); + + test('User is warned before uploading project file over an edited project', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + + // Change the project by deleting a sprite + await rightClickText('Sprite1', scope.spriteTile); + await clickText('delete', scope.spriteTile); + + await clickText('File'); + const input = await findByXpath('//input[@accept=".sb,.sb2,.sb3"]'); + await input.sendKeys(path.resolve(__dirname, '../fixtures/project1.sb3')); + await driver.switchTo().alert() + .accept(); + await waitUntilGone(findByText('Loading')); + await findByText('project1-sprite'); + }); });