From 451af268e5c4110eb007292c1cd27e764426c492 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 8 Apr 2022 22:11:39 +1000 Subject: [PATCH] add tests global ban, remove/deny appeal/edit ban duration --- test/actions.js | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/test/actions.js b/test/actions.js index f8c05480..20ff3394 100644 --- a/test/actions.js +++ b/test/actions.js @@ -449,6 +449,89 @@ int main() {...} expect(response.ok).toBe(true); }); + test('test global ban', async () => { + const threads = await fetch('http://localhost/test/catalog.json').then(res => res.json()); + const randomThreadId = threads[Math.floor(Math.random() * threads.length)].postId; + const params = new URLSearchParams({ + _csrf: csrfToken, + global_ban: '1', + checkedposts: randomThreadId, + }); + 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 banId + test('deny ban appeal', async () => { + const banPage = await fetch('http://localhost/globalmanage/bans.html', { + headers: { + 'cookie': sessionCookie, + }, + }).then(res => res.text()); + const checkString = 'name="checkedbans" value="'; + const checkIndex = banPage.indexOf(checkString); + banId = banPage.substring(checkIndex+checkString.length, checkIndex+checkString.length+24); + const params = new URLSearchParams({ + _csrf: csrfToken, + checkedbans: banId, + option: 'deny_appeal', + }); + const response = await fetch('http://localhost/forms/global/editbans', { + headers: { + 'x-using-xhr': 'true', + 'cookie': sessionCookie, + }, + method: 'POST', + body: params, + redirect: 'manual', + }) + expect(response.ok).toBe(true); + }); + + test('edit ban duration', async () => { + const params = new URLSearchParams({ + _csrf: csrfToken, + checkedbans: banId, + option: 'edit', + ban_duration: '3d', + }); + const response = await fetch('http://localhost/forms/global/editbans', { + headers: { + 'x-using-xhr': 'true', + 'cookie': sessionCookie, + }, + method: 'POST', + body: params, + redirect: 'manual', + }) + expect(response.ok).toBe(true); + }); + + test('remove ban', async () => { + const params = new URLSearchParams({ + _csrf: csrfToken, + checkedbans: banId, + option: 'unban', + }); + const response = await fetch('http://localhost/forms/global/editbans', { + headers: { + 'x-using-xhr': 'true', + 'cookie': sessionCookie, + }, + method: 'POST', + body: params, + redirect: 'manual', + }) + expect(response.ok).toBe(true); + }); + test('test ban + qrange + non-appealable + show post in ban + hide name in modlog + modlog message + ban reason', async () => { const threads = await fetch('http://localhost/test/catalog.json').then(res => res.json()); const randomThreadId = threads[Math.floor(Math.random() * threads.length)].postId;