ProjectFeaturesTests.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* eslint-disable
  2. n/handle-callback-err,
  3. max-len,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * DS207: Consider shorter variations of null checks
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. const { expect } = require('chai')
  14. const async = require('async')
  15. const User = require('./helpers/User')
  16. const request = require('./helpers/request')
  17. const settings = require('@overleaf/settings')
  18. const joinProject = (userId, projectId, callback) =>
  19. request.post(
  20. {
  21. url: `/project/${projectId}/join`,
  22. auth: {
  23. user: settings.apis.web.user,
  24. pass: settings.apis.web.pass,
  25. sendImmediately: true,
  26. },
  27. json: { userId },
  28. jar: false,
  29. },
  30. callback
  31. )
  32. describe('ProjectFeatures', function () {
  33. beforeEach(function (done) {
  34. this.timeout(90000)
  35. this.owner = new User()
  36. return async.series([cb => this.owner.login(cb)], done)
  37. })
  38. describe('with private project', function () {
  39. beforeEach(function (done) {
  40. return this.owner.createProject('private-project', (error, projectId) => {
  41. if (error != null) {
  42. return done(error)
  43. }
  44. this.project_id = projectId
  45. return done()
  46. })
  47. })
  48. describe('with an upgraded account', function () {
  49. beforeEach(function (done) {
  50. return this.owner.upgradeFeatures(done)
  51. })
  52. after(function (done) {
  53. return this.owner.defaultFeatures(done)
  54. })
  55. it('should have premium features', function (done) {
  56. return joinProject(
  57. this.owner._id,
  58. this.project_id,
  59. (error, response, body) => {
  60. expect(body.project.features.compileGroup).to.equal('priority')
  61. expect(body.project.features.versioning).to.equal(true)
  62. expect(body.project.features.templates).to.equal(true)
  63. expect(body.project.features.dropbox).to.equal(true)
  64. return done()
  65. }
  66. )
  67. })
  68. })
  69. describe('with an basic account', function () {
  70. beforeEach(function (done) {
  71. return this.owner.downgradeFeatures(done)
  72. })
  73. after(function (done) {
  74. return this.owner.defaultFeatures(done)
  75. })
  76. it('should have basic features', function (done) {
  77. return joinProject(
  78. this.owner._id,
  79. this.project_id,
  80. (error, response, body) => {
  81. expect(body.project.features.compileGroup).to.equal('standard')
  82. expect(body.project.features.versioning).to.equal(false)
  83. expect(body.project.features.templates).to.equal(false)
  84. expect(body.project.features.dropbox).to.equal(false)
  85. return done()
  86. }
  87. )
  88. })
  89. })
  90. })
  91. })