linkExternal.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import t from 'tap';
  2. import {testContentFunctions} from '#test-lib';
  3. testContentFunctions(t, 'linkExternal (snapshot)', async (t, evaluate) => {
  4. await evaluate.load();
  5. evaluate.snapshot('unknown domain (arbitrary world wide web path)', {
  6. name: 'linkExternal',
  7. args: ['https://snoo.ping.as/usual/i/see/'],
  8. });
  9. const urlsToArgs = urls =>
  10. urls.map(url => ({args: [url]}));
  11. const quickSnapshot = (message, urls, slots) =>
  12. evaluate.snapshot(message, {
  13. name: 'linkExternal',
  14. slots,
  15. multiple: urlsToArgs(urls),
  16. });
  17. const quickSnapshotAllStyles = (context, urls) => {
  18. for (const style of ['platform', 'handle']) {
  19. const message = `context: ${context}, style: ${style}`;
  20. quickSnapshot(message, urls, {context, style});
  21. }
  22. };
  23. // Try to comprehensively test every regular expression
  24. // (in `match` and extractions like `handle` or `details`).
  25. // Try to *also* represent a reasonable variety of what kinds
  26. // of URLs appear throughout the wiki. (This should serve to
  27. // identify areas which #external-links is expected to
  28. // accommodate, regardless whether or not there is special
  29. // attention given in the actual descriptors.)
  30. // For normal custom-domain matches (e.g. Mastodon),
  31. // it's OK to just test one custom domain in the list.
  32. // Generally match the sorting order in externalLinkSpec,
  33. // so corresponding and missing test cases are easy to locate.
  34. quickSnapshotAllStyles('generic', [
  35. // platform: appleMusic
  36. 'https://music.apple.com/us/artist/system-of-a-down/462715',
  37. // platform: artstation
  38. 'https://www.artstation.com/eevaningtea',
  39. 'https://witnesstheabsurd.artstation.com/',
  40. // platform: bandcamp
  41. 'https://music.solatrus.com/',
  42. 'https://homestuck.bandcamp.com/',
  43. // platform: bluesky
  44. 'https://bsky.app/profile/jacobtheloofah.bsky.social',
  45. // platform: carrd
  46. 'https://aliceflare.carrd.co',
  47. 'https://bigchaslappa.carrd.co/',
  48. // platform: cohost
  49. 'https://cohost.org/cosmoptera',
  50. // platform: deconreconstruction.music
  51. 'https://music.deconreconstruction.com/albums/catch-322',
  52. 'https://music.deconreconstruction.com/albums/catch-322?track=arcjecs-theme',
  53. // platform: deconreconstruction
  54. 'https://www.deconreconstruction.com/',
  55. // platform: deviantart
  56. 'https://culdhira.deviantart.com',
  57. 'https://www.deviantart.com/chesswanderlust-sama',
  58. 'https://www.deviantart.com/shilloshilloh/art/Homestuck-Jake-English-268874606',
  59. // platform: facebook
  60. 'https://www.facebook.com/DoomedCloud/',
  61. 'https://www.facebook.com/pages/WoodenToaster/280642235307371',
  62. 'https://www.facebook.com/Svixy/posts/400018786702633',
  63. // platform: fandom.mspaintadventures
  64. 'https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary',
  65. 'https://mspaintadventures.fandom.com/wiki/',
  66. 'https://mspaintadventures.fandom.com/',
  67. // platform: fandom
  68. 'https://community.fandom.com/',
  69. 'https://community.fandom.com/wiki/',
  70. 'https://community.fandom.com/wiki/Community_Central',
  71. // platform: gamebanana
  72. 'https://gamebanana.com/members/2028092',
  73. 'https://gamebanana.com/mods/459476',
  74. // platform: homestuck
  75. 'https://homestuck.com/',
  76. // platform: hsmusic.archive
  77. 'https://hsmusic.wiki/media/misc/archive/Firefly%20Cloud%20Remix.mp3',
  78. // platform: hsmusic
  79. 'https://hsmusic.wiki/feedback/',
  80. // platform: internetArchive
  81. 'https://archive.org/details/a-life-well-lived',
  82. 'https://archive.org/details/VastError_Volume1/11+Renaissance.mp3',
  83. // platform: instagram
  84. 'https://instagram.com/bass.and.noises',
  85. 'https://www.instagram.com/levc_egm/',
  86. // platform: itch
  87. 'https://tuyoki.itch.io/',
  88. 'https://itch.io/profile/bravelittletoreador',
  89. // platform: ko-fi
  90. 'https://ko-fi.com/gnaach',
  91. // platform: linktree
  92. 'https://linktr.ee/bbpanzu',
  93. // platform: mastodon
  94. 'https://types.pl/',
  95. // platform: mspfa
  96. 'https://canwc.mspfa.com/',
  97. 'https://mspfa.com/?s=12003&p=1045',
  98. 'https://mspfa.com/user/?u=103334508819793669241',
  99. // platform: neocities
  100. 'https://wodaro.neocities.org',
  101. 'https://neomints.neocities.org/',
  102. // platform: newgrounds
  103. 'https://buzinkai.newgrounds.com/',
  104. 'https://www.newgrounds.com/audio/listen/1256058',
  105. // platform: patreon
  106. 'https://www.patreon.com/CecilyRenns',
  107. // platform: poetryFoundation
  108. 'https://www.poetryfoundation.org/poets/christina-rossetti',
  109. 'https://www.poetryfoundation.org/poems/45000/remember-56d224509b7ae',
  110. // platform: soundcloud
  111. 'https://soundcloud.com/plazmataz',
  112. 'https://soundcloud.com/worthikids/1-i-accidentally-broke-my',
  113. // platform: spotify
  114. 'https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3',
  115. 'https://open.spotify.com/album/0iHvPD8rM3hQa0qeVtPQ3t',
  116. 'https://open.spotify.com/track/6YEGQH32aAXb9vQQbBrPlw',
  117. // platform: tiktok
  118. 'https://www.tiktok.com/@richaadeb',
  119. // platform: toyhouse
  120. 'https://toyhou.se/ghastaboo',
  121. // platform: tumblr
  122. 'https://aeritus.tumblr.com/',
  123. 'https://vol5anthology.tumblr.com/post/159528808107/hey-everyone-its-413-and-that-means-we-have',
  124. 'https://www.tumblr.com/electricwestern',
  125. 'https://www.tumblr.com/spellmynamewithabang/142767566733/happy-413-this-is-the-first-time-anyones-heard',
  126. // platform: twitch
  127. 'https://www.twitch.tv/ajhebard',
  128. 'https://www.twitch.tv/vargskelethor/',
  129. // platform: twitter
  130. 'https://twitter.com/awkwarddoesart',
  131. 'https://twitter.com/purenonsens/',
  132. 'https://twitter.com/circlejourney/status/1202265927183548416',
  133. // platform: waybackMachine
  134. 'https://web.archive.org/web/20120405160556/https://homestuck.bandcamp.com/album/colours-and-mayhem-universe-a',
  135. 'https://web.archive.org/web/20160807111207/http://griffinspacejam.com:80/',
  136. // platform: wikipedia
  137. 'https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)',
  138. // platform: youtube
  139. 'https://youtube.com/@bani-chan8949',
  140. 'https://www.youtube.com/@Razzie16',
  141. 'https://www.youtube.com/channel/UCQXfvlKkpbOqEz4BepHqK7g',
  142. 'https://www.youtube.com/watch?v=6ekVnZm29kw',
  143. 'https://youtu.be/WBkC038wSio',
  144. 'https://www.youtube.com/playlist?list=PLy5UGIMKOXpONMExgI7lVYFwQa54QFp_H',
  145. ]);
  146. quickSnapshotAllStyles('album', [
  147. 'https://youtu.be/abc',
  148. 'https://youtube.com/watch?v=abc',
  149. 'https://youtube.com/Playlist?list=kweh',
  150. ]);
  151. quickSnapshotAllStyles('albumNoTracks', [
  152. 'https://youtu.be/abc',
  153. 'https://youtube.com/watch?v=abc',
  154. 'https://youtube.com/Playlist?list=kweh',
  155. ]);
  156. quickSnapshotAllStyles('albumOneTrack', [
  157. 'https://youtu.be/abc',
  158. 'https://youtube.com/watch?v=abc',
  159. 'https://youtube.com/Playlist?list=kweh',
  160. ]);
  161. quickSnapshotAllStyles('albumMultipleTracks', [
  162. 'https://youtu.be/abc',
  163. 'https://youtube.com/watch?v=abc',
  164. 'https://youtube.com/Playlist?list=kweh',
  165. ]);
  166. quickSnapshotAllStyles('flash', [
  167. 'https://www.bgreco.net/hsflash/002238.html',
  168. 'https://homestuck.com/story/1234',
  169. 'https://homestuck.com/story/pony',
  170. 'https://www.youtube.com/watch?v=wKgOp3Kg2wI',
  171. 'https://youtu.be/IOcvkkklWmY',
  172. 'https://some.external.site/foo/bar/',
  173. ]);
  174. });