ProjectFeaturesTests.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. qs: { user_id: userId },
  23. auth: {
  24. user: settings.apis.web.user,
  25. pass: settings.apis.web.pass,
  26. sendImmediately: true,
  27. },
  28. json: true,
  29. jar: false,
  30. },
  31. callback
  32. )
  33. describe('ProjectFeatures', function () {
  34. beforeEach(function (done) {
  35. this.timeout(90000)
  36. this.owner = new User()
  37. return async.series([cb => this.owner.login(cb)], done)
  38. })
  39. describe('with private project', function () {
  40. beforeEach(function (done) {
  41. return this.owner.createProject('private-project', (error, projectId) => {
  42. if (error != null) {
  43. return done(error)
  44. }
  45. this.project_id = projectId
  46. return done()
  47. })
  48. })
  49. describe('with an upgraded account', function () {
  50. beforeEach(function (done) {
  51. return this.owner.upgradeFeatures(done)
  52. })
  53. after(function (done) {
  54. return this.owner.defaultFeatures(done)
  55. })
  56. it('should have premium features', function (done) {
  57. return joinProject(
  58. this.owner._id,
  59. this.project_id,
  60. (error, response, body) => {
  61. expect(body.project.features.compileGroup).to.equal('priority')
  62. expect(body.project.features.versioning).to.equal(true)
  63. expect(body.project.features.templates).to.equal(true)
  64. expect(body.project.features.dropbox).to.equal(true)
  65. return done()
  66. }
  67. )
  68. })
  69. })
  70. describe('with an basic account', function () {
  71. beforeEach(function (done) {
  72. return this.owner.downgradeFeatures(done)
  73. })
  74. after(function (done) {
  75. return this.owner.defaultFeatures(done)
  76. })
  77. it('should have basic features', function (done) {
  78. return joinProject(
  79. this.owner._id,
  80. this.project_id,
  81. (error, response, body) => {
  82. expect(body.project.features.compileGroup).to.equal('standard')
  83. expect(body.project.features.versioning).to.equal(false)
  84. expect(body.project.features.templates).to.equal(false)
  85. expect(body.project.features.dropbox).to.equal(false)
  86. return done()
  87. }
  88. )
  89. })
  90. })
  91. })
  92. })