Closed Bug 909631 Opened 11 years ago Closed 11 years ago

Renable Everything me test (fails in ci)

Categories

(Firefox OS Graveyard :: Gaia::Homescreen, defect)

defect
Not set
normal

Tracking

(blocking-b2g:-)

RESOLVED FIXED
blocking-b2g -

People

(Reporter: jlal, Assigned: evyatar)

References

Details

Attachments

(1 file)

      No description provided.
Flags: needinfo?(crdlc)
Summary: Everything me test fails in ci → Renable Everything me test (fails in ci)
Please Evyatar, could you take a look to this bug?, it is failing after landing the migration feature
Flags: needinfo?(crdlc) → needinfo?(evyatar)
It fails on the "asyncStorage" object, even though it's included in the homescreen's index.html. it works well when building - any idea what the test does differently?

including async_storage: https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen/index.html#L18
including everything.me.js: https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen/index.html#L38
the JS line: https://github.com/mozilla-b2g/gaia/blob/master/apps/homescreen/everything.me/js/everything.me.js#L196
Flags: needinfo?(evyatar)
so I should copy the mock_asyncStorage into the homescreen's test folder, and include it in everything.me's test JS?

just noting - this means that the "keys" will always be empty so this function won't "really" run. can I add demo values in my mock file?
Yes, you can add to your mock what you want and test it. If it is empty, really the function doesn't run and test shouldn't fail neither. Although if you add some key you can test the behavior of your algorithm as well. Thanks
should I mock the "localStorage" as well? or is that built in?
The mock could be like this, forget localStorage, right? or do you need to mock localStorage for something?

https://github.com/mozilla-b2g/gaia/blob/master/apps/communications/contacts/test/unit/mock_asyncstorage.js
if I just create this it would work - but it won't do anything.
I want to force some stuff into the localStorage, but the method to actually run.
At the beginning of the test you can add

MockasyncStorage.keys = {
 'blabla' : 'aaaa',
 'blabla' : 'bbbb'
};

At the end reset if by default

MockasyncStorage.keys = {};

So you have a storage filled :)
but I want to add the keys to the localStorage, not the async one :)

could I add inside the "suiteSetup" method something like that
localStorage["MY KEY"] = "MY VALUE";

or is that not the correct way?
Assignee: nobody → evyatar
yes, you can BUT remember save the original localStorage in the suiteSetup and restore this one in the suiteTeardown

For example mocking elementFromPoint from DOM

suite('blabla.js >', function() {

 var realElementFromPoint;

 suiteSetup(function() {
   realElementFromPoint = HTMLDocument.prototype.elementFromPoint;
 });

 suiteTeardown(function() {
   HTMLDocument.prototype.elementFromPoint = realElementFromPoint;
 });

 test('My test ', function() {
   HTMLDocument.prototype.elementFromPoint = function() {
     return {x: 0, y: 0};
   };
   // Do something
 });
}
Attachment #795969 - Flags: review?(crdlc)
Comment on attachment 795969 [details]
Patch - redirect to github PR

Great work as usual! thanks
Attachment #795969 - Flags: review?(crdlc) → review+
https://github.com/mozilla-b2g/gaia/commit/babd62446049592fb912aec0025c33a871979761
Status: NEW → RESOLVED
blocking-b2g: --- → leo?
Closed: 11 years ago
Resolution: --- → FIXED
adding leo since the original ticket 907160 also has leo+
If this doesn't fix a real bug, I don't think we want to include this in 1.1. Unit tests are (unfortunately) not passing in 1.1 for a long time anyway.
We discussed this during triage today and the consensus was that it didn't meet the criteria for what should block 1.1:

  https://wiki.mozilla.org/B2G/Triage#Issues_that_Should_Block

Obviously if you disagree please renom with some comments :)
blocking-b2g: leo? → -
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: