mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-15 16:07:03 +03:00
Store user-agent in postSkipSegment
This commit is contained in:
@@ -845,4 +845,85 @@ describe("postSkipSegments", () => {
|
||||
return e;
|
||||
}
|
||||
}).timeout(5000);
|
||||
|
||||
it("Should be able to submit with custom user-agent 1", (done: Done) => {
|
||||
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "MeaBot/5.0"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "testtesttesttesttesttesttesttesttest",
|
||||
videoID: "userAgent-1",
|
||||
segments: [{
|
||||
segment: [0, 10],
|
||||
category: "sponsor",
|
||||
}],
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-1"]);
|
||||
assert.strictEqual(row.startTime, 0);
|
||||
assert.strictEqual(row.endTime, 10);
|
||||
assert.strictEqual(row.userAgent, "MeaBot");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to submit with custom user-agent 2", (done: Done) => {
|
||||
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "MeaBot"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "testtesttesttesttesttesttesttesttest",
|
||||
videoID: "userAgent-2",
|
||||
segments: [{
|
||||
segment: [0, 10],
|
||||
category: "sponsor",
|
||||
}],
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-2"]);
|
||||
assert.strictEqual(row.startTime, 0);
|
||||
assert.strictEqual(row.endTime, 10);
|
||||
assert.strictEqual(row.userAgent, "MeaBot");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to submit with empty user-agent", (done: Done) => {
|
||||
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": ""
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: "testtesttesttesttesttesttesttesttest",
|
||||
videoID: "userAgent-3",
|
||||
segments: [{
|
||||
segment: [0, 10],
|
||||
category: "sponsor",
|
||||
}],
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-3"]);
|
||||
assert.strictEqual(row.startTime, 0);
|
||||
assert.strictEqual(row.endTime, 10);
|
||||
assert.strictEqual(row.userAgent, "");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user