build: switch from yarn to npm to manage js dependencies and move js contents to root

yarn v1 is being deprecated and starts to have some issues

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-11-14 17:24:42 +01:00
parent 32055122c3
commit 2e72f6faf4
595 changed files with 12078 additions and 7843 deletions

View File

@@ -0,0 +1,34 @@
export const loginMock = {
email: "some@email.tld",
password: "somepassword",
};
export const loginResponseMock = {
data: {
login: {
__typename: "Login",
accessToken: "some access token",
refreshToken: "some refresh token",
user: {
__typename: "User",
email: "some@email.tld",
id: "1",
role: "ADMINISTRATOR",
},
},
},
};
export const resetPasswordResponseMock = {
data: {
resetPassword: {
__typename: "Login",
accessToken: "some access token",
refreshToken: "some refresh token",
user: {
__typename: "User",
id: "1",
},
},
},
};

View File

@@ -0,0 +1,154 @@
export const configMock = {
data: {
config: {
__typename: "Config",
anonymous: {
__typename: "Anonymous",
actorId: "1",
eventCreation: {
__typename: "AnonymousEventCreation",
allowed: false,
validation: {
__typename: "AnonymousEventCreationValidation",
captcha: {
__typename: "AnonymousEventCreationValidationCaptcha",
enabled: false,
},
email: {
__typename: "AnonymousEventCreationValidationEmail",
confirmationRequired: true,
enabled: true,
},
},
},
participation: {
__typename: "AnonymousParticipation",
allowed: true,
validation: {
__typename: "AnonymousParticipationValidation",
captcha: {
__typename: "AnonymousParticipationValidationCaptcha",
enabled: false,
},
email: {
__typename: "AnonymousParticipationValidationEmail",
confirmationRequired: true,
enabled: true,
},
},
},
reports: {
__typename: "AnonymousReports",
allowed: false,
},
},
auth: {
__typename: "Auth",
ldap: false,
oauthProviders: [],
},
countryCode: "fr",
demoMode: false,
description: "Mobilizon.fr est l'instance Mobilizon de Framasoft.",
features: {
__typename: "Features",
eventCreation: true,
groups: true,
},
restrictions: {
__typename: "Restrictions",
onlyAdminCanCreateGroups: false,
onlyGroupsCanCreateEvents: false,
},
geocoding: {
__typename: "Geocoding",
autocomplete: true,
provider: "Elixir.Mobilizon.Service.Geospatial.Pelias",
},
languages: ["fr"],
location: {
__typename: "Lonlat",
latitude: 48.8717,
longitude: 2.32075,
},
maps: {
__typename: "Maps",
tiles: {
__typename: "Tiles",
attribution: "© The OpenStreetMap Contributors",
endpoint: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
},
routing: {
__typename: "Routing",
type: "OPENSTREETMAP",
},
},
name: "Mobilizon",
registrationsAllowlist: false,
registrationsOpen: true,
resourceProviders: [
{
__typename: "ResourceProvider",
endpoint: "https://lite.framacalc.org/",
software: "calc",
type: "ethercalc",
},
{
__typename: "ResourceProvider",
endpoint: "https://hebdo.framapad.org/p/",
software: "pad",
type: "etherpad",
},
{
__typename: "ResourceProvider",
endpoint: "https://framatalk.org/",
software: "visio",
type: "jitsi",
},
],
slogan: null,
uploadLimits: {
__typename: "UploadLimits",
default: 10_000_000,
avatar: 2_000_000,
banner: 4_000_000,
},
instanceFeeds: {
__typename: "InstanceFeeds",
enabled: false,
},
webPush: {
__typename: "WebPush",
enabled: true,
publicKey: "",
},
eventCategories: [],
analytics: [],
},
},
};
export const loginMock = {
data: {
config: {
__typename: "Config",
auth: {
__typename: "Auth",
oauthProviders: [],
},
registrationsOpen: true,
},
},
};
export const anonymousActorIdMock = {
data: {
config: {
__typename: "Config",
anonymous: {
__typename: "Anonymous",
actorId: "1",
},
},
},
};

View File

@@ -0,0 +1,190 @@
import { EventJoinOptions, ParticipantRole } from "@/types/enums";
type DataMock = {
data: Record<string, unknown>;
};
export const fetchEventBasicMock = {
data: {
event: {
__typename: "Event",
id: "1",
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
joinOptions: EventJoinOptions.FREE,
participantStats: {
__typename: "ParticipantStats",
notApproved: 0,
notConfirmed: 0,
participant: 0,
going: 1,
},
},
},
};
export const joinEventResponseMock = {
data: {
joinEvent: {
__typename: "Participant",
id: "5",
role: ParticipantRole.NOT_APPROVED,
insertedAt: "2020-12-07T09:33:41Z",
metadata: {
__typename: "ParticipantMetadata",
cancellationToken: "some token",
message: "a message long enough",
},
event: {
__typename: "Event",
id: "1",
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
},
actor: {
__typename: "Person",
preferredUsername: "some_actor",
name: "Some actor",
avatar: null,
domain: null,
id: "1",
},
},
},
};
export const joinEventMock = {
eventId: "1",
actorId: "1",
email: "some@email.tld",
message: "a message long enough",
locale: "en_US",
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
};
export const eventNoCommentThreadsMock = {
data: {
event: {
__typename: "Event",
id: "1",
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
comments: [],
},
},
};
export const eventCommentThreadsMock = {
data: {
event: {
__typename: "Event",
id: "1",
uuid: "f37910ea-fd5a-4756-9679-00971f3f4106",
comments: [
{
__typename: "Comment",
id: "2",
uuid: "e37910ea-fd5a-4756-9679-00971f3f4107",
url: "https://some-instance.tld/comments/e37910ea-fd5a-4756-9679-00971f3f4107",
text: "my comment text",
local: true,
visibility: "PUBLIC",
totalReplies: 5,
updatedAt: "2020-12-03T09:02:00Z",
inReplyToComment: null,
originComment: null,
replies: [],
actor: {
__typename: "Person",
avatar: {
__typename: "Media",
id: "78",
url: "http://someavatar.url.me",
},
id: "89",
domain: null,
preferredUsername: "someauthor",
name: "Some author",
summary: "I am the senate",
},
deletedAt: null,
insertedAt: "2020-12-03T09:02:00Z",
isAnnouncement: false,
language: "en",
},
{
__typename: "Comment",
id: "29",
uuid: "e37910ea-fd5a-4756-9679-01171f3f4107",
url: "https://some-instance.tld/comments/e37910ea-fd5a-4756-9679-01171f3f4107",
text: "a second comment",
local: true,
visibility: "PUBLIC",
totalReplies: 0,
updatedAt: "2020-12-03T11:02:00Z",
inReplyToComment: null,
originComment: null,
replies: [],
actor: {
__typename: "Person",
avatar: {
__typename: "Media",
id: "78",
url: "http://someavatar.url.me",
},
id: "89",
domain: null,
preferredUsername: "someauthor",
name: "Some author",
summary: "I am the senate",
},
deletedAt: null,
insertedAt: "2020-12-03T11:02:00Z",
isAnnouncement: false,
language: "en",
},
],
},
},
};
export const newCommentForEventMock = {
eventId: "1",
text: "my new comment",
inReplyToCommentId: undefined,
isAnnouncement: false,
originCommentId: undefined,
};
export const newCommentForEventResponse: DataMock = {
data: {
createComment: {
__typename: "Comment",
id: "79",
uuid: "e37910ea-fd5a-4756-9679-01171f3f4444",
url: "https://some-instance.tld/comments/e37910ea-fd5a-4756-9679-01171f3f4444",
text: newCommentForEventMock.text,
local: true,
visibility: "PUBLIC",
totalReplies: 0,
updatedAt: "2020-12-03T13:02:00Z",
originComment: null,
inReplyToComment: null,
replies: [],
actor: {
__typename: "Person",
avatar: {
__typename: "Media",
id: "78",
url: "http://someavatar.url.me",
},
id: "89",
domain: null,
preferredUsername: "someauthor",
name: "Some author",
summary: "I am the senate",
},
deletedAt: null,
insertedAt: "2020-12-03T13:02:00Z",
isAnnouncement: false,
language: "en",
},
},
};

View File

@@ -0,0 +1,12 @@
import { vi } from "vitest";
vi.stubGlobal("matchMedia", (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
}));