From d76b3ffae3fe7ad0c13d053030da3ed99efd6534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 11 Feb 2021 16:04:16 +0100 Subject: [PATCH 1/5] test-app added bare Meteor project for local tests --- test-app/.meteor/.finished-upgraders | 19 ++++++++ test-app/.meteor/.gitignore | 1 + test-app/.meteor/.id | 7 +++ test-app/.meteor/packages | 19 ++++++++ test-app/.meteor/platforms | 2 + test-app/.meteor/release | 1 + test-app/.meteor/versions | 70 ++++++++++++++++++++++++++++ 7 files changed, 119 insertions(+) create mode 100644 test-app/.meteor/.finished-upgraders create mode 100644 test-app/.meteor/.gitignore create mode 100644 test-app/.meteor/.id create mode 100644 test-app/.meteor/packages create mode 100644 test-app/.meteor/platforms create mode 100644 test-app/.meteor/release create mode 100644 test-app/.meteor/versions diff --git a/test-app/.meteor/.finished-upgraders b/test-app/.meteor/.finished-upgraders new file mode 100644 index 000000000..c07b6ff75 --- /dev/null +++ b/test-app/.meteor/.finished-upgraders @@ -0,0 +1,19 @@ +# This file contains information which helps Meteor properly upgrade your +# app when you run 'meteor update'. You should check it into version control +# with your project. + +notices-for-0.9.0 +notices-for-0.9.1 +0.9.4-platform-file +notices-for-facebook-graph-api-2 +1.2.0-standard-minifiers-package +1.2.0-meteor-platform-split +1.2.0-cordova-changes +1.2.0-breaking-changes +1.3.0-split-minifiers-package +1.4.0-remove-old-dev-bundle-link +1.4.1-add-shell-server-package +1.4.3-split-account-service-packages +1.5-add-dynamic-import-package +1.7-split-underscore-from-meteor-base +1.8.3-split-jquery-from-blaze diff --git a/test-app/.meteor/.gitignore b/test-app/.meteor/.gitignore new file mode 100644 index 000000000..408303742 --- /dev/null +++ b/test-app/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/test-app/.meteor/.id b/test-app/.meteor/.id new file mode 100644 index 000000000..23e17e722 --- /dev/null +++ b/test-app/.meteor/.id @@ -0,0 +1,7 @@ +# This file contains a token that is unique to your project. +# Check it into your repository along with the rest of this directory. +# It can be used for purposes such as: +# - ensuring you don't accidentally deploy one app on top of another +# - providing package authors with aggregated statistics + +ourgjhbe7m.zzee6dwnngho diff --git a/test-app/.meteor/packages b/test-app/.meteor/packages new file mode 100644 index 000000000..893e35b7d --- /dev/null +++ b/test-app/.meteor/packages @@ -0,0 +1,19 @@ +# Meteor packages used by this project, one per line. +# Check this file (and the other files in this directory) into your repository. +# +# 'meteor add' and 'meteor remove' will edit this file for you, +# but you can also edit it by hand. + +meteor-base@1.4.0 # Packages every Meteor app needs to have +mobile-experience@1.1.0 # Packages for a great mobile UX +mongo@1.10.1 # The database Meteor supports right now +static-html # Define static page content in .html files +reactive-var@1.0.11 # Reactive variable for tracker +tracker@1.2.0 # Meteor's client-side reactive programming library + +standard-minifier-css@1.7.2 # CSS minifier run for production mode +standard-minifier-js@2.6.0 # JS minifier run for production mode +es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers +ecmascript@0.15.0 # Enable ECMAScript2015+ syntax in app code +typescript@4.1.2 # Enable TypeScript syntax in .ts and .tsx modules +shell-server@0.5.0 # Server-side component of the `meteor shell` command diff --git a/test-app/.meteor/platforms b/test-app/.meteor/platforms new file mode 100644 index 000000000..efeba1b50 --- /dev/null +++ b/test-app/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/test-app/.meteor/release b/test-app/.meteor/release new file mode 100644 index 000000000..bc0e7170f --- /dev/null +++ b/test-app/.meteor/release @@ -0,0 +1 @@ +METEOR@2.0 diff --git a/test-app/.meteor/versions b/test-app/.meteor/versions new file mode 100644 index 000000000..af35c5e3b --- /dev/null +++ b/test-app/.meteor/versions @@ -0,0 +1,70 @@ +allow-deny@1.1.0 +autoupdate@1.7.0 +babel-compiler@7.6.0 +babel-runtime@1.5.0 +base64@1.0.12 +binary-heap@1.0.11 +blaze-tools@1.0.10 +boilerplate-generator@1.7.1 +caching-compiler@1.2.2 +caching-html-compiler@1.1.3 +callback-hook@1.3.0 +check@1.3.1 +ddp@1.4.0 +ddp-client@2.4.0 +ddp-common@1.4.0 +ddp-server@2.3.2 +deps@1.0.12 +diff-sequence@1.1.1 +dynamic-import@0.6.0 +ecmascript@0.15.0 +ecmascript-runtime@0.7.0 +ecmascript-runtime-client@0.11.0 +ecmascript-runtime-server@0.10.0 +ejson@1.1.1 +es5-shim@4.8.0 +fetch@0.1.1 +geojson-utils@1.0.10 +hot-code-push@1.0.4 +html-tools@1.0.11 +htmljs@1.0.11 +id-map@1.1.0 +inter-process-messaging@0.1.1 +launch-screen@1.2.0 +livedata@1.0.18 +logging@1.2.0 +meteor@1.9.3 +meteor-base@1.4.0 +minifier-css@1.5.3 +minifier-js@2.6.0 +minimongo@1.6.1 +mobile-experience@1.1.0 +mobile-status-bar@1.1.0 +modern-browsers@0.1.5 +modules@0.16.0 +modules-runtime@0.12.0 +mongo@1.10.1 +mongo-decimal@0.1.2 +mongo-dev-server@1.1.0 +mongo-id@1.0.7 +npm-mongo@3.8.1 +ordered-dict@1.1.0 +promise@0.11.2 +random@1.2.0 +react-fast-refresh@0.1.0 +reactive-var@1.0.11 +reload@1.3.1 +retry@1.1.0 +routepolicy@1.1.0 +shell-server@0.5.0 +socket-stream-client@0.3.1 +spacebars-compiler@1.1.3 +standard-minifier-css@1.7.2 +standard-minifier-js@2.6.0 +static-html@1.2.2 +templating-tools@1.1.2 +tracker@1.2.0 +typescript@4.1.2 +underscore@1.0.10 +webapp@1.10.0 +webapp-hashing@1.1.0 From 64450f2e8c593baf7e2bb9ce61b6bfc50ae72731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 11 Feb 2021 16:04:41 +0100 Subject: [PATCH 2/5] test-app added scripts for setup and test:watch --- test-app/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test-app/package.json b/test-app/package.json index 1e87ae04f..0e057ff8c 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -6,7 +6,10 @@ "test": "tests" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "meteor run", + "setup": "ln -sfn ../packages ./packages", + "test:watch": "meteor test-packages --raw-logs ./packages/*" }, "author": "", "license": "ISC", From 4d14ce91f3d1c8a2d058f5fe3bab1141da67d1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 11 Feb 2021 16:05:16 +0100 Subject: [PATCH 3/5] .gitignore ignore test-app artifacts --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 48d9692b0..c696cfbbf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ Thumbs.db db.json *.log .idea +test-app/packages +node_modules +package-lock.json From bb556af54c4ec8fb79b06e7093f235191e6e3896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 11 Feb 2021 16:05:31 +0100 Subject: [PATCH 4/5] updated CONTRIBUTING guide --- CONTRIBUTING.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c37d1984b..093ea8224 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,4 +33,27 @@ ln -s /home/user/projects/blaze/packages/blaze-html-templates packages/ ... ``` -And so on for all the packages. +### Run local tests + +The `test-app` folder contains a bare Meteor project you can utilize for local +testing. In order to run local tests, please setup the project first: + +#### Setting up the local test environment + +Everything is already prepared in scripts: + +```bash +$ cd test-app +$ meteor npm install # install dependencies +$ meteor npm run setup # create link to packages +``` + +This has to be done only once. + +#### Run the tests + +Simply execute the test script: + +```bash +$ meteor npm run test:watch +``` From bb256d4d43e2afe277864541e203f262b2835f85 Mon Sep 17 00:00:00 2001 From: filipenevola Date: Thu, 18 Mar 2021 13:56:34 -0400 Subject: [PATCH 5/5] running tests on CI --- .circleci/config.yml | 29 +++++++++++++++ test-app/ci.sh | 17 +++++++++ test-app/package.json | 8 +++-- test-app/puppeteerRunner.js | 70 +++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 .circleci/config.yml create mode 100755 test-app/ci.sh create mode 100644 test-app/puppeteerRunner.js diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..e66a43e8e --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,29 @@ +version: 2.1 + +commands: + install: + description: Install puppeteer and headless chrome + steps: + - run: + name: Install Headless Chrome dependencies + command: | + sudo apt-get install -yq \ + gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ + libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ + libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \ + libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \ + fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget + - run: + name: Install puppeteer with chronium + command: | + npm i puppeteer + +jobs: + Blaze Tests: + steps: + - checkout + - run: + name: running ci + command: | + cd test-app + ./ci.sh diff --git a/test-app/ci.sh b/test-app/ci.sh new file mode 100755 index 000000000..614c25f77 --- /dev/null +++ b/test-app/ci.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +meteor npm install + +export URL='http://localhost:4096/' + +exec 3< <(meteor test-packages --driver-package test-in-console -p 4096 --exclude ${TEST_PACKAGES_EXCLUDE:-''}) +EXEC_PID=$! + +sed '/test-in-console listening$/q' <&3 + +meteor node puppeteerRunner.js + +STATUS=$? + +pkill -TERM -P $EXEC_PID +exit $STATUS diff --git a/test-app/package.json b/test-app/package.json index 0e057ff8c..6c8e88b74 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -9,13 +9,15 @@ "test": "echo \"Error: no test specified\" && exit 1", "start": "meteor run", "setup": "ln -sfn ../packages ./packages", - "test:watch": "meteor test-packages --raw-logs ./packages/*" + "test:watch": "meteor test-packages --raw-logs ./packages/*", + "test:ci": "ci.sh" }, "author": "", "license": "ISC", "dependencies": { "jquery": "^3.4.1", - "@babel/runtime": "^7.6.0", - "meteor-node-stubs": "^1.0.0" + "@babel/runtime": "^7.13.10", + "meteor-node-stubs": "^1.0.2", + "puppeteer": "^8.0.0" } } diff --git a/test-app/puppeteerRunner.js b/test-app/puppeteerRunner.js new file mode 100644 index 000000000..97e54aeba --- /dev/null +++ b/test-app/puppeteerRunner.js @@ -0,0 +1,70 @@ +const puppeteer = require('puppeteer'); + +async function runNextUrl(browser) { + const page = await browser.newPage(); + + page.on('console', msg => { + console.log(msg._text); + }); + + if (!process.env.URL) { + process.exit(1); + return; + } + + await page.goto(process.env.URL); + + async function poll() { + if (await isDone(page)) { + let failCount = await getFailCount(page); + if (failCount > 0) { + await page.close(); + await browser.close(); + process.exit(1); + } else { + await page.close(); + await browser.close(); + process.exit(0); + } + } else { + setTimeout(poll, 1000); + } + } + + poll(); +} + +async function isDone(page) { + return await page.evaluate(function() { + if (typeof TEST_STATUS !== 'undefined') { + return TEST_STATUS.DONE; + } + + return typeof DONE !== 'undefined' && DONE; + }); +} + +async function getFailCount(page) { + return await page.evaluate(function() { + if (typeof TEST_STATUS !== 'undefined') { + return TEST_STATUS.FAILURES; + } + + if (typeof FAILURES === 'undefined') { + return 1; + } + + return 0; + }); +} + +async function runTests() { + console.log(`Running test with Puppeteer at ${process.env.URL}`); + + // --no-sandbox and --disable-setuid-sandbox must be disabled for CI compatibility + const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] }); + console.log(`Using version: ${await browser.version()}`); + runNextUrl(browser); +} + +runTests();