diff --git a/.github/workflows/local.yml b/.github/workflows/local.yml deleted file mode 100644 index 76a8a02d1..000000000 --- a/.github/workflows/local.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: local - -on: [pull_request] - -jobs: - polymer-2: - runs-on: ubuntu-latest - - steps: - - name: Set up Node 12.x - uses: actions/setup-node@v2 - with: - node-version: 12.x - - - name: Check out the source code - uses: actions/checkout@v2 - - - name: Install latest npm - # magi-cli 1.0 requires npm 7 or higher - run: "npm install -g npm@8" - - - name: Install global npm dependencies - # bower is needed to run 'bower install' - run: "npm install --quiet --no-progress --global bower" - - - name: Install project npm dependencies - run: "npm ci" - - - name: Install project Bower dependencies - run: "bower install --quiet" - - - name: Run automated magi-cli checks - run: "npm run check" - - - name: Run a linter - run: "npm run lint" - - - name: Run unit tests - run: xvfb-run -s '-screen 0 1024x768x24' npm test - - - name: Run unit tests - Polymer2 specific - run: xvfb-run -s '-screen 0 1024x768x24' npm test --suite polymer2Only - - polymer-3: - runs-on: ubuntu-latest - - steps: - - name: Set up Node 12.x - uses: actions/setup-node@v2 - with: - node-version: 12.x - - - name: Check out the (Polymer 2) source code - uses: actions/checkout@v2 - - - name: Install latest npm - # magi-cli 1.0 requires npm 7 or higher - run: "npm install -g npm@8" - - - name: Install global npm dependencies - # bower and polymer-modulizer are needed to run the Polymer 3 conversion step - run: "npm install --quiet --no-progress --global bower magi-cli polymer-modulizer" - - - name: Convert the source code to Polymer 3 - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - magi p3-convert --out . --import-style=name - - - name: Run unit tests - run: xvfb-run -s '-screen 0 1024x768x24' npm test diff --git a/.github/workflows/sauce-p2.yml b/.github/workflows/sauce-p2.yml deleted file mode 100644 index d10303e5f..000000000 --- a/.github/workflows/sauce-p2.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: sauce-p2 - -on: [push] - -jobs: - tests: - runs-on: ubuntu-latest - - steps: - - name: Set up Node 12.x - uses: actions/setup-node@v2 - with: - node-version: 12.x - - - name: Check out the source code - uses: actions/checkout@v2 - - - name: Install latest npm - # magi-cli 1.0 requires npm 7 or higher - run: "npm install -g npm@8" - - - name: Install global npm dependencies - # bower is needed to run 'bower install' - run: "npm install --quiet --no-progress --global bower" - - - name: Install project npm dependencies - run: "npm ci" - - - name: Install project Bower dependencies - run: "bower install --quiet" - - - name: Run unit tests [Desktop / Batch 1] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch1 - - - name: Run unit tests [Desktop / Batch 2] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch2 - - - name: Run unit tests [Desktop / Batch 3] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch3 - - - name: Run unit tests [Desktop / Batch 4] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch4 - - - name: Run unit tests [Desktop / Batch 5] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch5 - - - name: Run unit tests [Desktop / Polymer2 Only] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites polymer2Only diff --git a/.github/workflows/sauce-p3.yml b/.github/workflows/sauce-p3.yml deleted file mode 100644 index c5ea3540d..000000000 --- a/.github/workflows/sauce-p3.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: sauce-p3 - -on: [push] - -jobs: - tests: - runs-on: ubuntu-latest - - steps: - - name: Set up Node 12.x - uses: actions/setup-node@v2 - with: - node-version: 12.x - - - name: Check out the (Polymer 2) source code - uses: actions/checkout@v2 - - - name: Install latest npm - # magi-cli 1.0 requires npm 7 or higher - run: "npm install -g npm@8" - - - name: Install global npm dependencies - # bower and polymer-modulizer are needed to run the Polymer 3 conversion step - run: "npm install --quiet --no-progress --global bower magi-cli polymer-modulizer" - - - name: Convert the source code to Polymer 3 - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - magi p3-convert --out . --import-style=name - - - name: Run unit tests [Desktop / Batch 1] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch1 - - - name: Run unit tests [Desktop / Batch 2] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch2 - - - name: Run unit tests [Desktop / Batch 3] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch3 - - - name: Run unit tests [Desktop / Batch 4] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch4 - - - name: Run unit tests [Desktop / Batch 5] - env: - SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} - SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: npm test -- --env saucelabs:desktop --suites batch5 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..a6e71b225 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,96 @@ +name: Unit Tests + +# all pull requests +on: pull_request + +jobs: +# Running local tests is disabled due to outdated dependencies +# see https://github.com/vaadin/components-team-tasks/issues/628 +# unit-tests-p2: +# name: Polymer 2 on the CI agent +# runs-on: ubuntu-latest +# steps: +# - name: Set up Node 16.x +# uses: actions/setup-node@v4 +# with: +# node-version: 16.x +# +# - name: Check out the source code +# uses: actions/checkout@v2 +# +# - name: Install global npm dependencies +# # bower is needed to run 'bower install' +# # polymer-cli is needed to run the lint step +# run: "npm install --quiet --no-progress --global bower polymer-cli" +# +# - name: Install project npm dependencies +# run: "npm ci" +# +# - name: Install project Bower dependencies +# run: "bower install --quiet" +# +# - name: Run automated magi-cli checks +# run: "npm run check" +# +# - name: Run a linter +# run: "npm run lint" +# +# # the full set of environments is tested with Polymer 3 below +# - name: Run unit tests locally (in the VM instance running this job) +# run: "xvfb-run -s '-screen 0 1024x768x24' npm test" + + unit-tests-p3: + name: Polymer 3 on SauceLabs + runs-on: ubuntu-latest + steps: + - name: Set up Node 16.x + uses: actions/setup-node@v4 + with: + node-version: 16.x + + - name: Check out the (Polymer 2) source code + uses: actions/checkout@v2 + + - name: Install global npm dependencies + # bower and polymer-modulizer are needed to run the Polymer 3 conversion step + run: "npm install --quiet --no-progress --global bower magi-cli polymer-modulizer" + + - name: Convert the source code to Polymer 3 + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + magi p3-convert --out . --import-style=name + + # workaround for running tests on Android on SauceLabs (see wct.conf.js) + - name: Add 'localhost-for-saucelabs' to /etc/hosts + run: echo "127.0.0.1 localhost-for-saucelabs" | sudo tee -a /etc/hosts + + - name: Run unit tests [Desktop / Batch 1] + env: + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + run: npm test -- --env saucelabs --suites batch1 + + - name: Run unit tests [Desktop / Batch 2] + env: + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + run: npm test -- --env saucelabs --suites batch2 + + - name: Run unit tests [Desktop / Batch 3] + env: + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + run: npm test -- --env saucelabs --suites batch3 + + - name: Run unit tests [Desktop / Batch 4] + env: + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + run: npm test -- --env saucelabs --suites batch4 + + - name: Run unit tests [Desktop / Batch 5] + env: + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + run: npm test -- --env saucelabs --suites batch5 diff --git a/.github/workflows/sauce-visual.yaml b/.github/workflows/visual-tests.yml.disabled similarity index 100% rename from .github/workflows/sauce-visual.yaml rename to .github/workflows/visual-tests.yml.disabled diff --git a/README.md b/README.md index 27b42e135..2d7d83aee 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,9 @@ To use the Material theme, import the correspondent file from the `theme/materia ## Running tests from the command line +> [!WARNING] +> Running tests locally from the CLI does not work due to outdated dependencies. Run tests via SauceLabs or in the browser instead. + 1. When in the `vaadin-grid` directory, run `polymer test` diff --git a/package-lock-p3.json b/package-lock-p3.json index d2f15f3d3..aeac47d3b 100644 --- a/package-lock-p3.json +++ b/package-lock-p3.json @@ -9750,8 +9750,7 @@ }, "node_modules/sauce-connect-launcher": { "version": "1.3.2", - "resolved": "https://registry.npmjs.org/sauce-connect-launcher/-/sauce-connect-launcher-1.3.2.tgz", - "integrity": "sha512-wf0coUlidJ7rmeClgVVBh6Kw55/yalZCY/Un5RgjSnTXRAeGqagnTsTYpZaqC4dCtrY4myuYpOAZXCdbO7lHfQ==", + "resolved": "git+ssh://git@github.com/vaadin/sauce-connect-launcher.git#20fca782221404fef626c985e975268bfaba05cd", "dev": true, "hasInstallScript": true, "optional": true, @@ -21909,10 +21908,9 @@ "dev": true }, "sauce-connect-launcher": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/sauce-connect-launcher/-/sauce-connect-launcher-1.3.2.tgz", - "integrity": "sha512-wf0coUlidJ7rmeClgVVBh6Kw55/yalZCY/Un5RgjSnTXRAeGqagnTsTYpZaqC4dCtrY4myuYpOAZXCdbO7lHfQ==", + "version": "git+ssh://git@github.com/vaadin/sauce-connect-launcher.git#20fca782221404fef626c985e975268bfaba05cd", "dev": true, + "from": "sauce-connect-launcher@vaadin/sauce-connect-launcher#upgrade-sauce-connect-5", "optional": true, "requires": { "adm-zip": "~0.4.3", @@ -24520,7 +24518,7 @@ "cleankill": "^2.0.0", "lodash": "^4.17.10", "request": "^2.85.0", - "sauce-connect-launcher": "^1.0.0", + "sauce-connect-launcher": "vaadin/sauce-connect-launcher#upgrade-sauce-connect-5", "temp": "^0.8.1", "uuid": "^3.2.1" } diff --git a/package-lock.json b/package-lock.json index 161db52e0..9750bbcfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12115,8 +12115,7 @@ }, "node_modules/sauce-connect-launcher": { "version": "1.3.2", - "resolved": "https://registry.npmjs.org/sauce-connect-launcher/-/sauce-connect-launcher-1.3.2.tgz", - "integrity": "sha512-wf0coUlidJ7rmeClgVVBh6Kw55/yalZCY/Un5RgjSnTXRAeGqagnTsTYpZaqC4dCtrY4myuYpOAZXCdbO7lHfQ==", + "resolved": "git+ssh://git@github.com/vaadin/sauce-connect-launcher.git#20fca782221404fef626c985e975268bfaba05cd", "dev": true, "hasInstallScript": true, "optional": true, @@ -27255,10 +27254,9 @@ "dev": true }, "sauce-connect-launcher": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/sauce-connect-launcher/-/sauce-connect-launcher-1.3.2.tgz", - "integrity": "sha512-wf0coUlidJ7rmeClgVVBh6Kw55/yalZCY/Un5RgjSnTXRAeGqagnTsTYpZaqC4dCtrY4myuYpOAZXCdbO7lHfQ==", + "version": "git+ssh://git@github.com/vaadin/sauce-connect-launcher.git#20fca782221404fef626c985e975268bfaba05cd", "dev": true, + "from": "sauce-connect-launcher@vaadin/sauce-connect-launcher#upgrade-sauce-connect-5", "optional": true, "requires": { "adm-zip": "~0.4.3", @@ -30703,7 +30701,7 @@ "cleankill": "^2.0.0", "lodash": "^4.17.10", "request": "^2.85.0", - "sauce-connect-launcher": "^1.0.0", + "sauce-connect-launcher": "vaadin/sauce-connect-launcher#upgrade-sauce-connect-5", "temp": "^0.8.1", "uuid": "^3.2.1" } diff --git a/package.json b/package.json index 7b38f0730..c0c5f5807 100644 --- a/package.json +++ b/package.json @@ -51,5 +51,10 @@ "data-grid", "data-table" ], - "dependencies": {} + "dependencies": {}, + "overrides": { + "wct-sauce": { + "sauce-connect-launcher": "vaadin/sauce-connect-launcher#upgrade-sauce-connect-5" + } + } } diff --git a/wct.conf.js b/wct.conf.js index c27d0da53..80e2351cf 100644 --- a/wct.conf.js +++ b/wct.conf.js @@ -5,9 +5,14 @@ var env = envIndex ? process.argv[envIndex] : undefined; var suitesIndex = process.argv.indexOf('--suites') + 1; var suitesParam = suitesIndex ? process.argv[suitesIndex] : undefined; +// workaround for Android 7+ blocking all HTTP traffic +// see https://wiki.saucelabs.com/display/DOCS/Known+Issues +// add it to your own local `/etc/hosts` to run SauceLabs tests locally +var tunneledLocalhost = 'localhost-for-saucelabs'; + module.exports = { testTimeout: 360 * 1000, - verbose: true, + verbose: false, plugins: { local: { browserOptions: { @@ -17,80 +22,48 @@ module.exports = { 'no-sandbox' ] } - } + }, }, - registerHooks: function(context) { + registerHooks: function(context) { if (suitesParam) { context.options.suites = suites[suitesParam] || []; } else { context.options.suites = suites.all; } - const saucelabsPlatformsMobile = [ - 'iOS Simulator/iphone@12.2', - 'iOS Simulator/iphone@10.3' - ]; - - const saucelabsPlatformsDesktop = [ - 'macOS 10.13/safari@latest', - 'Windows 10/microsoftedge@18', - 'Windows 10/internet explorer@11' - ]; - - const cronPlatforms = [ - 'iOS Simulator/ipad@12.2', - 'iOS Simulator/iphone@10.3', + const testBrowsers = [ + { + deviceName: 'Android GoogleAPI Emulator', + platformName: 'Android', + platformVersion: '11.0', + browserName: 'Chrome', + }, + 'iOS Simulator/iphone@10.3', // should be 9.x, but SauceLabs does not provide that + 'macOS 11/safari@latest', + 'Windows 10/microsoftedge@latest', + 'Windows 10/internet explorer@11', 'Windows 10/chrome@latest', - 'Windows 10/firefox@latest' + 'Windows 10/firefox@latest', ]; - if (env === 'saucelabs:mobile') { - context.options.plugins.sauce.browsers = saucelabsPlatformsMobile; - - } else if (env === 'saucelabs:desktop') { - context.options.plugins.sauce.browsers = saucelabsPlatformsDesktop; - - } else if (env === 'saucelabs') { - context.options.plugins.sauce.browsers = [ - ...saucelabsPlatformsMobile, - ...saucelabsPlatformsDesktop - ]; + if (env === 'saucelabs') { + context.options.webserver = context.options.webserver || {}; + context.options.webserver.hostname = tunneledLocalhost; + context.options.plugins.sauce.tunnelOptions = { + tunnelDomains: tunneledLocalhost + }; - } else if (env === 'saucelabs-cron') { - context.options.plugins.sauce.browsers = cronPlatforms; - - // Add coverage for local tests only - } else { - /* context.options.plugins.istanbul = { - 'dir': './coverage', - 'reporters': ['text-summary', 'lcov'], - 'include': [ - '/vaadin-grid-active-item-mixin.html', - '/vaadin-grid-array-data-provider-mixin.html', - '/vaadin-grid-cell-click-mixin.html', - '/vaadin-grid-column-group.html', - '/vaadin-grid-column-reordering-mixin.html', - '/vaadin-grid-column-resizing-mixin.html', - '/vaadin-grid-column.html', - '/vaadin-grid-data-provider-mixin.html', - '/vaadin-grid-dynamic-columns-mixin.html', - '/vaadin-grid-filter-mixin.html', - '/vaadin-grid-filter.html', - '/vaadin-grid-keyboard-navigation-mixin.html', - '/vaadin-grid-row-details-mixin.html', - '/vaadin-grid-scroll-mixin.html', - '/vaadin-grid-scroller.html', - '/vaadin-grid-selection-column.html', - '/vaadin-grid-selection-mixin.html', - '/vaadin-grid-sort-mixin.html', - '/vaadin-grid-sorter.html', - '/vaadin-grid-styles.html', - '/vaadin-grid-templatizer.html', - '/vaadin-grid.html' - ], - 'exclude': [] - };*/ + context.options.plugins.sauce.browsers = testBrowsers; } + + // Map legacy tunnel-identifier option to new tunnel-name option + context.hookLate('prepare', (done) => { + context.options.activeBrowsers.forEach((browser) => { + browser['tunnel-name'] = browser['tunnel-identifier']; + delete browser['tunnel-identifier']; + }); + done(); + }); } };