From 0f7840cdae5e3ad48d93a0c3449d652bc5bacaac Mon Sep 17 00:00:00 2001 From: seotts Date: Tue, 31 May 2022 15:56:37 -0400 Subject: [PATCH 1/2] Download test sb3 to Saucelabs when remote delete sb3 --- test/integration/project-page.test.js | 64 ++++++++++++++++++--------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/test/integration/project-page.test.js b/test/integration/project-page.test.js index 2c9daeb8b..7715e9452 100644 --- a/test/integration/project-page.test.js +++ b/test/integration/project-page.test.js @@ -39,6 +39,8 @@ let ownedUnsharedScratch2Url = rootUrl + '/projects/' + ownedUnsharedScratch2ID; let username = process.env.SMOKE_USERNAME + '6'; let password = process.env.SMOKE_PASSWORD; +const remote = process.env.SMOKE_REMOTE || false; + jest.setTimeout(60000); let driver; @@ -181,7 +183,7 @@ describe('www-integration project-page signed in', () => { }); }); -describe('www-integration project-creation signed in', () => { +describe.only('www-integration project-creation signed in', () => { beforeAll(async () => { // expect(projectUrl).toBe(defined); driver = await buildDriver('www-integration project-creation signed in'); @@ -189,6 +191,14 @@ describe('www-integration project-creation signed in', () => { await driver.sleep(1000); await signIn(username, password); await findByXpath('//span[contains(@class, "profile-name")]'); + + // SauceLabs doesn't have access to the sb3 used in 'load project from file' test + // https://support.saucelabs.com/hc/en-us/articles/115003685593-Uploading-Files-to-a-Sauce-Labs-Virtual-Machine-during-a-Test + if (remote) { + await driver.get('https://github.com/LLK/scratch-www/blob/develop/test/fixtures/project1.sb3'); + await clickText('Download'); + await driver.sleep(3000); + } }); beforeEach(async () => { @@ -197,26 +207,6 @@ describe('www-integration project-creation signed in', () => { afterAll(async () => await driver.quit()); - test('load project from file', async () => { - await clickXpath('//li[@class="link create"]'); - let gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]'); - await gf.isDisplayed(); - await clickText('File'); - await clickText('Load from your computer'); - const input = await findByXpath('//input[@accept=".sb,.sb2,.sb3"]'); - await input.sendKeys(path.resolve(__dirname, '../fixtures/project1.sb3')); - await driver.sleep(200); - let alert = await driver.switchTo().alert(); - await alert.accept(); - let spriteTile = await findText('project1-sprite'); - let spriteTileVisible = await spriteTile.isDisplayed(); - await expect(spriteTileVisible).toBe(true); - await driver.sleep(1000); - let infoArea = await findByXpath('//div[@class="sprite-info_sprite-info_3EyZh box_box_2jjDp"]'); - let areaVisible = await infoArea.isDisplayed(); - await expect(areaVisible).toBe(true); - }); - test('make a copy of a project', async () => { await driver.get(ownedUnsharedUrl + '/editor'); let gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]'); @@ -245,4 +235,36 @@ describe('www-integration project-creation signed in', () => { let areaVisible = await infoArea.isDisplayed(); await expect(areaVisible).toBe(true); }); + + test('load project from file', async () => { + // if remote, projectPath is Saucelabs path to downloaded file + const projectPath = remote ? + '/Users/chef/Downloads/project1.sb3' : + path.resolve(__dirname, '../fixtures/project1.sb3'); + + // upload file + await clickXpath('//li[@class="link create"]'); + let gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]'); + await gf.isDisplayed(); + await clickText('File'); + await clickText('Load from your computer'); + await driver.sleep(1000); + const input = await findByXpath('//input[@accept=".sb,.sb2,.sb3"]'); + await input.sendKeys(projectPath); + + // accept alert + let alert = await driver.switchTo().alert(); + await alert.accept(); + + // check that project is loaded + let spriteTile = await findText('project1-sprite'); + let spriteTileVisible = await spriteTile.isDisplayed(); + await expect(spriteTileVisible).toBe(true); + + // check that gui is still there after some time has passed + await driver.sleep(1000); + let infoArea = await findByXpath('//div[@class="sprite-info_sprite-info_3EyZh box_box_2jjDp"]'); + let areaVisible = await infoArea.isDisplayed(); + await expect(areaVisible).toBe(true); + }); }); From 1ea22fa05b785f6595ef68d714ad26790424c416 Mon Sep 17 00:00:00 2001 From: seotts Date: Wed, 1 Jun 2022 16:15:44 -0400 Subject: [PATCH 2/2] =?UTF-8?q?Remove=20stray=20=E2=80=9Conly=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/integration/project-page.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/project-page.test.js b/test/integration/project-page.test.js index 7715e9452..676e1de7b 100644 --- a/test/integration/project-page.test.js +++ b/test/integration/project-page.test.js @@ -183,7 +183,7 @@ describe('www-integration project-page signed in', () => { }); }); -describe.only('www-integration project-creation signed in', () => { +describe('www-integration project-creation signed in', () => { beforeAll(async () => { // expect(projectUrl).toBe(defined); driver = await buildDriver('www-integration project-creation signed in');