mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-18 05:28:27 +03:00
Replace VIP starting with 1000 votes with locked submissions
This commit is contained in:
@@ -5,14 +5,16 @@ import {getHash} from '../../src/utils/getHash';
|
||||
|
||||
describe('getSkipSegments', () => {
|
||||
before(() => {
|
||||
let startOfQuery = "INSERT INTO sponsorTimes (videoID, startTime, endTime, votes, UUID, userID, timeSubmitted, views, category, shadowHidden, hashedVideoID) VALUES";
|
||||
db.exec(startOfQuery + "('testtesttest', 1, 11, 2, '1-uuid-0', 'testman', 0, 50, 'sponsor', 0, '" + getHash('testtesttest', 1) + "')");
|
||||
db.exec(startOfQuery + "('testtesttest', 20, 33, 2, '1-uuid-2', 'testman', 0, 50, 'intro', 0, '" + getHash('testtesttest', 1) + "')");
|
||||
db.exec(startOfQuery + "('testtesttest,test', 1, 11, 2, '1-uuid-1', 'testman', 0, 50, 'sponsor', 0, '" + getHash('testtesttest,test', 1) + "')");
|
||||
db.exec(startOfQuery + "('test3', 1, 11, 2, '1-uuid-4', 'testman', 0, 50, 'sponsor', 0, '" + getHash('test3', 1) + "')");
|
||||
db.exec(startOfQuery + "('test3', 7, 22, -3, '1-uuid-5', 'testman', 0, 50, 'sponsor', 0, '" + getHash('test3', 1) + "')");
|
||||
db.exec(startOfQuery + "('multiple', 1, 11, 2, '1-uuid-6', 'testman', 0, 50, 'intro', 0, '" + getHash('multiple', 1) + "')");
|
||||
db.exec(startOfQuery + "('multiple', 20, 33, 2, '1-uuid-7', 'testman', 0, 50, 'intro', 0, '" + getHash('multiple', 1) + "')");
|
||||
let startOfQuery = "INSERT INTO sponsorTimes (videoID, startTime, endTime, votes, locked, UUID, userID, timeSubmitted, views, category, shadowHidden, hashedVideoID) VALUES";
|
||||
db.exec(startOfQuery + "('testtesttest', 1, 11, 2, 0, '1-uuid-0', 'testman', 0, 50, 'sponsor', 0, '" + getHash('testtesttest', 1) + "')");
|
||||
db.exec(startOfQuery + "('testtesttest', 20, 33, 2, 0, '1-uuid-2', 'testman', 0, 50, 'intro', 0, '" + getHash('testtesttest', 1) + "')");
|
||||
db.exec(startOfQuery + "('testtesttest,test', 1, 11, 2, 0, '1-uuid-1', 'testman', 0, 50, 'sponsor', 0, '" + getHash('testtesttest,test', 1) + "')");
|
||||
db.exec(startOfQuery + "('test3', 1, 11, 2, 0, '1-uuid-4', 'testman', 0, 50, 'sponsor', 0, '" + getHash('test3', 1) + "')");
|
||||
db.exec(startOfQuery + "('test3', 7, 22, -3, 0, '1-uuid-5', 'testman', 0, 50, 'sponsor', 0, '" + getHash('test3', 1) + "')");
|
||||
db.exec(startOfQuery + "('multiple', 1, 11, 2, 0, '1-uuid-6', 'testman', 0, 50, 'intro', 0, '" + getHash('multiple', 1) + "')");
|
||||
db.exec(startOfQuery + "('multiple', 20, 33, 2, 0, '1-uuid-7', 'testman', 0, 50, 'intro', 0, '" + getHash('multiple', 1) + "')");
|
||||
db.exec(startOfQuery + "('locked', 20, 33, 2, 1, '1-uuid-locked-8', 'testman', 0, 50, 'intro', 0, '" + getHash('locked', 1) + "')");
|
||||
db.exec(startOfQuery + "('locked', 20, 34, 100000, 0, '1-uuid-9', 'testman', 0, 50, 'intro', 0, '" + getHash('locked', 1) + "')");
|
||||
});
|
||||
|
||||
|
||||
@@ -207,4 +209,21 @@ describe('getSkipSegments', () => {
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should always get locked segment', (done: Done) => {
|
||||
fetch(getbaseURL() + "/api/skipSegments?videoID=locked&category=intro")
|
||||
.then(async res => {
|
||||
if (res.status !== 200) done("Status code was: " + res.status);
|
||||
else {
|
||||
const data = await res.json();
|
||||
if (data.length === 1 && data[0].segment[0] === 20 && data[0].segment[1] === 33
|
||||
&& data[0].category === "intro" && data[0].UUID === "1-uuid-locked-8") {
|
||||
done();
|
||||
} else {
|
||||
done("Received incorrect body: " + (await res.text()));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => done("Couldn't call endpoint"));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -39,6 +39,8 @@ describe('postSkipSegments', () => {
|
||||
db.exec(startOfWarningQuery + "('" + warnUser03Hash + "', '" + (now - 1000) + "', '" + warnVip01Hash + "', 0)");
|
||||
db.exec(startOfWarningQuery + "('" + warnUser03Hash + "', '" + (now - 2000) + "', '" + warnVip01Hash + "', 1)");
|
||||
db.exec(startOfWarningQuery + "('" + warnUser03Hash + "', '" + (now - 3601000) + "', '" + warnVip01Hash + "', 1)");
|
||||
|
||||
db.exec("INSERT INTO vipUsers (userID) VALUES ('" + getHash("VIPUserSubmission") + "')");
|
||||
});
|
||||
|
||||
it('Should be able to submit a single time (Params method)', (done: Done) => {
|
||||
@@ -82,8 +84,8 @@ describe('postSkipSegments', () => {
|
||||
})
|
||||
.then(res => {
|
||||
if (res.status === 200) {
|
||||
const row = db.prepare('get', "SELECT startTime, endTime, category FROM sponsorTimes WHERE videoID = ?", ["dQw4w9WgXcF"]);
|
||||
if (row.startTime === 0 && row.endTime === 10 && row.category === "sponsor") {
|
||||
const row = db.prepare('get', "SELECT startTime, endTime, locked, category FROM sponsorTimes WHERE videoID = ?", ["dQw4w9WgXcF"]);
|
||||
if (row.startTime === 0 && row.endTime === 10 && row.locked === 0 && row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
done("Submitted times were not saved. Actual submission: " + JSON.stringify(row));
|
||||
@@ -95,6 +97,37 @@ describe('postSkipSegments', () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('VIP submission should start locked', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/postVideoSponsorTimes", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "VIPUserSubmission",
|
||||
videoID: "vipuserIDSubmission",
|
||||
segments: [{
|
||||
segment: [0, 10],
|
||||
category: "sponsor",
|
||||
}],
|
||||
}),
|
||||
})
|
||||
.then(res => {
|
||||
if (res.status === 200) {
|
||||
const row = db.prepare('get', "SELECT startTime, endTime, locked, category FROM sponsorTimes WHERE videoID = ?", ["vipuserIDSubmission"]);
|
||||
if (row.startTime === 0 && row.endTime === 10 && row.locked === 1 && row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
done("Submitted times were not saved. Actual submission: " + JSON.stringify(row));
|
||||
}
|
||||
} else {
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should be able to submit multiple times (JSON method)', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/postVideoSponsorTimes", {
|
||||
|
||||
Reference in New Issue
Block a user