update frontend lib : remove histoire (obselete) + update vitest - #1815

This commit is contained in:
Laurent GAY
2025-10-24 13:00:15 +02:00
committed by setop
parent ffa3e0ebd7
commit d971fd77af
192 changed files with 4767 additions and 5300 deletions

View File

@@ -0,0 +1,204 @@
import { beforeEach, describe, it, expect } from "vitest";
import { enUS } from "date-fns/locale";
import { routes } from "@/router";
import { createRouter, createWebHistory, Router } from "vue-router";
import { config, mount } from "@vue/test-utils";
import { Oruga } from "@oruga-ui/oruga-next";
import flushPromises from "flush-promises";
import { getMockClient } from "../../mocks/client";
import { htmlRemoveId } from "../../common";
import EventComment from "@/components/Comment/EventComment.vue";
import { IPerson } from "@/types/actor";
import { IComment } from "@/types/comment.model";
import {
ActorType,
CommentModeration,
EventJoinOptions,
EventStatus,
EventVisibility,
} from "@/types/enums";
import { IEvent } from "@/types/event.model";
import { reactive } from "vue";
config.global.plugins.push(Oruga);
let router: Router;
beforeEach(async () => {
router = createRouter({
history: createWebHistory(),
routes: routes,
});
// await router.isReady();
});
const baseActorAvatar = {
id: "",
name: "",
alt: "",
metadata: {},
url: "https://social.tcit.fr/system/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg",
};
const baseActor: IPerson = {
name: "Thomas Citharel",
preferredUsername: "tcit",
avatar: baseActorAvatar,
domain: null,
url: "",
summary: "",
suspended: false,
type: ActorType.PERSON,
id: "598",
};
const baseEvent: IEvent = {
uuid: "an-uuid",
title: "A very interesting event",
description: "Things happen",
beginsOn: new Date().toISOString(),
endsOn: new Date().toISOString(),
physicalAddress: {
description: "Somewhere",
street: "",
locality: "",
region: "",
country: "",
type: "",
postalCode: "",
},
picture: {
id: "",
name: "",
alt: "",
metadata: {},
url: "https://mobilizon.fr/media/81d9c76aaf740f84eefb28cf2b9988bdd2495ab1f3246159fd688e242155cb23.png?name=Screenshot_20220315_171848.png",
},
url: "",
local: true,
slug: "",
publishAt: new Date().toISOString(),
status: EventStatus.CONFIRMED,
visibility: EventVisibility.PUBLIC,
joinOptions: EventJoinOptions.FREE,
draft: false,
participantStats: {
notApproved: 0,
notConfirmed: 0,
rejected: 0,
participant: 0,
creator: 0,
moderator: 0,
administrator: 0,
going: 0,
},
participants: { total: 0, elements: [] },
relatedEvents: [],
tags: [{ slug: "something", title: "Something" }],
attributedTo: undefined,
organizerActor: {
...baseActor,
name: "Hello",
avatar: {
...baseActorAvatar,
url: "https://mobilizon.fr/media/653c2dcbb830636e0db975798163b85e038dfb7713e866e96d36bd411e105e3c.png?name=festivalsanantes%27s%20avatar.png",
},
},
comments: [],
options: {
maximumAttendeeCapacity: 0,
remainingAttendeeCapacity: 0,
showRemainingAttendeeCapacity: false,
anonymousParticipation: false,
hideOrganizerWhenGroupEvent: false,
offers: [],
participationConditions: [],
attendees: [],
program: "",
commentModeration: CommentModeration.ALLOW_ALL,
showParticipationPrice: false,
showStartTime: false,
showEndTime: false,
timezone: null,
isOnline: false,
},
metadata: [],
contacts: [],
language: "en",
category: "hello",
};
const event = reactive<IEvent>(baseEvent);
const comment = reactive<IComment>({
text: "hello",
local: true,
actor: baseActor,
totalReplies: 5,
replies: [
{
text: "a reply!",
id: "90",
actor: baseActor,
updatedAt: new Date().toISOString(),
url: "http://somewhere.tld",
replies: [],
totalReplies: 0,
isAnnouncement: false,
local: false,
},
{
text: "a reply to another reply!",
id: "92",
actor: baseActor,
updatedAt: new Date().toISOString(),
url: "http://somewhere.tld",
replies: [],
totalReplies: 0,
isAnnouncement: false,
local: false,
},
],
isAnnouncement: false,
updatedAt: new Date().toISOString(),
url: "http://somewhere.tld",
});
const generateWrapper = (props: any) => {
const global_data = getMockClient([]);
global_data.provide.dateFnsLocale = enUS;
global_data.plugins = [router];
return mount(EventComment, {
props: props,
global: {
...global_data,
stubs: {
RouterLink: false,
},
},
});
};
describe("EventComment", () => {
it("Show Basic", async () => {
const wrapper = generateWrapper({
comment: comment,
event: event,
currentActor: baseActor,
});
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
});
it("Show Announcement", async () => {
const wrapper = generateWrapper({
comment: { ...comment, isAnnouncement: true },
event: event,
currentActor: baseActor,
});
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,177 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`EventComment > Show Announcement 1`] = `
"<li class="bg-white dark:bg-zinc-800 rounded p-2 bg-mbz-purple-50 dark:bg-mbz-purple-500">
<article id="comment-undefined" dir="auto" class="mbz-comment">
<div>
<div class="flex items-center gap-2">
<div class="flex items-center gap-1">
<vmenu distance="16" triggers="hover" class="popover inline">
<figure><img class="rounded-xl" src="https://social.tcit.fr/system/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg" alt="" width="24" height="24"></figure>
</vmenu><strong dir="auto" class="organizer">Thomas Citharel</strong>
</div><a href="/events/an-uuid#comment-undefined"><small>in over 3 years</small></a>
</div>
<div dir="auto" class="prose dark:prose-invert xl:prose-lg !max-w-full text-black dark:text-white">hello</div>
<nav class="flex gap-1 mt-1"><button class="cursor-pointer flex hover:bg-zinc-300 dark:hover:bg-zinc-600 rounded p-1"><span aria-hidden="true" class="material-design-icon reply-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10,9V5L3,12L10,19V14.9C15,14.9 18.5,16.5 21,20C20,15 17,10 10,9Z"><!--v-if--></path></svg></span><span>Reply</span></button>
<div data-oruga="dropdown" class="o-drop o-drop--position-bottom-left">
<div tabindex="0" class="o-drop__trigger" aria-haspopup="true"><button class="cursor-pointer flex hover:bg-zinc-300 dark:hover:bg-zinc-600 rounded p-1"><span aria-hidden="true" class="material-design-icon dots-horizontal-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="24" height="24" viewBox="0 0 24 24"><path d="M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z"><!--v-if--></path></svg></span><span class="sr-only">More options</span></button></div>
<!--teleport start-->
<transition-stub name="fade" appear="false" persisted="false" css="true">
<!---->
</transition-stub>
<transition-stub name="fade" appear="false" persisted="false" css="true">
<div class="o-drop__menu o-drop__menu--bottom-left" role="list" aria-hidden="true" aria-modal="true" style="display: none;">
<div class="o-drop__item o-drop__item--clickable" role="listitem" tabindex="0" data-oruga="dropdown-item"><button class="flex items-center gap-1"><span aria-hidden="true" class="material-design-icon delete-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="16" height="16" viewBox="0 0 24 24"><path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"><!--v-if--></path></svg></span><span>Delete</span></button></div>
<div class="o-drop__item o-drop__item--clickable" role="listitem" tabindex="0" data-oruga="dropdown-item"><button class="flex items-center gap-1"><span aria-hidden="true" class="material-design-icon alert-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="16" height="16" viewBox="0 0 24 24"><path d="M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z"><!--v-if--></path></svg></span><span>Report</span></button></div>
</div>
</transition-stub>
<!--teleport end-->
</div>
</nav>
<div class=""><button class="flex cursor-pointer hover:bg-zinc-300 dark:hover:bg-zinc-600 rounded p-1"><span aria-hidden="true" class="material-design-icon chevron-down-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"><!--v-if--></path></svg></span><span>View a reply</span></button></div>
</div>
</article>
<form style="display: none;">
<article class="flex gap-2">
<figure class="mt-4"><img src="https://social.tcit.fr/system/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg" alt="" width="48" height="48" class="rounded-md"></figure>
<div class="flex-1">
<div class="flex gap-1 items-center"><strong>Thomas Citharel</strong><small dir="ltr">@tcit</small></div>
<div class="flex flex-col gap-2">
<!----><button disabled="" type="submit" class="o-btn o-btn--primary o-btn--disabled self-end" role="button" data-oruga="button"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Post a reply</span>
<!----></span>
</button>
</div>
</div>
</article>
</form>
<!--v-if-->
<!--teleport start-->
<transition-stub name="zoom-out" appear="false" persisted="false" css="true">
<div has-modal-card="" close-button-aria-label="Close" data-oruga="modal" class="o-modal" tabindex="-1" aria-modal="false" style="display: none;">
<div class="o-modal__overlay" tabindex="-1" aria-hidden="true"></div>
<div class="o-modal__content" style="max-width: 960px;">
<div data-v-e0cceef3="" class="p-2">
<header data-v-e0cceef3="" class="mb-3">
<h2 data-v-e0cceef3="" class="text-2xl">Report this comment</h2>
</header>
<section data-v-e0cceef3="">
<div data-v-e0cceef3="" class="flex gap-1 flex-row mb-3 bg-mbz-yellow dark:text-black p-3 rounded items-center"><span data-v-e0cceef3="" class="o-icon o-icon--warning hidden md:block flex-1" data-oruga="icon"><i class="mdi mdi-alert 48"></i></span>
<p data-v-e0cceef3="">The report will be sent to the moderators of your instance. You can explain why you report this content below.</p>
</div>
<div data-v-e0cceef3="">
<!--v-if-->
<div data-v-e0cceef3="" data-oruga="field" class="o-field"><label for="additional-comments" class="o-field__label">Additional comments</label>
<div class="o-field__body">
<div class="o-field o-field--addons">
<div data-v-e0cceef3="" data-oruga="input" class="o-input__wrapper o-input__wrapper--expanded"><textarea autofocus="" id="additional-comments" data-oruga-input="textarea" class="o-input o-input__textarea"></textarea>
<!---->
<!---->
<!---->
</div>
</div>
</div>
<!---->
</div>
<!--v-if-->
</div>
</section>
<footer data-v-e0cceef3="" class="flex gap-2 py-3"><button data-v-e0cceef3="" type="button" class="o-btn o-btn--outlined" role="button" data-oruga="button"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Cancel</span>
<!----></span>
</button><button data-v-e0cceef3="" type="button" class="o-btn o-btn--primary" role="button" data-oruga="button"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Send the report</span>
<!----></span>
</button></footer>
</div><span class="o-icon o-icon--clickable o-icon--medium o-modal__close" data-oruga="icon" style="display: none;"><i class="mdi mdi-close mdi-36px"></i></span>
</div>
</div>
</transition-stub>
<!--teleport end-->
</li>"
`;
exports[`EventComment > Show Basic 1`] = `
"<li class="bg-white dark:bg-zinc-800 rounded p-2">
<article id="comment-undefined" dir="auto" class="mbz-comment">
<div>
<div class="flex items-center gap-2">
<div class="flex items-center gap-1">
<vmenu distance="16" triggers="hover" class="popover inline">
<figure><img class="rounded-xl" src="https://social.tcit.fr/system/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg" alt="" width="24" height="24"></figure>
</vmenu><strong dir="auto" class="organizer">Thomas Citharel</strong>
</div><a href="/events/an-uuid#comment-undefined"><small>in over 3 years</small></a>
</div>
<div dir="auto" class="prose dark:prose-invert xl:prose-lg !max-w-full">hello</div>
<nav class="flex gap-1 mt-1"><button class="cursor-pointer flex hover:bg-zinc-300 dark:hover:bg-zinc-600 rounded p-1"><span aria-hidden="true" class="material-design-icon reply-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10,9V5L3,12L10,19V14.9C15,14.9 18.5,16.5 21,20C20,15 17,10 10,9Z"><!--v-if--></path></svg></span><span>Reply</span></button>
<div data-oruga="dropdown" class="o-drop o-drop--position-bottom-left">
<div tabindex="0" class="o-drop__trigger" aria-haspopup="true"><button class="cursor-pointer flex hover:bg-zinc-300 dark:hover:bg-zinc-600 rounded p-1"><span aria-hidden="true" class="material-design-icon dots-horizontal-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="24" height="24" viewBox="0 0 24 24"><path d="M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z"><!--v-if--></path></svg></span><span class="sr-only">More options</span></button></div>
<!--teleport start-->
<transition-stub name="fade" appear="false" persisted="false" css="true">
<!---->
</transition-stub>
<transition-stub name="fade" appear="false" persisted="false" css="true">
<div class="o-drop__menu o-drop__menu--bottom-left" role="list" aria-hidden="true" aria-modal="true" style="display: none;">
<div class="o-drop__item o-drop__item--clickable" role="listitem" tabindex="0" data-oruga="dropdown-item"><button class="flex items-center gap-1"><span aria-hidden="true" class="material-design-icon delete-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="16" height="16" viewBox="0 0 24 24"><path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"><!--v-if--></path></svg></span><span>Delete</span></button></div>
<div class="o-drop__item o-drop__item--clickable" role="listitem" tabindex="0" data-oruga="dropdown-item"><button class="flex items-center gap-1"><span aria-hidden="true" class="material-design-icon alert-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="16" height="16" viewBox="0 0 24 24"><path d="M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z"><!--v-if--></path></svg></span><span>Report</span></button></div>
</div>
</transition-stub>
<!--teleport end-->
</div>
</nav>
<div class=""><button class="flex cursor-pointer hover:bg-zinc-300 dark:hover:bg-zinc-600 rounded p-1"><span aria-hidden="true" class="material-design-icon chevron-down-icon" role="img"><svg fill="currentColor" class="material-design-icon__svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"><!--v-if--></path></svg></span><span>View a reply</span></button></div>
</div>
</article>
<form style="display: none;">
<article class="flex gap-2">
<figure class="mt-4"><img src="https://social.tcit.fr/system/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg" alt="" width="48" height="48" class="rounded-md"></figure>
<div class="flex-1">
<div class="flex gap-1 items-center"><strong>Thomas Citharel</strong><small dir="ltr">@tcit</small></div>
<div class="flex flex-col gap-2">
<!----><button disabled="" type="submit" class="o-btn o-btn--primary o-btn--disabled self-end" role="button" data-oruga="button"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Post a reply</span>
<!----></span>
</button>
</div>
</div>
</article>
</form>
<!--v-if-->
<!--teleport start-->
<transition-stub name="zoom-out" appear="false" persisted="false" css="true">
<div has-modal-card="" close-button-aria-label="Close" data-oruga="modal" class="o-modal" tabindex="-1" aria-modal="false" style="display: none;">
<div class="o-modal__overlay" tabindex="-1" aria-hidden="true"></div>
<div class="o-modal__content" style="max-width: 960px;">
<div data-v-e0cceef3="" class="p-2">
<header data-v-e0cceef3="" class="mb-3">
<h2 data-v-e0cceef3="" class="text-2xl">Report this comment</h2>
</header>
<section data-v-e0cceef3="">
<div data-v-e0cceef3="" class="flex gap-1 flex-row mb-3 bg-mbz-yellow dark:text-black p-3 rounded items-center"><span data-v-e0cceef3="" class="o-icon o-icon--warning hidden md:block flex-1" data-oruga="icon"><i class="mdi mdi-alert 48"></i></span>
<p data-v-e0cceef3="">The report will be sent to the moderators of your instance. You can explain why you report this content below.</p>
</div>
<div data-v-e0cceef3="">
<!--v-if-->
<div data-v-e0cceef3="" data-oruga="field" class="o-field"><label for="additional-comments" class="o-field__label">Additional comments</label>
<div class="o-field__body">
<div class="o-field o-field--addons">
<div data-v-e0cceef3="" data-oruga="input" class="o-input__wrapper o-input__wrapper--expanded"><textarea autofocus="" id="additional-comments" data-oruga-input="textarea" class="o-input o-input__textarea"></textarea>
<!---->
<!---->
<!---->
</div>
</div>
</div>
<!---->
</div>
<!--v-if-->
</div>
</section>
<footer data-v-e0cceef3="" class="flex gap-2 py-3"><button data-v-e0cceef3="" type="button" class="o-btn o-btn--outlined" role="button" data-oruga="button"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Cancel</span>
<!----></span>
</button><button data-v-e0cceef3="" type="button" class="o-btn o-btn--primary" role="button" data-oruga="button"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Send the report</span>
<!----></span>
</button></footer>
</div><span class="o-icon o-icon--clickable o-icon--medium o-modal__close" data-oruga="icon" style="display: none;"><i class="mdi mdi-close mdi-36px"></i></span>
</div>
</div>
</transition-stub>
<!--teleport end-->
</li>"
`;