Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Add Storybook smoketest to GitHub CI (#520)
sarayourfriend01561caf4b00
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex d59674ffa..e0521f82d 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -45,3 +45,6 @@ jobs:- name: Run testsrun: pnpm i18n:get-translations && pnpm test:unit++ - name: Run Storybook smoke-test+ run: pnpm storybook -- --ci --smoke-testdiff --git a/nuxt.config.js b/nuxt.config.jsindex 137204791..880cb4d85 100644--- a/nuxt.config.js+++ b/nuxt.config.js@@ -127,7 +127,7 @@ export default {},components: {dirs: [- '~/components',+ { path: '~/components', ignore: '**/*.types.js' },'~/components/ContentReport','~/components/Filters','~/components/ImageDetails',@@ -136,7 +136,6 @@ export default {'~/components/VMetaSearch','~/components/MediaTag','~/components/Skeleton',- '~/components/VPopover',],},plugins: [diff --git a/src/components/VModal/VModalContent.vue b/src/components/VModal/VModalContent.vueindex 4b3cb2e80..8b65dd96f 100644--- a/src/components/VModal/VModalContent.vue+++ b/src/components/VModal/VModalContent.vue@@ -40,7 +40,7 @@<script>import { defineComponent, toRefs, ref } from '@nuxtjs/composition-api'import { FocusTrap } from 'focus-trap-vue'-import { VTeleport } from '~/components/VTeleport'+import VTeleport from '~/components/VTeleport/VTeleport'import { useDialogContent } from '~/composables/use-dialog-content'import { warn } from '~/utils/warn'import VButton from '~/components/VButton.vue'diff --git a/src/components/VModal/VModalTarget.vue b/src/components/VModal/VModalTarget.vueindex 1118e12a7..13c03f326 100644--- a/src/components/VModal/VModalTarget.vue+++ b/src/components/VModal/VModalTarget.vue@@ -4,7 +4,7 @@<script>import { defineComponent } from '@nuxtjs/composition-api'-import { VTeleportTarget } from '~/components/VTeleport'+import VTeleportTarget from '~/components/VTeleport/VTeleportTarget'export default defineComponent({name: 'VModalTarget',diff --git a/src/components/VTeleport.js b/src/components/VTeleport.jsdeleted file mode 100644index 2dfbcc407..000000000--- a/src/components/VTeleport.js+++ /dev/null@@ -1,45 +0,0 @@-// https://gist.github.com/Alan-Liang/a847559433919ecb53dff217ed9708bb--const targets = {}--export const VTeleportTarget = {- name: 'VTeleportTarget',- data: () => ({ children: [] }),- props: {- name: { type: String, required: true },- },- created() {- if (this.name in targets)- throw new Error(`VTeleportTarget: duplicate name ${this.name}`)- targets[this.name] = this- },- beforeDestroy() {- delete targets[this.name]- if (this.children.length > 0)- throw new Error(- `VTeleportTarget: ${this.name} beforeDestroy but still has children mounted`- )- },- render(h) {- return h('div', this.children.map((vm) => vm.$slots.default || []).flat())- },-}--export const VTeleport = {- name: 'VTeleport',- props: {- to: { type: String, required: true },- },- mounted() {- if (!(this.to in targets))- throw new Error(`VTeleport: non-existent target ${this.to}`)- targets[this.to].children.push(this)- },- beforeDestroy() {- if (!(this.to in targets))- throw new Error(`VTeleport: non-existent target ${this.to} on unmount`)- const children = targets[this.to].children- children.splice(children.indexOf(this), 1)- },- render: (h) => h('span'),-}diff --git a/src/components/VTeleport/README.md b/src/components/VTeleport/README.mdnew file mode 100644index 000000000..6a30857e0--- /dev/null+++ b/src/components/VTeleport/README.md@@ -0,0 +1,3 @@+# VTeleport and VTeleportTarget++Directly based on code from https://gist.github.com/Alan-Liang/a847559433919ecb53dff217ed9708bbdiff --git a/src/components/VTeleport/VTeleport.vue b/src/components/VTeleport/VTeleport.vuenew file mode 100644index 000000000..ffdfdb568--- /dev/null+++ b/src/components/VTeleport/VTeleport.vue@@ -0,0 +1,23 @@+<script>+import { defineComponent } from '@nuxtjs/composition-api'+import { targets } from './meta/targets'++export default defineComponent({+ name: 'VTeleport',+ props: {+ to: { type: String, required: true },+ },+ mounted() {+ if (!(this.to in targets))+ throw new Error(`VTeleport: non-existent target ${this.to}`)+ targets[this.to].children.push(this)+ },+ beforeDestroy() {+ if (!(this.to in targets))+ throw new Error(`VTeleport: non-existent target ${this.to} on unmount`)+ const children = targets[this.to].children+ children.splice(children.indexOf(this), 1)+ },+ render: (h) => h('span'),+})+</script>diff --git a/src/components/VTeleport/VTeleportTarget.vue b/src/components/VTeleport/VTeleportTarget.vuenew file mode 100644index 000000000..048a43806--- /dev/null+++ b/src/components/VTeleport/VTeleportTarget.vue@@ -0,0 +1,27 @@+<script>+import { defineComponent } from '@nuxtjs/composition-api'+import { targets } from './meta/targets'++export default defineComponent({+ name: 'VTeleportTarget',+ props: {+ name: { type: String, required: true },+ },+ data: () => ({ children: [] }),+ created() {+ if (this.name in targets)+ throw new Error(`VTeleportTarget: duplicate name ${this.name}`)+ targets[this.name] = this+ },+ beforeDestroy() {+ delete targets[this.name]+ if (this.children.length > 0)+ throw new Error(+ `VTeleportTarget: ${this.name} beforeDestroy but still has children mounted`+ )+ },+ render(h) {+ return h('div', this.children.map((vm) => vm.$slots.default || []).flat())+ },+})+</script>diff --git a/src/components/VTeleport/meta/targets.js b/src/components/VTeleport/meta/targets.jsnew file mode 100644index 000000000..66ddff965--- /dev/null+++ b/src/components/VTeleport/meta/targets.js@@ -0,0 +1,11 @@+/* eslint-disable unicorn/filename-case */+/**+ * Disable this rule for this file until there's a way to disable it more generally+ * for everything inside of the `meta` folders.+ *+ * @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/686+ */+/**+ * @type {Record<string, import('vue').Component>}+ */+export const targets = {}