title: How to test multiple click events that make api calls with protractor
body: <p>I have some buttons that when clicked make an ajax request, and when the request completes it enables/disables buttons (for pagination). I am not 100% sure on how to handle this since the request takes upto 1000ms, I would like to know if this is the correct way to handle the click by waiting for the next button to become enabled:</p>
  <pre><code>When('I click {string} to navigate pagination', async (item: ButtonType) =&gt; {
    const first = element(by.css('#first'));
    const last = element(by.css('#last'));
    switch (item) {
      case 'first':
        await last.click();
        await browser.wait(until.elementIsEnabled(first.getWebElement()), 1500);
        await first.click();
        break;
    }
  });
  </code></pre>
  <p>Do I even need to tell the browser to wait or does protractor know that it needs to wait automatically?</p>
  <p>Here is one of my assertions:</p>
  <pre><code>Then('I should see the {string} set of items', async (item: ButtonType) =&gt; {
    const firstEnabled = await element(by.css('#first')).isEnabled();
    const prevEnabled = await element(by.css('#prev')).isEnabled();
    const nextEnabled = await element(by.css('#next')).isEnabled();
    const lastEnabled = await element(by.css('#last')).isEnabled();
    switch (item) {
      case 'first':
        expect(firstEnabled).to.eq(false);
        expect(prevEnabled).to.eq(false);
        expect(nextEnabled).to.eq(true);
        expect(lastEnabled).to.eq(true);
        break;
    }
  });
  </code></pre>
  <p>When it runs I am getting the following error:</p>
  <pre><code>[chrome #01-6]    ✖ Then I should see the &quot;first&quot; set of items
  [chrome #01-6]        AssertionError
  [chrome #01-6]            + expected - actual
  [chrome #01-6] 
  [chrome #01-6]            -true
  [chrome #01-6]            +false
  </code></pre>
  <p>The first button should be disabled because there are no more pages before it since it is the first page.</p>
  <p>What is it that I need to do to get this to pass?</p>