mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +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
8
.github/workflows/browser_test.yml
vendored
8
.github/workflows/browser_test.yml
vendored
@@ -1,12 +1,10 @@
|
|||||||
# This workflow will do a clean install, start the selenium server, and run
|
# This workflow will do a clean install, start the selenium server, and run
|
||||||
# all of our browser based tests
|
# all of our browser based tests
|
||||||
|
|
||||||
name: Run browser test nightly
|
name: Run browser manually
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# Trigger the workflow nightly
|
workflow_dispatch:
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *'
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -20,7 +18,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
# TODO (#2114): re-enable osx build.
|
# TODO (#2114): re-enable osx build.
|
||||||
# os: [ubuntu-latest, macos-latest]
|
# os: [ubuntu-latest, macos-latest]
|
||||||
os: [ubuntu-latest]
|
os: [macos-latest]
|
||||||
node-version: [16.x, 18.x, 20.x]
|
node-version: [16.x, 18.x, 20.x]
|
||||||
# See supported Node.js release schedule at
|
# See supported Node.js release schedule at
|
||||||
# https://nodejs.org/en/about/releases/
|
# https://nodejs.org/en/about/releases/
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
|
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const webdriverio = require('webdriverio');
|
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const path = require('path');
|
const {testSetup, testFileLocations} = require('./test_setup');
|
||||||
const {posixPath} = require('../../../scripts/helpers');
|
|
||||||
|
|
||||||
let browser;
|
let browser;
|
||||||
suite('Testing Connecting Blocks', function (done) {
|
suite('Testing Connecting Blocks', function (done) {
|
||||||
@@ -20,43 +18,7 @@ suite('Testing Connecting Blocks', function (done) {
|
|||||||
|
|
||||||
// Setup Selenium for all of the tests
|
// Setup Selenium for all of the tests
|
||||||
suiteSetup(async function () {
|
suiteSetup(async function () {
|
||||||
const options = {
|
browser = await testSetup(testFileLocations.blockfactory);
|
||||||
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
|
|
||||||
const url =
|
|
||||||
'file://' +
|
|
||||||
posixPath(
|
|
||||||
path.join(__dirname, '..', '..', '..', 'demos', 'blockfactory')
|
|
||||||
) +
|
|
||||||
'/index.html';
|
|
||||||
console.log(url);
|
|
||||||
console.log('Starting webdriverio...');
|
|
||||||
browser = await webdriverio.remote(options);
|
|
||||||
console.log('Loading URL: ' + url);
|
|
||||||
await browser.url(url);
|
|
||||||
return browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Testing Block Drag', async function () {
|
test('Testing Block Drag', async function () {
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
|
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const webdriverio = require('webdriverio');
|
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const path = require('path');
|
const {testSetup, testFileLocations} = require('./test_setup');
|
||||||
const {posixPath} = require('../../../scripts/helpers');
|
|
||||||
|
|
||||||
let browser;
|
let browser;
|
||||||
suite('Testing Connecting Blocks', function (done) {
|
suite('Testing Connecting Blocks', function (done) {
|
||||||
@@ -20,41 +18,7 @@ suite('Testing Connecting Blocks', function (done) {
|
|||||||
|
|
||||||
// Setup Selenium for all of the tests
|
// Setup Selenium for all of the tests
|
||||||
suiteSetup(async function () {
|
suiteSetup(async function () {
|
||||||
const options = {
|
browser = await testSetup(testFileLocations.playground);
|
||||||
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
|
|
||||||
const 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;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Testing Block Flyout', async function () {
|
test('Testing Block Flyout', async function () {
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
|
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const webdriverio = require('webdriverio');
|
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const path = require('path');
|
const {testSetup, testFileLocations} = require('./test_setup');
|
||||||
const {posixPath} = require('../../../scripts/helpers');
|
|
||||||
|
|
||||||
let browser;
|
let browser;
|
||||||
suite('Testing Connecting Blocks', function (done) {
|
suite('Testing Connecting Blocks', function (done) {
|
||||||
@@ -20,41 +18,7 @@ suite('Testing Connecting Blocks', function (done) {
|
|||||||
|
|
||||||
// Setup Selenium for all of the tests
|
// Setup Selenium for all of the tests
|
||||||
suiteSetup(async function () {
|
suiteSetup(async function () {
|
||||||
const options = {
|
browser = await testSetup(testFileLocations.code);
|
||||||
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
|
|
||||||
const url =
|
|
||||||
'file://' +
|
|
||||||
posixPath(path.join(__dirname, '..', '..', '..', 'demos', 'code')) +
|
|
||||||
'/index.html';
|
|
||||||
console.log(url);
|
|
||||||
console.log('Starting webdriverio...');
|
|
||||||
browser = await webdriverio.remote(options);
|
|
||||||
console.log('Loading URL: ' + url);
|
|
||||||
await browser.url(url);
|
|
||||||
return browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Testing Procedure', async function () {
|
test('Testing Procedure', async function () {
|
||||||
|
|||||||
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