mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-01-27 12:50:47 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into export
This commit is contained in:
@@ -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