Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Add Sketchfab and Thingiverse as additional sources for 3D models (#1203)
Dhruv Bhanushalica5b768e6a50
diff --git a/src/components/VButton.vue b/src/components/VButton.vueindex 2ce05069d..5f5e0aa59 100644--- a/src/components/VButton.vue+++ b/src/components/VButton.vue@@ -23,19 +23,46 @@</Component></template>-<script>+<script lang="ts">import {defineComponent,ref,watch,toRefs,computed,+ PropType,+ Ref,} from '@nuxtjs/composition-api'import { warn } from '~/utils/console'import VLink from '~/components/VLink.vue'+const buttonForms = ['VLink', 'button'] as const++type ButtonForm = typeof buttonForms[number]++const buttonVariants = [+ 'primary',+ 'secondary',+ 'tertiary',+ 'action-menu',+ 'action-menu-secondary',+ 'action-menu-muted',+ 'plain',+ 'plain-dangerous',+] as const++type ButtonVariant = typeof buttonVariants[number]++const buttonSizes = ['large', 'medium', 'small', 'disabled'] as const++type ButtonSize = typeof buttonSizes[number]++const buttonTypes = ['button', 'submit', 'reset'] as const++type ButtonType = typeof buttonTypes[number]+/*** A button component that behaves just like a regular HTML `button` element* aside from pre-applied styles based on the passed in variant.@@ -66,11 +93,9 @@ const VButton = defineComponent({* @default 'button'*/as: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'VLink' | 'button'>} */ (- String- ),+ type: String as PropType<ButtonForm>,default: 'button',- validate: (v) => ['VLink', 'button'].includes(v),+ validate: (val: ButtonForm) => buttonForms.includes(val),},/*** The variant of the button.@@ -81,21 +106,9 @@ const VButton = defineComponent({* @default 'primary'*/variant: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'primary' | 'secondary' | 'tertiary' | 'action-menu' | 'action-menu-muted' | 'plain' | 'plain-dangerous'>} */ (- String- ),+ type: String as PropType<ButtonVariant>,default: 'primary',- validate: (v) =>- [- 'primary',- 'secondary',- 'tertiary',- 'action-menu',- 'action-menu-secondary',- 'action-menu-muted',- 'plain',- 'plain-dangerous',- ].includes(v),+ validate: (val: ButtonVariant) => buttonVariants.includes(val),},/*** Allows for programmatically setting the pressed state of a button,@@ -114,11 +127,9 @@ const VButton = defineComponent({* @default 'medium'*/size: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'large' | 'medium' | 'small' | 'disabled'>} */ (- String- ),+ type: String as PropType<ButtonSize>,default: 'medium',- validate: (v) => ['large', 'medium', 'small', 'disabled'].includes(v),+ validate: (val: ButtonSize) => buttonSizes.includes(val),},/*** Whether the button is disabled. Used alone this will only@@ -150,23 +161,19 @@ const VButton = defineComponent({* @default 'button'*/type: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'buton' | 'submit' | 'reset'>} */ (- String- ),+ type: String as PropType<ButtonType>,default: 'button',- validate: (v) => ['button', 'submit', 'reset'].includes(v),+ validate: (val: ButtonType) => buttonTypes.includes(val),},},- /**- * @param {Props} props- * @param {import('@nuxtjs/composition-api').SetupContext}- */setup(props, { attrs }) {const propsRef = toRefs(props)- const disabledAttributeRef = ref(propsRef.disabled.value)+ const disabledAttributeRef: Ref<boolean | undefined> = ref(+ propsRef.disabled.value+ )const ariaDisabledRef = ref()const trulyDisabledRef = ref()- const typeRef = ref(propsRef.type.value)+ const typeRef: Ref<ButtonType | undefined> = ref(propsRef.type.value)const supportsDisabledAttributeRef = ref(true)const isActive = computed(() => {diff --git a/src/components/VIcon/VIcon.vue b/src/components/VIcon/VIcon.vueindex 3984e377c..8e2b3406c 100644--- a/src/components/VIcon/VIcon.vue+++ b/src/components/VIcon/VIcon.vue@@ -11,13 +11,15 @@</svg></template>-<script>+<script lang="ts">+import { defineComponent } from '@nuxtjs/composition-api'+import { isTest } from '~/utils/node-env'/*** Displays the given icon in a 24px × 24px square.*/-export default {+export default defineComponent({name: 'VIcon',props: {/**@@ -55,7 +57,7 @@ export default {size: {type: Number,default: 6,- validator: (val) => [4, 5, 6].includes(val),+ validator: (val: number) => [4, 5, 6].includes(val),},/*** whether to flip the icon for RTL languages; This generally makes sense@@ -66,7 +68,7 @@ export default {default: false,},},-}+})</script><style scoped>diff --git a/src/components/VMetaSearch/VMetaSearchForm.vue b/src/components/VMetaSearch/VMetaSearchForm.vueindex 001b5b965..59a562df5 100644--- a/src/components/VMetaSearch/VMetaSearchForm.vue+++ b/src/components/VMetaSearch/VMetaSearchForm.vue@@ -35,14 +35,14 @@<template #break><br /></template>- <template #filter>{{ unsupportedByUsefilter }}</template>+ <template #filter>{{ unsupportedByUseFilter }}</template></i18n></header><VMetaSourceListclass="md:justify-center mt-6 mb-10":type="type"- :query="metaQuery"+ :query="query"/><p class="caption font-semibold max-w-3xl my-0 mx-auto">@@ -51,44 +51,39 @@</section></template>-<script>-import { AUDIO, IMAGE, VIDEO } from '~/constants/media'+<script lang="ts">+import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'++import type { MediaType } from '~/constants/media'++import type { ApiQueryParams } from '~/store/types'++import { getAdditionalSourceBuilders } from '~/utils/get-additional-sources'import VMetaSourceList from './VMetaSourceList.vue'-export default {+export default defineComponent({name: 'VMetaSearchForm',components: {VMetaSourceList,},props: {- query: { type: Object, required: true },- type: { type: String, required: true },+ query: { type: Object as PropType<ApiQueryParams>, required: true },+ type: { type: String as PropType<MediaType>, required: true },isSupported: { type: Boolean, default: false },hasNoResults: { type: Boolean, required: true },},- computed: {- unsupportedByUsefilter() {- if (this.type === AUDIO) {- return 'CC Mixter'- }- if (this.type === VIDEO) return 'Wikimedia Commons or Youtube'- if (this.type === IMAGE) return 'Google Images'- return ''- },- metaQuery() {- return {- q: this.query.q,- filters: {- commercial: this.query.license_type- ? this.query.license_type.includes('commercial')- : false,- modify: this.query.license_type- ? this.query.license_type.includes('modification')- : false,- },- }- },+ setup(props) {+ const unsupportedByUseFilter = computed(() =>+ getAdditionalSourceBuilders(props.type)+ .filter((source) => !source.supportsUseFilters)+ .map((source) => source.name)+ .join(', ')+ )++ return {+ unsupportedByUseFilter,+ }},-}+})</script>diff --git a/src/components/VMetaSearch/VMetaSourceList.vue b/src/components/VMetaSearch/VMetaSourceList.vueindex 0b22981ff..2e8ad6603 100644--- a/src/components/VMetaSearch/VMetaSourceList.vue+++ b/src/components/VMetaSearch/VMetaSourceList.vue@@ -13,7 +13,7 @@{{ source.name }}<sup class="top-0"><VIcon- :icon-path="externalLinkIcon"+ :icon-path="icons.externalLink":size="4":rtl-flip="true"class="ms-2"@@ -24,39 +24,48 @@</ul></template>-<script>-import { computed } from '@nuxtjs/composition-api'+<script lang="ts">+import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'-import getLegacySourceUrl, {- legacySourceMap,-} from '~/utils/get-legacy-source-url'+import { getAdditionalSources } from '~/utils/get-additional-sources'++import type { ApiQueryParams } from '~/store/types'++import type { MediaType } from '~/constants/media'import VButton from '~/components/VButton.vue'import VIcon from '~/components/VIcon/VIcon.vue'import externalLinkIcon from '~/assets/icons/external-link.svg'-export default {- name: 'MetaSourceList',+/**+ * This component renders a list of pre-populated links to additional sources+ * when there are insufficient or zero search results.+ */+export default defineComponent({+ name: 'VMetaSourceList',components: { VButton, VIcon },props: {- type: { type: String },- query: { type: Object },+ /**+ * the media type to use as the criteria for filtering additional sources+ */+ type: { type: String as PropType<MediaType>, required: true },+ /**+ * the search query to pre-populate in the additional sources link+ */+ query: { type: Object as PropType<ApiQueryParams>, required: true },},setup(props) {const sources = computed(() =>- Object.keys(legacySourceMap)- .filter((sourceName) => legacySourceMap[sourceName][props.type])- .map((source) => ({- name: source,- url: getLegacySourceUrl(props.type)(source, props.query),- }))+ getAdditionalSources(props.type, props.query))return {- externalLinkIcon,+ icons: {+ externalLink: externalLinkIcon,+ },sources,}},-}+})</script>diff --git a/src/components/VMetaSearch/meta/VMetaSourceList.stories.mdx b/src/components/VMetaSearch/meta/VMetaSourceList.stories.mdxnew file mode 100644index 000000000..b919b0f30--- /dev/null+++ b/src/components/VMetaSearch/meta/VMetaSourceList.stories.mdx@@ -0,0 +1,81 @@+import {+ ArgsTable,+ Canvas,+ Description,+ Meta,+ Story,+} from '@storybook/addon-docs'++import VMetaSourceList from '~/components/VMetaSearch/VMetaSourceList.vue'++<Meta title="Components/VMetaSourceList" component={VMetaSourceList} />++export const Template = (args) => ({+ template: `<VMetaSourceList v-bind="args"/>`,+ components: { VMetaSourceList },+ setup() {+ return { args }+ },+})++# VMetaSourceList++<Description of={VMetaSourceList} />++<ArgsTable of={VMetaSourceList} />++## Images++<Canvas>+ <Story+ name="Images"+ args={{+ type: 'image',+ query: { q: 'cat' },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++## Audio++<Canvas>+ <Story+ name="Audio"+ args={{+ type: 'audio',+ query: { q: 'cat' },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++## Video++<Canvas>+ <Story+ name="Video"+ args={{+ type: 'video',+ query: { q: 'cat' },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++## 3D models++<Canvas>+ <Story+ name="3D models"+ args={{+ type: 'model_3d',+ query: { q: 'cat' },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>diff --git a/src/utils/get-additional-sources.ts b/src/utils/get-additional-sources.tsnew file mode 100644index 000000000..253caacee--- /dev/null+++ b/src/utils/get-additional-sources.ts@@ -0,0 +1,319 @@+import buildUrl from 'build-url'++import type { MediaType } from '~/constants/media'+import type { ApiQueryParams } from '~/store/types'++import type { BuildUrlOptions } from 'build-url'++/**+ * Describes the query format used by the URL builder functions of additional+ * sources. This includes the query string and the usage filters.+ */+interface AdditionalSearchQuery {+ q: string+ filters: {+ commercial: boolean+ modify: boolean+ }+}++/**+ * Convert the ApiQueryParams object from the store to a format used by all the+ * URL builder functions of all additional sources.+ *+ * @param query - the ApiQueryParams object+ * @returns the query and filters in the format used by the URL builders+ */+const transformSearchQuery = (+ query: ApiQueryParams+): AdditionalSearchQuery => ({+ q: query.q ?? '',+ filters: {+ commercial: query.license_type?.includes('commercial') ?? false,+ modify: query.license_type?.includes('modification') ?? false,+ },+})++type SearchFunctions = {+ [k in MediaType]?: (+ search: AdditionalSearchQuery+ ) => BuildUrlOptions & { url: string }+}++/**+ * Describes an additional source builder, which contains a display name,+ * whether the source supports use filters and a mapping of media type to a URL+ * builder function that leads to the search results for that media type.+ */+interface AdditionalSourceBuilder extends SearchFunctions {+ name: string+ supportsUseFilters: boolean+}++/**+ * Describes an additional source, consisting of the source name and the+ * pre-populated URL.+ */+interface AdditionalSource {+ name: string+ url: string+}++/**+ * Maps each additional source with search URL builder functions for each+ * content type.+ *+ * @see {@link https://github.com/creativecommons/cccatalog-frontend/issues/315}+ */+const additionalSourceBuilders: AdditionalSourceBuilder[] = [+ {+ name: 'Centre For Ageing Better',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'https://ageingbetter.resourcespace.com/pages/search.php',+ queryParams: {+ search: search.q,+ },+ }),+ },+ {+ name: 'EDU images',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'https://images.all4ed.org',+ queryParams: {+ s: search.q,+ },+ }),+ },+ {+ name: 'Google Images',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'https://www.google.com/search',+ queryParams: {+ q: search.q,+ tbm: 'isch', // this means 'search images'+ tbs: 'il:cl',+ },+ }),+ },+ {+ name: 'Images of Empowerment',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'https://www.imagesofempowerment.org/',+ queryParams: {+ s: search.q,+ },+ }),+ },+ {+ name: 'Open Clip Art Library',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'http://www.openclipart.org/search/',+ queryParams: {+ query: search.q,+ },+ }),+ },+ {+ name: 'Nappy',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'https://www.nappy.co/',+ queryParams: {+ s: search.q,+ },+ }),+ },+ {+ name: 'The Greats',+ supportsUseFilters: false,+ image: (search) => ({+ url: 'https://www.thegreats.co/artworks/',+ queryParams: {+ theme: '0',+ search: search.q,+ },+ }),+ },+ {+ name: 'ccMixter',+ supportsUseFilters: false,+ audio: (search) => ({+ // no https :(+ url: 'http://dig.ccmixter.org/search',+ queryParams: {+ lic: 'open',+ searchp: search.q,+ },+ }),+ },+ {+ name: 'SoundCloud',+ supportsUseFilters: true,+ audio: (search) => {+ let license = 'to_share'++ if (search.filters && search.filters.commercial) {+ if (search.filters.commercial) license = 'to_use_commercially'+ if (search.filters.modify) license = 'to_modify_commercially'+ }++ return {+ url: 'https://soundcloud.com/search/sounds',+ queryParams: {+ q: search.q,+ 'filter.license': license, // @todo: choose which type from the search object+ },+ }+ },+ },+ {+ name: 'Europeana',+ supportsUseFilters: true,+ audio: (search) => {+ let query = `${search.q} AND RIGHTS:*creative*` // search cc licensed works++ if (search.filters && search.filters.commercial) {+ if (search.filters.commercial) query = `${query} AND NOT RIGHTS:*nc*`+ if (search.filters.modify) query = `${query} AND NOT RIGHTS:*nd*`+ }++ return {+ url: 'https://www.europeana.eu/en/search',+ queryParams: {+ page: '1',+ qf: 'TYPE:"SOUND"',+ query,+ },+ }+ },+ video(search) {+ let query = `${search.q} AND RIGHTS:*creative*` // search cc licensed works++ if (search.filters && search.filters.commercial) {+ if (search.filters.commercial) query = `${query} AND NOT RIGHTS:*nc*`+ if (search.filters.modify) query = `${query} AND NOT RIGHTS:*nd*`+ }++ return {+ url: 'https://www.europeana.eu/en/search',+ queryParams: {+ page: '1',+ qf: 'TYPE:"VIDEO"',+ query,+ },+ }+ },+ },+ {+ name: 'Vimeo',+ supportsUseFilters: false,+ video: (search) => ({+ url: 'https://vimeo.com/search',+ queryParams: {+ license: 'by',+ q: search.q,+ },+ }),+ },+ {+ name: 'Wikimedia Commons',+ supportsUseFilters: false,+ video: (search) => ({+ url: 'https://commons.wikimedia.org/w/index.php',+ queryParams: {+ search: `${search.q}`,+ title: 'Special:MediaSearch',+ type: 'video',+ },+ }),+ },+ {+ name: 'YouTube',+ supportsUseFilters: false,+ video: (search) => ({+ url: 'https://www.youtube.com/results',+ queryParams: {+ search_query: search.q,+ sp: 'EgIwAQ%3D%3D', // this interesting line filters by cc license+ },+ }),+ },+ {+ name: 'Sketchfab',+ supportsUseFilters: false,+ model_3d(search) {+ // TODO: Use actual license from filters+ const licenseCodes: string[] = [+ '322a749bcfa841b29dff1e8a1bb74b0b', // CC BY+ 'b9ddc40b93e34cdca1fc152f39b9f375', // CC BY-SA+ '72360ff1740d419791934298b8b6d270', // CC BY-ND+ 'bbfe3f7dbcdd4122b966b85b9786a989', // CC BY-NC+ '2628dbe5140a4e9592126c8df566c0b7', // CC BY-NC-SA+ '34b725081a6a4184957efaec2cb84ed3', // CC BY-NC-ND+ '7c23a1ba438d4306920229c12afcb5f9', // CC0+ ]+ return {+ url: 'https://sketchfab.com/search',+ queryParams: {+ q: search.q,+ licenses: licenseCodes,+ },+ disableCSV: true,+ }+ },+ },+ {+ name: 'Thingiverse',+ supportsUseFilters: false,+ model_3d(search) {+ return {+ url: 'https://www.thingiverse.com/search',+ queryParams: {+ type: 'things',+ q: search.q,+ },+ }+ },+ },+]++/**+ * Get a list of source builders for a given media type.+ *+ * @param mediaType - the media type by which to filter source builders+ * @returns a list of additional source builders+ */+export const getAdditionalSourceBuilders = (+ mediaType: MediaType+): AdditionalSourceBuilder[] =>+ additionalSourceBuilders.filter((source) => source[mediaType])++/**+ * Get a list of sources for a given media type with the URL populated to show+ * the results of the given query.+ *+ * @param mediaType - the media type by which to filter source builders+ * @param query - the query to show results for in the additional sources+ * @returns a list of additional sources with pre-populated URLs+ */+export const getAdditionalSources = (+ mediaType: MediaType,+ query: ApiQueryParams+) =>+ getAdditionalSourceBuilders(mediaType).map((source) => {+ const urlFunc = source[mediaType]++ if (!urlFunc) return undefined // type-guard, never occurs++ const urlInfo = urlFunc(transformSearchQuery(query))+ return {+ url: buildUrl(urlInfo.url, urlInfo),+ name: source.name,+ supportsUseFilters: source.supportsUseFilters,+ }+ }) as AdditionalSource[]diff --git a/src/utils/get-legacy-source-url.js b/src/utils/get-legacy-source-url.jsdeleted file mode 100644index 3a5f55c2e..000000000--- a/src/utils/get-legacy-source-url.js+++ /dev/null@@ -1,214 +0,0 @@-import buildUrl from 'build-url'--/**- * A mapping of each legacy source with its url builder functions for each content type.- * Urls were based off of data found here: https://github.com/creativecommons/cccatalog-frontend/issues/315- */-export const legacySourceMap = {- ccMixter: {- audio(search) {- return {- // no https :(- url: 'http://dig.ccmixter.org/search',- query: {- lic: 'open',- searchp: search.q,- },- }- },- },- 'Centre For Ageing Better': {- image(search) {- return {- url: 'https://ageingbetter.resourcespace.com/pages/search.php',- query: {- search: search.q,- },- }- },- },- 'EDU images': {- image(search) {- return {- url: 'https://images.all4ed.org',- query: {- s: search.q,- },- }- },- },- Europeana: {- audio(search) {- let query = `${search.q} AND RIGHTS:*creative*` // search cc licensed works-- if (search.filters && search.filters.commercial) {- if (search.filters.commercial) query = `${query} AND NOT RIGHTS:*nc*`- if (search.filters.modify) query = `${query} AND NOT RIGHTS:*nd*`- }-- return {- url: 'https://www.europeana.eu/en/search',- query: {- page: 1,- qf: 'TYPE:"SOUND"',- query,- },- }- },- video(search) {- let query = `${search.q} AND RIGHTS:*creative*` // search cc licensed works-- if (search.filters && search.filters.commercial) {- if (search.filters.comercial) query = `${query} AND NOT RIGHTS:*nc*`- if (search.filters.modify) query = `${query} AND NOT RIGHTS:*nd*`- }-- return {- url: 'https://www.europeana.eu/en/search',- query: {- page: 1,- qf: 'TYPE:"VIDEO"',- query,- },- }- },- },- 'Google Images': {- image(search) {- return {- url: 'https://www.google.com/search',- query: {- q: search.q,- tbm: 'isch', // this means 'search images'- tbs: 'il:cl',- },- }- },- },- 'Images of Empowerment': {- image(search) {- return {- url: 'https://www.imagesofempowerment.org/',- query: {- s: search.q,- },- }- },- },- 'Open Clip Art Library': {- image(search) {- return {- url: 'http://www.openclipart.org/search/',- query: {- query: search.q,- },- }- },- },- Nappy: {- image(search) {- return {- url: 'https://www.nappy.co/',- query: {- s: search.q,- },- }- },- },- 'The Greats': {- image(search) {- return {- url: 'https://www.thegreats.co/artworks/',- query: {- theme: 0,- search: search.q,- },- }- },- },- SoundCloud: {- audio(search) {- let license = 'to_share'-- if (search.filters && search.filters.commercial) {- if (search.filters.commercial) license = 'to_use_commercially'- if (search.filters.modify) license = 'to_modify_commercially'- }-- return {- url: 'https://soundcloud.com/search/sounds',- query: {- q: search.q,- 'filter.license': license, // @todo: choose which type from the search object- },- }- },- },- Vimeo: {- video(search) {- return {- url: 'https://vimeo.com/search',- query: {- license: 'by',- q: search.q,- },- }- },- },- 'Wikimedia Commons': {- video(search) {- return {- url: 'https://commons.wikimedia.org/w/index.php',- query: {- search: `${search.q}`,- title: 'Special:MediaSearch',- type: 'video',- },- }- },- },- YouTube: {- video(search) {- return {- url: 'https://www.youtube.com/results',- query: {- search_query: search.q,- sp: 'EgIwAQ%3D%3D', // this interesting line filters by cc license- },- }- },- },-}--/**- * getLegacySourceUrl- *- * Return a valid url of search results for the provided meta search type- * @param {('image'|'audio'|'video')} type The type of media our meta search is for- *- * */-const getLegacySourceUrl = (type) => (sourceName, search) => {- if (!search) {- throw new Error(- `Please provide a valid query to search ${sourceName} for ${type} files.`- )- }-- const source = legacySourceMap[sourceName]- if (!source) {- throw new Error(- `No data available for provided legacy source: ${sourceName}`- )- }-- const getSourceUrlInfo = source[type]- if (!getSourceUrlInfo) {- throw new Error(`${sourceName} does not offer meta search for ${type}`)- }-- const urlInfo = getSourceUrlInfo(search)-- return buildUrl(urlInfo.url, { queryParams: urlInfo.query })-}--export default getLegacySourceUrldiff --git a/test/unit/specs/utils/get-additional-sources.spec.ts b/test/unit/specs/utils/get-additional-sources.spec.tsnew file mode 100644index 000000000..215294e50--- /dev/null+++ b/test/unit/specs/utils/get-additional-sources.spec.ts@@ -0,0 +1,25 @@+import { getAdditionalSources } from '~/utils/get-additional-sources'+import { AUDIO, IMAGE, MediaType, MODEL_3D, VIDEO } from '~/constants/media'++/**+ * These tests do not test the health or uptime of URLS, only that a valid URL+ * string is returned.+ */+describe('getAdditionalSources', () => {+ it.each`+ mediaType+ ${AUDIO}+ ${VIDEO}+ ${IMAGE}+ ${MODEL_3D}+ `(+ `returns a URL for each $mediaType source`,+ ({ mediaType }: { mediaType: MediaType }) => {+ const search = { q: 'dogs' }+ const audioSources = getAdditionalSources(mediaType, search)+ const urls = audioSources.map((source) => source.url)++ expect(urls.every((url) => url?.startsWith('http'))).toBeTruthy()+ }+ )+})diff --git a/test/unit/specs/utils/get-legacy-source-url.spec.js b/test/unit/specs/utils/get-legacy-source-url.spec.jsdeleted file mode 100644index cefd6e7d1..000000000--- a/test/unit/specs/utils/get-legacy-source-url.spec.js+++ /dev/null@@ -1,66 +0,0 @@-import getLegacySourceUrl, {- legacySourceMap,-} from '~/utils/get-legacy-source-url'--/**- * Note: this does not test the health or uptime of URLS, only that- * a valid url string with properly-encoded params is returned for each avaliable provider- */-describe('getLegacySourceUrl', () => {- it('returns a url for each audio source', () => {- const search = { q: 'dogs' }- const audioSources = Object.keys(legacySourceMap).filter(- (sourceName) => legacySourceMap[sourceName].audio- )- const getAudioSourceUrl = getLegacySourceUrl('audio')- const urls = audioSources.map((sourceName) =>- getAudioSourceUrl(sourceName, search)- )-- expect(urls.every((url) => url.startsWith('http'))).toBeTruthy()- })-- it('returns a url for each video source', () => {- const search = { q: 'dogs' }- const audioSources = Object.keys(legacySourceMap).filter(- (sourceName) => legacySourceMap[sourceName].video- )- const getVideoSourceUrl = getLegacySourceUrl('video')- const urls = audioSources.map((sourceName) =>- getVideoSourceUrl(sourceName, search)- )-- expect(urls.every((url) => url.startsWith('http'))).toBeTruthy()- })-- it('returns a url for each image source', () => {- const search = { q: 'dogs' }- const audioSources = Object.keys(legacySourceMap).filter(- (sourceName) => legacySourceMap[sourceName].image- )- const getImageSourceUrl = getLegacySourceUrl('image')- const urls = audioSources.map((sourceName) =>- getImageSourceUrl(sourceName, search)- )-- expect(urls.every((url) => url.startsWith('http'))).toBeTruthy()- })-- it('throws an error for invalid sources', () => {- const search = { q: 'dogs' }- const getImageSourceUrl = getLegacySourceUrl('image')-- expect(() => {- getImageSourceUrl('Fake Source', search)- }).toThrow('Fake Source')- })-- it('throws an error for valid sources but an invalid content type', () => {- const search = { q: 'dogs' }- const getImageSourceUrl = getLegacySourceUrl('paintings')-- expect(() => {- getImageSourceUrl(Object.keys(legacySourceMap)[0], search)- }).toThrow('paintings')- })-})diff --git a/tsconfig.json b/tsconfig.jsonindex a577198dd..88e084b7b 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -37,7 +37,10 @@"**/*.ts","test/proxy.js","src/components/VLink.vue",+ "src/components/VIcon.vue",+ "src/components/VButton.vue","src/components/VContentPage.vue",+ "src/components/VMetaSearch/*.vue","src/composables/types.js","src/composables/use-event-listener-outside.js","src/composables/use-active-audio.js",