feat: add admin smoke tests and enhance testing documentation with new strategies and configurations

This commit is contained in:
2026-05-12 21:01:25 +00:00
parent c058ec760f
commit 53ad012657
14 changed files with 388 additions and 51 deletions
+27 -3
View File
@@ -4,7 +4,9 @@ import { createCollectionEntry, deleteCollectionEntry, listCollectionEntries } f
type ContentEntry = {
id?: string
_id?: string | { $oid?: string }
_testdata?: boolean
translationKey?: string
path?: string
[key: string]: unknown
}
@@ -16,9 +18,27 @@ function getEntryId(entry: ContentEntry): string | undefined {
}
const SEEDED_TRANSLATION_KEYS = new Set<string>(Object.values(SEEDED_TEST_CONTENT).map((entry) => entry.translationKey))
const SEEDED_PATHS = new Set<string>(Object.values(SEEDED_TEST_CONTENT).map((entry) => entry.path))
function isSeededContentEntry(entry: ContentEntry): boolean {
if (entry._testdata === true) {
return true
}
if (typeof entry.translationKey === "string" && SEEDED_TRANSLATION_KEYS.has(entry.translationKey)) {
return true
}
if (typeof entry.path === "string" && SEEDED_PATHS.has(entry.path)) {
return true
}
return false
}
const SEEDED_CONTENT_ENTRIES = [
{
_testdata: true,
active: true,
type: "page",
lang: "de",
@@ -99,6 +119,7 @@ const SEEDED_CONTENT_ENTRIES = [
],
},
{
_testdata: true,
active: true,
type: "page",
lang: "en",
@@ -179,6 +200,7 @@ const SEEDED_CONTENT_ENTRIES = [
],
},
{
_testdata: true,
active: true,
type: "page",
lang: "de",
@@ -208,6 +230,7 @@ const SEEDED_CONTENT_ENTRIES = [
],
},
{
_testdata: true,
active: true,
type: "page",
lang: "en",
@@ -237,6 +260,7 @@ const SEEDED_CONTENT_ENTRIES = [
],
},
{
_testdata: true,
active: false,
type: "page",
lang: "de",
@@ -265,9 +289,9 @@ const SEEDED_CONTENT_ENTRIES = [
export async function cleanupSeededTestContent(baseURL: string): Promise<number> {
const contentEntries = await listCollectionEntries<ContentEntry>(baseURL, "content")
const seededEntries = contentEntries.filter(
(entry) => typeof entry.translationKey === "string" && SEEDED_TRANSLATION_KEYS.has(entry.translationKey)
)
// Cleanup runs before every seed pass so leftovers from aborted test runs
// are removed on the next successful global setup.
const seededEntries = contentEntries.filter((entry) => isSeededContentEntry(entry))
let deleted = 0
for (const entry of seededEntries) {