Merge pull request #2039 from overleaf/spd-more-nondependent-tests

Replace before with beforeEach in (most) acceptance tests

GitOrigin-RevId: 888c320d5616d541c112c007c488c38448c4c88d
This commit is contained in:
Eric Mc Sween
2019-08-06 12:34:15 +00:00
committed by sharelatex
parent 5d0c6cddf6
commit 1c43219315
16 changed files with 61 additions and 61 deletions
@@ -25,7 +25,7 @@ const authed_request = request.defaults({
describe('ApiClsiTests', function() {
describe('compile', function() {
before(function(done) {
beforeEach(function(done) {
this.compileSpec = {
compile: {
options: {
@@ -259,7 +259,7 @@ const expect_no_admin_access = (user, project_id, options, callback) =>
)
describe('Authorization', function() {
before(function(done) {
beforeEach(function(done) {
this.timeout(90000)
this.owner = new User()
this.other1 = new User()
@@ -286,7 +286,7 @@ describe('Authorization', function() {
})
describe('private project', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.createProject(
'private-project',
(error, project_id) => {
@@ -399,7 +399,7 @@ describe('Authorization', function() {
})
describe('shared project', function() {
before(function(done) {
beforeEach(function(done) {
this.rw_user = this.other1
this.ro_user = this.other2
return this.owner.createProject(
@@ -483,7 +483,7 @@ describe('Authorization', function() {
})
describe('public read-write project', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.createProject(
'public-rw-project',
(error, project_id) => {
@@ -550,7 +550,7 @@ describe('Authorization', function() {
})
describe('public read-only project', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.createProject(
'public-ro-project',
(error, project_id) => {
@@ -23,7 +23,7 @@ const MockProjectHistoryApi = require('./helpers/MockProjectHistoryApi')
const MockV1Api = require('./helpers/MockV1Api')
describe('Exports', function() {
before(function(done) {
beforeEach(function(done) {
this.brand_variation_id = '18'
this.owner = new User()
return this.owner.login(error => {
@@ -15,7 +15,7 @@ const async = require('async')
const User = require('./helpers/User')
describe('Project CRUD', function() {
before(function(done) {
beforeEach(function(done) {
this.user = new User()
return this.user.login(done)
})
@@ -33,7 +33,7 @@ const request = require('./helpers/request')
const User = require('./helpers/User')
describe('ProjectDuplicateNames', function() {
before(function(done) {
beforeEach(function(done) {
this.owner = new User()
this.owner.login(done)
this.project = {}
@@ -41,7 +41,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('creating a project from the example template', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.createProject(
'example-project',
{ template: 'example' },
@@ -101,7 +101,7 @@ describe('ProjectDuplicateNames', function() {
describe('for an existing doc', function() {
describe('trying to add a doc with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc`,
@@ -123,7 +123,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to add a folder with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder`,
@@ -145,7 +145,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to add a folder with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder`,
@@ -169,7 +169,7 @@ describe('ProjectDuplicateNames', function() {
describe('for an existing file', function() {
describe('trying to add a doc with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc`,
@@ -191,7 +191,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to add a folder with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder`,
@@ -213,7 +213,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to upload a file with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/upload`,
@@ -252,7 +252,7 @@ describe('ProjectDuplicateNames', function() {
describe('for an existing folder', function() {
describe('trying to add a doc with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc`,
@@ -274,7 +274,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to add a folder with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder`,
@@ -296,7 +296,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to upload a file with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/upload`,
@@ -332,7 +332,7 @@ describe('ProjectDuplicateNames', function() {
describe('for an existing doc', function() {
describe('trying to rename a doc to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc/${
@@ -355,7 +355,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to rename a folder to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder/${
@@ -378,7 +378,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to rename a file to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/file/${
@@ -403,7 +403,7 @@ describe('ProjectDuplicateNames', function() {
describe('for an existing file', function() {
describe('trying to rename a doc to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc/${
@@ -426,7 +426,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to rename a folder to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder/${
@@ -449,7 +449,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to rename a file to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/file/${
@@ -474,7 +474,7 @@ describe('ProjectDuplicateNames', function() {
describe('for an existing folder', function() {
describe('trying to rename a doc to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc/${
@@ -497,7 +497,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to rename a folder to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder/${
@@ -520,7 +520,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to rename a file to the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/file/${
@@ -544,7 +544,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('for an existing folder with a file with the same name', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc`,
@@ -595,7 +595,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to move a doc into the folder', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/doc/${
@@ -618,7 +618,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to move a file into the folder', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/file/${
@@ -641,7 +641,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to move a folder into the folder', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder/${
@@ -664,7 +664,7 @@ describe('ProjectDuplicateNames', function() {
})
describe('trying to move a folder into a subfolder of itself', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.request.post(
{
uri: `/project/${this.example_project_id}/folder/${
@@ -34,14 +34,14 @@ const joinProject = (user_id, project_id, callback) =>
)
describe('ProjectFeatures', function() {
before(function(done) {
beforeEach(function(done) {
this.timeout(90000)
this.owner = new User()
return async.series([cb => this.owner.login(cb)], done)
})
describe('with private project', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.createProject(
'private-project',
(error, project_id) => {
@@ -55,7 +55,7 @@ describe('ProjectFeatures', function() {
})
describe('with an upgraded account', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.upgradeFeatures(done)
})
after(function(done) {
@@ -78,7 +78,7 @@ describe('ProjectFeatures', function() {
})
describe('with an basic account', function() {
before(function(done) {
beforeEach(function(done) {
return this.owner.downgradeFeatures(done)
})
after(function(done) {
@@ -32,7 +32,7 @@ const _ = require('lodash')
describe('ProjectStructureMongoLock', () =>
describe('whilst a project lock is taken', function() {
before(function(done) {
beforeEach(function(done) {
// We want to instantly fail if the lock is taken
LockManager.MAX_LOCK_WAIT_TIME = 1
this.lockValue = 'lock-value'
@@ -124,7 +124,7 @@ describe('ProjectStructureMongoLock', () =>
})
describe('interacting with other projects', function() {
before(function(done) {
beforeEach(function(done) {
return ProjectCreationHandler.createBlankProject(
this.user._id,
'unlocked-project',
@@ -26,7 +26,7 @@ const assertResponse = (path, expectedStatusCode, expectedBody, cb) =>
})
describe('ProxyUrls', function() {
before(function() {
beforeEach(function() {
return this.timeout(1000)
})
@@ -24,7 +24,7 @@ const assertRedirect = (method, path, expectedStatusCode, destination, cb) =>
})
describe('RedirectUrls', function() {
before(function() {
beforeEach(function() {
return this.timeout(1000)
})
@@ -25,7 +25,7 @@ const MockDocstoreApi = require('./helpers/MockDocstoreApi')
const MockFileStoreApi = require('./helpers/MockFileStoreApi')
describe('RestoringFiles', function() {
before(function(done) {
beforeEach(function(done) {
this.owner = new User()
return this.owner.login(error => {
if (error != null) {
@@ -44,7 +44,7 @@ const assert_has_no_cache_headers = function(response) {
}
describe('SecurityHeaders', function() {
before(function() {
beforeEach(function() {
return (this.user = new User())
})
@@ -21,7 +21,7 @@ const MockV1Api = require('./helpers/MockV1Api')
const MockTagsApi = require('./helpers/MockTagsApi')
describe('Sessions', function() {
before(function(done) {
beforeEach(function(done) {
this.timeout(20000)
this.user1 = new User()
this.site_admin = new User({ email: 'admin@example.com' })
@@ -84,7 +84,7 @@ describe('Sessions', function() {
}))
describe('two sessions', function() {
before(function() {
beforeEach(function() {
// set up second session for this user
this.user2 = new User()
this.user2.email = this.user1.email
@@ -204,7 +204,7 @@ describe('Sessions', function() {
})
describe('three sessions, password reset', function() {
before(function() {
beforeEach(function() {
// set up second session for this user
this.user2 = new User()
this.user2.email = this.user1.email
@@ -323,7 +323,7 @@ describe('Sessions', function() {
})
describe('three sessions, sessions page', function() {
before(function(done) {
beforeEach(function(done) {
// set up second session for this user
this.user2 = new User()
this.user2.email = this.user1.email
@@ -14,7 +14,7 @@ const User = require('./helpers/User')
const MockV1Api = require('./helpers/MockV1Api')
describe('SettingsPage', function() {
before(function(done) {
beforeEach(function(done) {
this.user = new User()
this.v1Id = 1234
this.v1User = {
@@ -22,13 +22,13 @@ const MockV1Api = require('./helpers/MockV1Api')
describe('Subscriptions', function() {
describe('dashboard', function() {
before(function(done) {
beforeEach(function(done) {
this.user = new User()
return this.user.ensureUserExists(done)
})
describe('when the user has no subscription', function() {
before(function(done) {
beforeEach(function(done) {
return SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel(
this.user,
(error, data) => {
@@ -51,7 +51,7 @@ describe('Subscriptions', function() {
})
describe('when the user has a subscription with recurly', function() {
before(function(done) {
beforeEach(function(done) {
MockRecurlyApi.accounts['mock-account-id'] = this.accounts = {
hosted_login_token: 'mock-login-token'
}
@@ -168,7 +168,7 @@ describe('Subscriptions', function() {
})
describe('when the user has a subscription without recurly', function() {
before(function(done) {
beforeEach(function(done) {
Subscription.create(
{
admin_id: this.user._id,
@@ -215,7 +215,7 @@ describe('Subscriptions', function() {
})
describe('when the user is a member of a group subscription', function() {
before(function(done) {
beforeEach(function(done) {
this.owner1 = new User()
this.owner2 = new User()
async.series(
@@ -299,7 +299,7 @@ describe('Subscriptions', function() {
})
describe('when the user is a manager of a group subscription', function() {
before(function(done) {
beforeEach(function(done) {
this.owner1 = new User()
this.owner2 = new User()
async.series(
@@ -360,7 +360,7 @@ describe('Subscriptions', function() {
})
describe('when the user is a manager of an institution', function() {
before(function(done) {
beforeEach(function(done) {
this.v1Id = MockV1Api.nextV1Id()
async.series(
[
@@ -410,7 +410,7 @@ describe('Subscriptions', function() {
})
describe('when the user is a member of an affiliation', function() {
before(function(done) {
beforeEach(function(done) {
const v1Id = MockV1Api.nextV1Id()
MockV1Api.setUser(v1Id, {
subscription: {},
@@ -500,7 +500,7 @@ describe('Subscriptions', function() {
})
describe('when the user has a v1 subscription', function() {
before(function(done) {
beforeEach(function(done) {
let v1Id
MockV1Api.setUser((v1Id = MockV1Api.nextV1Id()), {
subscription: (this.subscription = {
@@ -552,7 +552,7 @@ describe('Subscriptions', function() {
})
describe('canceling', function() {
before(function(done) {
beforeEach(function(done) {
let v1Id
this.user = new User()
MockV1Api.setUser((v1Id = MockV1Api.nextV1Id()), (this.v1_user = {}))
@@ -17,7 +17,7 @@ const request = require('./helpers/request')
const User = require('./helpers/User')
describe('TpdsUpdateTests', function() {
before(function(done) {
beforeEach(function(done) {
this.owner = new User()
return this.owner.login(error => {
if (error != null) {
@@ -38,7 +38,7 @@ describe('TpdsUpdateTests', function() {
})
describe('deleting a file', function() {
before(function(done) {
beforeEach(function(done) {
return request(
{
method: 'DELETE',
@@ -17,7 +17,7 @@ const async = require('async')
const User = require('./helpers/User')
describe('User Must Reconfirm', function() {
before(function(done) {
beforeEach(function(done) {
this.user = new User()
return async.series(
[