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

Prevent crash after deleting sprite that had been highlighted

parent 5f10ba94
Branches
No related tags found
No related merge requests found
......@@ -32,7 +32,8 @@ class TargetHighlight extends React.Component {
vm
} = this.props;
if (!(highlightedTargetId && vm && vm.renderer)) return null;
if (!(highlightedTargetId && vm && vm.renderer &&
vm.runtime.getTargetById(highlightedTargetId))) return null;
const target = vm.runtime.getTargetById(highlightedTargetId);
const bounds = vm.renderer.getBounds(target.drawableID);
......
import path from 'path';
import SeleniumHelper from '../helpers/selenium-helper';
const {
clickText,
clickXpath,
rightClickText,
getDriver,
getLogs,
loadUri,
scope
} = new SeleniumHelper();
const uri = path.resolve(__dirname, '../../build/index.html');
let driver;
describe('Loading scratch gui', () => {
beforeAll(() => {
driver = getDriver();
});
afterAll(async () => {
await driver.quit();
});
test('Switching small/large stage after highlighting and deleting sprite', async () => {
await loadUri(uri);
await clickXpath('//button[@title="Try It"]');
// Highlight the sprite
await clickText('Sprite1', scope.spriteTile);
// Delete it
await rightClickText('Sprite1', scope.spriteTile);
await clickText('delete', scope.spriteTile);
// Go to small stage mode
await clickXpath('//img[@alt="Switch to small stage"]');
// Confirm app still working
await clickXpath('//img[@alt="Switch to large stage"]');
const logs = await getLogs();
await expect(logs).toEqual([]);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment