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,50 @@
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, requestHandlers } from "../../mocks/client";
import { htmlRemoveId } from "../../common";
import CategoriesPreview from "@/components/Home/CategoriesPreview.vue";
import { CATEGORY_STATISTICS } from "@/graphql/statistics";
config.global.plugins.push(Oruga);
let router: Router;
beforeEach(async () => {
router = createRouter({
history: createWebHistory(),
routes: routes,
});
// await router.isReady();
});
const generateWrapper = () => {
const global_data = getMockClient([CATEGORY_STATISTICS]);
global_data.provide.dateFnsLocale = enUS;
global_data.plugins = [router];
return mount(CategoriesPreview, {
props: {},
global: {
...global_data,
stubs: {
RouterLink: false,
},
},
});
};
describe("CategoriesPreview", () => {
it("Show simple", async () => {
const wrapper = generateWrapper();
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
expect(requestHandlers.handle_0).toHaveBeenCalledTimes(1);
expect(requestHandlers.handle_0).toHaveBeenCalledWith({});
});
});

View File

@@ -0,0 +1,47 @@
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 MobilizonPresentation from "@/components/Home/MobilizonPresentation.vue";
config.global.plugins.push(Oruga);
let router: Router;
beforeEach(async () => {
router = createRouter({
history: createWebHistory(),
routes: routes,
});
// await router.isReady();
});
const generateWrapper = () => {
const global_data = getMockClient([]);
global_data.provide.dateFnsLocale = enUS;
global_data.plugins = [router];
return mount(MobilizonPresentation, {
props: {},
global: {
...global_data,
stubs: {
RouterLink: false,
},
},
});
};
describe("MobilizonPresentation", () => {
it("Show simple", async () => {
const wrapper = generateWrapper();
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,50 @@
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 SearchFields from "@/components/Home/SearchFields.vue";
config.global.plugins.push(Oruga);
let router: Router;
beforeEach(async () => {
router = createRouter({
history: createWebHistory(),
routes: routes,
});
// await router.isReady();
});
const generateWrapper = () => {
const global_data = getMockClient([]);
global_data.provide.dateFnsLocale = enUS;
global_data.plugins = [router];
return mount(SearchFields, {
props: {
search: "",
location: {},
},
global: {
...global_data,
stubs: {
RouterLink: false,
},
},
});
};
describe("SearchFields", () => {
it("Show simple", async () => {
const wrapper = generateWrapper();
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,68 @@
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 UnloggedIntroduction from "@/components/Home/UnloggedIntroduction.vue";
import { reactive } from "vue";
config.global.plugins.push(Oruga);
let router: Router;
beforeEach(async () => {
router = createRouter({
history: createWebHistory(),
routes: routes,
});
// await router.isReady();
});
const generateWrapper = (props: any) => {
const global_data = getMockClient([]);
global_data.provide.dateFnsLocale = enUS;
global_data.plugins = [router];
return mount(UnloggedIntroduction, {
props: props,
global: {
...global_data,
stubs: {
RouterLink: false,
},
},
});
};
const mockconfig = reactive({
name: "My instance name",
description: "An instance that doesn't exist",
slogan: "Test! Test! Test!",
registrationsOpen: true,
});
const mockconfigClosed = reactive({ ...config, registrationsOpen: false });
describe("UnloggedIntroduction", () => {
it("Show open", async () => {
const wrapper = generateWrapper({
config: mockconfig,
});
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
});
it("Show close", async () => {
const wrapper = generateWrapper({
config: mockconfigClosed,
});
await wrapper.vm.$nextTick();
await flushPromises();
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`CategoriesPreview > Show simple 1`] = `"<!--v-if-->"`;

View File

@@ -0,0 +1,23 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`MobilizonPresentation > Show simple 1`] = `
"<div class="container mx-auto py-4 px-2">
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
<div>
<h3 class="dark:text-white text-3xl font-bold">A practical tool</h3>
<p class="dark:text-white">Mobilizon is a tool that helps you <b>find, create and organise events</b>.</p>
</div>
<div>
<h3 class="dark:text-white text-3xl font-bold">An ethical alternative</h3>
<p class="dark:text-white">Ethical alternative to Facebook events, groups and pages, Mobilizon is a <b>tool designed to serve you</b>. Period.</p>
</div>
<div>
<h3 class="dark:text-white text-3xl font-bold">A federated software</h3>
<p class="dark:text-white">Mobilizon is not a giant platform, but a <b>multitude of interconnected Mobilizon websites</b>.</p>
</div>
</div>
<div class="mt-4 text-center"><a class="o-btn o-btn--large o-btn--primary" role="button" data-oruga="button" href="https://mobilizon.org"><span class="o-btn__wrapper"><!----><span class="o-btn__label">Learn more about Mobilizon</span>
<!----></span>
</a></div>
</div>"
`;

View File

@@ -0,0 +1,21 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`SearchFields > Show simple 1`] = `
"<form data-v-a19720a3="" id="search-anchor" class="container mx-auto p-2 flex flex-col flex-wrap items-stretch gap-2 justify-center dark:text-slate-100" role="search" location="[object Object]">
<div data-v-a19720a3="" class="flex flex-col flex-wrap sm:flex-row gap-2 justify-center"><label data-v-a19720a3="" class="sr-only" for="search_field_input">Keyword, event title, group name, etc.</label>
<div data-v-a19720a3="" data-oruga="input" class="o-input__wrapper o-input__wrapper--expanded"><input class="min-w-48 o-input" autofocus="" autocapitalize="off" autocorrect="off" id="search_field_input" data-oruga-input="text" type="text" maxlength="1024" autocomplete="off" placeholder="Keyword, event title, group name, etc.">
<!---->
<!---->
<!---->
</div>
<!---->
</div>
<div data-v-a19720a3="" class="flex flex-col flex-wrap sm:flex-row gap-2 justify-center"><button data-v-a19720a3="" type="submit" class="o-btn search-Event min-w-40" role="button" data-oruga="button"><span class="o-btn__wrapper"><span class="o-icon o-btn__icon o-btn__icon-left" data-oruga="icon"><i class="mdi mdi-calendar mdi-24px"></i></span><span class="o-btn__label">Events</span>
<!----></span>
</button>
<!--v-if--><button data-v-a19720a3="" type="submit" class="o-btn search-Group min-w-40" role="button" data-oruga="button"><span class="o-btn__wrapper"><span class="o-icon o-btn__icon o-btn__icon-left" data-oruga="icon"><i class="mdi mdi-account-multiple mdi-24px"></i></span><span class="o-btn__label">Groups</span>
<!----></span>
</button>
</div>
</form>"
`;

View File

@@ -0,0 +1,15 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`UnloggedIntroduction > Show close 1`] = `
"<section class="container mx-auto px-2 my-3">
<h1 class="dark:text-white font-bold">Gather ⋅ Organize ⋅ Mobilize</h1>
<p class="dark:text-white mb-2"></p>
</section>"
`;
exports[`UnloggedIntroduction > Show open 1`] = `
"<section class="container mx-auto px-2 my-3">
<h1 class="dark:text-white font-bold">Test! Test! Test!</h1>
<p class="dark:text-white mb-2">An instance that doesn't exist</p>
</section>"
`;