test: fix (and speed up?) project-page.test.js

This commit is contained in:
Christopher Willis-Ford 2023-09-19 10:16:24 -07:00
parent b3efcb9f64
commit cdde117692
2 changed files with 16 additions and 21 deletions

View file

@ -123,10 +123,6 @@ describe('www-integration project-page signed in', () => {
await findByXpath('//span[contains(@class, "profile-name")]');
});
beforeEach(async () => {
await driver.get(rootUrl);
});
afterAll(async () => await driver.quit());
// LOGGED in TESTS
@ -191,23 +187,18 @@ describe('www-integration project-creation signed in', () => {
// expect(projectUrl).toBe(defined);
driver = await buildDriver('www-integration project-creation signed in');
await driver.get(rootUrl);
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.get('https://github.com/scratchfoundation/scratch-www/blob/develop/test/fixtures/project1.sb3');
await clickXpath('//button[@data-testid="download-raw-button"]');
await driver.sleep(3000);
}
});
beforeEach(async () => {
await driver.get(rootUrl);
});
afterAll(async () => await driver.quit());
test('make a copy of a project', async () => {
@ -240,6 +231,9 @@ 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' :

View file

@ -1,8 +1,9 @@
const webdriver = require('selenium-webdriver');
const {PageLoadStrategy} = require('selenium-webdriver/lib/capabilities');
const chrome = require('selenium-webdriver/chrome');
const bindAll = require('lodash.bindall');
require('chromedriver');
const chromedriverVersion = require('chromedriver').version;
const chromedriver = require('chromedriver');
const chromedriverVersion = chromedriver.version;
const headless = process.env.SMOKE_HEADLESS || false;
const remote = process.env.SMOKE_REMOTE || false;
@ -53,18 +54,18 @@ class SeleniumHelper {
}
getDriver () {
const chromeCapabilities = webdriver.Capabilities.chrome();
let args = [];
const chromeOptions = new chrome.Options();
if (headless) {
args.push('--headless');
args.push('window-size=1024,1680');
args.push('--no-sandbox');
chromeOptions.addArguments('--headless');
}
chromeCapabilities.set('chromeOptions', {args});
chromeCapabilities.setPageLoadStrategy(PageLoadStrategy.EAGER);
chromeOptions.addArguments('window-size=1024,1680');
chromeOptions.addArguments('--no-sandbox');
chromeOptions.addArguments('--disable-dev-shm-using');
chromeOptions.addArguments('--remote-debugging-port=9222');
chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
let driver = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(chromeCapabilities)
.withCapabilities(chromeOptions)
.build();
return driver;
}