1- import { jest } from '@jest/globals' ;
1+ import { beforeEach , describe , expect , jest , test } from '@jest/globals' ;
22import fetch from 'node-fetch' ;
33import { matchVideoConfidence } from '../../src/scripts/background/ifidf' ;
4+ import { getChannels } from '../../src/scripts/helpers/api' ;
45import '../../src/scripts/helpers/shared/prototype' ;
56import { 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+
1441describe ( 'matching' , ( ) => {
1542 const consoleError = console . error ;
1643 const consoleDebug = console . debug ;
0 commit comments