ProjectFeaturesTests.js 2.9 KB

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