mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Fix: Update browser test to run manually, and move browser test suiteSetup in to a separate function (#7138)
* feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Added basic example test for Blockly Playground and Blockly Demo * feat: Add functionality to run playground and block factory test locally * feat: Add functionality to run playground and block factory test locally * feat: Add functionality to run playground and block factory test locally * feat: Add functionality to run playground and block factory test locally * feat: Create procedure test * feat: Create procedure test * feat: Create procedure test * chore: test for procedures * chore: test for procedures * chore: test for procedures * chore: test for procedures * fix: Switch broswer_test.yaml to be macOS as to match local development evn * fix: Switch broswer_test.yaml to be macOS as to match local development evn * fix: Switch broswer_test.yaml to be macOS as to match local development evn * fix: Switch broswer_test.yaml to be macOS as to match local development evn * fix: Update browser test to run manually, and move browser test suiteSetup in to a separate function
This commit is contained in:
committed by
GitHub
parent
0f3fa22f66
commit
d22c3b4383
76
tests/browser/test/test_setup.js
Normal file
76
tests/browser/test/test_setup.js
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Node.js script to run automated functional tests in Chrome, via webdriver.
|
||||
* This file is to be used in the suiteSetup for any automated fuctional test.
|
||||
*/
|
||||
|
||||
const webdriverio = require('webdriverio');
|
||||
const path = require('path');
|
||||
const {posixPath} = require('../../../scripts/helpers');
|
||||
|
||||
let browser;
|
||||
async function testSetup(testFile) {
|
||||
let url;
|
||||
const options = {
|
||||
capabilities: {
|
||||
'browserName': 'chrome',
|
||||
'goog:chromeOptions': {
|
||||
args: ['--allow-file-access-from-files'],
|
||||
},
|
||||
},
|
||||
services: [['selenium-standalone']],
|
||||
logLevel: 'warn',
|
||||
};
|
||||
|
||||
// Run in headless mode on Github Actions.
|
||||
if (process.env.CI) {
|
||||
options.capabilities['goog:chromeOptions'].args.push(
|
||||
'--headless',
|
||||
'--no-sandbox',
|
||||
'--disable-dev-shm-usage'
|
||||
);
|
||||
} else {
|
||||
// --disable-gpu is needed to prevent Chrome from hanging on Linux with
|
||||
// NVIDIA drivers older than v295.20. See
|
||||
// https://github.com/google/blockly/issues/5345 for details.
|
||||
options.capabilities['goog:chromeOptions'].args.push('--disable-gpu');
|
||||
}
|
||||
// Use Selenium to bring up the page
|
||||
if (testFile == testFileLocations.blockfactory) {
|
||||
url =
|
||||
'file://' +
|
||||
posixPath(
|
||||
path.join(__dirname, '..', '..', '..', 'demos', 'blockfactory')
|
||||
) +
|
||||
'/index.html';
|
||||
} else if (testFile == testFileLocations.code) {
|
||||
url =
|
||||
'file://' +
|
||||
posixPath(path.join(__dirname, '..', '..', '..', 'demos', 'code')) +
|
||||
'/index.html';
|
||||
} else {
|
||||
url =
|
||||
'file://' +
|
||||
posixPath(path.join(__dirname, '..', '..')) +
|
||||
'/playground.html';
|
||||
}
|
||||
console.log(url);
|
||||
console.log('Starting webdriverio...');
|
||||
browser = await webdriverio.remote(options);
|
||||
console.log('Loading URL: ' + url);
|
||||
await browser.url(url);
|
||||
return browser;
|
||||
}
|
||||
|
||||
const testFileLocations = {
|
||||
blockfactory: 0,
|
||||
code: 1,
|
||||
playground: 2,
|
||||
};
|
||||
|
||||
module.exports = {testSetup, testFileLocations};
|
||||
Reference in New Issue
Block a user