update lockCategories

- migration to remove invalid locks
- lockCategories poi_highlight is now actionType poi
- deleteLockCategories now takes actionType
- update postLockCategories response, serverside filtering for accepted categories
- fix tests accordingly
This commit is contained in:
Michael C
2022-02-03 17:44:29 -05:00
parent 2b8944bf15
commit a2f2cf9c0d
6 changed files with 94 additions and 126 deletions

View File

@@ -76,7 +76,7 @@ describe("lockCategoriesRecords", () => {
const expected = {
submitted: [
"outro",
"shilling",
"intro"
],
submittedValues: [
{
@@ -87,14 +87,6 @@ describe("lockCategoriesRecords", () => {
actionType: "mute",
category: "outro"
},
{
actionType: "skip",
category: "shilling"
},
{
actionType: "mute",
category: "shilling"
},
{
actionType: "skip",
category: "intro"
@@ -132,14 +124,14 @@ describe("lockCategoriesRecords", () => {
.then(async res => {
assert.strictEqual(res.status, 200);
const result = await checkLockCategories(videoID);
assert.strictEqual(result.length, 8);
assert.strictEqual(result.length, 6);
const oldRecordNotChangeReason = result.filter(item =>
item.reason === "reason-2" && ["sponsor", "intro"].includes(item.category)
);
const newRecordWithEmptyReason = result.filter(item =>
item.reason === "" && ["outro", "shilling"].includes(item.category)
item.reason === "" && ["outro"].includes(item.category)
);
assert.strictEqual(newRecordWithEmptyReason.length, 4);
assert.strictEqual(newRecordWithEmptyReason.length, 2);
assert.strictEqual(oldRecordNotChangeReason.length, 4);
done();
})
@@ -164,7 +156,6 @@ describe("lockCategoriesRecords", () => {
const expected = {
submitted: [
"outro",
"shilling",
"intro"
],
};
@@ -196,7 +187,6 @@ describe("lockCategoriesRecords", () => {
const expectedWithNewReason = [
"outro",
"shilling",
"intro"
];
@@ -204,7 +194,7 @@ describe("lockCategoriesRecords", () => {
.then(async res => {
assert.strictEqual(res.status, 200);
const result = await checkLockCategories(videoID);
assert.strictEqual(result.length, 8);
assert.strictEqual(result.length, 6);
const newRecordWithNewReason = result.filter(item =>
expectedWithNewReason.includes(item.category) && item.reason === "new reason"
);
@@ -212,7 +202,7 @@ describe("lockCategoriesRecords", () => {
item.reason === "reason-2"
);
assert.strictEqual(newRecordWithNewReason.length, 6);
assert.strictEqual(newRecordWithNewReason.length, 4);
assert.strictEqual(oldRecordNotChangeReason.length, 2);
done();
})
@@ -220,56 +210,20 @@ describe("lockCategoriesRecords", () => {
});
it("Should be able to submit categories with _ in the category", (done) => {
const json = {
videoID: "underscore",
userID: lockVIPUser,
categories: [
"word_word",
],
};
client.post(endpoint, json)
.then(async res => {
assert.strictEqual(res.status, 200);
const result = await checkLockCategories("underscore");
assert.strictEqual(result.length, 2);
done();
})
.catch(err => done(err));
});
it("Should be able to submit categories with upper and lower case in the category", (done) => {
const json = {
videoID: "bothCases",
userID: lockVIPUser,
categories: [
"wordWord",
],
};
client.post(endpoint, json)
.then(async res => {
assert.strictEqual(res.status, 200);
const result = await checkLockCategories("bothCases");
assert.strictEqual(result.length, 2);
done();
})
.catch(err => done(err));
});
it("Should not be able to submit categories with $ in the category", (done) => {
const videoID = "specialChar";
const videoID = "underscore";
const json = {
videoID,
userID: lockVIPUser,
categories: [
"word&word",
"exclusive_access",
],
actionTypes: ["full"]
};
client.post(endpoint, json)
.then(async res => {
assert.strictEqual(res.status, 200);
const result = await checkLockCategories(videoID);
assert.strictEqual(result.length, 0);
assert.strictEqual(result.length, 1);
done();
})
.catch(err => done(err));
@@ -418,6 +372,7 @@ describe("lockCategoriesRecords", () => {
categories: [
"sponsor",
],
actionTypes: ["skip", "mute"]
};
client.delete(endpoint, { data: json })
@@ -438,6 +393,7 @@ describe("lockCategoriesRecords", () => {
categories: [
"sponsor",
],
actionTypes: ["skip", "mute"]
};
client.delete(endpoint, { data: json })
@@ -531,7 +487,6 @@ describe("lockCategoriesRecords", () => {
"sponsor",
"intro",
"outro",
"shilling"
],
};
client.get(endpoint, { params: { videoID: "no-segments-video-id" } })