Fix tests, run them again since localisation update (all pass)

Make server.js loga warning if started with NO_CAPTCHA e.g. in docker for tests
merge-requests/346/merge
Thomas Lynch 1 year ago
parent e2d33c0cdc
commit 69374012c3
  1. 1
      server.js
  2. 43
      test/actions.js
  3. 2
      test/integration.test.js
  4. 37
      test/posting.js
  5. 1
      test/setup.js

@ -25,6 +25,7 @@ const config = require(__dirname+'/lib/misc/config.js')
const env = process.env.NODE_ENV;
const production = env === 'production';
debugLogs && console.log('process.env.NODE_ENV =', env);
process.env.NO_CAPTCHA && console.warn('WARNING, RUNNING WITH process.env.NO_CAPTCHA, CAPTCHA CHECKS ARE SKIPPED!');
// connect to mongodb
debugLogs && console.log('CONNECTING TO MONGODB');

@ -112,27 +112,6 @@ module.exports = () => describe('Test post modactions', () => {
expect(response.ok).toBe(true);
});
test('delete 5 random posts from /test/', async () => {
const threads = await fetch('http://localhost/test/catalog.json').then(res => res.json());
const params = new URLSearchParams({
_csrf: csrfToken,
delete: '1',
});
for (let i = 0; i < 5; i++) {
const thread = threads[Math.floor(Math.random() * threads.length)];
params.append('checkedposts', thread.postId);
}
const response = await fetch('http://localhost/forms/board/test/modactions', {
headers: {
'x-using-xhr': 'true',
'cookie': sessionCookie,
},
method: 'POST',
body: params,
});
expect(response.ok).toBe(true);
});
test('lower reply limit', async () => {
const params = new URLSearchParams({
_csrf: csrfToken,
@ -143,6 +122,7 @@ module.exports = () => describe('Test post modactions', () => {
theme: 'yotsuba-b',
code_theme: 'ir-black',
custom_css: '',
language: 'en-GB',
enable_tegaki: 'true',
max_files: '5',
files_allow_video: 'true',
@ -327,6 +307,27 @@ module.exports = () => describe('Test post modactions', () => {
});
expect(response.ok).toBe(true);
});
test('delete 5 random posts from /test/', async () => {
const threads = await fetch('http://localhost/test/catalog.json').then(res => res.json());
const params = new URLSearchParams({
_csrf: csrfToken,
delete: '1',
});
for (let i = 0; i < 5; i++) {
const thread = threads[Math.floor(Math.random() * threads.length)];
params.append('checkedposts', thread.postId);
}
const response = await fetch('http://localhost/forms/board/test/modactions', {
headers: {
'x-using-xhr': 'true',
'cookie': sessionCookie,
},
method: 'POST',
body: params,
});
expect(response.ok).toBe(true);
});
let reportedPost;
test('test local report + global report', async () => {

@ -1,10 +1,10 @@
describe('run integration tests', () => {
require('./setup.js')();
// require('./twofactor.js')();
require('./posting.js')();
require('./global.js')();
require('./actions.js')();
require('./board.js')();
require('./pages.js')();
require('./cleanup.js')();
require('./twofactor.js')();
});

@ -94,34 +94,31 @@ int main() {...}
const threadParams = new URLSearchParams();
threadParams.append('message', Math.random());
threadParams.append('captcha', '000000');
const promises = [];
for (let t = 0; t < threads; t++) {
const promise = fetch(`http://localhost/forms/board/${board}/post`, {
const response = await fetch(`http://localhost/forms/board/${board}/post`, {
headers: {
'x-using-xhr': 'true',
},
method: 'POST',
body: threadParams
}).then(async (response) => {
expect(response.ok).toBe(true);
const thread = (await response.json()).postId;
for (let r = 0; r < replies; r++) {
const replyParams = new URLSearchParams();
replyParams.append('message', Math.random());
replyParams.append('thread', thread);
replyParams.append('captcha', '000000');
const promise2 = await fetch(`http://localhost/forms/board/${board}/post`, {
method: 'POST',
body: replyParams
}).then(async (response2) => {
expect(response2.ok).toBe(true);
});
promises.push(promise2);
}
});
promises.push(promise);
expect(response.ok).toBe(true);
const thread = (await response.json()).postId;
for (let r = 0; r < replies; r++) {
const replyParams = new URLSearchParams();
replyParams.append('message', Math.random());
replyParams.append('thread', thread);
replyParams.append('captcha', '000000');
const response2 = await fetch(`http://localhost/forms/board/${board}/post`, {
headers: {
'x-using-xhr': 'true',
},
method: 'POST',
body: replyParams
});
expect(response2.ok).toBe(true);
}
}
await Promise.all(promises); //wait for all posts to go through
}
jest.setTimeout(5*60*1000); //give a generous timeout

@ -99,6 +99,7 @@ module.exports = () => describe('login and create test board', () => {
overboard_limit: '20',
overboard_catalog_limit: '100',
allow_custom_overboard: 'true',
language: 'en-GB',
archive_links: 'https://archive.today/?run=1&url=%s',
reverse_links: 'https://tineye.com/search?url=%s',
prune_modlogs: '30',

Loading…
Cancel
Save