remove tests for maxNumberOfActiveWarnings

This commit is contained in:
Michael C 2023-02-22 00:35:58 -05:00
parent 780555e9df
commit 7ba654e476
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
3 changed files with 23 additions and 25 deletions

View file

@ -56,7 +56,6 @@
]
}
],
"maxNumberOfActiveWarnings": 3,
"hoursAfterWarningExpires": 24,
"rateLimit": {
"vote": {

View file

@ -44,7 +44,6 @@
]
}
],
"maxNumberOfActiveWarnings": 3,
"hoursAfterWarningExpires": 24,
"rateLimit": {
"vote": {

View file

@ -6,12 +6,14 @@ import { client } from "../utils/httpClient";
describe("postSkipSegments Warnings", () => {
// Constant and helpers
const warnUser01 = "warn-user01-qwertyuiopasdfghjklzxcvbnm";
const warnUser01 = "warn-user01";
const warnUser01Hash = getHash(warnUser01);
const warnUser02 = "warn-user02-qwertyuiopasdfghjklzxcvbnm";
const warnUser02 = "warn-user02";
const warnUser02Hash = getHash(warnUser02);
const warnUser03 = "warn-user03-qwertyuiopasdfghjklzxcvbnm";
const warnUser03 = "warn-user03";
const warnUser03Hash = getHash(warnUser03);
const warnUser04 = "warn-user04";
const warnUser04Hash = getHash(warnUser04);
const warnVideoID = "postSkipSegments-warn-video";
@ -32,26 +34,20 @@ describe("postSkipSegments Warnings", () => {
const reason03 = "Reason03";
const MILLISECONDS_IN_HOUR = 3600000;
const warningExpireTime = MILLISECONDS_IN_HOUR * config.hoursAfterWarningExpires;
const WARNING_EXPIRATION_TIME = config.hoursAfterWarningExpires * MILLISECONDS_IN_HOUR;
const insertWarningQuery = 'INSERT INTO warnings ("userID", "issuerUserID", "enabled", "reason", "issueTime") VALUES(?, ?, ?, ?, ?)';
// User 1 - 4 active warnings
// User 1 | 1 active | custom reason
db.prepare("run", insertWarningQuery, [warnUser01Hash, warnVip01Hash, 1, reason01, now]);
db.prepare("run", insertWarningQuery, [warnUser01Hash, warnVip01Hash, 1, reason01, (now - 1000)]);
db.prepare("run", insertWarningQuery, [warnUser01Hash, warnVip01Hash, 1, reason01, (now - 2000)]);
db.prepare("run", insertWarningQuery, [warnUser01Hash, warnVip01Hash, 1, reason01, (now - 3601000)]);
// User 2 - 3 active warnings
db.prepare("run", insertWarningQuery, [warnUser02Hash, warnVip01Hash, 1, reason02, now]);
db.prepare("run", insertWarningQuery, [warnUser02Hash, warnVip01Hash, 1, reason02, (now - (warningExpireTime + 1000))]);
db.prepare("run", insertWarningQuery, [warnUser02Hash, warnVip01Hash, 1, reason02, (now - (warningExpireTime + 2000))]);
// User 3 - 2 active warnings, 2 expired warnings
db.prepare("run", insertWarningQuery, [warnUser03Hash, warnVip01Hash, 0, reason03, now]);
db.prepare("run", insertWarningQuery, [warnUser03Hash, warnVip01Hash, 0, reason03, (now - 1000)]);
db.prepare("run", insertWarningQuery, [warnUser03Hash, warnVip01Hash, 1, reason03, (now - 2000)]);
db.prepare("run", insertWarningQuery, [warnUser03Hash, warnVip01Hash, 1, reason03, (now - 3601000)]);
// User 2 | 1 inactive | default reason
db.prepare("run", insertWarningQuery, [warnUser02Hash, warnVip01Hash, 0, reason02, now]);
// User 3 | 1 expired, active | custom reason
db.prepare("run", insertWarningQuery, [warnUser03Hash, warnVip01Hash, 1, reason03, (now - WARNING_EXPIRATION_TIME - 1000)]);
// User 4 | 1 active | default reason
db.prepare("run", insertWarningQuery, [warnUser04Hash, warnVip01Hash, 1, reason02, now]);
});
it("Should be rejected with custom message if user has too many active warnings", (done) => {
it("Should be rejected with custom message if user has active warnings", (done) => {
postSkipSegmentJSON({
userID: warnUser01,
videoID: warnVideoID,
@ -75,7 +71,7 @@ describe("postSkipSegments Warnings", () => {
.catch(err => done(err));
});
it("Should be accepted if user has some active warnings", (done) => {
it("Should be accepted if user has inactive warning", (done) => {
postSkipSegmentJSON({
userID: warnUser02,
videoID: warnVideoID,
@ -91,7 +87,7 @@ describe("postSkipSegments Warnings", () => {
.catch(err => done(err));
});
it("Should be accepted if user has some warnings removed", (done) => {
it("Should be accepted if user has expired warning", (done) => {
postSkipSegmentJSON({
userID: warnUser03,
videoID: warnVideoID,
@ -107,9 +103,9 @@ describe("postSkipSegments Warnings", () => {
.catch(err => done(err));
});
it("Should be rejected with default message if user has to many active warnings", (done) => {
it("Should be rejected with default message if user has active warning", (done) => {
postSkipSegmentJSON({
userID: warnUser01,
userID: warnUser04,
videoID: warnVideoID,
segments: [{
segment: [0, 10],
@ -119,7 +115,11 @@ describe("postSkipSegments Warnings", () => {
.then(res => {
assert.strictEqual(res.status, 403);
const errorMessage = res.data;
assert.notStrictEqual(errorMessage, "");
const expected = "Submission rejected due to a warning from a moderator. This means that we noticed you were making some common mistakes"
+ " that are not malicious, and we just want to clarify the rules. "
+ "Could you please send a message in discord.gg/SponsorBlock or matrix.to/#/#sponsor:ajay.app so we can further help you? "
+ `Your userID is ${warnUser04Hash}.`;
assert.strictEqual(errorMessage, expected);
done();
})
.catch(err => done(err));