mercredi 29 juin 2016

Ember/Emberfire + Firebase 3 Acceptance Test

Prior to firebase 3 update our acceptance test have been running without any issues. We use the following in our beforeTest and afterTest

moduleForAcceptance('Acceptance | Dashboard | Items | Library | New', {
  beforeEach() {
    stubFirebase();
    var ref = createOfflineRef(basicDataRef, 'http://ift.tt/1Fn9FlZ');
    replaceAppRef(this.application, ref);
    stubValidSession(this.application, {uid: 'xxxx'});
  },
  afterEach() {
    unstubFirebase();
  }
});

basicDataRef is a fixture for the test. The above code allows my to mock session following the test-helper in torii library to allow my application to correctly obtain the data needed as my firebase hieararchy is as follows: / +--uid +--profile +--otherdata

I am not testing for permission rules, just interaction to save/edit data in the application, and this has worked OK prior to firebase 3 migration. After version 3 all my test returns the following:

    actual: >
        false
    expected: >
        true
    stack: >
            at http://localhost:7357/assets/test-support.js:4130:12
            at exports.default._emberTestingAdaptersAdapter.default.extend.exception (http://localhost:7357/assets/vendor.js:49473:7)
            at onerrorDefault (http://localhost:7357/assets/vendor.js:41461:24)
            at Object.exports.default.trigger (http://localhost:7357/assets/vendor.js:62212:11)
            at http://localhost:7357/assets/vendor.js:63463:40
            at Queue.invoke (http://localhost:7357/assets/vendor.js:10415:16)
    message: >
        Error: permission_denied at /xxxx/profile: Client doesn't have permission to access the desired data.

I always thought the createOfflineRef in emberfire allows us to bypass rules checking. the fact that it keeps returning permission_denied is quite perplexing. Maybe i need to re-engineer the test? Or I approach this wrongly all this time? Any input is greatly appreciated




Aucun commentaire:

Enregistrer un commentaire