diff --git a/run_accords_testing.sh b/run_accords_testing.sh
index 0ea2be6..5b91b7b 100755
--- a/run_accords_testing.sh
+++ b/run_accords_testing.sh
@@ -1,2 +1,4 @@
NODE_ENV=test
-npx next build |& tee ./testing_logs/$(date +"%Y-%m-%d---%H-%M-%S").log
\ No newline at end of file
+# npx next build | tee ./testing_logs/$(date +"%Y-%m-%d---%H-%M-%S").log
+
+npx next build 2> >(tee ./testing_logs/$(date +"%Y-%m-%d---%H-%M-%S").stderr.tsv) 1> >(tee ./testing_logs/$(date +"%Y-%m-%d---%H-%M-%S").stdout.tsv)
\ No newline at end of file
diff --git a/src/components/Markdown/Markdawn.tsx b/src/components/Markdown/Markdawn.tsx
index 8b5259d..8212ad4 100644
--- a/src/components/Markdown/Markdawn.tsx
+++ b/src/components/Markdown/Markdawn.tsx
@@ -7,18 +7,24 @@ type ScenBreakProps = {
};
export default function Markdawn(props: ScenBreakProps): JSX.Element {
- return (
- {return {""}}
+ },
},
- },
- }}
- >
- {props.text}
-
- );
-}
+ }}
+ >
+ {props.text}
+
+ );
+ }
+ return <>>;
+}
\ No newline at end of file
diff --git a/src/contexts/AppLayoutContext.tsx b/src/contexts/AppLayoutContext.tsx
index b5a76ec..eac6321 100644
--- a/src/contexts/AppLayoutContext.tsx
+++ b/src/contexts/AppLayoutContext.tsx
@@ -1,6 +1,6 @@
import useDarkMode from "hooks/useDarkMode";
import useStateWithLocalStorage from "hooks/useStateWithLocalStorage";
-import React, { ReactNode, useContext, useEffect } from "react";
+import React, { ReactNode, useContext } from "react";
export interface AppLayoutState {
subPanelOpen: boolean | undefined;
diff --git a/src/graphql/operation.graphql b/src/graphql/operation.graphql
index c73773f..63d9963 100644
--- a/src/graphql/operation.graphql
+++ b/src/graphql/operation.graphql
@@ -181,8 +181,9 @@ query getLibraryItemsPreview($language_code: String) {
}
}
... on ComponentMetadataGame {
- platform {
+ platforms {
data {
+ id
attributes {
short
}
@@ -255,6 +256,9 @@ query getLibraryItem($slug: String, $language_code: String) {
title
subtitle
slug
+ root_item
+ primary
+ digital
thumbnail {
data {
attributes {
@@ -345,8 +349,9 @@ query getLibraryItem($slug: String, $language_code: String) {
}
}
... on ComponentMetadataGame {
- platform {
+ platforms {
data {
+ id
attributes {
short
}
@@ -470,8 +475,9 @@ query getLibraryItem($slug: String, $language_code: String) {
}
}
... on ComponentMetadataGame {
- platform {
+ platforms {
data {
+ id
attributes {
short
}
@@ -812,6 +818,7 @@ query getContent($slug: String, $language_code: String) {
query getContentText($slug: String, $language_code: String) {
contents(filters: { slug: { eq: $slug } }) {
data {
+ id
attributes {
slug
titles(filters: { language: { code: { eq: $language_code } } }) {
diff --git a/src/graphql/operations-types.ts b/src/graphql/operations-types.ts
index 50863f1..57b4615 100644
--- a/src/graphql/operations-types.ts
+++ b/src/graphql/operations-types.ts
@@ -311,15 +311,16 @@ export type GetLibraryItemsPreviewQuery = {
}
| {
__typename: "ComponentMetadataGame";
- platform: {
- __typename: "GamePlatformEntityResponse";
- data: {
+ platforms: {
+ __typename: "GamePlatformRelationResponseCollection";
+ data: Array<{
__typename: "GamePlatformEntity";
+ id: string;
attributes: {
__typename: "GamePlatform";
short: string;
};
- };
+ }>;
};
}
| {
@@ -395,6 +396,9 @@ export type GetLibraryItemQuery = {
title: string;
subtitle: string;
slug: string;
+ root_item: boolean;
+ primary: boolean;
+ digital: boolean;
thumbnail: {
__typename: "UploadFileEntityResponse";
data: {
@@ -507,15 +511,16 @@ export type GetLibraryItemQuery = {
}
| {
__typename: "ComponentMetadataGame";
- platform: {
- __typename: "GamePlatformEntityResponse";
- data: {
+ platforms: {
+ __typename: "GamePlatformRelationResponseCollection";
+ data: Array<{
__typename: "GamePlatformEntity";
+ id: string;
attributes: {
__typename: "GamePlatform";
short: string;
};
- };
+ }>;
};
audio_languages: {
__typename: "LanguageRelationResponseCollection";
@@ -683,15 +688,16 @@ export type GetLibraryItemQuery = {
}
| {
__typename: "ComponentMetadataGame";
- platform: {
- __typename: "GamePlatformEntityResponse";
- data: {
+ platforms: {
+ __typename: "GamePlatformRelationResponseCollection";
+ data: Array<{
__typename: "GamePlatformEntity";
+ id: string;
attributes: {
__typename: "GamePlatform";
short: string;
};
- };
+ }>;
};
}
| {
@@ -861,11 +867,6 @@ export type GetContentsSlugsQuery = {
};
};
-export type GetContentQueryVariables = Exact<{
- slug: InputMaybe;
- language_code: InputMaybe;
-}>;
-
export type GetContentsQueryVariables = Exact<{
language_code: InputMaybe;
}>;
@@ -982,6 +983,11 @@ export type GetContentsQuery = {
};
};
+export type GetContentQueryVariables = Exact<{
+ slug: InputMaybe;
+ language_code: InputMaybe;
+}>;
+
export type GetContentQuery = {
__typename: "Query";
contents: {
@@ -1109,6 +1115,7 @@ export type GetContentTextQuery = {
__typename: "ContentEntityResponseCollection";
data: Array<{
__typename: "ContentEntity";
+ id: string;
attributes: {
__typename: "Content";
slug: string;
diff --git a/src/graphql/schema.graphql b/src/graphql/schema.graphql
index 890a052..41e523f 100644
--- a/src/graphql/schema.graphql
+++ b/src/graphql/schema.graphql
@@ -486,7 +486,11 @@ type ComponentMetadataBooks {
type ComponentMetadataGame {
id: ID!
- platform: GamePlatformEntityResponse
+ platforms(
+ filters: GamePlatformFiltersInput
+ pagination: PaginationArg = {}
+ sort: [String] = []
+ ): GamePlatformRelationResponseCollection
demo: Boolean!
audio_languages(
filters: LanguageFiltersInput
@@ -589,8 +593,8 @@ type ComponentRangeOther {
type ComponentRangePageRange {
id: ID!
- starting_page: Int
- ending_page: Int
+ starting_page: Int!
+ ending_page: Int!
}
type ComponentRangeTimeRange {
@@ -1708,6 +1712,10 @@ type GamePlatformEntityResponseCollection {
meta: ResponseCollectionMeta!
}
+type GamePlatformRelationResponseCollection {
+ data: [GamePlatformEntity!]!
+}
+
input GlossaryItemFiltersInput {
id: IDFilterInput
slug: StringFilterInput
@@ -2132,7 +2140,7 @@ input RangedContentInput {
type RangedContent {
slug: String!
- range: [RangedContentRangeDynamicZone]
+ range: [RangedContentRangeDynamicZone]!
scan_set(
filters: ComponentSetsScanSetFiltersInput
pagination: PaginationArg = {}
diff --git a/src/pages/contents/[slug]/read.tsx b/src/pages/contents/[slug]/read.tsx
index e7200ca..f6dd015 100644
--- a/src/pages/contents/[slug]/read.tsx
+++ b/src/pages/contents/[slug]/read.tsx
@@ -29,18 +29,17 @@ import Chip from "components/Chip";
import ReactTooltip from "react-tooltip";
import RecorderChip from "components/RecorderChip";
-type ContentReadProps = {
+interface ContentReadProps {
content: GetContentTextQuery;
langui: GetWebsiteInterfaceQuery;
-};
+}
export default function ContentRead(props: ContentReadProps): JSX.Element {
+ useTesting(props);
const content = props.content.contents.data[0].attributes;
const langui = props.langui.websiteInterfaces.data[0].attributes;
const router = useRouter();
- useTesting(props.content);
-
const subPanel = (
{
};
};
-export function useTesting(content: GetContentTextQuery) {
+export function useTesting(props: ContentReadProps) {
const router = useRouter();
- const contentAtr = content.contents.data[0].attributes;
- if (contentAtr.categories.data.length === 0) {
- prettyTestError(router, "Missing categories", ["content"]);
+ const content = props.content.contents.data[0].attributes;
+
+ const contentURL =
+ "/admin/content-manager/collectionType/api::content.content/" +
+ props.content.contents.data[0].id;
+
+ if (router.locale === "en") {
+ if (content.categories.data.length === 0) {
+ prettyTestError(router, "Missing categories", ["content"], contentURL);
+ }
}
- if (contentAtr.ranged_contents.data.length === 0) {
- prettyTestWarning(router, "Unconnected to any source", ["content"]);
- }
-
- if (contentAtr.text_set.length === 0) {
- prettyTestWarning(router, "Has no textset, nor audioset, nor videoset", [
- "content",
- ]);
- }
-
- if (contentAtr.text_set.length > 1) {
- console.warn(
- prettyTestError(router, "More than one textset for this language", [
- "content",
- "text_set",
- ])
+ if (content.ranged_contents.data.length === 0) {
+ prettyTestWarning(
+ router,
+ "Unconnected to any source",
+ ["content"],
+ contentURL
);
}
- if (contentAtr.text_set.length === 1) {
- const textset = contentAtr.text_set[0];
+ if (content.text_set.length === 0) {
+ prettyTestWarning(
+ router,
+ "Has no textset, nor audioset, nor videoset",
+ ["content"],
+ contentURL
+ );
+ }
+
+ if (content.text_set.length > 1) {
+ console.warn(
+ prettyTestError(
+ router,
+ "More than one textset for this language",
+ ["content", "text_set"],
+ contentURL
+ )
+ );
+ }
+
+ if (content.text_set.length === 1) {
+ const textset = content.text_set[0];
if (!textset.text) {
- prettyTestError(router, "Missing text", ["content", "text_set"]);
+ prettyTestError(
+ router,
+ "Missing text",
+ ["content", "text_set"],
+ contentURL
+ );
}
if (!textset.source_language.data) {
- prettyTestError(router, "Missing source language", [
- "content",
- "text_set",
- ]);
+ prettyTestError(
+ router,
+ "Missing source language",
+ ["content", "text_set"],
+ contentURL
+ );
}
if (textset.source_language.data.attributes.code === router.locale) {
// This is a transcript
if (textset.transcribers.data.length === 0) {
- prettyTestError(router, "Missing transcribers attribution", [
- "content",
- "text_set",
- ]);
+ prettyTestError(
+ router,
+ "Missing transcribers attribution",
+ ["content", "text_set"],
+ contentURL
+ );
}
if (textset.translators.data.length > 0) {
- prettyTestError(router, "Transcripts shouldn't have translators", [
- "content",
- "text_set",
- ]);
+ prettyTestError(
+ router,
+ "Transcripts shouldn't have translators",
+ ["content", "text_set"],
+ contentURL
+ );
}
} else {
// This is a translation
if (textset.translators.data.length === 0) {
- prettyTestError(router, "Missing translators attribution", [
- "content",
- "text_set",
- ]);
+ prettyTestError(
+ router,
+ "Missing translators attribution",
+ ["content", "text_set"],
+ contentURL
+ );
}
if (textset.transcribers.data.length > 0) {
- prettyTestError(router, "Translations shouldn't have transcribers", [
- "content",
- "text_set",
- ]);
+ prettyTestError(
+ router,
+ "Translations shouldn't have transcribers",
+ ["content", "text_set"],
+ contentURL
+ );
}
}
}
diff --git a/src/pages/library/[slug].tsx b/src/pages/library/[slug].tsx
index 9758c7b..cd44876 100644
--- a/src/pages/library/[slug].tsx
+++ b/src/pages/library/[slug].tsx
@@ -21,6 +21,9 @@ import {
prettyItemSubType,
prettyPrice,
prettySlug,
+ prettyTestError,
+ prettyTestWarning,
+ sortContent,
} from "queries/helpers";
import SubPanel from "components/Panels/SubPanel";
import ReturnButton from "components/PanelComponents/ReturnButton";
@@ -33,13 +36,15 @@ import LibraryItemsPreview from "components/Library/LibraryItemsPreview";
import InsetBox from "components/InsetBox";
import Img, { ImageQuality } from "components/Img";
import { useAppLayout } from "contexts/AppLayoutContext";
+import { useRouter } from "next/router";
-type LibrarySlugProps = {
+interface LibrarySlugProps {
libraryItem: GetLibraryItemQuery;
langui: GetWebsiteInterfaceQuery;
-};
+}
export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
+ useTesting(props);
const item = props.libraryItem.libraryItems.data[0].attributes;
const langui = props.langui.websiteInterfaces.data[0].attributes;
const appLayout = useAppLayout();
@@ -49,6 +54,8 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
item.metadata[0].__typename === "ComponentMetadataOther" &&
item.metadata[0].subtype.data.attributes.slug === "variant-set";
+ sortContent(item.contents);
+
const subPanel = (
);
- // Sort content by range
- item.contents.data.sort((a, b) => {
- if (
- a.attributes.range[0].__typename === "ComponentRangePageRange" &&
- b.attributes.range[0].__typename === "ComponentRangePageRange"
- ) {
- return (
- a.attributes.range[0].starting_page -
- b.attributes.range[0].starting_page
- );
- }
- return 0;
- });
-
return (
0
? item.descriptions[0].description
@@ -539,3 +532,394 @@ export const getStaticPaths: GetStaticPaths = async (context) => {
fallback: false,
};
};
+
+function useTesting(props: LibrarySlugProps) {
+ const libraryItem = props.libraryItem.libraryItems.data[0].attributes;
+ const router = useRouter();
+
+ const libraryItemURL =
+ "/admin/content-manager/collectionType/api::library-item.library-item/" +
+ props.libraryItem.libraryItems.data[0].id;
+
+ sortContent(libraryItem.contents);
+
+ if (router.locale === "en") {
+ if (!libraryItem.thumbnail.data) {
+ prettyTestError(
+ router,
+ "Missing thumbnail",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ if (libraryItem.metadata.length === 0) {
+ prettyTestError(
+ router,
+ "Missing metadata",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ } else {
+ if (
+ libraryItem.metadata[0].__typename === "ComponentMetadataOther" &&
+ (libraryItem.metadata[0].subtype.data.attributes.slug ===
+ "relation-set" ||
+ libraryItem.metadata[0].subtype.data.attributes.slug ===
+ "variant-set")
+ ) {
+ // This is a group type item
+ if (libraryItem.price) {
+ prettyTestError(
+ router,
+ "Group-type items shouldn't have price",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ if (libraryItem.size) {
+ prettyTestError(
+ router,
+ "Group-type items shouldn't have size",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ if (libraryItem.release_date) {
+ prettyTestError(
+ router,
+ "Group-type items shouldn't have release_date",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ if (libraryItem.contents.data.length > 0) {
+ prettyTestError(
+ router,
+ "Group-type items shouldn't have contents",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ if (libraryItem.subitems.data.length === 0) {
+ prettyTestError(
+ router,
+ "Group-type items should have subitems",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ } else {
+ // This is a normal item
+
+ if (libraryItem.metadata[0].__typename === "ComponentMetadataOther") {
+ if (
+ libraryItem.metadata[0].subtype.data.attributes.slug ===
+ "audio-case"
+ ) {
+ let hasAudioSubItem = false;
+ libraryItem.subitems.data.map((subitem) => {
+ if (
+ subitem.attributes.metadata.length > 0 &&
+ subitem.attributes.metadata[0].__typename ===
+ "ComponentMetadataAudio"
+ )
+ hasAudioSubItem = true;
+ });
+ if (!hasAudioSubItem) {
+ prettyTestError(
+ router,
+ "Audio-case item doesn't have an audio-typed subitem",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ } else if (
+ libraryItem.metadata[0].subtype.data.attributes.slug === "game-case"
+ ) {
+ let hasGameSubItem = false;
+ libraryItem.subitems.data.map((subitem) => {
+ if (
+ subitem.attributes.metadata.length > 0 &&
+ subitem.attributes.metadata[0].__typename ===
+ "ComponentMetadataGame"
+ )
+ hasGameSubItem = true;
+ });
+ if (!hasGameSubItem) {
+ prettyTestError(
+ router,
+ "Game-case item doesn't have an Game-typed subitem",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ } else if (
+ libraryItem.metadata[0].subtype.data.attributes.slug ===
+ "video-case"
+ ) {
+ let hasVideoSubItem = false;
+ libraryItem.subitems.data.map((subitem) => {
+ if (
+ subitem.attributes.metadata.length > 0 &&
+ subitem.attributes.metadata[0].__typename ===
+ "ComponentMetadataVideo"
+ )
+ hasVideoSubItem = true;
+ });
+ if (!hasVideoSubItem) {
+ prettyTestError(
+ router,
+ "Video-case item doesn't have an Video-typed subitem",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ } else if (
+ libraryItem.metadata[0].subtype.data.attributes.slug === "item-set"
+ ) {
+ if (libraryItem.subitems.data.length === 0) {
+ prettyTestError(
+ router,
+ "Item-set item should have subitems",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ }
+ }
+
+ if (!libraryItem.price) {
+ prettyTestWarning(
+ router,
+ "Missing price",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ } else {
+ if (!libraryItem.price.amount) {
+ prettyTestError(
+ router,
+ "Missing amount",
+ ["libraryItem", "price"],
+ libraryItemURL
+ );
+ }
+ if (!libraryItem.price.currency) {
+ prettyTestError(
+ router,
+ "Missing currency",
+ ["libraryItem", "price"],
+ libraryItemURL
+ );
+ }
+ }
+
+ if (!libraryItem.digital) {
+ if (!libraryItem.size) {
+ prettyTestWarning(
+ router,
+ "Missing size",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ } else {
+ if (!libraryItem.size.width) {
+ prettyTestWarning(
+ router,
+ "Missing width",
+ ["libraryItem", "size"],
+ libraryItemURL
+ );
+ }
+ if (!libraryItem.size.height) {
+ prettyTestWarning(
+ router,
+ "Missing height",
+ ["libraryItem", "size"],
+ libraryItemURL
+ );
+ }
+ if (!libraryItem.size.thickness) {
+ prettyTestWarning(
+ router,
+ "Missing thickness",
+ ["libraryItem", "size"],
+ libraryItemURL
+ );
+ }
+ }
+ }
+
+ if (!libraryItem.release_date) {
+ prettyTestWarning(
+ router,
+ "Missing release_date",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ } else {
+ if (!libraryItem.release_date.year) {
+ prettyTestError(
+ router,
+ "Missing year",
+ ["libraryItem", "release_date"],
+ libraryItemURL
+ );
+ }
+ if (!libraryItem.release_date.month) {
+ prettyTestError(
+ router,
+ "Missing month",
+ ["libraryItem", "release_date"],
+ libraryItemURL
+ );
+ }
+ if (!libraryItem.release_date.day) {
+ prettyTestError(
+ router,
+ "Missing day",
+ ["libraryItem", "release_date"],
+ libraryItemURL
+ );
+ }
+ }
+
+ if (libraryItem.contents.data.length === 0) {
+ prettyTestWarning(
+ router,
+ "Missing contents",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ } else {
+ let currentRangePage = 0;
+ libraryItem.contents.data.map((content) => {
+ const contentURL =
+ "/admin/content-manager/collectionType/api::content.content/" +
+ content.id;
+
+ if (content.attributes.scan_set.length === 0) {
+ prettyTestWarning(
+ router,
+ "Missing scan_set",
+ ["libraryItem", "content", content.id],
+ contentURL
+ );
+ }
+ if (content.attributes.range.length === 0) {
+ prettyTestWarning(
+ router,
+ "Missing range",
+ ["libraryItem", "content", content.id],
+ contentURL
+ );
+ } else if (
+ content.attributes.range[0].__typename ===
+ "ComponentRangePageRange"
+ ) {
+ if (
+ content.attributes.range[0].starting_page <
+ currentRangePage + 1
+ ) {
+ prettyTestError(
+ router,
+ `Overlapping pages ${content.attributes.range[0].starting_page} to ${currentRangePage}`,
+ ["libraryItem", "content", content.id, "range"],
+ libraryItemURL
+ );
+ } else if (
+ content.attributes.range[0].starting_page >
+ currentRangePage + 1
+ ) {
+ prettyTestError(
+ router,
+ `Missing pages ${currentRangePage + 1} to ${
+ content.attributes.range[0].starting_page - 1
+ }`,
+ ["libraryItem", "content", content.id, "range"],
+ libraryItemURL
+ );
+ }
+
+ if (!content.attributes.content.data) {
+ prettyTestWarning(
+ router,
+ "Missing content",
+ ["libraryItem", "content", content.id, "range"],
+ libraryItemURL
+ );
+ }
+
+ currentRangePage = content.attributes.range[0].ending_page;
+ }
+ });
+
+ if (libraryItem.metadata[0].__typename === "ComponentMetadataBooks") {
+ if (currentRangePage < libraryItem.metadata[0].page_count) {
+ prettyTestError(
+ router,
+ `Missing pages ${currentRangePage + 1} to ${
+ libraryItem.metadata[0].page_count
+ }`,
+ ["libraryItem", "content"],
+ libraryItemURL
+ );
+ } else if (currentRangePage > libraryItem.metadata[0].page_count) {
+ prettyTestError(
+ router,
+ `Page overflow, content references pages up to ${currentRangePage} when the highest expected was ${libraryItem.metadata[0].page_count}`,
+ ["libraryItem", "content"],
+ libraryItemURL
+ );
+ }
+
+ if (libraryItem.metadata[0].languages.data.length === 0) {
+ prettyTestWarning(
+ router,
+ "Missing language",
+ ["libraryItem", "metadata"],
+ libraryItemURL
+ );
+ }
+
+ if (!libraryItem.metadata[0].page_count) {
+ prettyTestWarning(
+ router,
+ "Missing page_count",
+ ["libraryItem", "metadata"],
+ libraryItemURL
+ );
+ }
+ }
+ }
+ }
+ }
+
+ if (!libraryItem.root_item && libraryItem.subitem_of.data.length === 0) {
+ prettyTestError(
+ router,
+ "This item is inaccessible (not root item and not subitem of another item)",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+
+ if (libraryItem.gallery.data.length === 0) {
+ prettyTestWarning(
+ router,
+ "Missing gallery",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+ }
+
+ if (libraryItem.descriptions.length === 0) {
+ prettyTestWarning(
+ router,
+ "Missing description",
+ ["libraryItem"],
+ libraryItemURL
+ );
+ }
+}
diff --git a/src/pages/wiki/chronology.tsx b/src/pages/wiki/chronology.tsx
index 25a51ba..e78981a 100644
--- a/src/pages/wiki/chronology.tsx
+++ b/src/pages/wiki/chronology.tsx
@@ -34,10 +34,10 @@ interface DataChronologyProps {
export default function DataChronology(
props: DataChronologyProps
): JSX.Element {
+ useTesting(props);
const langui = props.langui.websiteInterfaces.data[0].attributes;
const chronologyItems = props.chronologyItems.chronologyItems;
const chronologyEras = props.chronologyEras.chronologyEras;
- useTesting(props.chronologyItems, props.chronologyEras);
// Group by year the Chronology items
let chronologyItemYearGroups: GetChronologyItemsQuery["chronologyItems"]["data"][number][][][] =
@@ -162,59 +162,76 @@ export const getStaticProps: GetStaticProps = async (context) => {
return { props: {} };
};
-export function useTesting(
- chronologyItems: GetChronologyItemsQuery,
- chronologyEras: GetErasQuery
-) {
+function useTesting({ chronologyItems, chronologyEras }: DataChronologyProps) {
const router = useRouter();
chronologyEras.chronologyEras.data.map((era) => {
+ const chronologyErasURL =
+ "/admin/content-manager/collectionType/api::chronology-era.chronology-era/" +
+ chronologyItems.chronologyItems.data[0].id;
+
if (era.attributes.title.length === 0) {
prettyTestError(
router,
"Missing translation for title and description, using slug instead",
- ["chronologyEras", era.attributes.slug]
+ ["chronologyEras", era.attributes.slug],
+ chronologyErasURL
);
} else if (era.attributes.title.length > 1) {
- prettyTestError(router, "More than one title and description", [
- "chronologyEras",
- era.attributes.slug,
- ]);
+ prettyTestError(
+ router,
+ "More than one title and description",
+ ["chronologyEras", era.attributes.slug],
+ chronologyErasURL
+ );
} else {
if (!era.attributes.title[0].title)
- prettyTestError(router, "Missing title, using slug instead", [
- "chronologyEras",
- era.attributes.slug,
- ]);
+ prettyTestError(
+ router,
+ "Missing title, using slug instead",
+ ["chronologyEras", era.attributes.slug],
+ chronologyErasURL
+ );
if (!era.attributes.title[0].description)
- prettyTestError(router, "Missing description", [
- "chronologyEras",
- era.attributes.slug,
- ]);
+ prettyTestError(
+ router,
+ "Missing description",
+ ["chronologyEras", era.attributes.slug],
+ chronologyErasURL
+ );
}
});
chronologyItems.chronologyItems.data.map((item) => {
+ const chronologyItemsURL =
+ "/admin/content-manager/collectionType/api::chronology-item.chronology-item/" +
+ chronologyItems.chronologyItems.data[0].id;
+
const date = `${item.attributes.year}/${item.attributes.month}/${item.attributes.day}`;
+
if (!(item.attributes.events.length > 0)) {
- prettyTestError(router, "No events for this date", [
- "chronologyItems",
- date,
- ]);
+ prettyTestError(
+ router,
+ "No events for this date",
+ ["chronologyItems", date],
+ chronologyItemsURL
+ );
} else {
item.attributes.events.map((event) => {
if (!event.source.data) {
- prettyTestError(router, "No source for this event", [
- "chronologyItems",
- date,
- event.id,
- ]);
+ prettyTestError(
+ router,
+ "No source for this event",
+ ["chronologyItems", date, event.id],
+ chronologyItemsURL
+ );
}
if (!(event.translations.length > 0)) {
- prettyTestWarning(router, "No translation for this event", [
- "chronologyItems",
- date,
- event.id,
- ]);
+ prettyTestWarning(
+ router,
+ "No translation for this event",
+ ["chronologyItems", date, event.id],
+ chronologyItemsURL
+ );
}
});
}
diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts
index 4b75647..817b3c5 100644
--- a/src/queries/helpers.ts
+++ b/src/queries/helpers.ts
@@ -4,6 +4,7 @@ import {
ImageQuality,
} from "components/Img";
import {
+ GetLibraryItemQuery,
GetLibraryItemsPreviewQuery,
GetWebsiteInterfaceQuery,
StrapiImage,
@@ -80,7 +81,7 @@ export function prettyItemType(
export function prettyItemSubType(metadata: {
__typename: GetLibraryItemsPreviewQuery["libraryItems"]["data"][number]["attributes"]["metadata"][number]["__typename"];
subtype?: any;
- platform?: any;
+ platforms?: any;
}): string {
switch (metadata.__typename) {
case "ComponentMetadataAudio":
@@ -92,7 +93,9 @@ export function prettyItemSubType(metadata: {
: prettySlug(metadata.subtype.data.attributes.slug);
}
case "ComponentMetadataGame":
- return metadata.platform.data.attributes.short;
+ return metadata.platforms.data.length > 0
+ ? metadata.platforms.data[0].attributes.short
+ : "";
default:
return "";
@@ -121,17 +124,19 @@ export function prettyLanguage(code: string): string {
export function prettyTestWarning(
router: NextRouter,
message: string,
- subCategory?: string[]
+ subCategory: string[],
+ url: string
): void {
- prettyTestWritter(TestingLevel.Warning, router, message, subCategory);
+ prettyTestWritter(TestingLevel.Warning, router, message, subCategory, url);
}
export function prettyTestError(
router: NextRouter,
message: string,
- subCategory?: string[]
+ subCategory: string[],
+ url: string
): void {
- prettyTestWritter(TestingLevel.Error, router, message, subCategory);
+ prettyTestWritter(TestingLevel.Error, router, message, subCategory, url);
}
enum TestingLevel {
@@ -143,12 +148,23 @@ function prettyTestWritter(
level: TestingLevel,
{ asPath, locale }: NextRouter,
message: string,
- subCategory?: string[]
+ subCategory: string[],
+ url: string
): void {
- subCategory?.push("");
- console.warn(
- `${level} - ${asPath} | ${locale} | ${subCategory?.join(" | ")}${message}`
- );
+ const line = [
+ level,
+ process.env.NEXT_PUBLIC_URL_SELF + "/" + locale + asPath,
+ locale,
+ subCategory?.join(" -> "),
+ message,
+ process.env.NEXT_PUBLIC_URL_CMS + url,
+ ];
+
+ if (level === TestingLevel.Warning) {
+ console.warn(line.join("\t"));
+ } else {
+ console.error(line.join("\t"));
+ }
}
export function capitalizeString(string: string): string {
@@ -185,3 +201,20 @@ export function getOgImage(quality: ImageQuality, image: StrapiImage): OgImage {
alt: image.alternativeText,
};
}
+
+export function sortContent(
+ contents: GetLibraryItemQuery["libraryItems"]["data"][number]["attributes"]["contents"]
+) {
+ contents.data.sort((a, b) => {
+ if (
+ a.attributes.range[0].__typename === "ComponentRangePageRange" &&
+ b.attributes.range[0].__typename === "ComponentRangePageRange"
+ ) {
+ return (
+ a.attributes.range[0].starting_page -
+ b.attributes.range[0].starting_page
+ );
+ }
+ return 0;
+ });
+}