mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-20 14:38:24 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into more-coverage
This commit is contained in:
@@ -19,9 +19,9 @@ if (db instanceof Postgres) {
|
||||
await db.prepare("run", query, [chapterNamesVid1, 70, 75, 2, 0, "chapterNamesVid-2", "testman", 0, 50, "chapter", "chapter", "YouTube", 0, 0, 0, "A different one"]);
|
||||
await db.prepare("run", query, [chapterNamesVid1, 71, 76, 2, 0, "chapterNamesVid-3", "testman", 0, 50, "chapter", "chapter", "YouTube", 0, 0, 0, "Something else"]);
|
||||
|
||||
await db.prepare("run", `INSERT INTO "videoInfo" ("videoID", "channelID", "title", "published", "genreUrl")
|
||||
SELECT ?, ?, ?, ?, ?`, [
|
||||
chapterNamesVid1, chapterChannelID, "", 0, ""
|
||||
await db.prepare("run", `INSERT INTO "videoInfo" ("videoID", "channelID", "title", "published")
|
||||
SELECT ?, ?, ?, ?`, [
|
||||
chapterNamesVid1, chapterChannelID, "", 0
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -110,4 +110,16 @@ describe("getStatus", () => {
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get redis latency", function (done) {
|
||||
if (!config.redis?.enabled) this.skip();
|
||||
client.get(endpoint)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
assert.ok(data.redisProcessTime >= 0);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
49
test/cases/innerTubeApi.ts
Normal file
49
test/cases/innerTubeApi.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { config } from "../../src/config";
|
||||
import assert from "assert";
|
||||
import { YouTubeAPI } from "../../src/utils/youtubeApi";
|
||||
import * as innerTube from "../../src/utils/innerTubeAPI";
|
||||
import { partialDeepEquals } from "../utils/partialDeepEquals";
|
||||
import { getVideoDetails } from "../../src/utils/getVideoDetails";
|
||||
|
||||
const videoID = "BaW_jenozKc";
|
||||
const expectedInnerTube = { // partial type of innerTubeVideoDetails
|
||||
videoId: videoID,
|
||||
title: "youtube-dl test video \"'/\\ä↭𝕐",
|
||||
lengthSeconds: "10",
|
||||
channelId: "UCLqxVugv74EIW3VWh2NOa3Q",
|
||||
isOwnerViewing: false,
|
||||
isCrawlable: true,
|
||||
allowRatings: true,
|
||||
author: "Philipp Hagemeister",
|
||||
isPrivate: false,
|
||||
isUnpluggedCorpus: false,
|
||||
isLiveContent: false
|
||||
};
|
||||
const currentViews = 49816;
|
||||
|
||||
describe("innertube API test", function() {
|
||||
it("should be able to get innerTube details", async () => {
|
||||
const result = await innerTube.getPlayerData(videoID, true);
|
||||
assert.ok(partialDeepEquals(result, expectedInnerTube));
|
||||
});
|
||||
it("Should have more views than current", async () => {
|
||||
const result = await innerTube.getPlayerData(videoID, true);
|
||||
assert.ok(Number(result.viewCount) >= currentViews);
|
||||
});
|
||||
it("Should have equivalent response from NewLeaf", async function () {
|
||||
if (!config.newLeafURLs || config.newLeafURLs.length <= 0 || config.newLeafURLs[0] == "placeholder") this.skip();
|
||||
const itResponse = await innerTube.getPlayerData(videoID, true);
|
||||
const newLeafResponse = await YouTubeAPI.listVideos(videoID, true);
|
||||
// validate videoID
|
||||
assert.strictEqual(itResponse.videoId, videoID);
|
||||
assert.strictEqual(newLeafResponse.data?.videoId, videoID);
|
||||
// validate description
|
||||
assert.strictEqual(itResponse.shortDescription, newLeafResponse.data?.description);
|
||||
// validate authorId
|
||||
assert.strictEqual(itResponse.channelId, newLeafResponse.data?.authorId);
|
||||
});
|
||||
it("Should return data from generic endpoint", async function () {
|
||||
const videoDetail = await getVideoDetails(videoID);
|
||||
assert.ok(videoDetail);
|
||||
});
|
||||
});
|
||||
@@ -141,7 +141,6 @@ describe("postSkipSegments", () => {
|
||||
title: "Example Title",
|
||||
channelID: "ExampleChannel",
|
||||
published: 123,
|
||||
genreUrl: ""
|
||||
};
|
||||
assert.ok(partialDeepEquals(videoInfo, expectedVideoInfo));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user