From bfbc299f37e36a430b18d5dc2c78f79a3f90af6e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 14 Nov 2023 18:59:28 +0100 Subject: [PATCH] test: fix histoire configuration Nearly Signed-off-by: Thomas Citharel --- .gitignore | 4 +- histoire.config.ts | 1 + src/components/Comment/EventComment.story.vue | 29 ++++++++---- .../Event/OrganizerPicker.story.vue | 6 +-- .../Event/OrganizerPickerWrapper.story.vue | 6 +-- .../Event/ParticipationButton.story.vue | 18 ++++---- src/components/Home/SearchFields.story.vue | 6 +-- vite.config.js | 45 ++++++++++++------- 8 files changed, 71 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index b04be4bae..b97d7ba2f 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,6 @@ codeclimate.json node_modules stats.html /coverage -/playwright-report/ \ No newline at end of file +/playwright-report/ +.histoire + diff --git a/histoire.config.ts b/histoire.config.ts index 349d77575..8cd1c1719 100644 --- a/histoire.config.ts +++ b/histoire.config.ts @@ -8,6 +8,7 @@ export default defineConfig({ plugins: [HstVue()], setupFile: path.resolve(__dirname, "./src/histoire.setup.ts"), viteNodeInlineDeps: [/date-fns/], + // viteIgnorePlugins: ['vite-plugin-pwa', 'vite-plugin-pwa:build', 'vite-plugin-pwa:info'], tree: { groups: [ { diff --git a/src/components/Comment/EventComment.story.vue b/src/components/Comment/EventComment.story.vue index b8a125449..b0baf3295 100644 --- a/src/components/Comment/EventComment.story.vue +++ b/src/components/Comment/EventComment.story.vue @@ -5,9 +5,9 @@ :comment="comment" :event="event" :currentActor="baseActor" - @create-comment="hstEvent('Create comment', $event)" - @delete-comment="hstEvent('Delete comment', $event)" - @report-comment="hstEvent('Report comment', $event)" + @create-comment="logEvent('Create comment', $event)" + @delete-comment="logEvent('Delete comment', $event)" + @report-comment="logEvent('Report comment', $event)" /> @@ -15,9 +15,9 @@ :comment="{ ...comment, isAnnouncement: true }" :event="event" :currentActor="baseActor" - @create-comment="hstEvent('Create comment', $event)" - @delete-comment="hstEvent('Delete comment', $event)" - @report-comment="hstEvent('Report comment', $event)" + @create-comment="logEvent('Create comment', $event)" + @delete-comment="logEvent('Delete comment', $event)" + @report-comment="logEvent('Report comment', $event)" /> @@ -37,10 +37,23 @@ import { reactive } from "vue"; import Comment from "./EventComment.vue"; import FloatingVue from "floating-vue"; import "floating-vue/dist/style.css"; -import { hstEvent } from "histoire/client"; +import { logEvent } from "histoire/client"; +import { createMemoryHistory, createRouter } from "vue-router"; function setupApp({ app }) { app.use(FloatingVue); + app.use( + createRouter({ + history: createMemoryHistory(), + routes: [ + { + path: "/event/:uuid", + name: "Event", + component: { render: () => null }, + }, + ], + }) + ); } const baseActorAvatar = { @@ -64,7 +77,7 @@ const baseActor: IPerson = { }; const baseEvent: IEvent = { - uuid: "", + uuid: "an-uuid", title: "A very interesting event", description: "Things happen", beginsOn: new Date().toISOString(), diff --git a/src/components/Event/OrganizerPicker.story.vue b/src/components/Event/OrganizerPicker.story.vue index 0a84c8fc8..a58dcd68d 100644 --- a/src/components/Event/OrganizerPicker.story.vue +++ b/src/components/Event/OrganizerPicker.story.vue @@ -7,8 +7,8 @@ v-model:actor-filter="actorFilter" :groupMemberships="[]" :current-actor="currentActor" - @update:actor-filter="hstEvent('Actor Filter updated', $event)" - @update:model-value="hstEvent('Selected actor updated', $event)" + @update:actor-filter="logEvent('Actor Filter updated', $event)" + @update:model-value="logEvent('Selected actor updated', $event)" /> @@ -18,7 +18,7 @@ import OrganizerPicker from "./OrganizerPicker.vue"; import { createMemoryHistory, createRouter } from "vue-router"; import { reactive, ref } from "vue"; import { ActorType } from "@/types/enums"; -import { hstEvent } from "histoire/client"; +import { logEvent } from "histoire/client"; const currentActor = reactive({ id: "59", diff --git a/src/components/Event/OrganizerPickerWrapper.story.vue b/src/components/Event/OrganizerPickerWrapper.story.vue index 73299baf9..0906588d0 100644 --- a/src/components/Event/OrganizerPickerWrapper.story.vue +++ b/src/components/Event/OrganizerPickerWrapper.story.vue @@ -3,8 +3,8 @@ @@ -19,7 +19,7 @@ import { PERSON_GROUP_MEMBERSHIPS } from "@/graphql/actor"; import { createMemoryHistory, createRouter } from "vue-router"; import { IDENTITIES } from "@/graphql/actor"; import { reactive } from "vue"; -import { hstEvent } from "histoire/client"; +import { logEvent } from "histoire/client"; const actor = reactive({ id: "5", diff --git a/src/components/Event/ParticipationButton.story.vue b/src/components/Event/ParticipationButton.story.vue index e1e16b511..594a3353d 100644 --- a/src/components/Event/ParticipationButton.story.vue +++ b/src/components/Event/ParticipationButton.story.vue @@ -14,9 +14,9 @@ :current-actor="currentActor" :participation="undefined" :identities="identities" - @join-event="hstEvent('Join event', $event)" - @join-modal="hstEvent('Join modal', $event)" - @confirm-leave="hstEvent('Confirm leave', $event)" + @join-event="logEvent('Join event', $event)" + @join-modal="logEvent('Join modal', $event)" + @confirm-leave="logEvent('Confirm leave', $event)" /> @@ -26,9 +26,9 @@ :participation="undefined" :identities="identities" @join-event-with-confirmation=" - hstEvent('Join Event with confirmation', $event) + logEvent('Join Event with confirmation', $event) " - @join-modal="hstEvent('Join modal', $event)" + @join-modal="logEvent('Join modal', $event)" /> @@ -37,7 +37,7 @@ :current-actor="currentActor" :participation="participation" :identities="identities" - @confirm-leave="hstEvent('Confirm leave', $event)" + @confirm-leave="logEvent('Confirm leave', $event)" /> @@ -49,7 +49,7 @@ role: ParticipantRole.NOT_APPROVED, }" :identities="identities" - @confirm-leave="hstEvent('Confirm leave', $event)" + @confirm-leave="logEvent('Confirm leave', $event)" /> @@ -61,7 +61,7 @@ role: ParticipantRole.REJECTED, }" :identities="identities" - @confirm-leave="hstEvent('Confirm leave', $event)" + @confirm-leave="logEvent('Confirm leave', $event)" /> @@ -72,7 +72,7 @@ import { IPerson } from "@/types/actor"; import { EventJoinOptions, ParticipantRole } from "@/types/enums"; import { IEvent } from "@/types/event.model"; import ParticipationButton from "./ParticipationButton.vue"; -import { hstEvent } from "histoire/client"; +import { logEvent } from "histoire/client"; import { IParticipant } from "@/types/participant.model"; const emptyCurrentActor: IPerson = {}; diff --git a/src/components/Home/SearchFields.story.vue b/src/components/Home/SearchFields.story.vue index 93aa1da51..fd3f8112e 100644 --- a/src/components/Home/SearchFields.story.vue +++ b/src/components/Home/SearchFields.story.vue @@ -4,8 +4,8 @@ @@ -14,7 +14,7 @@ import { apolloClient } from "@/vue-apollo"; import { DefaultApolloClient } from "@vue/apollo-composable"; import SearchFields from "./SearchFields.vue"; -import { hstEvent } from "histoire/client"; +import { logEvent } from "histoire/client"; function setupApp({ app }) { app.provide(DefaultApolloClient, apolloClient); diff --git a/vite.config.js b/vite.config.js index 56cb0cca7..e20c7d603 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,9 +15,12 @@ export default defineConfig(({ command }) => { process.stdin.resume(); } - return { - plugins: [ - vue(), + const isStory = Boolean(process.env.HISTOIRE); + + const plugins = [vue(), visualizer()]; + + if (!isStory) { + plugins.push( VitePWA({ registerType: "autoUpdate", strategies: "injectManifest", @@ -57,21 +60,29 @@ export default defineConfig(({ command }) => { }, ], }, - }), - visualizer(), - ], - build: { - manifest: true, - outDir: path.resolve(__dirname, "priv/static"), - emptyOutDir: true, - sourcemap: true, - rollupOptions: { - // overwrite default .html entry - input: { - main: "src/main.ts", - }, + }) + ); + } + + const build = { + manifest: true, + outDir: path.resolve(__dirname, "priv/static"), + emptyOutDir: true, + sourcemap: true, + }; + + if (!isStory) { + // overwrite default .html entry + build.rollupOptions = { + input: { + main: "src/main.ts", }, - }, + }; + } + + return { + plugins, + build, resolve: { alias: { "@": path.resolve(__dirname, "./src"),