Skip to content
Snippets Groups Projects
Unverified Commit 10e78150 authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub
Browse files

Merge pull request #920 from paulkaplan/fix-sound-editor-explosion

Prevent deleting a sound from exploding
parents 4180b226 022bec3e
No related branches found
No related tags found
No related merge requests found
...@@ -52,20 +52,18 @@ class SoundTab extends React.Component { ...@@ -52,20 +52,18 @@ class SoundTab extends React.Component {
render () { render () {
const { const {
editingTarget, vm,
sprites,
stage,
onNewSoundFromLibraryClick, onNewSoundFromLibraryClick,
onNewSoundFromRecordingClick onNewSoundFromRecordingClick
} = this.props; } = this.props;
const target = editingTarget && sprites[editingTarget] ? sprites[editingTarget] : stage; if (!vm.editingTarget) {
if (!target) {
return null; 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, url: soundIcon,
name: sound.name name: sound.name
...@@ -106,7 +104,7 @@ class SoundTab extends React.Component { ...@@ -106,7 +104,7 @@ class SoundTab extends React.Component {
onDeleteClick={this.handleDeleteSound} onDeleteClick={this.handleDeleteSound}
onItemClick={this.handleSelectSound} onItemClick={this.handleSelectSound}
> >
{editingTarget && target.sounds && target.sounds.length > 0 ? ( {sprite.sounds && sprite.sounds.length > 0 ? (
<SoundEditor soundIndex={this.state.selectedSoundIndex} /> <SoundEditor soundIndex={this.state.selectedSoundIndex} />
) : null} ) : null}
{this.props.soundRecorderVisible ? ( {this.props.soundRecorderVisible ? (
......
...@@ -4,7 +4,7 @@ import bindAll from 'lodash.bindall'; ...@@ -4,7 +4,7 @@ import bindAll from 'lodash.bindall';
import 'chromedriver'; // register path import 'chromedriver'; // register path
import webdriver from 'selenium-webdriver'; import webdriver from 'selenium-webdriver';
const {By, until} = webdriver; const {By, until, Button} = webdriver;
class SeleniumHelper { class SeleniumHelper {
constructor () { constructor () {
...@@ -15,7 +15,8 @@ class SeleniumHelper { ...@@ -15,7 +15,8 @@ class SeleniumHelper {
'findByText', 'findByText',
'findByXpath', 'findByXpath',
'getDriver', 'getDriver',
'getLogs' 'getLogs',
'rightClickText'
]); ]);
} }
...@@ -42,6 +43,12 @@ class SeleniumHelper { ...@@ -42,6 +43,12 @@ class SeleniumHelper {
return this.findByText(text, scope).then(el => el.click()); 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) { clickButton (text) {
return this.clickXpath(`//button[contains(text(), '${text}')]`); return this.clickXpath(`//button[contains(text(), '${text}')]`);
} }
......
...@@ -8,7 +8,8 @@ const { ...@@ -8,7 +8,8 @@ const {
findByText, findByText,
findByXpath, findByXpath,
getDriver, getDriver,
getLogs getLogs,
rightClickText
} = new SeleniumHelper(); } = new SeleniumHelper();
const uri = path.resolve(__dirname, '../../build/index.html'); const uri = path.resolve(__dirname, '../../build/index.html');
...@@ -34,7 +35,6 @@ describe('costumes, sounds and variables', () => { ...@@ -34,7 +35,6 @@ describe('costumes, sounds and variables', () => {
await driver.quit(); await driver.quit();
}); });
test('Blocks report when clicked in the toolbox', async () => { test('Blocks report when clicked in the toolbox', async () => {
await driver.get(`file://${uri}`); await driver.get(`file://${uri}`);
await clickText('Blocks'); await clickText('Blocks');
...@@ -75,15 +75,20 @@ describe('costumes, sounds and variables', () => { ...@@ -75,15 +75,20 @@ describe('costumes, sounds and variables', () => {
test('Adding a sound', async () => { test('Adding a sound', async () => {
await driver.get(`file://${uri}`); await driver.get(`file://${uri}`);
await clickText('Sounds'); 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'); await clickText('Add Sound');
const el = await findByXpath("//input[@placeholder='what are you looking for?']"); const el = await findByXpath("//input[@placeholder='what are you looking for?']");
await el.sendKeys('chom'); await el.sendKeys('chom');
await clickText('chomp'); // Should close the modal, then click the sounds in the selector await clickText('chomp'); // Should close the modal, then click the sounds in the selector
await clickText('meow', soundsTabScope);
await clickText('chomp', soundsTabScope); await clickText('chomp', soundsTabScope);
await clickXpath('//button[@title="Play"]'); await clickXpath('//button[@title="Play"]');
await clickText('meow', soundsTabScope);
await clickXpath('//button[@title="Play"]');
await clickText('Louder'); await clickText('Louder');
await clickText('Softer'); await clickText('Softer');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment