diff --git a/test/cases/getBranding.ts b/test/cases/getBranding.ts index 403f7359..f8f18ea7 100644 --- a/test/cases/getBranding.ts +++ b/test/cases/getBranding.ts @@ -42,7 +42,7 @@ describe("getBranding", () => { const titleVotesQuery = `INSERT INTO "titleVotes" ("UUID", "votes", "locked", "shadowHidden", "verification", "downvotes", "removed", "createdAt", "updatedAt") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`; const thumbnailQuery = `INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID") VALUES (?, ?, ?, ?, ?, ?, ?)`; const thumbnailTimestampsQuery = `INSERT INTO "thumbnailTimestamps" ("UUID", "timestamp") VALUES (?, ?)`; - const thumbnailVotesQuery = `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "downvotes", "removed") VALUES (?, ?, ?, ?, ?, ?)`; + const thumbnailVotesQuery = `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "downvotes", "removed", "createdAt", "updatedAt") VALUES (?, ?, ?, ?, ?, ?, ?, ?)`; const segmentQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "locked", "UUID", "userID", "timeSubmitted", "views", "category", "actionType", "service", "videoDuration", "hidden", "shadowHidden", "description", "hashedVideoID", "updatedAt") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; await Promise.all([ @@ -64,10 +64,10 @@ describe("getBranding", () => { db.prepare("run", thumbnailTimestampsQuery, ["UUID1T", 1]), db.prepare("run", thumbnailTimestampsQuery, ["UUID3T", 3]), db.prepare("run", thumbnailTimestampsQuery, ["UUID4T", 18]), - db.prepare("run", thumbnailVotesQuery, ["UUID1T", 3, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID2T", 3, 0, 0, 1, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID3T", 1, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID4T", 5, 0, 0, 0, 1]) + db.prepare("run", thumbnailVotesQuery, ["UUID1T", 3, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID2T", 3, 0, 0, 1, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID3T", 1, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID4T", 5, 0, 0, 0, 1, isoDate, isoDate]) ]); await Promise.all([ @@ -86,9 +86,9 @@ describe("getBranding", () => { db.prepare("run", thumbnailTimestampsQuery, ["UUID11T", 1]), db.prepare("run", thumbnailTimestampsQuery, ["UUID31T", 3]), - db.prepare("run", thumbnailVotesQuery, ["UUID11T", 3, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID21T", 2, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID31T", 1, 1, 0, 0, 0]), + db.prepare("run", thumbnailVotesQuery, ["UUID11T", 3, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID21T", 2, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID31T", 1, 1, 0, 0, 0, isoDate, isoDate]), ]); await Promise.all([ @@ -106,9 +106,9 @@ describe("getBranding", () => { db.prepare("run", titleVotesQuery, ["UUID32", 1, 0, 1, 0, 0, 0, isoDate, isoDate]), db.prepare("run", thumbnailTimestampsQuery, ["UUID12T", 1]), db.prepare("run", thumbnailTimestampsQuery, ["UUID32T", 3]), - db.prepare("run", thumbnailVotesQuery, ["UUID12T", 3, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID22T", 2, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID32T", 1, 0, 1, 0, 0]) + db.prepare("run", thumbnailVotesQuery, ["UUID12T", 3, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID22T", 2, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID32T", 1, 0, 1, 0, 0, isoDate, isoDate]) ]); await db.prepare("run", segmentQuery, [videoIDRandomTime, 1, 11, 1, 0, "uuidbranding1", "testman", 0, 50, "sponsor", "skip", "YouTube", 100, 0, 0, "", videoIDRandomTimeHash, isoDate]); @@ -129,9 +129,9 @@ describe("getBranding", () => { db.prepare("run", titleVotesQuery, ["UUID-uv-3", 0, 0, 0, -1, 0, 0, isoDate, isoDate]), db.prepare("run", thumbnailTimestampsQuery, ["UUID-uv-1T", 1]), db.prepare("run", thumbnailTimestampsQuery, ["UUID-uv-3T", 3]), - db.prepare("run", thumbnailVotesQuery, ["UUID-uv-1T", 3, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID-uv-2T", 2, 0, 0, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID-uv-3T", 1, 0, 0, 0, 0]) + db.prepare("run", thumbnailVotesQuery, ["UUID-uv-1T", 3, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID-uv-2T", 2, 0, 0, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID-uv-3T", 1, 0, 0, 0, 0, isoDate, isoDate]) ]); // Video duration test segments diff --git a/test/cases/postBranding.ts b/test/cases/postBranding.ts index 10961b59..9251ac7e 100644 --- a/test/cases/postBranding.ts +++ b/test/cases/postBranding.ts @@ -50,9 +50,9 @@ describe("postBranding", () => { const insertThumbnailQuery = 'INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID") VALUES (?, ?, ?, ?, ?, ?, ?)'; await db.prepare("run", insertThumbnailQuery, ["postBrandLocked1", 0, getHash(userID3), Service.YouTube, getHash("postBrandLocked1"), Date.now(), "postBrandLocked1"]); await db.prepare("run", insertThumbnailQuery, ["postBrandLocked2", 1, getHash(userID4), Service.YouTube, getHash("postBrandLocked2"), Date.now(), "postBrandLocked2"]); - const insertThumbnailVotesQuery = 'INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, ?, ?, ?);'; - await db.prepare("run", insertThumbnailVotesQuery, ["postBrandLocked1", 0, 1, 0]); - await db.prepare("run", insertThumbnailVotesQuery, ["postBrandLocked2", 0, 1, 0]); + const insertThumbnailVotesQuery = 'INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "createdAt", "updatedAt") VALUES (?, ?, ?, ?, ?, ?);'; + await db.prepare("run", insertThumbnailVotesQuery, ["postBrandLocked1", 0, 1, 0, isoDate, isoDate]); + await db.prepare("run", insertThumbnailVotesQuery, ["postBrandLocked2", 0, 1, 0, isoDate, isoDate]); // Testing vip submission removal await db.prepare("run", insertTitleQuery, ["postBrandRemoved1", "Some title", 0, getHash(userID1), Service.YouTube, getHash("postBrandRemoved1"), Date.now(), "postBrandRemoved1"]); @@ -64,10 +64,10 @@ describe("postBranding", () => { const insertThumbnailTimestampQuery = 'INSERT INTO "thumbnailTimestamps" ("UUID", "timestamp") VALUES (?, ?)'; await db.prepare("run", insertThumbnailQuery, ["postBrandRemoved1", 0, getHash(userID3), Service.YouTube, getHash("postBrandRemoved1"), Date.now(), "postBrandRemoved1"]); await db.prepare("run", insertThumbnailTimestampQuery, ["postBrandRemoved1", 12.34]); - await db.prepare("run", insertThumbnailVotesQuery, ["postBrandRemoved1", 0, 1, 0]); + await db.prepare("run", insertThumbnailVotesQuery, ["postBrandRemoved1", 0, 1, 0, isoDate, isoDate]); await db.prepare("run", insertThumbnailQuery, ["postBrandRemoved1", 0, getHash(userID3), Service.YouTube, getHash("postBrandRemoved1"), Date.now(), "postBrandRemoved2"]); await db.prepare("run", insertThumbnailTimestampQuery, ["postBrandRemoved2", 13.34]); - await db.prepare("run", insertThumbnailVotesQuery, ["postBrandRemoved2", 0, 1, 0]); + await db.prepare("run", insertThumbnailVotesQuery, ["postBrandRemoved2", 0, 1, 0, isoDate, isoDate]); // Verified through title submissions await db.prepare("run", insertTitleQuery, ["postBrandVerified1", "Some title", 0, getHash(userID7), Service.YouTube, getHash("postBrandVerified1"), Date.now(), "postBrandVerified1"]); @@ -82,8 +82,8 @@ describe("postBranding", () => { await db.prepare("run", insertTitleVotesQuery, ["postBrandBannedOriginalVote", 0, 0, 0, 0, isoDate, isoDate]); await db.prepare("run", insertThumbnailQuery, ["postBrandBannedCustomVote", 0, getHash(userID1), Service.YouTube, getHash("postBrandBannedCustomVote"), Date.now(), "postBrandBannedCustomVote"]); await db.prepare("run", insertThumbnailQuery, ["postBrandBannedOriginalVote", 1, getHash(userID1), Service.YouTube, getHash("postBrandBannedOriginalVote"), Date.now(), "postBrandBannedOriginalVote"]); - await db.prepare("run", insertThumbnailVotesQuery, ["postBrandBannedCustomVote", 0, 0, 0]); - await db.prepare("run", insertThumbnailVotesQuery, ["postBrandBannedOriginalVote", 0, 0, 0]); + await db.prepare("run", insertThumbnailVotesQuery, ["postBrandBannedCustomVote", 0, 0, 0, isoDate, isoDate]); + await db.prepare("run", insertThumbnailVotesQuery, ["postBrandBannedOriginalVote", 0, 0, 0, isoDate, isoDate]); await db.prepare("run", insertThumbnailTimestampQuery, ["postBrandBannedCustomVote", 12.34]); }); diff --git a/test/cases/shadowBanUser.ts b/test/cases/shadowBanUser.ts index c666b38c..99b52b43 100644 --- a/test/cases/shadowBanUser.ts +++ b/test/cases/shadowBanUser.ts @@ -61,7 +61,7 @@ describe("shadowBanUser", () => { const titleVotesQuery = `INSERT INTO "titleVotes" ("UUID", "votes", "locked", "shadowHidden", "verification", "createdAt", "updatedAt") VALUES (?, ?, ?, ?, ?, ?, ?)`; const thumbnailQuery = `INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID") VALUES (?, ?, ?, ?, ?, ?, ?)`; const thumbnailTimestampsQuery = `INSERT INTO "thumbnailTimestamps" ("UUID", "timestamp") VALUES (?, ?)`; - const thumbnailVotesQuery = `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, ?, ?, ?)`; + const thumbnailVotesQuery = `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "createdAt", "updatedAt") VALUES (?, ?, ?, ?, ?, ?)`; await Promise.all([ db.prepare("run", titleQuery, [video, "title1", 0, "userID1-ban", Service.YouTube, videohash, 1, "UUID1-ban"]), @@ -78,9 +78,9 @@ describe("shadowBanUser", () => { db.prepare("run", titleVotesQuery, ["UUID3-ban", 1, 0, 0, 0, isoDate, isoDate]), db.prepare("run", thumbnailTimestampsQuery, ["UUID1T-ban", 1]), db.prepare("run", thumbnailTimestampsQuery, ["UUID3T-ban", 3]), - db.prepare("run", thumbnailVotesQuery, ["UUID1T-ban", 3, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID2T-ban", 2, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID3T-ban", 1, 0, 0]), + db.prepare("run", thumbnailVotesQuery, ["UUID1T-ban", 3, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID2T-ban", 2, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID3T-ban", 1, 0, 0, isoDate, isoDate]), ]); await Promise.all([ @@ -98,9 +98,9 @@ describe("shadowBanUser", () => { db.prepare("run", titleVotesQuery, ["UUID3-ban2", 1, 0, 0, 0, isoDate, isoDate]), db.prepare("run", thumbnailTimestampsQuery, ["UUID1T-ban2", 1]), db.prepare("run", thumbnailTimestampsQuery, ["UUID3T-ban2", 3]), - db.prepare("run", thumbnailVotesQuery, ["UUID1T-ban2", 3, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID2T-ban2", 2, 0, 0]), - db.prepare("run", thumbnailVotesQuery, ["UUID3T-ban2", 1, 0, 0]) + db.prepare("run", thumbnailVotesQuery, ["UUID1T-ban2", 3, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID2T-ban2", 2, 0, 0, isoDate, isoDate]), + db.prepare("run", thumbnailVotesQuery, ["UUID3T-ban2", 1, 0, 0, isoDate, isoDate]) ]); await Promise.all([ diff --git a/test/utils/segmentQueryGen.ts b/test/utils/segmentQueryGen.ts index 6b542463..23839607 100644 --- a/test/utils/segmentQueryGen.ts +++ b/test/utils/segmentQueryGen.ts @@ -127,8 +127,8 @@ export const insertThumbnail = async (db: IDatabase, overrides: insertThumbnailP await db.prepare("run", query, Object.values(params)); }; -export const insertThumbnailVote = async (db: IDatabase, UUID: string, votes: number, locked = false, shadowHidden = false) => { - const query = 'INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, ?, ?, ?)'; - const params = [UUID, votes, Number(locked), Number(shadowHidden)]; +export const insertThumbnailVote = async (db: IDatabase, UUID: string, votes: number, locked = false, shadowHidden = false, isoDate: string = new Date().toISOString()) => { + const query = 'INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "createdAt", "updatedAt") VALUES (?, ?, ?, ?, ?, ?)'; + const params = [UUID, votes, Number(locked), Number(shadowHidden), isoDate, isoDate]; await db.prepare("run", query, params); }; \ No newline at end of file