Unverified Commit a73ea44c authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

test: fix invalid URL in app-types test (#68360)

This PR fixes a test that typechecks, but crashes when actually running
the page, because
1. `new URL("/relative")` will throw (so we change it to absolute)
2. We cannot pass a URL object from RSC to a client component (so we
just make the page 'use client', which also requires removing
`metadata`, but that wasn't used for anything)

See https://github.com/vercel/next.js/pull/68323#discussion_r1698468251,
where this was split from
parent 44bac510
...@@ -40,8 +40,8 @@ const appDir = __dirname ...@@ -40,8 +40,8 @@ const appDir = __dirname
), ),
].map(([, line]) => +line) ].map(([, line]) => +line)
const ST = 17 const ST = 18
const ED = 34 const ED = 35
expect(errorLines).toEqual( expect(errorLines).toEqual(
Array.from({ length: ED - ST + 1 }, (_, i) => i + ST) Array.from({ length: ED - ST + 1 }, (_, i) => i + ST)
) )
......
import type { Route, Metadata } from 'next' 'use client'
import type { Route } from 'next'
import Link from 'next/link' import Link from 'next/link'
export function Card<T extends string>({ href }: { href: Route<T> | URL }) { export function Card<T extends string>({ href }: { href: Route<T> | URL }) {
...@@ -62,7 +63,7 @@ export default function page() { ...@@ -62,7 +63,7 @@ export default function page() {
<Link href="/redirect">test</Link> <Link href="/redirect">test</Link>
<Link href="/redirect/v1/guides/x/page">test</Link> <Link href="/redirect/v1/guides/x/page">test</Link>
<Link href="/redirect/guides/x/page">test</Link> <Link href="/redirect/guides/x/page">test</Link>
<Link href={new URL('/about')}>test</Link> <Link href={new URL('https://nextjs.org')}>test</Link>
<Link href="https://nextjs.org">test</Link> <Link href="https://nextjs.org">test</Link>
<Link href="http://nextjs.org">test</Link> <Link href="http://nextjs.org">test</Link>
<Link href="#id">test</Link> <Link href="#id">test</Link>
...@@ -78,7 +79,3 @@ export default function page() { ...@@ -78,7 +79,3 @@ export default function page() {
</> </>
) )
} }
export const metadata: Metadata = {
title: 'test',
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment