Users.spec.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /// <reference types="Cypress" />
  2. describe('Users endpoints', () => {
  3. let token;
  4. before(() => {
  5. cy.getToken().then((tok) => {
  6. token = tok;
  7. });
  8. });
  9. it('Should be able to get yourself', function() {
  10. cy.task('backendApiGet', {
  11. token: token,
  12. path: '/api/users/me'
  13. }).then((data) => {
  14. cy.validateSwaggerSchema('get', 200, '/users/{userID}', data);
  15. expect(data).to.have.property('id');
  16. expect(data.id).to.be.greaterThan(0);
  17. });
  18. });
  19. it('Should be able to get all users', function() {
  20. cy.task('backendApiGet', {
  21. token: token,
  22. path: '/api/users'
  23. }).then((data) => {
  24. cy.validateSwaggerSchema('get', 200, '/users', data);
  25. expect(typeof data).to.be.equal('array');
  26. expect(data.length).to.be.greaterThan(0);
  27. });
  28. });
  29. it('Should be able to update yourself', function() {
  30. cy.task('backendApiPut', {
  31. token: token,
  32. path: '/api/users/me',
  33. data: {
  34. name: 'changed name'
  35. }
  36. }).then((data) => {
  37. cy.validateSwaggerSchema('put', 200, '/users/{userID}', data);
  38. expect(data).to.have.property('id');
  39. expect(data.id).to.be.greaterThan(0);
  40. expect(data.name).to.be.equal('changed name');
  41. });
  42. });
  43. });