From ea48303b57c26a7b42f1039ad1ae99419e02b9ef Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Wed, 7 Dec 2022 21:10:51 +0100 Subject: [PATCH] Fix tests with Firefox (#5180) * Run tests on Ubuntu 22.04 and install Firefox * set window.hasNativeWebVRImplementation to false before calling enterVR to fix tests on Firefox --- .github/workflows/ci.yml | 28 +++++++++++++++-------- tests/components/scene/vr-mode-ui.test.js | 2 ++ tests/core/scene/a-scene.test.js | 3 +++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3770dc702c..63f30ae23b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,10 +11,11 @@ permissions: jobs: test: name: Test Cases - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: node-version: ['16.x'] + firefox-version: ['latest'] steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -31,6 +32,15 @@ jobs: - name: Install dependencies run: npm install + - name: Check Lint + run: npm run lint + + - name: Check Build Minified + run: npm run dist + + - name: Check Docs + run: npm run test:docs + - name: Test Cases Using Chrome uses: GabrielBB/xvfb-action@v1 env: @@ -38,6 +48,13 @@ jobs: with: run: npm run test:chrome -- --single-run + - name: Install Firefox + uses: browser-actions/setup-firefox@latest + with: + firefox-version: ${{ matrix['firefox-version'] }} + + - run: firefox --version + - name: Test Cases Using Firefox uses: GabrielBB/xvfb-action@v1 env: @@ -45,15 +62,6 @@ jobs: with: run: npm run test:firefox -- --single-run - - name: Check Lint - run: npm run lint - - - name: Check Build Minified - run: npm run dist - - - name: Check Docs - run: npm run test:docs - - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/tests/components/scene/vr-mode-ui.test.js b/tests/components/scene/vr-mode-ui.test.js index 6a9a3d05682..abf1811d9d2 100644 --- a/tests/components/scene/vr-mode-ui.test.js +++ b/tests/components/scene/vr-mode-ui.test.js @@ -38,6 +38,7 @@ suite('vr-mode-ui', function () { el: {object3D: {}}, updateProjectionMatrix: function () {} }; + window.hasNativeWebVRImplementation = false; scene.enterVR(); UI_CLASSES.forEach(function (uiClass) { assert.ok(scene.querySelector(uiClass).className.indexOf('a-hidden')); @@ -51,6 +52,7 @@ suite('vr-mode-ui', function () { el: {object3D: {}, getAttribute: function () { return {spectator: false}; }}, updateProjectionMatrix: function () {} }; + window.hasNativeWebVRImplementation = false; scene.enterVR(); scene.exitVR(); diff --git a/tests/core/scene/a-scene.test.js b/tests/core/scene/a-scene.test.js index f8e346d1dd0..f552f69a548 100644 --- a/tests/core/scene/a-scene.test.js +++ b/tests/core/scene/a-scene.test.js @@ -182,6 +182,7 @@ suite('a-scene (without renderer)', function () { test('calls requestPresent if headset connected', function (done) { var sceneEl = this.el; this.sinon.stub(sceneEl, 'checkHeadsetConnected').returns(true); + window.hasNativeWebVRImplementation = false; sceneEl.enterVR().then(function () { assert.ok(sceneEl.renderer.xr.enabled); done(); @@ -203,6 +204,7 @@ suite('a-scene (without renderer)', function () { test('does not call requestPresent if flat desktop', function (done) { var sceneEl = this.el; this.sinon.stub(sceneEl, 'checkHeadsetConnected').returns(false); + window.hasNativeWebVRImplementation = false; sceneEl.enterVR().then(function () { assert.notOk(sceneEl.renderer.xr.enabled); done(); @@ -248,6 +250,7 @@ suite('a-scene (without renderer)', function () { } this.sinon.stub(sceneEl, 'checkHeadsetConnected').returns(false); + window.hasNativeWebVRImplementation = false; sceneEl.enterVR().then(function () { assert.ok(fullscreenSpy.called); done();