diff --git a/package.json b/package.json index c16938f83b3b3189eb74984c0abcc2cae53996e3..708548e41e57fada32daa9bff8179aa06dfb68f3 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "start": "npm run i18n:msgs && webpack-dev-server", "unit-test": "jest test/unit", "integration-test": "jest --runInBand test/integration", - "test": "npm run lint && npm run unit-test && npm run build", + "test": "npm run lint && npm run unit-test && npm run build && npm run integration-test", "watch": "webpack --progress --colors --watch" }, "author": "Massachusetts Institute of Technology", diff --git a/test/helpers/selenium-helper.js b/test/helpers/selenium-helper.js index b250bcbe5e82798a4d05c426de198a967cc7a180..29edc67849aef2487f402f36bc9c5ac270630ce6 100644 --- a/test/helpers/selenium-helper.js +++ b/test/helpers/selenium-helper.js @@ -32,8 +32,8 @@ class SeleniumHelper { return this.findByXpath(xpath).then(el => el.click()); } - clickText (text) { - return this.clickXpath(`//body//*[contains(text(), '${text}')]`); + clickText (text, scope) { + return this.clickXpath(`//body//${scope || '*'}//*[contains(text(), '${text}')]`); } clickButton (text) { diff --git a/test/integration/test.js b/test/integration/test.js index 39e8c6faec5a2451e08fb0133a0dd34462738fb4..aa5029728d9b329aa44ed4e54b70d6e06b8c78e4 100644 --- a/test/integration/test.js +++ b/test/integration/test.js @@ -18,6 +18,10 @@ const errorWhitelist = [ let driver; +const blocksTabScope = "*[@id='react-tabs-1']"; +const costumesTabScope = "*[@id='react-tabs-3']"; +const soundsTabScope = "*[@id='react-tabs-5']"; + describe('costumes, sounds and variables', () => { beforeAll(() => { driver = getDriver(); @@ -34,8 +38,8 @@ describe('costumes, sounds and variables', () => { const el = await findByXpath("//input[@placeholder='what are you looking for?']"); await el.sendKeys('abb'); await clickText('abby-a'); // Should close the modal, then click the costumes in the selector - await clickText('costume1'); - await clickText('abby-a'); + await clickText('costume1', costumesTabScope); + await clickText('abby-a', costumesTabScope); const logs = await getLogs(errorWhitelist); await expect(logs).toEqual([]); }); @@ -47,10 +51,10 @@ describe('costumes, sounds and variables', () => { const el = await findByXpath("//input[@placeholder='what are you looking for?']"); await el.sendKeys('chom'); await clickText('chomp'); // Should close the modal, then click the sounds in the selector - await clickText('meow'); - await clickText('chomp'); + await clickText('meow', soundsTabScope); + await clickText('chomp', soundsTabScope); await clickXpath('//button[@title="Play"]'); - await clickText('meow'); + await clickText('meow', soundsTabScope); await clickXpath('//button[@title="Play"]'); await clickText('Louder'); @@ -79,7 +83,8 @@ describe('costumes, sounds and variables', () => { test('Creating variables', async () => { await driver.get(`file://${uri}`); await clickText('Blocks'); - await clickText('Data'); + await clickText('Data', blocksTabScope); + await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation await clickText('Create variable...'); let el = await findByXpath("//input[@placeholder='']"); await el.sendKeys('score');