ProjectFeaturesTests.mjs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. import { expect } from 'chai'
  14. import async from 'async'
  15. import User from './helpers/User.mjs'
  16. import request from './helpers/request.js'
  17. import settings from '@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.dropbox).to.equal(true)
  63. return done()
  64. }
  65. )
  66. })
  67. })
  68. describe('with an basic account', function () {
  69. beforeEach(function (done) {
  70. return this.owner.downgradeFeatures(done)
  71. })
  72. after(function (done) {
  73. return this.owner.defaultFeatures(done)
  74. })
  75. it('should have basic features', function (done) {
  76. return joinProject(
  77. this.owner._id,
  78. this.project_id,
  79. (error, response, body) => {
  80. expect(body.project.features.compileGroup).to.equal('standard')
  81. expect(body.project.features.versioning).to.equal(false)
  82. expect(body.project.features.dropbox).to.equal(false)
  83. return done()
  84. }
  85. )
  86. })
  87. })
  88. })
  89. })