From 0fda349a2cbb2cc9a3bff036ade6f7530c74559c Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:24:32 -0700 Subject: [PATCH] test: unbreak 'load project from file' and make it more robust --- test/integration/project-page.test.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/integration/project-page.test.js b/test/integration/project-page.test.js index 5bf588c63..2c21509e3 100644 --- a/test/integration/project-page.test.js +++ b/test/integration/project-page.test.js @@ -3,6 +3,7 @@ // some tests use projects owned by user #2 const SeleniumHelper = require('./selenium-helpers.js'); +const {until} = require('selenium-webdriver'); import path from 'path'; const { @@ -238,25 +239,22 @@ describe('www-integration project-creation signed in', () => { }); test('load project from file', async () => { - // load the editor without making a new project - await driver.get(unownedSharedUrl); - // 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 + // create a new project so there's unsaved content to trigger an alert await clickXpath('//li[@class="link create"]'); - let gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]'); - await gf.isDisplayed(); + + // upload file await clickXpath(FILE_MENU_XPATH); await clickText('Load from your computer'); - await driver.sleep(1000); - const input = await findByXpath('//input[@accept=".sb,.sb2,.sb3"]'); + const input = await driver.wait(() => findByXpath('//input[@accept=".sb,.sb2,.sb3"]')); await input.sendKeys(projectPath); // accept alert + await driver.wait(until.alertIsPresent()); let alert = await driver.switchTo().alert(); await alert.accept();