diff --git a/test/fixtures/100-100.svg b/test/fixtures/100-100.svg new file mode 100644 index 0000000000000000000000000000000000000000..108f7aa1bc9c4c6cd0d5b4a4728ae0261d5342b7 Binary files /dev/null and b/test/fixtures/100-100.svg differ diff --git a/test/fixtures/gh-3582-png.png b/test/fixtures/gh-3582-png.png new file mode 100644 index 0000000000000000000000000000000000000000..cc1f1464e957dbddf5bc1aa4b8915b988bc97f0f Binary files /dev/null and b/test/fixtures/gh-3582-png.png differ diff --git a/test/integration/costumes.test.js b/test/integration/costumes.test.js index 7aa3b969fc2e152cd461c1c649f392e5fc00dfc9..78c7b911e191c316c0c9b0bd4aa4439edafc32f5 100644 --- a/test/integration/costumes.test.js +++ b/test/integration/costumes.test.js @@ -129,4 +129,35 @@ describe('Working with costumes', () => { const logs = await getLogs(); await expect(logs).toEqual([]); }); + + test('Adding an svg from file', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + await clickText('Costumes'); + const el = await findByXpath('//button[@aria-label="Choose a Costume"]'); + await driver.actions().mouseMove(el) + .perform(); + await driver.sleep(500); // Wait for thermometer menu to come up + const input = await findByXpath('//input[@type="file"]'); + await input.sendKeys(path.resolve(__dirname, '../fixtures/100-100.svg')); + await clickText('100-100', scope.costumesTab); // Name from filename + await clickText('100 x 100', scope.costumesTab); // Size is right + const logs = await getLogs(); + await expect(logs).toEqual([]); + }); + + test('Adding a png from file (gh-3582)', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + await clickText('Costumes'); + const el = await findByXpath('//button[@aria-label="Choose a Costume"]'); + await driver.actions().mouseMove(el) + .perform(); + await driver.sleep(500); // Wait for thermometer menu to come up + const input = await findByXpath('//input[@type="file"]'); + await input.sendKeys(path.resolve(__dirname, '../fixtures/gh-3582-png.png')); + await clickText('gh-3582-png', scope.costumesTab); + const logs = await getLogs(); + await expect(logs).toEqual([]); + }); }); diff --git a/test/integration/sprites.test.js b/test/integration/sprites.test.js index 83a07793dc7264c4a555c5d6d017802806003eaa..ca6a84ebaca6bdb7f5de3938e5410495e12023f6 100644 --- a/test/integration/sprites.test.js +++ b/test/integration/sprites.test.js @@ -74,4 +74,39 @@ describe('Working with sprites', () => { const logs = await getLogs(); await expect(logs).toEqual([]); }); + + test('Adding a sprite by uploading a png', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + const el = await findByXpath('//button[@aria-label="Choose a Sprite"]'); + await driver.actions().mouseMove(el) + .perform(); + await driver.sleep(500); // Wait for thermometer menu to come up + const input = await findByXpath('//input[@type="file"]'); + await input.sendKeys(path.resolve(__dirname, '../fixtures/gh-3582-png.png')); + await clickText('gh-3582-png', scope.spriteTile); + const logs = await getLogs(); + await expect(logs).toEqual([]); + }); + + // This test fails because uploading an SVG as a sprite changes the scaling + // Enable when this is fixed issues/3608 + test.skip('Adding a sprite by uploading an svg (gh-3608)', async () => { + await loadUri(uri); + await clickXpath('//button[@title="Try It"]'); + const el = await findByXpath('//button[@aria-label="Choose a Sprite"]'); + await driver.actions().mouseMove(el) + .perform(); + await driver.sleep(500); // Wait for thermometer menu to come up + const input = await findByXpath('//input[@type="file"]'); + await input.sendKeys(path.resolve(__dirname, '../fixtures/100-100.svg')); + await clickText('100-100', scope.spriteTile); // Sprite is named for costume filename + + // Check to make sure the size is right + await clickText('Costumes'); + await clickText('100-100-costume1', scope.costumesTab); // The name of the costume + await clickText('100 x 100', scope.costumesTab); // The size of the costume + const logs = await getLogs(); + await expect(logs).toEqual([]); + }); });