mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 06:27:10 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into export
This commit is contained in:
@@ -4,21 +4,21 @@ import {getHash} from '../../src/utils/getHash';
|
||||
import {db} from '../../src/databases/databases';
|
||||
|
||||
|
||||
describe('noSegmentRecords', () => {
|
||||
describe('lockCategoriesRecords', () => {
|
||||
before(async () => {
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('` + getHash("VIPUser-noSegments") + "')");
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('` + getHash("VIPUser-lockCategories") + "')");
|
||||
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'no-segments-video-id', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'no-segments-video-id', 'intro')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'no-segments-video-id', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'no-segments-video-id', 'intro')");
|
||||
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'no-segments-video-id-1', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'no-segments-video-id-1', 'intro')");
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'noSubmitVideo', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'no-segments-video-id-1', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'no-segments-video-id-1', 'intro')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'lockCategoryVideo', 'sponsor')");
|
||||
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'delete-record', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'delete-record', 'sponsor')");
|
||||
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'delete-record-1', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-noSegments") + "', 'delete-record-1', 'intro')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'delete-record-1', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-lockCategories") + "', 'delete-record-1', 'intro')");
|
||||
});
|
||||
|
||||
it('Should update the database version when starting the application', async () => {
|
||||
@@ -30,7 +30,7 @@ describe('noSegmentRecords', () => {
|
||||
it('Should be able to submit categories not in video (http response)', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'no-segments-video-id',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'outro',
|
||||
'shilling',
|
||||
@@ -48,7 +48,7 @@ describe('noSegmentRecords', () => {
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -75,7 +75,7 @@ describe('noSegmentRecords', () => {
|
||||
it('Should be able to submit categories not in video (sql check)', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'no-segments-video-id-1',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'outro',
|
||||
'shilling',
|
||||
@@ -86,7 +86,7 @@ describe('noSegmentRecords', () => {
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -95,7 +95,7 @@ describe('noSegmentRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "noSegments" WHERE "videoID" = ?', ['no-segments-video-id-1']);
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['no-segments-video-id-1']);
|
||||
if (result.length !== 4) {
|
||||
console.log(result);
|
||||
done("Expected 4 entrys in db, got " + result.length);
|
||||
@@ -114,13 +114,13 @@ describe('noSegmentRecords', () => {
|
||||
it('Should be able to submit categories with _ in the category', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'underscore',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'word_word',
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -129,7 +129,7 @@ describe('noSegmentRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "noSegments" WHERE "videoID" = ?', ['underscore']);
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['underscore']);
|
||||
if (result.length !== 1) {
|
||||
console.log(result);
|
||||
done("Expected 1 entrys in db, got " + result.length);
|
||||
@@ -148,13 +148,13 @@ describe('noSegmentRecords', () => {
|
||||
it('Should be able to submit categories with upper and lower case in the category', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'bothCases',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'wordWord',
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -163,7 +163,7 @@ describe('noSegmentRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "noSegments" WHERE "videoID" = ?', ['bothCases']);
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['bothCases']);
|
||||
if (result.length !== 1) {
|
||||
console.log(result);
|
||||
done("Expected 1 entrys in db, got " + result.length);
|
||||
@@ -182,13 +182,13 @@ describe('noSegmentRecords', () => {
|
||||
it('Should not be able to submit categories with $ in the category', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'specialChar',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'word&word',
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -197,7 +197,7 @@ describe('noSegmentRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "noSegments" WHERE "videoID" = ?', ['specialChar']);
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['specialChar']);
|
||||
if (result.length !== 0) {
|
||||
console.log(result);
|
||||
done("Expected 0 entrys in db, got " + result.length);
|
||||
@@ -214,7 +214,7 @@ describe('noSegmentRecords', () => {
|
||||
});
|
||||
|
||||
it('Should return 400 for missing params', (done: Done) => {
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -238,7 +238,7 @@ describe('noSegmentRecords', () => {
|
||||
categories: [],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -262,7 +262,7 @@ describe('noSegmentRecords', () => {
|
||||
categories: ['sponsor'],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -286,7 +286,7 @@ describe('noSegmentRecords', () => {
|
||||
categories: ['sponsor'],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -310,7 +310,7 @@ describe('noSegmentRecords', () => {
|
||||
categories: {},
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -334,7 +334,7 @@ describe('noSegmentRecords', () => {
|
||||
categories: 'sponsor',
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -360,7 +360,7 @@ describe('noSegmentRecords', () => {
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -377,16 +377,16 @@ describe('noSegmentRecords', () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should be able to delete a noSegment record', (done: Done) => {
|
||||
it('Should be able to delete a lockCategories record', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'delete-record',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'sponsor',
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -395,7 +395,7 @@ describe('noSegmentRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "noSegments" WHERE "videoID" = ?', ['delete-record']);
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['delete-record']);
|
||||
if (result.length === 0) {
|
||||
done();
|
||||
} else {
|
||||
@@ -408,16 +408,16 @@ describe('noSegmentRecords', () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should be able to delete one noSegment record without removing another', (done: Done) => {
|
||||
it('Should be able to delete one lockCategories record without removing another', (done: Done) => {
|
||||
let json = {
|
||||
videoID: 'delete-record-1',
|
||||
userID: 'VIPUser-noSegments',
|
||||
userID: 'VIPUser-lockCategories',
|
||||
categories: [
|
||||
'sponsor',
|
||||
],
|
||||
};
|
||||
|
||||
fetch(getbaseURL() + "/api/noSegments", {
|
||||
fetch(getbaseURL() + "/api/lockCategories", {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -426,7 +426,7 @@ describe('noSegmentRecords', () => {
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let result = await db.prepare('all', 'SELECT * FROM "noSegments" WHERE "videoID" = ?', ['delete-record-1']);
|
||||
let result = await db.prepare('all', 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', ['delete-record-1']);
|
||||
if (result.length === 1) {
|
||||
done();
|
||||
} else {
|
||||
@@ -445,7 +445,7 @@ describe('noSegmentRecords', () => {
|
||||
* To test the submission code properly see ./test/cases/postSkipSegments.js
|
||||
*/
|
||||
|
||||
it('Should not be able to submit a segment to a video with a no-segment record (single submission)', (done: Done) => {
|
||||
it('Should not be able to submit a segment to a video with a lock-category record (single submission)', (done: Done) => {
|
||||
fetch(getbaseURL() + "/api/postVideoSponsorTimes", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -453,7 +453,7 @@ describe('noSegmentRecords', () => {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "testman42",
|
||||
videoID: "noSubmitVideo",
|
||||
videoID: "lockCategoryVideo",
|
||||
segments: [{
|
||||
segment: [20, 40],
|
||||
category: "sponsor",
|
||||
@@ -478,7 +478,7 @@ describe('noSegmentRecords', () => {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "testman42",
|
||||
videoID: "noSubmitVideo",
|
||||
videoID: "lockCategoryVideo",
|
||||
segments: [{
|
||||
segment: [20, 40],
|
||||
category: "sponsor",
|
||||
@@ -507,7 +507,7 @@ describe('noSegmentRecords', () => {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "testman42",
|
||||
videoID: "noSubmitVideo",
|
||||
videoID: "lockCategoryVideo",
|
||||
segments: [{
|
||||
segment: [20, 40],
|
||||
category: "intro",
|
||||
@@ -195,8 +195,8 @@ describe('postSkipSegments', () => {
|
||||
});
|
||||
|
||||
it('Should be able to submit with a new duration, and hide old submissions and remove segment locks', async () => {
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category")
|
||||
VALUES ('` + getHash("VIPUser-noSegments") + "', 'noDuration', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category")
|
||||
VALUES ('` + getHash("VIPUser-lockCategories") + "', 'noDuration', 'sponsor')");
|
||||
|
||||
try {
|
||||
const res = await fetch(getbaseURL()
|
||||
@@ -217,13 +217,13 @@ describe('postSkipSegments', () => {
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
const noSegmentsRow = await db.prepare('get', `SELECT * from "noSegments" WHERE videoID = ?`, ["noDuration"]);
|
||||
const lockCategoriesRow = await db.prepare('get', `SELECT * from "lockCategories" WHERE videoID = ?`, ["noDuration"]);
|
||||
const videoRows = await db.prepare('all', `SELECT "startTime", "endTime", "locked", "category", "videoDuration"
|
||||
FROM "sponsorTimes" WHERE "videoID" = ? AND hidden = 0`, ["noDuration"]);
|
||||
const videoRow = videoRows[0];
|
||||
const hiddenVideoRows = await db.prepare('all', `SELECT "startTime", "endTime", "locked", "category", "videoDuration"
|
||||
FROM "sponsorTimes" WHERE "videoID" = ? AND hidden = 1`, ["noDuration"]);
|
||||
if (noSegmentsRow === undefined && videoRows.length === 1 && hiddenVideoRows.length === 1 && videoRow.startTime === 1 && videoRow.endTime === 10
|
||||
if (lockCategoriesRow === undefined && videoRows.length === 1 && hiddenVideoRows.length === 1 && videoRow.startTime === 1 && videoRow.endTime === 10
|
||||
&& videoRow.locked === 0 && videoRow.category === "sponsor" && videoRow.videoDuration === 100) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('unBan', () => {
|
||||
await privateDB.prepare("run", `INSERT INTO "shadowBannedUsers" VALUES('testEntity-unBan')`);
|
||||
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('` + getHash("VIPUser-unBan") + "')");
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-unBan") + "', 'unBan-videoID-1', 'sponsor')");
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "category") VALUES ('` + getHash("VIPUser-unBan") + "', 'unBan-videoID-1', 'sponsor')");
|
||||
|
||||
let startOfInsertSegmentQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "shadowHidden", "hashedVideoID") VALUES';
|
||||
await db.prepare("run", startOfInsertSegmentQuery + "('unBan-videoID-0', 1, 11, 2, 'unBan-uuid-0', 'testMan-unBan', 0, 50, 'sponsor', 1, '" + getHash('unBan-videoID-0', 1) + "')");
|
||||
@@ -47,7 +47,7 @@ describe('unBan', () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should be able to unban a user and re-enable shadow banned segments without noSegment entrys', (done) => {
|
||||
it('Should be able to unban a user and re-enable shadow banned segments without lockCategories entrys', (done) => {
|
||||
fetch(utils.getbaseURL() + "/api/shadowBanUser?userID=testWoman-unBan&adminUserID=VIPUser-unBan&enabled=false", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -72,7 +72,7 @@ describe('unBan', () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should be able to unban a user and re-enable shadow banned segments with a mix of noSegment entrys', (done) => {
|
||||
it('Should be able to unban a user and re-enable shadow banned segments with a mix of lockCategories entrys', (done) => {
|
||||
fetch(utils.getbaseURL() + "/api/shadowBanUser?userID=testEntity-unBan&adminUserID=VIPUser-unBan&enabled=false", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('voteOnSponsorTime', () => {
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES ('` + getHash("VIPUser") + "')");
|
||||
await privateDB.prepare("run", `INSERT INTO "shadowBannedUsers" ("userID") VALUES ('` + getHash("randomID4") + "')");
|
||||
|
||||
await db.prepare("run", `INSERT INTO "noSegments" ("videoID", "userID", "category") VALUES ('no-sponsor-segments-video', 'someUser', 'sponsor')`);
|
||||
await db.prepare("run", `INSERT INTO "lockCategories" ("videoID", "userID", "category") VALUES ('no-sponsor-segments-video', 'someUser', 'sponsor')`);
|
||||
|
||||
});
|
||||
|
||||
@@ -386,10 +386,25 @@ describe('voteOnSponsorTime', () => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-5&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 403) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["vote-uuid-5"]);
|
||||
if (res.status === 403 && row.votes === -3) {
|
||||
done();
|
||||
} else {
|
||||
done("Status code was " + res.status + " instead of 403");
|
||||
done("Status code was " + res.status + ", row is " + JSON.stringify(row));
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Non-VIP should not be able to downvote "dead" submission', (done: Done) => {
|
||||
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"]);
|
||||
if (res.status === 200 && row.votes === -3) {
|
||||
done();
|
||||
} else {
|
||||
done("Status code was " + res.status + ", row is " + JSON.stringify(row));
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
@@ -428,12 +443,13 @@ describe('voteOnSponsorTime', () => {
|
||||
|
||||
it('Non-VIP should not be able to downvote on a segment with no-segments category', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=no-segments-voter&UUID=no-sponsor-segments-uuid-0&type=0")
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=no-sponsor-segments-uuid-0&type=0")
|
||||
.then(async res => {
|
||||
if (res.status === 403) {
|
||||
let row = await db.prepare('get', `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
if (res.status === 403 && row.votes === 2) {
|
||||
done();
|
||||
} else {
|
||||
done("Status code was " + res.status + " instead of 403");
|
||||
done("Status code was " + res.status + " instead of 403, row was " + JSON.stringify(row));
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
@@ -441,12 +457,13 @@ describe('voteOnSponsorTime', () => {
|
||||
|
||||
it('Non-VIP should be able to upvote on a segment with no-segments category', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=no-segments-voter&UUID=no-sponsor-segments-uuid-0&type=1")
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=no-sponsor-segments-uuid-0&type=1")
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
let 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 {
|
||||
done("Status code was " + res.status + " instead of 200");
|
||||
done("Status code was " + res.status + " instead of 403, row was " + JSON.stringify(row));
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
@@ -454,12 +471,13 @@ describe('voteOnSponsorTime', () => {
|
||||
|
||||
it('Non-VIP should not be able to category vote on a segment with no-segments category', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=no-segments-voter&UUID=no-sponsor-segments-uuid-0&category=outro")
|
||||
+ "/api/voteOnSponsorTime?userID=randomID&UUID=no-sponsor-segments-uuid-0&category=outro")
|
||||
.then(async res => {
|
||||
if (res.status === 403) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["no-sponsor-segments-uuid-0"]);
|
||||
if (res.status === 403 && row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
done("Status code was " + res.status + " instead of 403");
|
||||
done("Status code was " + res.status + " instead of 403, row was " + JSON.stringify(row));
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
|
||||
Reference in New Issue
Block a user