mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-05 07:09:02 +02:00
Merge pull request #20087 from overleaf/bg-clean-up-web-crash-tests
read crash test files from a directory GitOrigin-RevId: 3e498bd73dc9ca97cbe96899f9c1661d430a7d75
This commit is contained in:
@@ -4,24 +4,28 @@ const Path = require('path')
|
||||
const fetch = require('node-fetch')
|
||||
const UserHelper = require('./helpers/UserHelper')
|
||||
const BASE_URL = UserHelper.baseUrl()
|
||||
const glob = require('glob')
|
||||
|
||||
const CRASH_TEST_URLS = fs
|
||||
.readFileSync(Path.join(__dirname, '../files/crash_test_urls.txt'))
|
||||
.toString()
|
||||
.split('\n')
|
||||
// Test all files in the crash_test_urls directory
|
||||
const CRASH_TEST_FILES = glob.sync(
|
||||
Path.join(__dirname, '../files/crash_test_urls/*.txt')
|
||||
)
|
||||
|
||||
describe('Server Crash Tests', function () {
|
||||
it(`should not crash on bad urls`, async function () {
|
||||
// increase the timeout for this test due to the number of urls
|
||||
this.timeout(60 * 1000)
|
||||
// test each url in the list
|
||||
for (let i = 0; i < CRASH_TEST_URLS.length; i++) {
|
||||
const url = BASE_URL + CRASH_TEST_URLS[i]
|
||||
const response = await fetch(url)
|
||||
expect(response.status).to.not.match(
|
||||
/5\d\d/,
|
||||
`Request to ${url} failed with status ${response.status}`
|
||||
)
|
||||
}
|
||||
})
|
||||
for (const file of CRASH_TEST_FILES) {
|
||||
const crashTestUrls = fs.readFileSync(file).toString().split('\n')
|
||||
it(`should not crash on bad urls in ${file}`, async function () {
|
||||
// increase the timeout for these tests due to the number of urls
|
||||
this.timeout(60 * 1000)
|
||||
// test each url in the list
|
||||
for (let i = 0; i < crashTestUrls.length; i++) {
|
||||
const url = BASE_URL + crashTestUrls[i]
|
||||
const response = await fetch(url)
|
||||
expect(response.status).to.not.match(
|
||||
/5\d\d/,
|
||||
`Request to ${url} failed with status ${response.status}`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user