Skip to content

Commit 51c1700

Browse files
committed
Add a test to ensure all channels represented
1 parent 14555ba commit 51c1700

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

channels.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
{ "name": "Submerged", "nebula": "submerged", "channel": "UCPwEGa03Fk3Dd0uptJt0wEA", "uploads": "UUPwEGa03Fk3Dd0uptJt0wEA" },
127127
{ "name": "Synthet", "nebula": "synthet", "channel": "UCdbetV_5wxUnBTdb_d51qoA", "uploads": "UUdbetV_5wxUnBTdb_d51qoA" },
128128
{ "name": "That's Absurd Please Elaborate", "nebula": "thatsabsurdvideo", "channel": "UCW5-NTCwRphUL_9RpY2Sbtw", "uploads": "UUW5-NTCwRphUL_9RpY2Sbtw" },
129-
{ "name": "The Friday Chillout", "nebula": "chillout", "channel": "UCGTTVp2tAa997OaHQXvjjzg", "uploads": "UUGTTVp2tAa997OaHQXvjjzg" },
129+
{ "name": "The Friday Chillout", "nebula": "chillout", "channel": "UCGTTVp2tAa997OaHQXvjjzg" },
130130
{ "name": "Thomas Percy Kim", "nebula": "thomaspercykim", "channel": "UCcFoxUZrPn3qT0WGLDjqaxA", "uploads": "UUcFoxUZrPn3qT0WGLDjqaxA" },
131131
{ "name": "Tiana Michele", "nebula": "tianamichele", "channel": "UCldWHorkNMxl-LyGZKrrWFQ", "uploads": "UUldWHorkNMxl-LyGZKrrWFQ" },
132132
{ "name": "Tom Nicholas 2", "nebula": "tomnicholas2", "channel": "UCV4MuJHfEXNMjrjwcd4tHEA", "uploads": "UUV4MuJHfEXNMjrjwcd4tHEA" },

tests/unit/creators.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { jest } from '@jest/globals';
1+
import { beforeEach, describe, expect, jest, test } from '@jest/globals';
22
import fetch from 'node-fetch';
33
import { matchVideoConfidence } from '../../src/scripts/background/ifidf';
4+
import { getChannels } from '../../src/scripts/helpers/api';
45
import '../../src/scripts/helpers/shared/prototype';
56
import { getInformation as loadCreators } from '../../src/scripts/page/offscreen';
67

@@ -11,6 +12,32 @@ test('loading creators works', async () => {
1112
expect(creators.length).not.toBe(0);
1213
});
1314

15+
test('loaded creators cover all channels', async () => {
16+
const channels = await getChannels();
17+
const creators = await loadCreators();
18+
const excluded = [ 'apple-talk', 'avoidclimatechange', 'nextlevelworldbuilding', 'dinnerplan', 'dex', 'edith', 'faithless', 'getaway', 'one-villainous-scene', 'one-x-cellent-scene', 'rng', 'scav', 'trussissues', 'theeditorial', 'layover', 'theprince', 'wtf', 'workingtitles' ];
19+
for (const channel of channels) {
20+
const match = creators.find(c => c.nebula === channel.slug || c.nebulaAlt === channel.slug);
21+
if (match) continue;
22+
if (excluded.includes(channel.slug)) continue;
23+
expect(channel.slug).toBeUndefined();
24+
}
25+
26+
return; // only run manually
27+
let i = 0;
28+
for (const creator of creators) {
29+
if (!creator.uploads) continue;
30+
const url = new URL('https://youtube.googleapis.com/youtube/v3/playlistItems');
31+
url.searchParams.set('part', 'snippet');
32+
url.searchParams.set('playlistId', creator.uploads);
33+
url.searchParams.set('key', __YT_API_KEY__);
34+
url.searchParams.set('maxResults', '0');
35+
console.log('creator ', creator.name, ' (', creator.nebula, '): ');
36+
await expect(fetch(url).then(r => r.status)).resolves.toBe(200);
37+
if ((i++ % 20) === 0) await new Promise(resolve => setTimeout(resolve, 1000));
38+
}
39+
}, 200_000);
40+
1441
describe('matching', () => {
1542
const consoleError = console.error;
1643
const consoleDebug = console.debug;

0 commit comments

Comments
 (0)