From 79a9cbea1fe1b88a28f2f66cf6a91da01ff0ceb8 Mon Sep 17 00:00:00 2001 From: Paul Kaplan <pkaplan@media.mit.edu> Date: Mon, 26 Nov 2018 10:02:20 -0500 Subject: [PATCH] Do not change to backdrops tab after adding a backdrop. Expand on the backdrop integration test to make sure this is documented/tested behavior --- src/containers/backdrop-library.jsx | 11 +----- test/integration/backdrops.test.js | 52 +++++++++++++++++++++++++++++ test/integration/costumes.test.js | 11 ------ 3 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 test/integration/backdrops.test.js diff --git a/src/containers/backdrop-library.jsx b/src/containers/backdrop-library.jsx index 5a0266038..9d7a709cc 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 000000000..9a527b2c9 --- /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 3f1e6714c..d46e1a4b0 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"]'); -- GitLab