|
|
@ -2,72 +2,58 @@ const fetch = require('node-fetch'); |
|
|
|
|
|
|
|
|
|
|
|
module.exports = () => describe('Test loading a bunch of pages', () => { |
|
|
|
module.exports = () => describe('Test loading a bunch of pages', () => { |
|
|
|
|
|
|
|
|
|
|
|
test('/boards.html', async () => { |
|
|
|
const urls = [ |
|
|
|
const response = await fetch('http://localhost/boards.html'); |
|
|
|
'boards.html', |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
'boards.json', |
|
|
|
}); |
|
|
|
'boards.json?search=test&sort=popularity&direction=desc', |
|
|
|
|
|
|
|
'boards.html?search=test&sort=popularity&direction=desc', |
|
|
|
test('/boards.json', async () => { |
|
|
|
'overboard.html', |
|
|
|
const response = await fetch('http://localhost/boards.json'); |
|
|
|
'overboard.json', |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
'overboard.html?add=test&rem=abc', |
|
|
|
expect((await response.json()).boards.length).toBeGreaterThan(0); |
|
|
|
'overboard.json?add=test&rem=abc', |
|
|
|
}); |
|
|
|
'index.html', |
|
|
|
|
|
|
|
'news.html', |
|
|
|
test('/boards.html with query search for existing board', async () => { |
|
|
|
'rules.html', |
|
|
|
const response = await fetch('http://localhost/boards.html?search=test&sort=popularity&direction=desc'); |
|
|
|
'faq.html', |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
'globalmanage/recent.html', |
|
|
|
}); |
|
|
|
'globalmanage/reports.html', |
|
|
|
|
|
|
|
'globalmanage/bans.html', |
|
|
|
test('/boards.json with query search for existing board', async () => { |
|
|
|
'globalmanage/boards.html', |
|
|
|
const response = await fetch('http://localhost/boards.json?search=test&sort=popularity&direction=desc'); |
|
|
|
'globalmanage/globallogs.html', |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
'globalmanage/accounts.html', |
|
|
|
expect((await response.json()).boards.length).toBeGreaterThan(0); |
|
|
|
'globalmanage/roles.html', |
|
|
|
}); |
|
|
|
'globalmanage/news.html', |
|
|
|
|
|
|
|
'globalmanage/settings.html', |
|
|
|
test('/boards.json with query search for not existing board', async () => { |
|
|
|
] |
|
|
|
const response = await fetch('http://localhost/boards.json?search=notexistingboard'); |
|
|
|
|
|
|
|
expect(response.ok).toBe(true); |
|
|
|
let sessionCookie |
|
|
|
expect((await response.json()).boards.length).toBe(0); |
|
|
|
test('login as admin', async () => { |
|
|
|
}); |
|
|
|
const params = new URLSearchParams(); |
|
|
|
|
|
|
|
params.append('username', 'admin'); |
|
|
|
test('/overboard.html', async () => { |
|
|
|
params.append('password', process.env.TEST_ADMIN_PASSWORD); |
|
|
|
const response = await fetch('http://localhost/overboard.html'); |
|
|
|
const response = await fetch('http://localhost/forms/login', { |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
headers: { |
|
|
|
}); |
|
|
|
'x-using-xhr': 'true', |
|
|
|
|
|
|
|
}, |
|
|
|
test('/overboard.json', async () => { |
|
|
|
method: 'POST', |
|
|
|
const response = await fetch('http://localhost/overboard.json'); |
|
|
|
body: params, |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
redirect: 'manual', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const rawHeaders = response.headers.raw(); |
|
|
|
test('/overboard.html with query', async () => { |
|
|
|
expect(rawHeaders['set-cookie']).toBeDefined(); |
|
|
|
const response = await fetch('http://localhost/overboard.html?add=test&rem=abc'); |
|
|
|
expect(rawHeaders['set-cookie'][0]).toMatch(/^connect\.sid/); |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
sessionCookie = rawHeaders['set-cookie'][0]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('/overboard.json with query', async () => { |
|
|
|
urls.forEach(u => { |
|
|
|
const response = await fetch('http://localhost/overboard.json?add=test&rem=abc'); |
|
|
|
test(u, async () => { |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
const response = await fetch(`http://localhost/${u}`, { |
|
|
|
}); |
|
|
|
headers: { |
|
|
|
|
|
|
|
cookie: sessionCookie, |
|
|
|
test('/index.html', async () => { |
|
|
|
}, |
|
|
|
const response = await fetch('http://localhost/index.html'); |
|
|
|
}); |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
expect(response.ok).toBe(true); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}) |
|
|
|
test('/news.html', async () => { |
|
|
|
|
|
|
|
const response = await fetch('http://localhost/news.html'); |
|
|
|
|
|
|
|
expect(response.ok).toBe(true); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('/rules.html', async () => { |
|
|
|
|
|
|
|
const response = await fetch('http://localhost/rules.html'); |
|
|
|
|
|
|
|
expect(response.ok).toBe(true); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('/faq.html', async () => { |
|
|
|
|
|
|
|
const response = await fetch('http://localhost/faq.html'); |
|
|
|
|
|
|
|
expect(response.ok).toBe(true); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|