From 6d56f6654b737b01364a76ec25157086e1d7c099 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Sun, 11 Feb 2024 23:10:00 +0100 Subject: [PATCH] chore: misc cleanup --- app/root.tsx | 25 ++++++++++++++----------- env.d.ts | 1 - package.json | 1 - tests/playwright.ts | 15 ++++++++++++--- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index 37bd958..0832532 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -23,11 +23,9 @@ import { RemixLogo } from './components'; export const meta: MetaFunction = () => { return [ - { - charset: 'utf-8', - title: 'remix-cloudlfare-template', - viewport: 'width=device-width,initial-scale=1', - }, + { charset: 'utf-8' }, + { name: 'viewport', content: 'width=device-width, initial-scale=1' }, + { title: 'remix-cloudlfare-template' }, ]; }; @@ -99,13 +97,15 @@ function Layout({ className={`relative flex-1 ${children ? 'border-t lg:border-t-0' : ''}`.trim()} >
-
+
-
+

{title}

{description}

{actionText ? ( @@ -126,9 +126,11 @@ function Layout({
-
-
{children}
-
+ {children ? ( +
+
{children}
+
+ ) : null}
); @@ -154,7 +156,8 @@ export function ErrorBoundary() { 'Oops! Looks like you tried to visit a page that does not exist.'; break; default: - throw new Error(error.data || error.statusText); + message = JSON.stringify(error.data, null, 2); + break; } return ( diff --git a/env.d.ts b/env.d.ts index cc30c92..5ec33de 100644 --- a/env.d.ts +++ b/env.d.ts @@ -11,6 +11,5 @@ interface Env { declare module '@remix-run/cloudflare' { export interface AppLoadContext { env: Env; - waitUntil(promise: Promise): void; } } diff --git a/package.json b/package.json index 6906c1b..11f8d06 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "eslint-config-prettier": "^9.1.0", "husky": "^9.0.10", "lint-staged": "^15.2.2", - "miniflare": "^3.20240129.1", "msw": "^2.1.7", "postcss": "^8.4.35", "prettier": "^3.2.5", diff --git a/tests/playwright.ts b/tests/playwright.ts index 20a432e..21899b4 100644 --- a/tests/playwright.ts +++ b/tests/playwright.ts @@ -13,6 +13,12 @@ interface WorkerFixtures { msw: SetupServer; } +export async function clearKV(namespace: KVNamespace): Promise { + const result = await namespace.list(); + + await Promise.all(result.keys.map(key => namespace.delete(key.name))); +} + export const expect = baseExpect.extend({}); export const test = baseTest.extend({ @@ -65,12 +71,15 @@ export const test = baseTest.extend({ wrangler: [ // eslint-disable-next-line no-empty-pattern async ({}, use) => { - const bindings = await getBindingsProxy(); + const wrangler = await getBindingsProxy(); // To access bindings in the tests. - await use(bindings); + await use(wrangler); + + // Ensure all cachees are cleaned up + await clearKV(wrangler.bindings.cache); - await bindings.dispose(); + await wrangler.dispose(); }, { scope: 'worker', auto: true }, ],