Files
tibi-svelte-starter/tests/global-teardown.ts
T
apairon 4020ad62c5 feat: enhance medialib image handling and add asset URL resolution
- Implemented `resolveApiAssetUrl` function to normalize asset URLs based on API base.
- Updated `MedialibImage` component to utilize new asset URL resolution and added support for alt text and class properties.
- Enhanced image loading behavior with improved width measurement and focal point handling.
- Added placeholder image handling and improved accessibility with alt text.
- Introduced new test script for auditing broken links in skill documentation.
- Expanded seeded test content to include medialib entries and updated related tests for pagebuilder previews.
- Improved global setup and teardown logging for clarity on seeded content management.
2026-05-17 00:52:41 +00:00

48 lines
1.8 KiB
TypeScript

import { cleanupAllTestData, disposeAdminApi } from "./api/helpers/admin-api"
import { deleteAllEmails, disposeMailDev } from "./api/helpers/maildev"
import { cleanupSeededTestContent } from "./api/helpers/seed-data"
import { TEST_BASE_URL } from "./fixtures/test-constants"
async function globalTeardown() {
const baseURL = TEST_BASE_URL
// Final seed cleanup also stays run-scoped here. Per-test or per-worker
// cleanup would race with parallel workers against the shared seeded data.
try {
const probeContext = await import("@playwright/test").then(({ request }) =>
request.newContext({ baseURL, ignoreHTTPSErrors: true })
)
const apiProbe = await probeContext.get("/api/content?limit=1")
const contentType = apiProbe.headers()["content-type"] || ""
await probeContext.dispose()
if (!apiProbe.ok() || contentType.includes("text/html")) {
console.warn(
`Playwright teardown: skipped seeded cleanup because ${baseURL} has no usable /api endpoint (${apiProbe.status()} ${contentType || "without content-type"})`
)
return
}
const deletedSeedEntries = await cleanupSeededTestContent(baseURL)
const result = await cleanupAllTestData(baseURL)
if (deletedSeedEntries > 0 || result.users > 0) {
console.log(
`Playwright teardown: deleted ${deletedSeedEntries} seeded content/media entries and ${result.users} test users`
)
}
} catch (err) {
console.warn("Playwright teardown: test data cleanup failed:", err)
}
try {
await deleteAllEmails()
} catch {
// MailDev cleanup is optional.
}
await Promise.all([disposeAdminApi(), disposeMailDev()])
}
export default globalTeardown