Skip to content
Snippets Groups Projects
Commit b12ea50c authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Make sure to switch back to code when adding new sprites

parent d1024cdd
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,9 @@ class SpriteLibrary extends React.PureComponent {
clearInterval(this.intervalId);
}
handleItemSelect (item) {
this.props.vm.addSprite(JSON.stringify(item.json));
this.props.vm.addSprite(JSON.stringify(item.json)).then(() => {
this.props.onActivateBlocksTab();
});
analytics.event({
category: 'library',
action: 'Select Sprite',
......@@ -95,6 +97,7 @@ class SpriteLibrary extends React.PureComponent {
SpriteLibrary.propTypes = {
intl: intlShape.isRequired,
onActivateBlocksTab: PropTypes.func.isRequired,
onRequestClose: PropTypes.func,
vm: PropTypes.instanceOf(VM).isRequired
};
......
......@@ -9,7 +9,7 @@ import {
closeSpriteLibrary
} from '../reducers/modals';
import {activateTab, COSTUMES_TAB_INDEX} from '../reducers/editor-tab';
import {activateTab, COSTUMES_TAB_INDEX, BLOCKS_TAB_INDEX} from '../reducers/editor-tab';
import {setReceivedBlocks} from '../reducers/hovered-target';
import {setRestore} from '../reducers/restore-deletion';
import DragConstants from '../lib/drag-constants';
......@@ -23,6 +23,7 @@ class TargetPane extends React.Component {
constructor (props) {
super(props);
bindAll(this, [
'handleActivateBlocksTab',
'handleBlockDragEnd',
'handleChangeSpriteRotationStyle',
'handleChangeSpriteDirection',
......@@ -109,7 +110,8 @@ class TargetPane extends React.Component {
}
handleSurpriseSpriteClick () {
const item = spriteLibraryContent[Math.floor(Math.random() * spriteLibraryContent.length)];
this.props.vm.addSprite(JSON.stringify(item.json));
this.props.vm.addSprite(JSON.stringify(item.json))
.then(this.handleActivateBlocksTab);
}
handlePaintSpriteClick () {
const formatMessage = this.props.intl.formatMessage;
......@@ -124,8 +126,12 @@ class TargetPane extends React.Component {
});
});
}
handleActivateBlocksTab () {
this.props.onActivateTab(BLOCKS_TAB_INDEX);
}
handleNewSprite (spriteJSONString) {
this.props.vm.addSprite(spriteJSONString);
this.props.vm.addSprite(spriteJSONString)
.then(this.handleActivateBlocksTab);
}
handleFileUploadClick () {
this.fileInput.click();
......
......@@ -33,6 +33,7 @@ describe('Working with sprites', () => {
await clickXpath('//button[@aria-label="Choose a Sprite"]');
await clickText('Apple', scope.modal); // Closes modal
await rightClickText('Apple', scope.spriteTile); // Make sure it is there
await findByText('Motion'); // Make sure we are back to the code tab
const logs = await getLogs();
await expect(logs).toEqual([]);
});
......@@ -49,6 +50,19 @@ describe('Working with sprites', () => {
await expect(logs).toEqual([]);
});
test('Adding a sprite by paint button', async () => {
await loadUri(uri);
await clickXpath('//button[@title="Try It"]');
const el = await findByXpath('//button[@aria-label="Choose a Sprite"]');
await driver.actions().mouseMove(el)
.perform();
await driver.sleep(500); // Wait for thermometer menu to come up
await clickXpath('//button[@aria-label="Paint"]');
await findByText('Convert to Bitmap'); // Make sure we are on the paint editor
const logs = await getLogs();
await expect(logs).toEqual([]);
});
test('Deleting only sprite does not crash', async () => {
await loadUri(uri);
await clickXpath('//button[@title="Try It"]');
......
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