diff --git a/.gitignore b/.gitignore index 359aca70..f01f9f9c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ node_modules/ tests/node_modules/ tests/cucumber/screenshots/ .idea/ +.screenshots diff --git a/README.md b/README.md index ed86fbb4..b2d8781f 100644 --- a/README.md +++ b/README.md @@ -120,3 +120,22 @@ docker-compose up -d materials-designer sleep 30 # let the app actually start docker-compose run materials-designer-test ``` + +## GitHub Codespace + +When using a GitHub codespace "from scratch", see [codespace-setup.sh](codespace-setup.sh) for how the application and tests can be started. + +When coming back to the previously used codespace - to run application: + +```bash +nvm use 12.21.0 +npm start +``` + +then, to run tests in headless mode in another terminal session, use the following example: + +```bash +nvm use 8 +export PATH=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH +./run-tests.sh -s=true -hm=true -f=menu/edit/reset-clone-undo-redo.feature +``` diff --git a/codespace-setup.sh b/codespace-setup.sh new file mode 100644 index 00000000..5d7d755f --- /dev/null +++ b/codespace-setup.sh @@ -0,0 +1,25 @@ +# Setup for a default GitHub codespace container (Linux/Ubuntu) circa 2022-12 +# TODO: migrate to using `.devcontainer` setup per +# https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers + +# Application +nvm install 12.21.0 +chmod +x run-application.sh +npm start + +# Run Tests +sudo apt-get upgrade +sudo apt-get update +sudo apt-get install openjdk-8-jdk +sudo apt-get install git bzip2 +wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +sudo dpkg -i google-chrome-stable_current_amd64.deb +sudo apt-get --fix-broken install +nvm use 8 +cd tests +npm install +cd .. +export PATH=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH +java -version +./run-tests.sh -s=true -hm=true -f=menu/edit/reset-clone-undo-redo.feature + diff --git a/package-lock.json b/package-lock.json index 4c52e807..86908721 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1582,10 +1582,52 @@ "semver": "^6.3.0" } }, + "acorn": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-1.0.1.tgz", + "integrity": "sha512-goyeqJaYIEon7Xw+ltfheM2MSoZ1lDffIYDBMP9UyUDYhsBiw1dAV07wlUGwRYntyvlxGpk/Avk58Ff9clZuUw==" + }, + "codemirror": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz", + "integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==", + "requires": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/commands": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/search": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0" + } + }, + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha512-AWwVMNxwhN8+NIPQzAQZCm7RkLC4RbM3B1OobMuyp3i+w73X57KCKaVIxaRZb+DYCojq7rspo+fmuQfAboyhFg==" + }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + }, + "three": { + "version": "npm:@exabyte-io/three@2022.10.13-0", + "resolved": "https://registry.npmjs.org/@exabyte-io/three/-/three-2022.10.13-0.tgz", + "integrity": "sha512-6UdC5BtpdZqx12ZQKK9cgqCWCSteVIVKNYMFTHYM7JW/wdsozJo2eRehi2JHC8gyfFyV9HjHU07x22eR1vKzOQ==", + "requires": { + "@codemirror/commands": "^6.1.0", + "@codemirror/lang-javascript": "^6.0.2", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.1.1", + "@codemirror/theme-one-dark": "^6.0.0", + "@codemirror/view": "^6.2.1", + "acorn": "1.0.1", + "codemirror": "^6.0.1", + "eslint4b-prebuilt": "^6.7.2", + "esprima": "^3.1.3", + "signals": "1.0.0" + } } } }, @@ -17376,50 +17418,6 @@ "prop-types": "^15.5.8" } }, - "three": { - "version": "npm:@exabyte-io/three@2022.10.13-0", - "resolved": "https://registry.npmjs.org/@exabyte-io/three/-/three-2022.10.13-0.tgz", - "integrity": "sha512-6UdC5BtpdZqx12ZQKK9cgqCWCSteVIVKNYMFTHYM7JW/wdsozJo2eRehi2JHC8gyfFyV9HjHU07x22eR1vKzOQ==", - "requires": { - "@codemirror/commands": "^6.1.0", - "@codemirror/lang-javascript": "^6.0.2", - "@codemirror/lint": "^6.0.0", - "@codemirror/state": "^6.1.1", - "@codemirror/theme-one-dark": "^6.0.0", - "@codemirror/view": "^6.2.1", - "acorn": "1.0.1", - "codemirror": "^6.0.1", - "eslint4b-prebuilt": "^6.7.2", - "esprima": "^3.1.3", - "signals": "1.0.0" - }, - "dependencies": { - "acorn": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-1.0.1.tgz", - "integrity": "sha512-goyeqJaYIEon7Xw+ltfheM2MSoZ1lDffIYDBMP9UyUDYhsBiw1dAV07wlUGwRYntyvlxGpk/Avk58Ff9clZuUw==" - }, - "codemirror": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz", - "integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==", - "requires": { - "@codemirror/autocomplete": "^6.0.0", - "@codemirror/commands": "^6.0.0", - "@codemirror/language": "^6.0.0", - "@codemirror/lint": "^6.0.0", - "@codemirror/search": "^6.0.0", - "@codemirror/state": "^6.0.0", - "@codemirror/view": "^6.0.0" - } - }, - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha512-AWwVMNxwhN8+NIPQzAQZCm7RkLC4RbM3B1OobMuyp3i+w73X57KCKaVIxaRZb+DYCojq7rspo+fmuQfAboyhFg==" - } - } - }, "throat": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", diff --git a/run-application.sh b/run-application.sh old mode 100644 new mode 100755 diff --git a/run-tests.sh b/run-tests.sh index 39ea25f6..30281fa5 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -26,6 +26,7 @@ check_args () { FEATURES="/" OPTIONS="" BROWSER="chrome" + HEADLESS_MODE="false" for i in "$@" do case $i in @@ -33,12 +34,16 @@ check_args () { HOST="${i#*=}" shift ;; + -p=*|--port=*) + PORT="${i#*=}" + shift + ;; -s=*|--skip-install=*) SKIP_INSTALL="${i#*=}" shift ;; - -p=*|--port=*) - PORT="${i#*=}" + -hm=*|--headless-mode=*) + HEADLESS_MODE="${i#*=}" shift ;; -f=*|--features-dir=*) @@ -79,6 +84,9 @@ SCREENSHOTS_DIR="${CUCUMBER_DIR}/screenshots" export ROOT_URL="${HOST}:${PORT}" +# For using Java inside a GitHub Codespace VM; TODO: find a better way +export PATH=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH + cd ${TESTS_DIR} DEFAULT_NVM_DIR="${HOME}/.nvm" source ${NVM_DIR:-$DEFAULT_NVM_DIR}/nvm.sh @@ -94,14 +102,26 @@ rm -rf ${SCREENSHOTS_DIR} # https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html#node_debugging_overview # sed -ie 's/--debug/--inspect/g' ${TESTS_DIR}/node_modules/chimp/dist/lib/cucumberjs/cucumber.js -${TESTS_DIR}/node_modules/.bin/chimp \ +DEFAULT_OPTIONS="\ --serverHost="${HOST}" \ --serverPort="${PORT}" \ - --path=${CUCUMBER_DIR}/features/$FEATURES -r=${SUPPORT_DIR} \ + --path=${CUCUMBER_DIR}/features/${FEATURES} \ + -r=${SUPPORT_DIR} \ --singleSnippetPerFile=1 \ --screenshotsOnError=true --captureAllStepScreenshots=false \ --screenshotsPath=${SCREENSHOTS_DIR} \ --browser=${BROWSER} \ --webdriverio.deprecationWarnings=false \ --webdriverio.logLevel="silent" \ - ${OPTIONS} + " + +if [[ ${HEADLESS_MODE} == "true" ]]; then + DEFAULT_OPTIONS="${DEFAULT_OPTIONS} \ + --webdriverio.desiredCapabilities.chromeOptions.args="headless" \ + --webdriverio.desiredCapabilities.chromeOptions.args="disable-gpu" \ + --webdriverio.desiredCapabilities.chromeOptions.args="no-sandbox" \ + --webdriverio.desiredCapabilities.chromeOptions.args="window-size=1920,1080" \ + " +fi + +${TESTS_DIR}/node_modules/.bin/chimp ${DEFAULT_OPTIONS} ${OPTIONS} \ No newline at end of file