DemocracyOS / democracyos

Democracia en Red is focusing on specific implementations of DemocracyOS. We are working now working with governments and activists all over Latin America. If you are interested in our online participation tools you can check them out on our site.
https://democraciaos.org/en/
GNU General Public License v3.0
1.77k stars 616 forks source link

[v3] Fix API & db-API tests for models #1593

Closed guillecro closed 6 years ago

guillecro commented 6 years ago

Finished all the tests!


  /api/v1.0/posts
> Ready on http://localhost:3000 [test]
    As Anonymous
      ✓ should get csrfToken
      ✓ GET / should be able to get a list of all the posts
      ✓ POST / should not be able to create a post
      ✓ GET /:id should be able to get a post
      ✓ PUT /:id should not be able to modify a post
      ✓ DELETE /:id should not be able to delete a post
    As Logged user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to get a list of all the posts
      ✓ POST / should not be able to create a post
      ✓ GET /:id should be able to get a post
      ✓ PUT /:id should not be able to modify a post
      ✓ DELETE /:id should not be able to delete a post
    As an admin user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to get a list of all the posts
      ✓ POST / should be able to create a post
      ✓ GET /:id should be able to get a post
      ✓ PUT /:id should not be able to modify a post
      ✓ DELETE /:id should not be able to delete a post

  /api/v1.0/settings
    As Anonymous
      ✓ should get csrfToken
      ✓ GET / should be able to access settings
      ✓ POST / should not be able to create a setting
      ✓ GET /:id should be able to access a setting
      ✓ PUT /:id should not be able to create a setting
      ✓ DELETE /:id should not be able to delete a setting
    As Logged user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to access the list of settings
      ✓ POST / should not be able to create a setting
      ✓ GET /:id should be able to access a setting
      ✓ PUT /:id should not be able to create a setting
      ✓ DELETE /:id should not be able to delete a setting
    As an admin user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to access the list of settings
      ✓ POST / should return an error if a setting is already created
      ✓ GET /:id should be able to access a setting
      ✓ PUT /:id should be able to modify a setting
      ✓ DELETE /:id should be able to delete a setting

  db-api.posts
    ✓ should #create a post (81ms)
    ✓ should #get a post
    ✓ should #list all posts
    ✓ should #update a post
    ✓ should #remove a post

  db-api.settings
    ✓ should #create a setting
    ✓ should #get a setting
    ✓ should #update a setting
    ✓ should #remove a setting

  /api/v1.0/reaction-instance
    As Anonymous
      ✓ should get csrfToken
      ✓ GET / should NOT be able to get a list of all the reaction instances
      ✓ POST / should not be able to create a reaction instance
      ✓ GET /:id should not be able to get a reaction instance
      ✓ PUT /:id should not be able to modify a reaction instance
      ✓ DELETE /:id should not be able to delete a reaction instance
    As Logged user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should not be able to get a list of all the rules
      ✓ POST / should not be able to create a rule
      ✓ GET /:id should not be able to get a rule
      ✓ PUT /:id should not be able to modify a rule
      ✓ DELETE /:id should not be able to delete a rule
    As an admin user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to get a list of all the rules
      ✓ POST / should be able to create a rule
      ✓ GET /:id should be able to get a rule
      ✓ PUT /:id should be able to modify a rule
      ✓ DELETE /:id should be able to delete a rule

  /api/v1.0/reaction-rule
    As Anonymous
      ✓ should get csrfToken
      ✓ GET / should NOT be able to get a list of all the rules
      ✓ POST / should not be able to create a rule
      ✓ GET /:id should not be able to get a rule
      ✓ PUT /:id should not be able to modify a rule
      ✓ DELETE /:id should not be able to delete a rule
    As Logged user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should not be able to get a list of all the rules
      ✓ POST / should not be able to create a rule
      ✓ GET /:id should not be able to get a rule
      ✓ PUT /:id should not be able to modify a rule
      ✓ DELETE /:id should not be able to delete a rule
    As an admin user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to get a list of all the rules
      ✓ POST / should be able to create a rule
      ✓ GET /:id should be able to get a rule
      ✓ PUT /:id should be able to modify a rule
      ✓ DELETE /:id should be able to delete a rule

  /api/v1.0/reaction-vote
    As Anonymous
      ✓ should get csrfToken
      ✓ GET / should NOT be able to get a list of all the votes
      ✓ POST / should not be able to create a vote
      ✓ GET /:id should not be able to get a vote
      ✓ PUT /:id should not be able to modify a vote
      ✓ DELETE /:id should not be able to delete a vote
    As Logged user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should not be able to get a list of all the votes
      ✓ POST / should not be able to create a vote
      ✓ GET /:id should not be able to get a vote
      ✓ PUT /:id should not be able to modify a vote
      ✓ DELETE /:id should not be able to delete a vote
    As an admin user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to get a list of all the votes
      ✓ POST / should not be able to create a vote
      ✓ GET /:id should be able to get a vote
      ✓ PUT /:id should not be able to modify a vote
      ✓ DELETE /:id should not be able to delete a vote

  db-api.reactionInstance
    ✓ should #create a reaction instance (49ms)
    ✓ should #get a reactionInstance
    ✓ should #list all reactionInstances
    ✓ should #update a reactionInstance
    ✓ should #remove a reactionInstance
    ✓ should #list all the reactions instances
    ✓ should get the result #getResult of a reaction instance

  db-api.reactionRule
    ✓ should #create a reaction rule
    ✓ should #get a reactionRule
    ✓ should #get a reactionRule by a specific name
    ✓ should #list all reactionRules by a partial name
    ✓ should #list all reactionRules
    ✓ should #update a reactionRule
    ✓ should #remove a reactionRule

  db-api.reactionVote
    ✓ should #create a reaction vote
    ✓ should #get a reactionVote
    ✓ should #list all reactionVotes
    ✓ should #update a reactionVote
    ✓ should #remove a reactionVote

  /api/v1.0/services/reactions
    As Anonymous
      ✓ should get csrfToken
      ✓ POST /:idInstance/vote should NOT be able to vote.
      GET /posts/:id/results should get the results of the reaction instances of a post.
        ✓ should have status OK
        ✓ should have 2 reaction instances
        ✓ should have all its property
        ✓ should not have the vote of a user
      GET /:id/result should get the result of one reaction instance.
        ✓ should have status OK
        ✓ should have all its property
        ✓ should not have the vote of a user
    As Logged user (voter1, one who has already voted)
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      GET /posts/:id/results should get the results of the reaction instances of a post.
        ✓ should have status OK
        ✓ should have 2 reaction instances
        ✓ should have all its property
        ✓ should have the vote of the user
      GET /:id/result should get the result of one reaction instance.
        ✓ should have status OK
        ✓ should have all its property
        ✓ should have the vote of a user
      POST /:idInstance/vote should be able to DELETE its vote.
        ✓ should have status OK
        ✓ should have all the properties of a vote
        ✓ GET the just voted reaction instannce. Should have status OK
        ✓ should have all its property
        ✓ should have the vote of a user
    As Logged user (voter3, one who has already voted 5 times..)
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      GET /posts/:id/results should get the results of the reaction instances of a post.
        ✓ should have status OK
        ✓ should have 2 reaction instances
        ✓ should have all its property
        ✓ should have the vote of the user
      GET /:id/result should get the result of one reaction instance.
        ✓ should have status OK
        ✓ should have all its property
        ✓ should have the vote of a user
      POST /:idInstance/vote should be able to change its vote.
        ✓ should have status FORBIDDEN (Limit of 5 votes reached)
        ✓ GET the just voted reaction instannce. Should have status OK
        ✓ should have all its property
        ✓ should have the vote of a user
    As Logged user (voter3, who hasnt voted in instance3..)
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      GET /posts/:id/results should get the results of the reaction instances of post two.
        ✓ should have status OK
        ✓ should have 1 reaction instances
        ✓ should have all its property
        ✓ should have the vote of the user
      GET /:id/result should get the result of one reaction instance.
        ✓ should have status OK
        ✓ should have all its property
        ✓ should have the vote of a user
      POST /:idInstance/vote shoulnt be able to change its vote.
        ✓ should have status FORBIDDEN (Vote has closed - Closing date very old!)
        ✓ GET the just voted reaction instance. Should have status OK
        ✓ should have all its property
        ✓ should have the vote of a user

  /api/v1.0/users
    As Anonymous
      ✓ should get csrfToken
      ✓ GET / should not be able to access the list of all users
      ✓ POST / should not be able to create a user
      ✓ GET /:id should be able to get an user without private data a user
      ✓ PUT /:id should not be able to modify a user
      ✓ DELETE /:id should not be able to delete a user
    As Logged user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to access the list of all users BUT without email info
      ✓ POST / should not be able to create a user
      ✓ GET /:id should be able to get its data with its private data
      ✓ GET /:id should be able to get others data but not its private data
      ✓ PUT /:id should be able to modify its user data
      ✓ PUT /:id should not be able to modify others user data
      ✓ DELETE /:id should not be able to self-delete
      ✓ DELETE /:id should not be able to delete another user
    As an admin user
      ✓ should get csrfToken
      ✓ should log in
      ✓ the session should have a user object
      ✓ GET / should be able to access the list of all users
      ✓ POST / should not be able to create a user
      ✓ GET /:id should be able to get its data with its private data + admin data
      ✓ GET /:id should be able to get others data + its private data (admin purposes)
      ✓ PUT /:id should be able to modify its user data
      ✓ PUT /:id should be able to modify others user data
      ✓ DELETE /:id should be able to delete another user
      ✓ DELETE /:id should be able to self-delete (DANGER)

  db-api.users
    ✓ should #create a user
    ✓ should #get a user
    ✓ should #list all users
    ✓ should #update a user
    ✓ should #remove a user

  223 passing (4s)