mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
fix eslint-errors
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import {db, privateDB} from '../../src/databases/databases';
|
||||
import {Done} from '../utils';
|
||||
|
||||
describe('dbUpgrade', () => {
|
||||
it('Should update the database version when starting the application', async () => {
|
||||
let dbVersion = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
let privateVersion = (await privateDB.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
const dbVersion = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
const privateVersion = (await privateDB.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
if (dbVersion >= 1 && privateVersion >= 1) return;
|
||||
else return 'Versions are not at least 1. db is ' + dbVersion + ', private is ' + privateVersion;
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('getIsUserVIP', () => {
|
||||
if (res.status !== 200) done("non 200: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('getIsUserVIP', () => {
|
||||
if (res.status !== 400) done("non 400: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should say a VIP is a VIP', (done: Done) => {
|
||||
@@ -37,7 +37,7 @@ describe('getIsUserVIP', () => {
|
||||
else done("Result was non-vip when should have been vip");
|
||||
}
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should say a normal user is not a VIP', (done: Done) => {
|
||||
@@ -50,6 +50,6 @@ describe('getIsUserVIP', () => {
|
||||
else done("Result was vip when should have been non-vip");
|
||||
}
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getHash} from '../../src/utils/getHash';
|
||||
|
||||
describe('getSavedTimeForUser', () => {
|
||||
before(async () => {
|
||||
let startOfQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "shadowHidden", "hashedVideoID") VALUES';
|
||||
const startOfQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "shadowHidden", "hashedVideoID") VALUES';
|
||||
await db.prepare("run", startOfQuery + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
['getSavedTimeForUser', 1, 11, 2, 'abc1239999', getHash("testman"), 0, 50, 'sponsor', 0, getHash('getSavedTimeForUser', 0)]);
|
||||
return;
|
||||
@@ -17,6 +17,6 @@ describe('getSavedTimeForUser', () => {
|
||||
if (res.status !== 200) done("non 200");
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ const oldID = `${'0'.repeat(8)}-${'0000-'.repeat(3)}${'0'.repeat(12)}`
|
||||
|
||||
describe('getSegmentInfo', () => {
|
||||
before(async () => {
|
||||
let insertQuery = `INSERT INTO
|
||||
const insertQuery = `INSERT INTO
|
||||
"sponsorTimes"("videoID", "startTime", "endTime", "votes", "locked",
|
||||
"UUID", "userID", "timeSubmitted", "views", "category", "service",
|
||||
"videoDuration", "hidden", "shadowHidden", "hashedVideoID")
|
||||
@@ -53,7 +53,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive downvoted segment', (done: Done) => {
|
||||
@@ -69,7 +69,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive locked up segment', (done: Done) => {
|
||||
@@ -85,7 +85,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive infinite vote segment', (done: Done) => {
|
||||
@@ -101,7 +101,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive shadowhidden segment', (done: Done) => {
|
||||
@@ -117,7 +117,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive locked down segment', (done: Done) => {
|
||||
@@ -133,7 +133,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive hidden segment', (done: Done) => {
|
||||
@@ -149,7 +149,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive segment with old ID', (done: Done) => {
|
||||
@@ -165,7 +165,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive single segment in array', (done: Done) => {
|
||||
@@ -181,7 +181,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to retreive multiple segments in array', (done: Done) => {
|
||||
@@ -199,7 +199,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be possible to send unexpected query parameters', (done: Done) => {
|
||||
@@ -215,7 +215,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should return 400 if array passed to UUID', (done: Done) => {
|
||||
@@ -224,7 +224,7 @@ describe('getSegmentInfo', () => {
|
||||
if (res.status !== 400) done("non 400 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 if bad array passed to UUIDs', (done: Done) => {
|
||||
@@ -233,7 +233,7 @@ describe('getSegmentInfo', () => {
|
||||
if (res.status !== 400) done("non 404 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 if bad UUID passed', (done: Done) => {
|
||||
@@ -242,7 +242,7 @@ describe('getSegmentInfo', () => {
|
||||
if (res.status !== 400) done("non 400 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 if bad UUIDs passed in array', (done: Done) => {
|
||||
@@ -251,7 +251,7 @@ describe('getSegmentInfo', () => {
|
||||
if (res.status !== 400) done("non 400 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return good UUID when mixed with bad UUIDs', (done: Done) => {
|
||||
@@ -267,7 +267,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should cut off array at 10', function(done: Done) {
|
||||
@@ -286,7 +286,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should not duplicate reponses', (done: Done) => {
|
||||
@@ -302,7 +302,7 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 if UUID not found', (done: Done) => {
|
||||
@@ -311,7 +311,7 @@ describe('getSegmentInfo', () => {
|
||||
if (res.status !== 400) done("non 400 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to retreive multiple segments with multiple parameters', (done: Done) => {
|
||||
@@ -329,11 +329,11 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should not parse repeated UUID if UUIDs present', (done: Done) => {
|
||||
fetch(getbaseURL() + `/api/segmentInfo?UUID=${downvotedID}&UUID=${lockedupID}&UUIDs=[\"${upvotedID}\"]`)
|
||||
fetch(getbaseURL() + `/api/segmentInfo?UUID=${downvotedID}&UUID=${lockedupID}&UUIDs=["${upvotedID}"]`)
|
||||
.then(async res => {
|
||||
if (res.status !== 200) done("Status code was: " + res.status);
|
||||
else {
|
||||
@@ -346,6 +346,6 @@ describe('getSegmentInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to get a time by category for a different service 1', (done: Done) => {
|
||||
@@ -52,7 +52,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => "Couldn't call endpoint");
|
||||
.catch(() => "Couldn't call endpoint");
|
||||
});
|
||||
|
||||
it('Should be able to get a time by category 2', (done: Done) => {
|
||||
@@ -69,7 +69,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get a time by categories array', (done: Done) => {
|
||||
@@ -86,7 +86,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get a time by categories array 2', (done: Done) => {
|
||||
@@ -103,7 +103,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 404 if all submissions are hidden', (done: Done) => {
|
||||
@@ -112,7 +112,7 @@ describe('getSkipSegments', () => {
|
||||
if (res.status !== 404) done("non 404 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get multiple times by category', (done: Done) => {
|
||||
@@ -171,7 +171,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be possible to send unexpected query parameters', (done: Done) => {
|
||||
@@ -189,7 +189,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Low voted submissions should be hidden', (done: Done) => {
|
||||
@@ -207,7 +207,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 404 if no segment found', (done: Done) => {
|
||||
@@ -216,7 +216,7 @@ describe('getSkipSegments', () => {
|
||||
if (res.status !== 404) done("non 404 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 if bad categories argument', (done: Done) => {
|
||||
@@ -225,7 +225,7 @@ describe('getSkipSegments', () => {
|
||||
if (res.status !== 400) done("non 400 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able send a comma in a query param', (done: Done) => {
|
||||
@@ -243,7 +243,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should always get locked segment', (done: Done) => {
|
||||
@@ -260,7 +260,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get multiple categories with repeating parameters', (done: Done) => {
|
||||
@@ -290,7 +290,7 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get, categories param overriding repeating category', (done: Done) => {
|
||||
@@ -307,6 +307,6 @@ describe('getSkipSegments', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("Couldn't call endpoint"));
|
||||
.catch(() => ("Couldn't call endpoint"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('getSegmentsByHash', () => {
|
||||
if (res.status !== 200) done("non 200 status code, was " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 404 if no segments are found even if a video for the given hash is known', (done: Done) => {
|
||||
@@ -42,7 +42,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done("Response had videos");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get an empty array if no videos', (done: Done) => {
|
||||
@@ -55,7 +55,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done("non empty array returned");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get an empty array if only hidden videos', (done: Done) => {
|
||||
@@ -68,7 +68,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done("non empty array returned");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 prefix too short', (done: Done) => {
|
||||
@@ -77,11 +77,11 @@ describe('getSegmentsByHash', () => {
|
||||
if (res.status !== 400) done("non 400 status code, was " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 prefix too long', (done: Done) => {
|
||||
let prefix = new Array(50).join('1');
|
||||
const prefix = new Array(50).join('1');
|
||||
if (prefix.length <= 32) { // default value, config can change this
|
||||
done('failed to generate a long enough string for the test ' + prefix.length);
|
||||
return;
|
||||
@@ -91,7 +91,7 @@ describe('getSegmentsByHash', () => {
|
||||
if (res.status !== 400) done("non 400 status code, was " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should not return 400 prefix in range', (done: Done) => {
|
||||
@@ -100,7 +100,7 @@ describe('getSegmentsByHash', () => {
|
||||
if (res.status === 400) done("prefix length 5 gave 400 " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 404 for no hash', (done: Done) => {
|
||||
@@ -109,7 +109,7 @@ describe('getSegmentsByHash', () => {
|
||||
if (res.status !== 404) done("expected 404, got " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 for bad format categories', (done: Done) => {
|
||||
@@ -118,7 +118,7 @@ describe('getSegmentsByHash', () => {
|
||||
if (res.status !== 400) done("expected 400 got " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get multiple videos', (done: Done) => {
|
||||
@@ -133,7 +133,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get 200 for no categories (default sponsor)', (done: Done) => {
|
||||
@@ -151,7 +151,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get 200 for no categories (default sponsor) for a non YouTube service', (done: Done) => {
|
||||
@@ -166,7 +166,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should only return one segment when fetching highlight segments', (done: Done) => {
|
||||
@@ -180,11 +180,11 @@ describe('getSegmentsByHash', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to post a segment and get it using endpoint', (done: Done) => {
|
||||
let testID = 'abc123goodVideo';
|
||||
const testID = 'abc123goodVideo';
|
||||
fetch(getbaseURL() + "/api/postVideoSponsorTimes", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -212,7 +212,7 @@ describe('getSegmentsByHash', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => done("(get) Couldn't call endpoint"));
|
||||
.catch(() => done("(get) Couldn't call endpoint"));
|
||||
} else {
|
||||
done("(post) non 200 status code, was " + res.status);
|
||||
}
|
||||
|
||||
@@ -23,11 +23,10 @@ describe('getUserID', () => {
|
||||
it('Should be able to get a 200', (done: Done) => {
|
||||
fetch(getbaseURL() + '/api/userID?username=fuzzy+user+01')
|
||||
.then(async res => {
|
||||
const text = await res.text()
|
||||
if (res.status !== 200) done('non 200 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should be able to get a 400 (No username parameter)', (done: Done) => {
|
||||
@@ -36,17 +35,16 @@ describe('getUserID', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should be able to get a 200 (username is public id)', (done: Done) => {
|
||||
fetch(getbaseURL() + '/api/userID?username='+getHash("getuserid_user_06"))
|
||||
.then(async res => {
|
||||
const text = await res.text()
|
||||
if (res.status !== 200) done('non 200 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should be able to get a 400 (username longer than 64 chars)', (done: Done) => {
|
||||
@@ -55,7 +53,7 @@ describe('getUserID', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should be able to get single username', (done: Done) => {
|
||||
@@ -76,7 +74,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get multiple fuzzy user info from start', (done: Done) => {
|
||||
@@ -101,7 +99,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get multiple fuzzy user info from middle', (done: Done) => {
|
||||
@@ -130,7 +128,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get with public ID', (done: Done) => {
|
||||
@@ -152,7 +150,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get with fuzzy public ID', (done: Done) => {
|
||||
@@ -174,7 +172,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get repeating username', (done: Done) => {
|
||||
@@ -199,7 +197,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get repeating fuzzy username', (done: Done) => {
|
||||
@@ -224,7 +222,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should avoid ReDOS with _', (done: Done) => {
|
||||
@@ -245,7 +243,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should avoid ReDOS with %', (done: Done) => {
|
||||
@@ -266,7 +264,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should return 404 if escaped backslashes present', (done: Done) => {
|
||||
@@ -275,7 +273,7 @@ describe('getUserID', () => {
|
||||
if (res.status !== 404) done('non 404 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should return 404 if backslashes present', (done: Done) => {
|
||||
@@ -284,7 +282,7 @@ describe('getUserID', () => {
|
||||
if (res.status !== 404) done('non 404 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should return user if just backslashes', (done: Done) => {
|
||||
@@ -305,7 +303,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should not allow usernames more than 64 characters', (done: Done) => {
|
||||
@@ -314,7 +312,7 @@ describe('getUserID', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should not allow usernames less than 3 characters', (done: Done) => {
|
||||
@@ -323,7 +321,7 @@ describe('getUserID', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('should allow exact match', (done: Done) => {
|
||||
@@ -344,7 +342,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get repeating username with exact username', (done: Done) => {
|
||||
@@ -369,7 +367,7 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should not get exact unless explicitly set to true', (done: Done) => {
|
||||
@@ -398,6 +396,6 @@ describe('getUserID', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('getUserInfo', () => {
|
||||
if (res.status !== 200) done('non 200 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should be able to get a 400 (No userID parameter)', (done: Done) => {
|
||||
@@ -39,7 +39,7 @@ describe('getUserInfo', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should be able to get user info', (done: Done) => {
|
||||
@@ -70,7 +70,7 @@ describe('getUserInfo', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should get warning data', (done: Done) => {
|
||||
@@ -79,12 +79,12 @@ describe('getUserInfo', () => {
|
||||
if (res.status !== 200) {
|
||||
done('non 200 (' + res.status + ')');
|
||||
} else {
|
||||
const data = await res.json();;
|
||||
const data = await res.json();
|
||||
if (data.warnings !== 1) done('wrong number of warnings: ' + data.warnings + ', not ' + 1);
|
||||
else done(); // pass
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should get warning data with public ID', (done: Done) => {
|
||||
@@ -98,7 +98,7 @@ describe('getUserInfo', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should get multiple warnings', (done: Done) => {
|
||||
@@ -112,7 +112,7 @@ describe('getUserInfo', () => {
|
||||
else done(); // pass
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should not get warnings if none', (done: Done) => {
|
||||
@@ -126,7 +126,7 @@ describe('getUserInfo', () => {
|
||||
else done(); // pass
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should done(userID for userName (No userName set)', (done: Done) => {
|
||||
@@ -142,7 +142,7 @@ describe('getUserInfo', () => {
|
||||
done(); // pass
|
||||
}
|
||||
})
|
||||
.catch(err => ('couldn\'t call endpoint'));
|
||||
.catch(() => ('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should return null segment if none', (done: Done) => {
|
||||
@@ -156,20 +156,20 @@ describe('getUserInfo', () => {
|
||||
else done(); // pass
|
||||
}
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return zeroes if userid does not exist', (done: Done) => {
|
||||
fetch(getbaseURL() + '/api/userInfo?userID=getuserinfo_null')
|
||||
.then(async res => {
|
||||
const data = await res.json();
|
||||
for (var value in data) {
|
||||
for (const value in data) {
|
||||
if (data[value] === null && value !== "lastSegmentID") {
|
||||
done(`returned null for ${value}`)
|
||||
}
|
||||
}
|
||||
done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
.catch(() => ("couldn't call endpoint"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,13 +24,13 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should update the database version when starting the application', async () => {
|
||||
let version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
const version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
if (version > 1) return;
|
||||
else return 'Version isn\'t greater than 1. Version is ' + version;
|
||||
});
|
||||
|
||||
it('Should be able to submit categories not in video (http response)', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'no-segments-video-id',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -43,7 +43,7 @@ describe('lockCategoriesRecords', () => {
|
||||
],
|
||||
};
|
||||
|
||||
let expected = {
|
||||
const expected = {
|
||||
submitted: [
|
||||
'outro',
|
||||
'shilling',
|
||||
@@ -66,7 +66,6 @@ describe('lockCategoriesRecords', () => {
|
||||
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
||||
}
|
||||
} else {
|
||||
const body = await res.text();
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
@@ -74,7 +73,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should be able to submit categories not in video (sql check)', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'no-segments-video-id-1',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -96,14 +95,13 @@ describe('lockCategoriesRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['no-segments-video-id-1']);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['no-segments-video-id-1']);
|
||||
if (result.length !== 4) {
|
||||
done("Expected 4 entrys in db, got " + result.length);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
} else {
|
||||
const body = await res.text();
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
@@ -111,7 +109,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should be able to submit categories with _ in the category', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'underscore',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -128,14 +126,13 @@ describe('lockCategoriesRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['underscore']);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['underscore']);
|
||||
if (result.length !== 1) {
|
||||
done("Expected 1 entrys in db, got " + result.length);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
} else {
|
||||
const body = await res.text();
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
@@ -143,7 +140,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should be able to submit categories with upper and lower case in the category', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'bothCases',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -160,14 +157,13 @@ describe('lockCategoriesRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['bothCases']);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['bothCases']);
|
||||
if (result.length !== 1) {
|
||||
done("Expected 1 entrys in db, got " + result.length);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
} else {
|
||||
const body = await res.text();
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
@@ -175,7 +171,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should not be able to submit categories with $ in the category', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'specialChar',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -192,14 +188,13 @@ describe('lockCategoriesRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['specialChar']);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['specialChar']);
|
||||
if (result.length !== 0) {
|
||||
done("Expected 0 entrys in db, got " + result.length);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
} else {
|
||||
const body = await res.text();
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
@@ -225,7 +220,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 400 for no categories', (done: Done) => {
|
||||
let json: any = {
|
||||
const json: any = {
|
||||
videoID: 'test',
|
||||
userID: 'test',
|
||||
categories: [],
|
||||
@@ -249,7 +244,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 400 for no userID', (done: Done) => {
|
||||
let json: any = {
|
||||
const json: any = {
|
||||
videoID: 'test',
|
||||
userID: null,
|
||||
categories: ['sponsor'],
|
||||
@@ -273,7 +268,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 400 for no videoID', (done: Done) => {
|
||||
let json: any = {
|
||||
const json: any = {
|
||||
videoID: null,
|
||||
userID: 'test',
|
||||
categories: ['sponsor'],
|
||||
@@ -297,7 +292,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 400 object categories', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'test',
|
||||
userID: 'test',
|
||||
categories: {},
|
||||
@@ -321,7 +316,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 400 bad format categories', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'test',
|
||||
userID: 'test',
|
||||
categories: 'sponsor',
|
||||
@@ -345,7 +340,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 403 if user is not VIP', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'test',
|
||||
userID: 'test',
|
||||
categories: [
|
||||
@@ -371,7 +366,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should be able to delete a lockCategories record', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'delete-record',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -388,7 +383,7 @@ describe('lockCategoriesRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['delete-record']);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['delete-record']);
|
||||
if (result.length === 0) {
|
||||
done();
|
||||
} else {
|
||||
@@ -402,7 +397,7 @@ describe('lockCategoriesRecords', () => {
|
||||
});
|
||||
|
||||
it('Should be able to delete one lockCategories record without removing another', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
videoID: 'delete-record-1',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
@@ -419,7 +414,7 @@ describe('lockCategoriesRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['delete-record-1']);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['delete-record-1']);
|
||||
if (result.length === 1) {
|
||||
done();
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('getVideoSponsorTime (Old get method)', () => {
|
||||
if (res.status !== 200) done("non 200 (" + res.status + ")");
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 404 if no segment found', (done: Done) => {
|
||||
@@ -25,7 +25,7 @@ describe('getVideoSponsorTime (Old get method)', () => {
|
||||
if (res.status !== 404) done("non 404 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('getVideoSponsorTime (Old get method)', () => {
|
||||
if (res.status !== 200) done("non 200");
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done("couldn't callendpoint"));
|
||||
.catch(() => done("couldn't callendpoint"));
|
||||
});
|
||||
|
||||
it('Should be able send a comma in a query param', (done: Done) => {
|
||||
@@ -46,7 +46,7 @@ describe('getVideoSponsorTime (Old get method)', () => {
|
||||
else if (JSON.parse(body).UUIDs[0] === 'uuid-1') done(); // pass
|
||||
else done("couldn't parse response");
|
||||
})
|
||||
.catch(err => done("couln't call endpoint"));
|
||||
.catch(() => done("couln't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to get the correct time', (done: Done) => {
|
||||
@@ -65,6 +65,6 @@ describe('getVideoSponsorTime (Old get method)', () => {
|
||||
}
|
||||
|
||||
})
|
||||
.catch(err => done("couldn't call endpoint"));
|
||||
.catch(() => done("couldn't call endpoint"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('postVideoSponsorTime (Old submission method)', () => {
|
||||
+ "/api/postVideoSponsorTimes?videoID=dQw4w9WgXcQ&startTime=1&endTime=10&userID=test")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "startTime", "endTime", "category" FROM "sponsorTimes" WHERE "videoID" = ?`, ["dQw4w9WgXcQ"]);
|
||||
const row = await db.prepare('get', `SELECT "startTime", "endTime", "category" FROM "sponsorTimes" WHERE "videoID" = ?`, ["dQw4w9WgXcQ"]);
|
||||
if (row.startTime === 1 && row.endTime === 10 && row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
@@ -32,7 +32,7 @@ describe('postVideoSponsorTime (Old submission method)', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "startTime", "endTime", "category" FROM "sponsorTimes" WHERE "videoID" = ?`, ["dQw4w9WgXcE"]);
|
||||
const row = await db.prepare('get', `SELECT "startTime", "endTime", "category" FROM "sponsorTimes" WHERE "videoID" = ?`, ["dQw4w9WgXcE"]);
|
||||
if (row.startTime === 1 && row.endTime === 11 && row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {getHash} from '../../src/utils/getHash';
|
||||
describe('postClearCache', () => {
|
||||
before(async () => {
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('` + getHash("clearing-vip") + "')");
|
||||
let startOfQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "shadowHidden", "hashedVideoID") VALUES';
|
||||
const startOfQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "shadowHidden", "hashedVideoID") VALUES';
|
||||
await db.prepare("run", startOfQuery + "('clear-test', 0, 1, 2, 'clear-uuid', 'testman', 0, 50, 'sponsor', 0, '" + getHash('clear-test', 1) + "')");
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ async function dbSponsorTimesAdd(db: IDatabase, videoID: string, startTime: numb
|
||||
}
|
||||
|
||||
async function dbSponsorTimesCompareExpect(db: IDatabase, videoId: string, expectdHidden: number) {
|
||||
let seg = await db.prepare('get', `SELECT "hidden", "UUID" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoId]);
|
||||
const seg = await db.prepare('get', `SELECT "hidden", "UUID" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoId]);
|
||||
for (let i = 0, len = seg.length; i < len; i++) {
|
||||
if (seg.hidden !== expectdHidden) {
|
||||
return `${seg.UUID} hidden expected to be ${expectdHidden} but found ${seg.hidden}`;
|
||||
|
||||
@@ -249,7 +249,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 403 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to submit a single time under a different service (JSON method)', (done: Done) => {
|
||||
@@ -512,7 +512,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 200 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be rejected if segment starts and ends at the same time', (done: Done) => {
|
||||
@@ -527,7 +527,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 400 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be accepted if highlight segment starts and ends at the same time', (done: Done) => {
|
||||
@@ -542,7 +542,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 200 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be rejected if highlight segment doesn\'t start and end at the same time', (done: Done) => {
|
||||
@@ -557,7 +557,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 400 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be rejected if a sponsor is less than 1 second', (done: Done) => {
|
||||
@@ -572,7 +572,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 403 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be rejected if over 80% of the video', (done: Done) => {
|
||||
@@ -585,7 +585,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 403 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it("Should be rejected if NB's predicted probability is <70%.", (done: Done) => {
|
||||
@@ -598,7 +598,7 @@ describe('postSkipSegments', () => {
|
||||
done("non 200 status code: " + res.status + " (" + body + ")");
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be rejected if user has to many active warnings', (done: Done) => {
|
||||
@@ -690,7 +690,7 @@ describe('postSkipSegments', () => {
|
||||
if (res.status === 400) done();
|
||||
else done(true);
|
||||
})
|
||||
.catch(err => done(true));
|
||||
.catch(() => done(true));
|
||||
});
|
||||
|
||||
it('Should return 400 for missing params (JSON method) 1', (done: Done) => {
|
||||
@@ -715,7 +715,7 @@ describe('postSkipSegments', () => {
|
||||
if (res.status === 400) done();
|
||||
else done(true);
|
||||
})
|
||||
.catch(err => done(true));
|
||||
.catch(() => done(true));
|
||||
});
|
||||
it('Should return 400 for missing params (JSON method) 2', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
@@ -733,7 +733,7 @@ describe('postSkipSegments', () => {
|
||||
if (res.status === 400) done();
|
||||
else done(true);
|
||||
})
|
||||
.catch(err => done(true));
|
||||
.catch(() => done(true));
|
||||
});
|
||||
it('Should return 400 for missing params (JSON method) 3', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
@@ -758,7 +758,7 @@ describe('postSkipSegments', () => {
|
||||
if (res.status === 400) done();
|
||||
else done(true);
|
||||
})
|
||||
.catch(err => done(true));
|
||||
.catch(() => done(true));
|
||||
});
|
||||
it('Should return 400 for missing params (JSON method) 4', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
@@ -782,7 +782,7 @@ describe('postSkipSegments', () => {
|
||||
if (res.status === 400) done();
|
||||
else done(true);
|
||||
})
|
||||
.catch(err => done(true));
|
||||
.catch(() => done(true));
|
||||
});
|
||||
it('Should return 400 for missing params (JSON method) 5', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
@@ -800,6 +800,6 @@ describe('postSkipSegments', () => {
|
||||
if (res.status === 400) done();
|
||||
else done(true);
|
||||
})
|
||||
.catch(err => done(true));
|
||||
.catch(() => done(true));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('postWarning', () => {
|
||||
});
|
||||
|
||||
it('Should be able to create warning if vip (exp 200)', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
issuerUserID: 'warning-vip',
|
||||
userID: 'warning-0',
|
||||
reason: 'warning-reason-0'
|
||||
@@ -24,7 +24,7 @@ describe('postWarning', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled, "reason" FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
const row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled, "reason" FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
if (row?.enabled == 1 && row?.issuerUserID == getHash(json.issuerUserID) && row?.reason === json.reason) {
|
||||
done();
|
||||
} else {
|
||||
@@ -40,7 +40,7 @@ describe('postWarning', () => {
|
||||
});
|
||||
|
||||
it('Should be not be able to create a duplicate warning if vip', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
issuerUserID: 'warning-vip',
|
||||
userID: 'warning-0',
|
||||
};
|
||||
@@ -55,7 +55,7 @@ describe('postWarning', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 409) {
|
||||
let row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
const row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
if (row?.enabled == 1 && row?.issuerUserID == getHash(json.issuerUserID)) {
|
||||
done();
|
||||
} else {
|
||||
@@ -71,7 +71,7 @@ describe('postWarning', () => {
|
||||
});
|
||||
|
||||
it('Should be able to remove warning if vip', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
issuerUserID: 'warning-vip',
|
||||
userID: 'warning-0',
|
||||
enabled: false
|
||||
@@ -87,7 +87,7 @@ describe('postWarning', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
const row = await db.prepare('get', `SELECT "userID", "issueTime", "issuerUserID", enabled FROM warnings WHERE "userID" = ?`, [json.userID]);
|
||||
if (row?.enabled == 0) {
|
||||
done();
|
||||
} else {
|
||||
@@ -103,7 +103,7 @@ describe('postWarning', () => {
|
||||
});
|
||||
|
||||
it('Should not be able to create warning if not vip (exp 403)', (done: Done) => {
|
||||
let json = {
|
||||
const json = {
|
||||
issuerUserID: 'warning-not-vip',
|
||||
userID: 'warning-1',
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('reputation', () => {
|
||||
this.timeout(5000); // this preparation takes longer then usual
|
||||
const videoID = "reputation-videoID";
|
||||
|
||||
let sponsorTimesInsertQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "locked", "UUID", "userID", "timeSubmitted", "views", "category", "service", "videoDuration", "hidden", "shadowHidden", "hashedVideoID") VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
|
||||
const sponsorTimesInsertQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "locked", "UUID", "userID", "timeSubmitted", "views", "category", "service", "videoDuration", "hidden", "shadowHidden", "hashedVideoID") VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
|
||||
await db.prepare("run", sponsorTimesInsertQuery, [videoID, 1, 11, 2, 0, 'reputation-0-uuid-0', getHash(userIDLowSubmissions), 1606240000000, 50, 'sponsor', 'YouTube', 100, 0, 0, getHash(videoID, 1)]);
|
||||
await db.prepare("run", sponsorTimesInsertQuery, [videoID, 1, 11, 2, 0, 'reputation-0-uuid-1', getHash(userIDLowSubmissions), 1606240000000, 50, 'sponsor', 'YouTube', 100, 0, 0, getHash(videoID, 1)]);
|
||||
await db.prepare("run", sponsorTimesInsertQuery, [videoID, 1, 11, 100, 0, 'reputation-0-uuid-2', getHash(userIDLowSubmissions), 1606240000000, 50, 'sponsor', 'YouTube', 100, 0, 0, getHash(videoID, 1)]);
|
||||
|
||||
@@ -25,7 +25,7 @@ async function dbSponsorTimesSetByUUID(db: IDatabase, UUID: string, startTime: n
|
||||
async function dbSponsorTimesCompareExpect(db: IDatabase, expect: any) {
|
||||
for (let i = 0, len = expect.length; i < len; i++) {
|
||||
const expectSeg = expect[i];
|
||||
let seg = await db.prepare('get', `SELECT "startTime", "endTime" FROM "sponsorTimes" WHERE "UUID" = ?`, [expectSeg.UUID]);
|
||||
const seg = await db.prepare('get', `SELECT "startTime", "endTime" FROM "sponsorTimes" WHERE "UUID" = ?`, [expectSeg.UUID]);
|
||||
if ('removed' in expect) {
|
||||
if (expect.removed === true && seg.votes === -2) {
|
||||
return;
|
||||
|
||||
@@ -34,7 +34,7 @@ async function getUsernameInfo(userID: string): Promise<{ userName: string, lock
|
||||
return row;
|
||||
}
|
||||
|
||||
async function addLogUserNameChange(userID: string, newUserName: string, oldUserName: string = '') {
|
||||
async function addLogUserNameChange(userID: string, newUserName: string, oldUserName = '') {
|
||||
privateDB.prepare('run',
|
||||
`INSERT INTO "userNameLogs"("userID", "newUserName", "oldUserName", "updatedAt", "updatedByAdmin") VALUES(?, ?, ?, ?, ?)`,
|
||||
[getHash(userID), newUserName, oldUserName, new Date().getTime(), + true]
|
||||
@@ -90,7 +90,7 @@ describe('setUsername', () => {
|
||||
if (usernameInfo.locked == "1") done(`Username was locked when it shouldn't have been`);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should return 200', (done: Done) => {
|
||||
@@ -103,7 +103,7 @@ describe('setUsername', () => {
|
||||
testUserNameChangelog(user01PrivateUserID, decodeURIComponent('Changed%20Username'), username01, false, done);
|
||||
}
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should return 400 for missing param "userID"', (done: Done) => {
|
||||
@@ -114,7 +114,7 @@ describe('setUsername', () => {
|
||||
if (res.status !== 400) done(`Status code was ${res.status}`);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should return 400 for missing param "username"', (done: Done) => {
|
||||
@@ -125,7 +125,7 @@ describe('setUsername', () => {
|
||||
if (res.status !== 400) done(`Status code was ${res.status}`);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should return 400 for "username" longer then 64 characters', (done: Done) => {
|
||||
@@ -137,7 +137,7 @@ describe('setUsername', () => {
|
||||
if (res.status !== 400) done(`Status code was ${res.status}`);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should not change username if it contains "discord"', (done: Done) => {
|
||||
@@ -155,7 +155,7 @@ describe('setUsername', () => {
|
||||
else done();
|
||||
}
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should be able to change username', (done: Done) => {
|
||||
@@ -163,13 +163,13 @@ describe('setUsername', () => {
|
||||
fetch(`${getbaseURL()}/api/setUsername?userID=${user03PrivateUserID}&username=${encodeURIComponent(newUsername)}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
.then(async res => {
|
||||
.then(async () => {
|
||||
const usernameInfo = await getUsernameInfo(getHash(user03PrivateUserID));
|
||||
if (usernameInfo.userName !== newUsername) done(`Username did not change`);
|
||||
if (usernameInfo.locked == "1") done(`Username was locked when it shouldn't have been`);
|
||||
testUserNameChangelog(user03PrivateUserID, newUsername, username03, false, done);
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should not be able to change locked username', (done: Done) => {
|
||||
@@ -177,13 +177,13 @@ describe('setUsername', () => {
|
||||
fetch(`${getbaseURL()}/api/setUsername?userID=${user04PrivateUserID}&username=${encodeURIComponent(newUsername)}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
.then(async res => {
|
||||
.then(async () => {
|
||||
const usernameInfo = await getUsernameInfo(getHash(user04PrivateUserID));
|
||||
if (usernameInfo.userName === newUsername) done(`Username '${username04}' got changed to '${usernameInfo}'`);
|
||||
if (usernameInfo.locked == "0") done(`Username was unlocked when it shouldn't have been`);
|
||||
else done();
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Should filter out unicode control characters', (done: Done) => {
|
||||
@@ -191,12 +191,12 @@ describe('setUsername', () => {
|
||||
fetch(`${getbaseURL()}/api/setUsername?userID=${user05PrivateUserID}&username=${encodeURIComponent(newUsername)}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
.then(async res => {
|
||||
.then(async () => {
|
||||
const usernameInfo = await getUsernameInfo(getHash(user05PrivateUserID));
|
||||
if (usernameInfo.userName === newUsername) done(`Username contains unicode control characters`);
|
||||
testUserNameChangelog(user05PrivateUserID, wellFormatUserName(newUsername), username05, false, done);
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Incorrect adminUserID should return 403', (done: Done) => {
|
||||
@@ -208,7 +208,7 @@ describe('setUsername', () => {
|
||||
if (res.status !== 403) done(`Status code was ${res.status}`);
|
||||
else done();
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Admin should be able to change username', (done: Done) => {
|
||||
@@ -216,13 +216,13 @@ describe('setUsername', () => {
|
||||
fetch(`${getbaseURL()}/api/setUsername?adminUserID=${adminPrivateUserID}&userID=${getHash(user06PrivateUserID)}&username=${encodeURIComponent(newUsername)}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
.then(async res => {
|
||||
.then(async () => {
|
||||
const usernameInfo = await getUsernameInfo(getHash(user06PrivateUserID));
|
||||
if (usernameInfo.userName !== newUsername) done(`Failed to change username from '${username06}' to '${newUsername}'`);
|
||||
if (usernameInfo.locked == "0") done(`Username was not locked`);
|
||||
else testUserNameChangelog(user06PrivateUserID, newUsername, username06, true, done);
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
|
||||
it('Admin should be able to change locked username', (done: Done) => {
|
||||
@@ -230,12 +230,12 @@ describe('setUsername', () => {
|
||||
fetch(`${getbaseURL()}/api/setUsername?adminUserID=${adminPrivateUserID}&userID=${getHash(user07PrivateUserID)}&username=${encodeURIComponent(newUsername)}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
.then(async res => {
|
||||
.then(async () => {
|
||||
const usernameInfo = await getUsernameInfo(getHash(user06PrivateUserID));
|
||||
if (usernameInfo.userName !== newUsername) done(`Failed to change username from '${username06}' to '${newUsername}'`);
|
||||
if (usernameInfo.locked == "0") done(`Username was unlocked when it shouldn't have been`);
|
||||
else testUserNameChangelog(user07PrivateUserID, newUsername, username07, true, done);
|
||||
})
|
||||
.catch(err => done(`couldn't call endpoint`));
|
||||
.catch(() => done(`couldn't call endpoint`));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('shadowBanUser', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to unban user without unhiding submissions', (done: Done) => {
|
||||
@@ -60,7 +60,7 @@ describe('shadowBanUser', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to ban user and hide submissions from only some categories', (done: Done) => {
|
||||
@@ -80,7 +80,7 @@ describe('shadowBanUser', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to unban user and unhide submissions', (done: Done) => {
|
||||
@@ -100,7 +100,7 @@ describe('shadowBanUser', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able to unban user and unhide some submissions', (done: Done) => {
|
||||
@@ -120,7 +120,7 @@ describe('shadowBanUser', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
.catch(() => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('unBan', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-0', 'testMan-unBan', 1]);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-0', 'testMan-unBan', 1]);
|
||||
if (result.length !== 0) {
|
||||
console.log(result);
|
||||
done("Expected 0 banned entrys in db, got " + result.length);
|
||||
@@ -57,7 +57,7 @@ describe('unBan', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-1', 'testWoman-unBan', 1]);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-1', 'testWoman-unBan', 1]);
|
||||
if (result.length !== 1) {
|
||||
console.log(result);
|
||||
done("Expected 1 banned entry1 in db, got " + result.length);
|
||||
@@ -82,7 +82,7 @@ describe('unBan', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "userID" = ? AND "shadowHidden" = ?', ['testEntity-unBan', 1]);
|
||||
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "userID" = ? AND "shadowHidden" = ?', ['testEntity-unBan', 1]);
|
||||
if (result.length !== 1) {
|
||||
console.log(result);
|
||||
done("Expected 1 banned entry1 in db, got " + result.length);
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=vote-uuid-0&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-0"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-0"]);
|
||||
if (row.votes === 3) {
|
||||
done();
|
||||
} else {
|
||||
@@ -85,7 +85,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-2&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-2"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-2"]);
|
||||
if (row.votes < 10) {
|
||||
done();
|
||||
} else {
|
||||
@@ -103,7 +103,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID3&UUID=vote-uuid-2&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-2"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-2"]);
|
||||
if (row.votes === 9) {
|
||||
done();
|
||||
} else {
|
||||
@@ -121,7 +121,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID4&UUID=vote-uuid-1.6&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-1.6"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-1.6"]);
|
||||
if (row.votes === 10) {
|
||||
done();
|
||||
} else {
|
||||
@@ -139,7 +139,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=hasNotSubmittedID&UUID=vote-uuid-1&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-1"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-1"]);
|
||||
if (row.votes === 2) {
|
||||
done();
|
||||
} else {
|
||||
@@ -157,7 +157,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=hasNotSubmittedID&UUID=vote-uuid-1.5&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-1.5"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-1.5"]);
|
||||
if (row.votes === 10) {
|
||||
done();
|
||||
} else {
|
||||
@@ -175,7 +175,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=vote-uuid-3&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-3"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-3"]);
|
||||
if (row.votes <= -2) {
|
||||
done();
|
||||
} else {
|
||||
@@ -193,7 +193,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=own-submission-id&UUID=own-submission-uuid&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["own-submission-uuid"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["own-submission-uuid"]);
|
||||
if (row.votes <= -2) {
|
||||
done();
|
||||
} else {
|
||||
@@ -211,7 +211,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=not-own-submission-uuid&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["not-own-submission-uuid"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["not-own-submission-uuid"]);
|
||||
if (row.votes === 499) {
|
||||
done();
|
||||
} else {
|
||||
@@ -229,8 +229,8 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-4&category=intro")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
let categoryRows = await db.prepare('all', `SELECT votes, category FROM "categoryVotes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
const categoryRows = await db.prepare('all', `SELECT votes, category FROM "categoryVotes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
if (row.category === "sponsor" && categoryRows.length === 2
|
||||
&& categoryRows[0]?.votes === 1 && categoryRows[0]?.category === "intro"
|
||||
&& categoryRows[1]?.votes === 1 && categoryRows[1]?.category === "sponsor") {
|
||||
@@ -250,7 +250,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=incorrect-category&category=fakecategory")
|
||||
.then(async res => {
|
||||
if (res.status === 400) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category"]);
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category"]);
|
||||
if (row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
@@ -268,7 +268,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=incorrect-category&category=highlight")
|
||||
.then(async res => {
|
||||
if (res.status === 400) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category"]);
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category"]);
|
||||
if (row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
@@ -286,8 +286,8 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-4&category=outro")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let submissionRow = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
let categoryRows = await db.prepare('all', `SELECT votes, category FROM "categoryVotes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
const submissionRow = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
const categoryRows = await db.prepare('all', `SELECT votes, category FROM "categoryVotes" WHERE "UUID" = ?`, ["vote-uuid-4"]);
|
||||
let introVotes = 0;
|
||||
let outroVotes = 0;
|
||||
let sponsorVotes = 0;
|
||||
@@ -315,8 +315,8 @@ describe('voteOnSponsorTime', () => {
|
||||
const vote = (inputCat: string, assertCat: string, callback: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=incorrect-category-change&category=" + inputCat)
|
||||
.then(async res => {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category-change"]);
|
||||
.then(async () => {
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category-change"]);
|
||||
if (row.category === assertCat) {
|
||||
callback();
|
||||
} else {
|
||||
@@ -336,8 +336,8 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=vote-uuid-5&category=outro")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
let row2 = await db.prepare('get', `SELECT votes FROM "categoryVotes" WHERE "UUID" = ? and category = ?`, ["vote-uuid-5", "outro"]);
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
const row2 = await db.prepare('get', `SELECT votes FROM "categoryVotes" WHERE "UUID" = ? and category = ?`, ["vote-uuid-5", "outro"]);
|
||||
if (row.category === "outro" && row2.votes === 500) {
|
||||
done();
|
||||
} else {
|
||||
@@ -355,7 +355,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=testman&UUID=vote-uuid-5_1&category=outro")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
if (row.category === "outro") {
|
||||
done();
|
||||
} else {
|
||||
@@ -385,7 +385,7 @@ describe('voteOnSponsorTime', () => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-5&type=1")
|
||||
.then(async res => {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
if (res.status === 403 && row.votes === -3) {
|
||||
done();
|
||||
} else {
|
||||
@@ -399,7 +399,7 @@ describe('voteOnSponsorTime', () => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-5&type=0")
|
||||
.then(async res => {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
if (res.status === 200 && row.votes === -3) {
|
||||
done();
|
||||
} else {
|
||||
@@ -414,7 +414,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=vote-uuid-5&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
if (row.votes > -3) {
|
||||
done();
|
||||
} else {
|
||||
@@ -444,7 +444,7 @@ describe('voteOnSponsorTime', () => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=no-sponsor-segments-uuid-0&type=0")
|
||||
.then(async res => {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
if (res.status === 200 && row.votes === 2) {
|
||||
done();
|
||||
} else {
|
||||
@@ -458,7 +458,7 @@ describe('voteOnSponsorTime', () => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=no-sponsor-segments-uuid-0&type=1")
|
||||
.then(async res => {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
if (res.status === 200 && row.votes === 3) {
|
||||
done();
|
||||
} else {
|
||||
@@ -472,7 +472,7 @@ describe('voteOnSponsorTime', () => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=no-sponsor-segments-uuid-0&category=outro")
|
||||
.then(async res => {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
const row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
if (res.status === 200 && row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
@@ -487,7 +487,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=segment-locking-uuid-1&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, ["segment-locking-uuid-1"]);
|
||||
const row = await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, ["segment-locking-uuid-1"]);
|
||||
if (row?.locked) {
|
||||
done();
|
||||
} else {
|
||||
@@ -505,7 +505,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=segment-locking-uuid-1&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, ["segment-locking-uuid-1"]);
|
||||
const row = await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, ["segment-locking-uuid-1"]);
|
||||
if (!row?.locked) {
|
||||
done();
|
||||
} else {
|
||||
@@ -523,7 +523,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=segment-hidden-uuid-1&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "hidden" FROM "sponsorTimes" WHERE "UUID" = ?`, ["segment-hidden-uuid-1"]);
|
||||
const row = await db.prepare('get', `SELECT "hidden" FROM "sponsorTimes" WHERE "UUID" = ?`, ["segment-hidden-uuid-1"]);
|
||||
if (!row?.hidden) {
|
||||
done();
|
||||
} else {
|
||||
@@ -541,7 +541,7 @@ describe('voteOnSponsorTime', () => {
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-2&type=20")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-2"]);
|
||||
const row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-2"]);
|
||||
if (row.votes === 10) {
|
||||
done();
|
||||
} else {
|
||||
@@ -560,7 +560,7 @@ describe('voteOnSponsorTime', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
it('Should not be able to vote with type 11', (done: Done) => {
|
||||
@@ -569,7 +569,7 @@ describe('voteOnSponsorTime', () => {
|
||||
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => done('couldn\'t call endpoint'));
|
||||
.catch(() => done('couldn\'t call endpoint'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {config} from '../src/config';
|
||||
|
||||
export function getbaseURL() {
|
||||
export function getbaseURL(): string {
|
||||
return "http://localhost:" + config.port;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { APIVideoData, APIVideoInfo } from "../src/types/youtubeApi.model";
|
||||
|
||||
export class YouTubeApiMock {
|
||||
static async listVideos(videoID: string, ignoreCache = false): Promise<APIVideoInfo> {
|
||||
static async listVideos(videoID: string): Promise<APIVideoInfo> {
|
||||
const obj = {
|
||||
id: videoID
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user