2019-05-29 09:21:06 +00:00
|
|
|
/* eslint-disable
|
2022-05-16 14:25:49 +00:00
|
|
|
n/handle-callback-err,
|
2019-05-29 09:21:06 +00:00
|
|
|
no-return-assign,
|
|
|
|
no-unused-vars,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2021-07-07 09:38:56 +00:00
|
|
|
const Settings = require('@overleaf/settings')
|
2019-05-29 09:21:06 +00:00
|
|
|
const request = require('./helpers/request')
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
describe('siteIsOpen', function () {
|
|
|
|
describe('when siteIsOpen is default (true)', function () {
|
|
|
|
it('should get page', function (done) {
|
2019-08-07 14:04:04 +00:00
|
|
|
return request.get('/login', (error, response, body) => {
|
2019-05-29 09:21:06 +00:00
|
|
|
response.statusCode.should.equal(200)
|
|
|
|
return done()
|
2019-08-07 14:04:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 09:21:06 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
describe('when siteIsOpen is false', function () {
|
|
|
|
beforeEach(function () {
|
2019-08-07 14:04:04 +00:00
|
|
|
return (Settings.siteIsOpen = false)
|
|
|
|
})
|
2019-05-29 09:21:06 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
afterEach(function () {
|
2019-08-07 14:04:04 +00:00
|
|
|
return (Settings.siteIsOpen = true)
|
|
|
|
})
|
2019-05-29 09:21:06 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('should return maintenance page', function (done) {
|
2020-07-27 10:46:27 +00:00
|
|
|
request.get('/login', (error, response, body) => {
|
2019-05-29 09:21:06 +00:00
|
|
|
response.statusCode.should.equal(503)
|
2020-07-27 10:46:27 +00:00
|
|
|
body.should.match(/is currently down for maintenance/)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('should return a plain text message for a json request', function (done) {
|
2020-07-27 10:46:27 +00:00
|
|
|
request.get('/some/route', { json: true }, (error, response, body) => {
|
|
|
|
response.statusCode.should.equal(503)
|
|
|
|
body.message.should.match(/maintenance/)
|
2021-07-20 09:26:23 +00:00
|
|
|
body.message.should.match(/status.example.com/)
|
2020-07-27 10:46:27 +00:00
|
|
|
done()
|
2019-08-07 14:04:04 +00:00
|
|
|
})
|
|
|
|
})
|
2020-11-30 10:10:28 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('should return a 200 on / for load balancer health checks', function (done) {
|
2020-11-30 10:10:28 +00:00
|
|
|
request.get('/', (error, response, body) => {
|
|
|
|
response.statusCode.should.equal(200)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('should return a 200 on /status for readiness checks', function (done) {
|
2020-11-30 10:10:28 +00:00
|
|
|
request.get('/status', (error, response, body) => {
|
|
|
|
response.statusCode.should.equal(200)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 09:21:06 +00:00
|
|
|
})
|
|
|
|
})
|