Skip to content
This repository has been archived by the owner on Aug 8, 2018. It is now read-only.

WIP: hit backend api #85

Closed
wants to merge 1 commit into from
Closed

WIP: hit backend api #85

wants to merge 1 commit into from

Conversation

bcipolli
Copy link
Contributor

I stubbed each API function in the back-end, so that the front-end can actually hit them. I'm 90% sure I'm doing this wrong, but hopefully I can get a pointer or two so I can learn how to do this for myself!

@bcipolli bcipolli added this to the v0.1-API milestone Jan 25, 2016
pageDescription: 'Some description.'
}
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these moved to locality, but yeah, this is the right idea.

@adborden
Copy link
Member

Looks like we're on the right track. Is there a corresponding backend branch that can be used to test this against?

@bcipolli
Copy link
Contributor Author

Thanks @adborden for the notes! With caciviclab/disclosure-backend#149 , I finally understand the frontend/backend interaction.

Once I get caciviclab/disclosure-backend#149 squared away, I will update here.

@bcipolli
Copy link
Contributor Author

@adborden Just one quick question: is the method parameter to setupProxy equivalent to the nickname published by the backend swagger API docs?

@adborden
Copy link
Member

adborden commented Feb 2, 2016

On Tue, 2016-01-26 at 08:27 -0800, Ben Cipollini [email protected] wrote:

@adborden Just one quick question: is the method parameter to setupProxy equivalent to the nickname published by the backend swagger API docs?

Mostly. I think the nickname would also include the '.list' or
'.retrieve' part?

I should also mention that the swagger-client lib we're using on the
frontend supports swagger 1.2 (supported by rest-swagger), but works
better for 2.0. So it might make sense to add some name munging in the
frontend swagger client wrapper where swagger-client isn't cutting it.

Aaron Borden
Human and Hacker

@bcipolli
Copy link
Contributor Author

bcipolli commented Feb 7, 2016

@adborden This is updated, corresponding to backend PR caciviclab/disclosure-backend#177

locality_id: $stateParams.locality_id
}).then(function(ballot) {
disclosureApi.ballot.summary({ballot_id: ballot.ballot_id});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adborden This is more complex than before; I like the way this API is defined, but not sure if this is the right way to chain API calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but your hunch is right. angular ui-router cleans this up for us:

resolve: {
  locality: function($stateParams, disclosureApi) {
    return disclosureApi.locations.get({locality_id: $stateParams.locality_id});
  },
  ballot: function($stateParams, disclosureApi) {
    return disclosureApi.locality.current_ballot({locality_id: $stateParams.locality_id });
  },
  ballotSummary: function(disclosureApi, ballot) {
   return disclosureApi.ballot.summary({ballot_id: ballot.ballot_id});
  }
}

expect(ballot).to.have.property('ballot_id');
expect(ballot).to.have.property('ballot_items');
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use a known-good locality id. Otherwise it's testing too much IMHO.

@adborden
Copy link
Member

This is great! The tests are a bit too complicated IMHO, so I'd like to swap the chained calls for known good IDs. As soon as the build is green I'll merge this.

@bcipolli
Copy link
Contributor Author

@adborden I'm not sure there are known good IDs that will be common to every system. It will depend on what data has been added to the backend.

Perhaps simply refactoring the tests, so that they're easier to read, would keep the flexibility of running these tests on systems with different data, but make the tests easier to grok?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants