diff --git a/src/containers/sound-tab.jsx b/src/containers/sound-tab.jsx index 1984923d541427b16a82980d1c6bc627f4541413..6143175ddace4a3755d81c743bc8c81192cd23ad 100644 --- a/src/containers/sound-tab.jsx +++ b/src/containers/sound-tab.jsx @@ -52,20 +52,18 @@ class SoundTab extends React.Component { render () { const { - editingTarget, - sprites, - stage, + vm, onNewSoundFromLibraryClick, onNewSoundFromRecordingClick } = this.props; - const target = editingTarget && sprites[editingTarget] ? sprites[editingTarget] : stage; - - if (!target) { + if (!vm.editingTarget) { return null; } - const sounds = target.sounds ? target.sounds.map(sound => ( + const sprite = vm.editingTarget.sprite; + + const sounds = sprite.sounds ? sprite.sounds.map(sound => ( { url: soundIcon, name: sound.name @@ -106,7 +104,7 @@ class SoundTab extends React.Component { onDeleteClick={this.handleDeleteSound} onItemClick={this.handleSelectSound} > - {editingTarget && target.sounds && target.sounds.length > 0 ? ( + {sprite.sounds && sprite.sounds.length > 0 ? ( <SoundEditor soundIndex={this.state.selectedSoundIndex} /> ) : null} {this.props.soundRecorderVisible ? ( diff --git a/test/helpers/selenium-helper.js b/test/helpers/selenium-helper.js index c4f36ca05b712e36c30246c269d47c6c1afa78ce..07002a94a7ba1a39cc64a14fe882db2d34140de1 100644 --- a/test/helpers/selenium-helper.js +++ b/test/helpers/selenium-helper.js @@ -4,7 +4,7 @@ import bindAll from 'lodash.bindall'; import 'chromedriver'; // register path import webdriver from 'selenium-webdriver'; -const {By, until} = webdriver; +const {By, until, Button} = webdriver; class SeleniumHelper { constructor () { @@ -15,7 +15,8 @@ class SeleniumHelper { 'findByText', 'findByXpath', 'getDriver', - 'getLogs' + 'getLogs', + 'rightClickText' ]); } @@ -42,6 +43,12 @@ class SeleniumHelper { return this.findByText(text, scope).then(el => el.click()); } + rightClickText (text, scope) { + return this.findByText(text, scope).then(el => this.driver.actions() + .click(el, Button.RIGHT) + .perform()); + } + clickButton (text) { return this.clickXpath(`//button[contains(text(), '${text}')]`); } diff --git a/test/integration/test.js b/test/integration/test.js index 86729cf277017b5cb99f9b858514633583564d47..c2b5f2945d9610d7ea42efe6a58089be89d4da8b 100644 --- a/test/integration/test.js +++ b/test/integration/test.js @@ -8,7 +8,8 @@ const { findByText, findByXpath, getDriver, - getLogs + getLogs, + rightClickText } = new SeleniumHelper(); const uri = path.resolve(__dirname, '../../build/index.html'); @@ -34,7 +35,6 @@ describe('costumes, sounds and variables', () => { await driver.quit(); }); - test('Blocks report when clicked in the toolbox', async () => { await driver.get(`file://${uri}`); await clickText('Blocks'); @@ -75,15 +75,20 @@ describe('costumes, sounds and variables', () => { test('Adding a sound', async () => { await driver.get(`file://${uri}`); await clickText('Sounds'); + + // Delete the sound + await rightClickText('meow', soundsTabScope); + await clickText('delete', soundsTabScope); + await driver.switchTo().alert() + .accept(); + + // Add a sound await clickText('Add Sound'); 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', soundsTabScope); await clickText('chomp', soundsTabScope); await clickXpath('//button[@title="Play"]'); - await clickText('meow', soundsTabScope); - await clickXpath('//button[@title="Play"]'); await clickText('Louder'); await clickText('Softer');