zooniverse / json-api-client

Apache License 2.0
10 stars 5 forks source link

Track saving keys #6

Closed brian-c closed 9 years ago

brian-c commented 9 years ago

Now tracks keys being saved. Changed or saving keys are not overwritten by responses.

parrish commented 9 years ago

I've been messing with this a bit, so I'll check it out

edpaget commented 9 years ago

Thanks.

edpaget commented 9 years ago

We all saw how good my review was last night.

parrish commented 9 years ago

Looks good to me.

Here's my torture test on the project builder:

function name() { return document.getElementsByName('display_name')[0]; }
function description() { return document.getElementsByName('description')[0]; }
function introduction() { return document.getElementsByName('introduction')[0]; }
function focus(el){ el.dispatchEvent(new FocusEvent('focus')); }
function blur(el){ el.dispatchEvent(new FocusEvent('blur')); }
function change(el){ el.dispatchEvent(new Event('input', { bubbles: true })); }

function setValues(value, delay) {
  setTimeout(function() {
    focus(name());

    setTimeout(function() {
      name().value = value;
      change(name());
      blur(name());

      setTimeout(function() {
        focus(description())

        setTimeout(function() {
          description().value = value;
          change(description());
          blur(description());
          focus(introduction());

          setTimeout(function() {
            introduction().value = value;
            change(introduction());
            blur(introduction());
          }, delay); // set introduction
        }, delay); // set description
      }, delay); // focus description
    }, delay); // set name
  }, delay); // focus name
}

function makeAMess(delay) {
  for(var i = 0; i < 10; i++) {
    setTimeout(function() {
      setValues('test ' + this.i, delay / 5);
    }.bind({ i: i }), i * delay)
  }
}

makeAMess(1000);