diff --git a/src/containers/backdrop-library.jsx b/src/containers/backdrop-library.jsx index 5a02660385dcac2232b7598ac4483c3a31413923..9d7a709ccbf53b031ffa56e8b3f6c669d37e3808 100644 --- a/src/containers/backdrop-library.jsx +++ b/src/containers/backdrop-library.jsx @@ -5,11 +5,6 @@ import {defineMessages, injectIntl, intlShape} from 'react-intl'; import {connect} from 'react-redux'; import VM from 'scratch-vm'; -import { - activateTab, - COSTUMES_TAB_INDEX -} from '../reducers/editor-tab'; - import analytics from '../lib/analytics'; import backdropLibraryContent from '../lib/libraries/backdrops.json'; import backdropTags from '../lib/libraries/backdrop-tags'; @@ -40,7 +35,6 @@ class BackdropLibrary extends React.Component { skinId: null }; this.props.vm.setEditingTarget(this.props.stageID); - this.props.onActivateTab(COSTUMES_TAB_INDEX); this.props.vm.addBackdrop(item.md5, vmBackdrop); analytics.event({ category: 'library', @@ -64,7 +58,6 @@ class BackdropLibrary extends React.Component { BackdropLibrary.propTypes = { intl: intlShape.isRequired, - onActivateTab: PropTypes.func.isRequired, onRequestClose: PropTypes.func, stageID: PropTypes.string.isRequired, vm: PropTypes.instanceOf(VM).isRequired @@ -74,9 +67,7 @@ const mapStateToProps = state => ({ stageID: state.scratchGui.targets.stage.id }); -const mapDispatchToProps = dispatch => ({ - onActivateTab: tab => dispatch(activateTab(tab)) -}); +const mapDispatchToProps = () => ({}); export default injectIntl(connect( mapStateToProps, diff --git a/test/integration/backdrops.test.js b/test/integration/backdrops.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9a527b2c9d4caa39287b9566af459648efb6ae7b --- /dev/null +++ b/test/integration/backdrops.test.js @@ -0,0 +1,52 @@ +import path from 'path'; +import SeleniumHelper from '../helpers/selenium-helper'; + +const { + clickText, + clickXpath, + findByXpath, + getDriver, + getLogs, + loadUri, + scope +} = new SeleniumHelper(); + +const uri = path.resolve(__dirname, '../../build/index.html'); + +let driver; + +describe('Working with backdrops', () => { + beforeAll(() => { + driver = getDriver(); + }); + + afterAll(async () => { + await driver.quit(); + }); + + test('Adding a backdrop from the library', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + + // Start on the sounds tab of sprite1 to test switching behavior + await clickText('Sounds'); + + // Add a backdrop without selecting the stage first to test switching + await clickXpath('//button[@aria-label="Choose a Backdrop"]'); + const el = await findByXpath("//input[@placeholder='Search']"); + await el.sendKeys('blue'); + await clickText('Blue Sky'); // Adds the backdrop + + // Make sure the stage is selected and the sound tab remains selected. + // This is different from Scratch2 which selected backdrop tab automatically + // See issue #3500 + await clickText('pop', scope.soundsTab); + + // Make sure the backdrop was actually added by going to the backdrops tab + await clickText('Backdrops'); + await clickText('Blue Sky', scope.costumesTab); + + const logs = await getLogs(); + await expect(logs).toEqual([]); + }); +}); diff --git a/test/integration/costumes.test.js b/test/integration/costumes.test.js index 3f1e6714cfe6e69689cf9fc29f9e90957f64cdaa..d46e1a4b07d43c15d4efcdfe555c5c868dd1d9af 100644 --- a/test/integration/costumes.test.js +++ b/test/integration/costumes.test.js @@ -80,17 +80,6 @@ describe('Working with costumes', () => { await expect(logs).toEqual([]); }); - test('Adding a backdrop', async () => { - await loadUri(uri); - await clickXpath('//button[@title="Try It"]'); - await clickXpath('//button[@aria-label="Choose a Backdrop"]'); - const el = await findByXpath("//input[@placeholder='Search']"); - await el.sendKeys('blue'); - await clickText('Blue Sky'); // Should close the modal - const logs = await getLogs(); - await expect(logs).toEqual([]); - }); - test('Converting bitmap/vector in paint editor', async () => { await loadUri(uri); await clickXpath('//button[@title="Try It"]');