Skip to content

Commit 32723a8

Browse files
authored
Merge pull request scratchfoundation#5114 from LLK/default-last-asset
Default blocks to last asset instead of first
2 parents 2a167ba + 7b9aed7 commit 32723a8

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/containers/blocks.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ class Blocks extends React.Component {
340340
const targetSounds = target.getSounds();
341341
const dynamicBlocksXML = this.props.vm.runtime.getBlocksXML();
342342
return makeToolboxXML(target.isStage, target.id, dynamicBlocksXML,
343-
targetCostumes[0].name,
344-
stageCostumes[0].name,
345-
targetSounds.length > 0 ? targetSounds[0].name : ''
343+
targetCostumes[targetCostumes.length - 1].name,
344+
stageCostumes[stageCostumes.length - 1].name,
345+
targetSounds.length > 0 ? targetSounds[targetSounds.length - 1].name : ''
346346
);
347347
} catch {
348348
return null;

test/integration/blocks.test.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ describe('Working with the blocks', () => {
182182

183183
// Rename the costume
184184
await clickText('Costumes');
185-
const el = await findByXpath("//input[@value='costume1']");
185+
await clickText('costume2', scope.costumesTab);
186+
const el = await findByXpath("//input[@value='costume2']");
186187
await el.sendKeys('newname');
187188

188189
// Make sure it is updated in the block menu
@@ -197,7 +198,8 @@ describe('Working with the blocks', () => {
197198

198199
// Rename the costume
199200
await clickText('Costumes');
200-
const el = await findByXpath("//input[@value='costume1']");
201+
await clickText('costume2', scope.costumesTab);
202+
const el = await findByXpath("//input[@value='costume2']");
201203
await el.sendKeys('<NewCostume>');
202204

203205
// Make sure it is updated in the block menu
@@ -209,40 +211,36 @@ describe('Working with the blocks', () => {
209211
await clickText('Sound', scope.blocksTab);
210212
});
211213

212-
// NOTE: This test describes the current behavior so that changes are not
213-
// introduced inadvertly, but I know this is not the desired behavior
214-
test('Adding costumes DOES NOT update the default costume name in the toolbox', async () => {
214+
test('Adding costumes DOES update the default costume name in the toolbox', async () => {
215215
await loadUri(uri);
216216

217-
// By default, costume1 is in the costume tab
217+
// By default, costume2 is in the costume tab
218218
await clickText('Looks', scope.blocksTab);
219219
await driver.sleep(500); // Wait for scroll to finish
220-
await clickText('costume1', scope.blocksTab);
220+
await clickText('costume2', scope.blocksTab);
221221

222-
// Also check that adding a new costume does not update the list
222+
// Also check that adding a new costume does update the list
223223
await clickText('Costumes');
224224
const el = await findByXpath('//button[@aria-label="Choose a Costume"]');
225225
await driver.actions().mouseMove(el)
226226
.perform();
227227
await driver.sleep(500); // Wait for thermometer menu to come up
228228
await clickXpath('//button[@aria-label="Paint"]');
229229
await clickText('costume3', scope.costumesTab);
230-
// Check that the menu has not been updated
230+
// Check that the menu has been updated
231231
await clickText('Code');
232-
await clickText('costume1', scope.blocksTab);
232+
await clickText('costume3', scope.blocksTab);
233233
});
234234

235-
// NOTE: This test describes the current behavior so that changes are not
236-
// introduced inadvertly, but I know this is not the desired behavior
237-
test('Adding a sound DOES NOT update the default sound name in the toolbox', async () => {
235+
test('Adding a sound DOES update the default sound name in the toolbox', async () => {
238236
await loadUri(uri);
239237
await clickText('Sounds');
240238
await clickXpath('//button[@aria-label="Choose a Sound"]');
241239
await clickText('A Bass', scope.modal); // Should close the modal
242240
await clickText('Code');
243241
await clickText('Sound', scope.blocksTab);
244242
await driver.sleep(500); // Wait for scroll to finish
245-
await clickText('Meow', scope.blocksTab); // Meow, not A Bass
243+
await clickText('A\u00A0Bass', scope.blocksTab); // Need &nbsp; for block text
246244
});
247245

248246
// Regression test for switching between editor/player causing toolbox to stop updating

0 commit comments

Comments
 (0)