diff --git a/src/containers/list-monitor.jsx b/src/containers/list-monitor.jsx index 4b7cc80dbc299c0830b135a11e4318aad645688f..d6e8bf7ae2e32f37b3006bf6ac3c80e58bacb1bf 100644 --- a/src/containers/list-monitor.jsx +++ b/src/containers/list-monitor.jsx @@ -31,6 +31,11 @@ class ListMonitor extends React.Component { } handleActivate (index) { + // Do nothing if activating the currently active item + if (this.state.activeIndex === index) { + return; + } + this.setState({ activeIndex: index, activeValue: this.props.value[index] @@ -178,6 +183,6 @@ ListMonitor.propTypes = { y: PropTypes.number }; -const mapStateToProps = state => ({vm: state.vm}); +const mapStateToProps = state => ({vm: state.scratchGui.vm}); export default connect(mapStateToProps)(ListMonitor); diff --git a/src/containers/slider-monitor.jsx b/src/containers/slider-monitor.jsx index 8df6f92a9879c7aaa9ee364424ac0dd955b3e688..b6f43eed5f86d67025a0ce0d9a7de8199a830468 100644 --- a/src/containers/slider-monitor.jsx +++ b/src/containers/slider-monitor.jsx @@ -54,6 +54,6 @@ SliderMonitor.propTypes = { vm: PropTypes.instanceOf(VM) }; -const mapStateToProps = state => ({vm: state.vm}); +const mapStateToProps = state => ({vm: state.scratchGui.vm}); export default connect(mapStateToProps)(SliderMonitor); diff --git a/test/helpers/selenium-helper.js b/test/helpers/selenium-helper.js index 8ed17e2f7ab76cef8f0b97988f71b8092733af0c..70e3bfed8d89a7059280d62a43d7784e97d592ed 100644 --- a/test/helpers/selenium-helper.js +++ b/test/helpers/selenium-helper.js @@ -31,7 +31,8 @@ class SeleniumHelper { modal: '*[@class="ReactModalPortal"]', reportedValue: '*[@class="blocklyDropDownContent"]', soundsTab: "*[@id='react-tabs-5']", - spriteTile: '*[starts-with(@class,"react-contextmenu-wrapper")]' + spriteTile: '*[starts-with(@class,"react-contextmenu-wrapper")]', + monitors: '*[starts-with(@class,"stage_monitor-wrapper")]' }; } diff --git a/test/integration/blocks.test.js b/test/integration/blocks.test.js index 2e0466d3bfbb0a0e9fe8e03ca362461a5d8ddbba..e7fcf0b827f94f5f8baedb3237a4a4728e6eaa20 100644 --- a/test/integration/blocks.test.js +++ b/test/integration/blocks.test.js @@ -10,6 +10,7 @@ const { getDriver, getLogs, loadUri, + rightClickText, scope } = new SeleniumHelper(); @@ -81,6 +82,45 @@ describe('Working with the blocks', () => { await clickText('score', scope.blocksTab); await findByText('0', scope.reportedValue); // Tooltip with result + // And there should be a monitor visible + await rightClickText('score', scope.monitors); + await clickText('slider'); + + const logs = await getLogs(); + await expect(logs).toEqual([]); + }); + + test('Creating a list', async () => { + await loadUri(uri); + await clickXpath('//button[@title="tryit"]'); + await clickText('Code'); + await clickText('Variables', scope.blocksTab); + await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation + + await clickText('Make a List'); + let el = await findByXpath("//input[@placeholder='']"); + await el.sendKeys('list1'); + await clickButton('OK'); + + // Click the "add <thing> to list" block 3 times + await clickText('add', scope.blocksTab); + await clickText('add', scope.blocksTab); + await clickText('add', scope.blocksTab); + await clickText('list1', scope.blocksTab); + await findByText('thing thing thing', scope.reportedValue); // Tooltip with result + + // Interact with the monitor, adding an item + await findByText('list1', scope.monitors); // Just to be sure it is there + await clickText('+', scope.monitors); + el = await findByXpath(`//body//${scope.monitors}//input`); + await el.sendKeys('thing2'); + await el.click(); // Regression for "clicking active input erases value" bug. + await clickText('list1', scope.monitors); // Blur the input to submit + + // Check that the list value has been propagated. + await clickText('list1', scope.blocksTab); + await findByText('thing thing thing thing2', scope.reportedValue); // Tooltip with result + const logs = await getLogs(); await expect(logs).toEqual([]); });