From 21e9909f9d30ddf1d577da82350b41a47e4464eb Mon Sep 17 00:00:00 2001 From: Ben Wheeler <wheeler.benjamin@gmail.com> Date: Fri, 14 Dec 2018 16:28:21 -0500 Subject: [PATCH] revised and added tests to handle confirm on doing file new --- test/integration/project-loading.test.js | 39 ++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/test/integration/project-loading.test.js b/test/integration/project-loading.test.js index a3b492334..115c29576 100644 --- a/test/integration/project-loading.test.js +++ b/test/integration/project-loading.test.js @@ -115,9 +115,9 @@ describe('Loading scratch gui', () => { test('Creating new project resets active tab to Code tab', async () => { await loadUri(uri); await clickText('View 2.0 Project'); - const el = await findByXpath("//input[@placeholder='scratch.mit.edu/projects/123456789']"); + const inputElement = await findByXpath("//input[@placeholder='scratch.mit.edu/projects/123456789']"); const projectId = '96708228'; - await el.sendKeys(`scratch.mit.edu/projects/${projectId}`); + await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`); await clickXpath('//button[@title="View Project"]'); await new Promise(resolve => setTimeout(resolve, 2000)); await findByXpath('//*[span[text()="Costumes"]]'); @@ -127,6 +127,41 @@ describe('Loading scratch gui', () => { 'contains(@class, "menu-bar_hoverable")][span[text()="File"]]' ); await clickXpath('//li[span[text()="New"]]'); + await findByXpath('//*[div[@class="scratchCategoryMenu"]]'); + await clickText('Operators', scope.blocksTab); + }); + + test('Not logged in->made no changes to project->create new project should not show alert', async () => { + await loadUri(uri); + await clickText('View 2.0 Project'); + const inputElement = await findByXpath("//input[@placeholder='scratch.mit.edu/projects/123456789']"); + const projectId = '96708228'; + await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`); + await clickXpath('//button[@title="View Project"]'); + await new Promise(resolve => setTimeout(resolve, 2000)); + 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"]]'); + await findByXpath('//*[div[@class="scratchCategoryMenu"]]'); + await clickText('Operators', scope.blocksTab); + }); + + test('Not logged in->made a change to project->create new project should show alert', async () => { + await loadUri(uri); + await clickText('View 2.0 Project'); + const inputElement = await findByXpath("//input[@placeholder='scratch.mit.edu/projects/123456789']"); + const projectId = '96708228'; + await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`); + await clickXpath('//button[@title="View Project"]'); + await new Promise(resolve => setTimeout(resolve, 2000)); + await clickText('move'); + 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"]]'); driver.switchTo() .alert() .accept(); -- GitLab