DemocracyOS / core

1 stars 1 forks source link

New batch of tests for add/user branch #39

Closed guillecro closed 6 years ago

guillecro commented 6 years ago

For User model

  1. (The user) should be able to edits the profile info (Validating the profile info with the profile info schema) (Should i make tests for failure events? Like.. if i try to edit another's profile info?) (Also, the URI should be PUT /api/v1/user/:id or PUT /api/v1/user/edit and get the user id from keycloak id?)

For Documents

Remake the tests for documents, having in mind the refactoring of CustomType

  1. Should be able to create a document POST /api/v1/documents
  2. Should be able to edit a document PUT /api/v1/documents

For Custom Forms

  1. Admin should be able to create a valid custom form POST /api/v1/user/custom-forms
  2. Admin shouldn't be able to create a custom form if schema is not valid POST /api/v1/user/custom-forms
  3. Admin shouldn't be able to edit a custom form if schema is not valid PUT /api/v1/user/custom-forms

Ideas?

guillecro commented 6 years ago

Done!

> core@3.0.0 test /home/zaqueo/www/core
> NODE_ENV=test mocha --recursive --timeout 10000

  Community API (/api/v1/community)
    As anonymous user
      ✓ GET (/) Anyone should be able to get the community data (95ms)
    As an admin user
      ✓ should get access_token from auth provider (127ms)
      ✓ PUT (/) should be able to update a community info (43ms)

  CustomForm API (/api/v1/custom-forms)
    As anonymous user
      ✓ GET (/) Anyone should be able to get customForm (50ms)
    As an admin user
      ✓ should get access_token from auth provider (133ms)
      ✓ POST (/) it should be able to create a new customForm
      ✓ PUT (/) it should be able to update document type

  Documents API (/api/v1/documents)
    As anonymous user
      ✓ GET (/) should not be able to list documents
      ✓ POST (/) should not be able to create a document
      ✓ GET (/:id) An anonymous user should not be able to get a unpublished document
      ✓ GET (/:id) An anonymous user should able to get a published document
    As an "Accountable" user (Group member: Accountable - Role: accountable)
      ✓ should get access_token from auth provider (134ms)
      ✓ POST (/) it should be able to create a document
      ✓ POST (/) should fail because the permission -documentLimit- is set (Test is limited to 10 tries)
      ✓ GET (/) The author should be able to list its own documents, drafts or published
      ✓ GET (/:id) it should be to retrieve a document
      ✓ PUT (/:id) it should be to update a document (Ex: publishing the document)
      ✓ DELETE (/:id) it should be to delete a document

  User API (/api/v1/users)
    As an logged user
      ✓ should get access_token from auth provider (130ms)
      ✓ PUT (/) should be able to update "my" profile info

  Community DB-APIs
    ✓ Community.create() should create a community (53ms)
    ✓ Community.get() should get the only community created in the database
    ✓ Community.update() should update the only community created in the database

  CustomForm DB-APIs
    ✓ CustomForm.create() should create a customForm
    ✓ CustomForm.get() should get the only customForm created in the database
    ✓ CustomForm.update() should update a customForm
    ✓ CustomForm.list() should list customForms
    ✓ CustomForm.remove() should remove a customForm

  Document DB-APIs
    ✓ Document.create() should create a document
    ✓ Document.get() should get a document
    ✓ Document.list() should list all documents
    ✓ Document.update() should modify a document
    ✓ Document.remove() should remove a document

  User DB-APIs
    ✓ User.create() should create a user
    ✓ User.get() should get a user
    ✓ User.list() should list all users
    ✓ User.update() should modify a user
    ✓ User.remove() should remove a user

  38 passing (1s)