Skip to content

Commit

Permalink
Fix tests with Firefox (aframevr#5180)
Browse files Browse the repository at this point in the history
* Run tests on Ubuntu 22.04 and install Firefox

* set window.hasNativeWebVRImplementation to false before calling enterVR to fix tests on Firefox
  • Loading branch information
vincentfretin authored Dec 7, 2022
1 parent 5189765 commit ea48303
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,29 +32,36 @@ 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:
TEST_ENV: ci
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:
TEST_ENV: ci
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:
Expand Down
2 changes: 2 additions & 0 deletions tests/components/scene/vr-mode-ui.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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();

Expand Down
3 changes: 3 additions & 0 deletions tests/core/scene/a-scene.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ea48303

Please sign in to comment.