From 2fa0880f9028dbdffc4f01919fc3e8ef3cd0ffcc Mon Sep 17 00:00:00 2001 From: Andy O'Neill Date: Fri, 9 Dec 2022 13:14:22 -0500 Subject: [PATCH] fix: load flyout correctly when switching languages --- src/containers/blocks.jsx | 3 +++ test/integration/blocks.test.js | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index 36a1de706..5756249f7 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -191,6 +191,9 @@ class Blocks extends React.Component { this.detachVM(); this.workspace.dispose(); clearTimeout(this.toolboxUpdateTimeout); + + // Clear the flyout blocks so that they can be recreated on mount. + this.props.vm.clearFlyoutBlocks(); } requestToolboxUpdate () { clearTimeout(this.toolboxUpdateTimeout); diff --git a/test/integration/blocks.test.js b/test/integration/blocks.test.js index 851c2f4b1..1a709d34a 100644 --- a/test/integration/blocks.test.js +++ b/test/integration/blocks.test.js @@ -291,4 +291,45 @@ describe('Working with the blocks', () => { await clickButton('OK'); await clickText('list1', scope.blocksTab); }); + + test('Use variable blocks after switching languages', async () => { + const myVariable = 'my\u00A0variable'; + const changeVariableByScope = "*[@data-id='data_changevariableby']"; + + await loadUri(uri); + + await clickText('Code'); + await clickBlocksCategory('Variables'); + + // change "my variable" by 1 + await clickText('change', changeVariableByScope); + + // check reported value 1 + await clickText(myVariable, scope.blocksTab); + await findByText('1', scope.reportedValue); + + // change language + await clickXpath('//*[@aria-label="language selector"]'); + await clickText('Deutsch'); + + await clickText('Skripte'); + await clickBlocksCategory('Variablen'); + + // make sure "my variable" is still 1 + await clickText(myVariable); + await findByText('1', scope.reportedValue); + + // change step from 1 to 10 + await clickText('1', changeVariableByScope); + await driver.actions() + .sendKeys('10') + .perform(); + + // change "my variable" by 10 + await clickText('ändere', changeVariableByScope); + + // check it is turned up to 11 + await clickText(myVariable); + await findByText('11', scope.reportedValue); + }); });